Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpUnitMotion_System.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | void CCmpUnitMotionManager::ClassInit(CComponentManager& componentManager) | ||||
componentManager.SubscribeToMessageType(MT_Update_Final); | componentManager.SubscribeToMessageType(MT_Update_Final); | ||||
componentManager.SubscribeToMessageType(MT_Update_MotionUnit); | componentManager.SubscribeToMessageType(MT_Update_MotionUnit); | ||||
componentManager.SubscribeToMessageType(MT_Update_MotionFormation); | componentManager.SubscribeToMessageType(MT_Update_MotionFormation); | ||||
#if DEBUG_RENDER | #if DEBUG_RENDER | ||||
componentManager.SubscribeToMessageType(MT_RenderSubmit); | componentManager.SubscribeToMessageType(MT_RenderSubmit); | ||||
#endif | #endif | ||||
} | } | ||||
IComponent* CCmpUnitMotionManager::Allocate(const ScriptInterface&, JS::HandleValue) | |||||
{ | |||||
return nullptr; | |||||
} | |||||
void CCmpUnitMotionManager::Deallocate(IComponent*) | |||||
{} | |||||
int CCmpUnitMotionManager::GetComponentTypeId() const | |||||
{ | |||||
return CID_UnitMotionManager; | |||||
} | |||||
void CCmpUnitMotionManager::HandleMessage(const CMessage& msg, bool UNUSED(global)) | void CCmpUnitMotionManager::HandleMessage(const CMessage& msg, bool UNUSED(global)) | ||||
{ | { | ||||
switch (msg.GetType()) | switch (msg.GetType()) | ||||
{ | { | ||||
case MT_TerrainChanged: | case MT_TerrainChanged: | ||||
{ | { | ||||
CmpPtr<ICmpTerrain> cmpTerrain(GetSystemEntity()); | CmpPtr<ICmpTerrain> cmpTerrain(GetSystemEntity()); | ||||
if (cmpTerrain->GetVerticesPerSide() != m_MovingUnits.width()) | if (cmpTerrain->GetVerticesPerSide() != m_MovingUnits.width()) | ||||
▲ Show 20 Lines • Show All 631 Lines • ▼ Show 20 Lines | |||||
#if DEBUG_RENDER | #if DEBUG_RENDER | ||||
// Make the lines thicker if the force is stronger. | // Make the lines thicker if the force is stronger. | ||||
line.m_Thickness = distanceFactor.ToDouble() / 10.0; | line.m_Thickness = distanceFactor.ToDouble() / 10.0; | ||||
line.m_Color = CColor(1, addedPressure / 20.f, 0, 0.8); | line.m_Color = CColor(1, addedPressure / 20.f, 0, 0.8); | ||||
debugDataMotionMgr.m_Lines.push_back(line); | debugDataMotionMgr.m_Lines.push_back(line); | ||||
#endif | #endif | ||||
} | } | ||||
REGISTER_COMPONENT_TYPE(UnitMotionManager) | |||||
#if DEBUG_RENDER | #if DEBUG_RENDER | ||||
void RenderDebugOverlay(SceneCollector& collector, const CFrustum& frustum, bool UNUSED(culling)) | void RenderDebugOverlay(SceneCollector& collector, const CFrustum& frustum, bool UNUSED(culling)) | ||||
{ | { | ||||
for (SOverlaySphere& sph: debugDataMotionMgr.m_Spheres) | for (SOverlaySphere& sph: debugDataMotionMgr.m_Spheres) | ||||
if (frustum.IsSphereVisible(sph.m_Center, sph.m_Radius)) | if (frustum.IsSphereVisible(sph.m_Center, sph.m_Radius)) | ||||
collector.Submit(&sph); | collector.Submit(&sph); | ||||
for (SOverlayLine& l: debugDataMotionMgr.m_Lines) | for (SOverlayLine& l: debugDataMotionMgr.m_Lines) | ||||
if (frustum.IsPointVisible(l.m_Coords[0]) || frustum.IsPointVisible(l.m_Coords[1])) | if (frustum.IsPointVisible(l.m_Coords[0]) || frustum.IsPointVisible(l.m_Coords[1])) | ||||
Show All 9 Lines |
Wildfire Games · Phabricator