Ticket #1958: UnitMotionTech.patch
File UnitMotionTech.patch, 2.2 KB (added by , 11 years ago) |
---|
-
source/simulation2/components/CCmpUnitMotion.cpp
26 26 #include "simulation2/components/ICmpPosition.h" 27 27 #include "simulation2/components/ICmpPathfinder.h" 28 28 #include "simulation2/components/ICmpRangeManager.h" 29 #include "simulation2/components/ICmpPlayerManager.h" 30 #include "simulation2/components/ICmpTechnologyManager.h" 29 31 #include "simulation2/helpers/Geometry.h" 30 32 #include "simulation2/helpers/Render.h" 31 33 #include "simulation2/MessageTypes.h" … … 109 111 componentManager.SubscribeToMessageType(MT_Update_MotionUnit); 110 112 componentManager.SubscribeToMessageType(MT_RenderSubmit); // for debug overlays 111 113 componentManager.SubscribeToMessageType(MT_PathResult); 114 componentManager.SubscribeGloballyToMessageType(MT_TechnologyModification); 112 115 } 113 116 114 117 DEFAULT_COMPONENT_ALLOCATOR(UnitMotion) … … 395 398 PathResult(msgData.ticket, msgData.path); 396 399 break; 397 400 } 401 case MT_TechnologyModification: 402 { 403 const CMessageTechnologyModification& msgData = static_cast<const CMessageTechnologyModification&> (msg); 404 if (msgData.component == L"UnitMotion") 405 { 406 CmpPtr<ICmpOwnership> cmpOwnership(GetSimContext(), GetEntityId()); 407 if (cmpOwnership) 408 { 409 player_id_t owner = cmpOwnership->GetOwner(); 410 if (owner != INVALID_PLAYER && owner == msgData.player) 411 { 412 CmpPtr<ICmpPlayerManager> cmpPlayerManager(GetSimContext(), SYSTEM_ENTITY); 413 entity_id_t playerEnt = cmpPlayerManager->GetPlayerByID(owner); 414 CmpPtr<ICmpTechnologyManager> cmpTechnologyManager(GetSimContext(), playerEnt); 415 if (playerEnt != INVALID_ENTITY && cmpTechnologyManager) 416 { 417 m_WalkSpeed = cmpTechnologyManager->ApplyModifications(L"UnitMotion/Walk/Speed", m_WalkSpeed, GetEntityId()); 418 m_Speed = m_WalkSpeed; 419 m_RunSpeed = cmpTechnologyManager->ApplyModifications(L"UnitMotion/Run/Speed", m_RunSpeed, GetEntityId()); 420 } 421 } 422 } 423 } 424 break; 398 425 } 426 427 } 399 428 } 400 429 401 430 virtual bool IsMoving()