Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/Simulation2.cpp
Show First 20 Lines • Show All 534 Lines • ▼ Show 20 Lines | CComponentManager& componentManager = simContext.GetComponentManager(); | ||||
PROFILE2("Sim - Update Start"); | PROFILE2("Sim - Update Start"); | ||||
CMessageTurnStart msgTurnStart; | CMessageTurnStart msgTurnStart; | ||||
componentManager.BroadcastMessage(msgTurnStart); | componentManager.BroadcastMessage(msgTurnStart); | ||||
} | } | ||||
CmpPtr<ICmpPathfinder> cmpPathfinder(simContext, SYSTEM_ENTITY); | CmpPtr<ICmpPathfinder> cmpPathfinder(simContext, SYSTEM_ENTITY); | ||||
if (cmpPathfinder) | if (cmpPathfinder) | ||||
{ | { | ||||
cmpPathfinder->FetchAsyncResultsAndSendMessages(); | |||||
cmpPathfinder->UpdateGrid(); | cmpPathfinder->UpdateGrid(); | ||||
cmpPathfinder->FinishAsyncRequests(); | |||||
} | } | ||||
// Push AI commands onto the queue before we use them | // Push AI commands onto the queue before we use them | ||||
CmpPtr<ICmpAIManager> cmpAIManager(simContext, SYSTEM_ENTITY); | CmpPtr<ICmpAIManager> cmpAIManager(simContext, SYSTEM_ENTITY); | ||||
if (cmpAIManager) | if (cmpAIManager) | ||||
cmpAIManager->PushCommands(); | cmpAIManager->PushCommands(); | ||||
CmpPtr<ICmpCommandQueue> cmpCommandQueue(simContext, SYSTEM_ENTITY); | CmpPtr<ICmpCommandQueue> cmpCommandQueue(simContext, SYSTEM_ENTITY); | ||||
if (cmpCommandQueue) | if (cmpCommandQueue) | ||||
cmpCommandQueue->FlushTurn(commands); | cmpCommandQueue->FlushTurn(commands); | ||||
// Process newly generated move commands so the UI feels snappy | // Process newly generated move commands so the UI feels snappy | ||||
if (cmpPathfinder) | if (cmpPathfinder) | ||||
cmpPathfinder->ProcessSameTurnMoves(); | { | ||||
cmpPathfinder->StartProcessingMoves(true); | |||||
cmpPathfinder->FetchAsyncResultsAndSendMessages(); | |||||
} | |||||
// Send all the update phases | // Send all the update phases | ||||
{ | { | ||||
PROFILE2("Sim - Update"); | PROFILE2("Sim - Update"); | ||||
CMessageUpdate msgUpdate(turnLengthFixed); | CMessageUpdate msgUpdate(turnLengthFixed); | ||||
componentManager.BroadcastMessage(msgUpdate); | componentManager.BroadcastMessage(msgUpdate); | ||||
} | } | ||||
{ | { | ||||
CMessageUpdate_MotionFormation msgUpdate(turnLengthFixed); | CMessageUpdate_MotionFormation msgUpdate(turnLengthFixed); | ||||
componentManager.BroadcastMessage(msgUpdate); | componentManager.BroadcastMessage(msgUpdate); | ||||
} | } | ||||
// Process move commands for formations (group proxy) | // Process move commands for formations (group proxy) | ||||
if (cmpPathfinder) | if (cmpPathfinder) | ||||
cmpPathfinder->ProcessSameTurnMoves(); | { | ||||
cmpPathfinder->StartProcessingMoves(true); | |||||
cmpPathfinder->FetchAsyncResultsAndSendMessages(); | |||||
} | |||||
{ | { | ||||
PROFILE2("Sim - Motion Unit"); | PROFILE2("Sim - Motion Unit"); | ||||
CMessageUpdate_MotionUnit msgUpdate(turnLengthFixed); | CMessageUpdate_MotionUnit msgUpdate(turnLengthFixed); | ||||
componentManager.BroadcastMessage(msgUpdate); | componentManager.BroadcastMessage(msgUpdate); | ||||
} | } | ||||
{ | { | ||||
PROFILE2("Sim - Update Final"); | PROFILE2("Sim - Update Final"); | ||||
CMessageUpdate_Final msgUpdate(turnLengthFixed); | CMessageUpdate_Final msgUpdate(turnLengthFixed); | ||||
componentManager.BroadcastMessage(msgUpdate); | componentManager.BroadcastMessage(msgUpdate); | ||||
} | } | ||||
// Process moves resulting from group proxy movement (unit needs to catch up or realign) and any others | |||||
if (cmpPathfinder) | |||||
cmpPathfinder->ProcessSameTurnMoves(); | |||||
// Clean up any entities destroyed during the simulation update | // Clean up any entities destroyed during the simulation update | ||||
componentManager.FlushDestroyedComponents(); | componentManager.FlushDestroyedComponents(); | ||||
// Process all remaining moves | |||||
if (cmpPathfinder) | |||||
cmpPathfinder->StartProcessingMoves(false); | |||||
} | } | ||||
void CSimulation2Impl::Interpolate(float simFrameLength, float frameOffset, float realFrameLength) | void CSimulation2Impl::Interpolate(float simFrameLength, float frameOffset, float realFrameLength) | ||||
{ | { | ||||
PROFILE3("sim interpolate"); | PROFILE3("sim interpolate"); | ||||
m_LastFrameOffset = frameOffset; | m_LastFrameOffset = frameOffset; | ||||
▲ Show 20 Lines • Show All 391 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator