MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / ProcessKeys

Method ProcessKeys

CryGame/AdvCamSystem.cpp:156–306  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////// Process input.

Source from the content-addressed store, hash-verified

154//////////////////////////////////////////////////////////////////////////
155// Process input.
156void CAdvCamSystem::ProcessKeys( CXEntityProcessingCmd &epc )
157{
158 if(m_eiPlayerA && m_eiPlayerB)
159 {
160 // get entities
161 IEntitySystem *pEntitySystem=m_pGame->m_pSystem->GetIEntitySystem(); assert(pEntitySystem);
162 IEntity *pEntityA = pEntitySystem->GetEntity(m_eiPlayerA); assert(pEntityA);if(!pEntityA)return;
163 IEntity *pEntityB = pEntitySystem->GetEntity(m_eiPlayerB); assert(pEntityB);if(!pEntityB)return;
164
165 // get player containers of the entities
166 CPlayer *pPlayerA = NULL;
167 pEntityA->GetContainer()->QueryContainerInterface(CIT_IPLAYER,(void **) &pPlayerA); assert(pPlayerA);
168 CPlayer *pPlayerB = NULL;
169 pEntityB->GetContainer()->QueryContainerInterface(CIT_IPLAYER,(void **) &pPlayerB); assert(pPlayerB);
170
171 // determine which direction we are moving in
172 // build camera matrix
173 Vec3 vCamAngles;
174 Matrix33 matCamera;
175 vCamAngles = m_pEntity->GetAngles();
176 matCamera.SetRotationAA(gf_DEGTORAD*vCamAngles.z, Vec3(0,0,1));
177 Matrix33 matPlayerA;
178 vCamAngles = pEntityA->GetAngles();
179 matPlayerA.SetRotationAA(gf_DEGTORAD*vCamAngles.z, Vec3(0,0,1));
180 Matrix33 matPlayerB;
181 vCamAngles = pEntityB->GetAngles();
182 matPlayerB.SetRotationAA(gf_DEGTORAD*vCamAngles.z, Vec3(0,0,1));
183
184 // we have to make a copy, because the function is called twice per frame. We modify the actions in the epc, so this
185 // would cause side effects the second time running through the function.
186 CXEntityProcessingCmd epcCopyA = epc;
187 CXEntityProcessingCmd epcCopyB = epc;
188
189 _SmartScriptObject sm(m_pGame->GetScriptSystem(),true);
190 _SmartScriptObject current(m_pGame->GetScriptSystem(),true);
191 int currentState = 0;
192 float blendFactor = 0;
193 m_pEntity->GetScriptObject()->GetValue("currentState", currentState);
194 m_pEntity->GetScriptObject()->GetValue("states", sm);
195 sm->GetAt(currentState, current);
196
197 bool linked_a;
198
199 current->GetValue("linked_a", linked_a);
200
201 Vec3 vMoveDirA;
202
203 if (linked_a)
204 vMoveDirA = CalcPlayerMoveDirection(matCamera, 0);
205 else
206 vMoveDirA = CalcPlayerMoveDirection(matCamera, 0);
207
208 Vec3 vMoveDirB = CalcPlayerMoveDirection(matCamera, 1);
209
210 // vector from player A to player B
211 Vec3 vToB = pEntityB->GetPos()-pEntityA->GetPos();
212
213 // if player a is outside the follow radius, we move into the direction of player b

Callers

nothing calls this directly

Calls 15

GetLengthSquaredFunction · 0.85
GetIEntitySystemMethod · 0.80
JoyButtonPressedMethod · 0.80
SetGlobalValueMethod · 0.80
GetEntityMethod · 0.45
GetContainerMethod · 0.45
GetAnglesMethod · 0.45
SetRotationAAMethod · 0.45
GetScriptSystemMethod · 0.45
GetValueMethod · 0.45
GetScriptObjectMethod · 0.45

Tested by

no test coverage detected