Ticket #4279: update_vision_on_ownershipchange_v1.patch
File update_vision_on_ownershipchange_v1.patch, 2.3 KB (added by , 8 years ago) |
---|
-
source/simulation2/components/CCmpVision.cpp
public: 83 83 { 84 84 switch (msg.GetType()) 85 85 { 86 86 case MT_OwnershipChanged: 87 87 { 88 if (!m_RevealShore)89 break;90 91 88 const CMessageOwnershipChanged& msgData = static_cast<const CMessageOwnershipChanged&> (msg); 92 89 if (msgData.entity != GetEntityId()) 93 90 break; 94 91 92 ReloadRange(); 93 94 if (!m_RevealShore) 95 break; 95 96 CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); 96 97 cmpRangeManager->RevealShore(msgData.from, false); 97 98 cmpRangeManager->RevealShore(msgData.to, true); 98 99 break; 99 100 } … … public: 101 102 { 102 103 const CMessageValueModification& msgData = static_cast<const CMessageValueModification&> (msg); 103 104 if (msgData.component != L"Vision") 104 105 break; 105 106 106 CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity()); 107 if (!cmpValueModificationManager) 108 break; 109 110 entity_pos_t newRange = cmpValueModificationManager->ApplyModifications(L"Vision/Range", m_BaseRange, GetEntityId()); 111 if (newRange == m_Range) 112 break; 113 114 // Update our vision range and broadcast message 115 entity_pos_t oldRange = m_Range; 116 m_Range = newRange; 117 CMessageVisionRangeChanged msg(GetEntityId(), oldRange, newRange); 118 GetSimContext().GetComponentManager().BroadcastMessage(msg); 107 ReloadRange(); 119 108 break; 120 109 } 121 110 case MT_Deserialized: 122 111 { 123 112 CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity()); … … public: 126 115 break; 127 116 } 128 117 } 129 118 } 130 119 120 virtual void ReloadRange() 121 { 122 CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity()); 123 if (!cmpValueModificationManager) 124 return; 125 126 entity_pos_t range newRange = cmpValueModificationManager->ApplyModifications(L"Vision/Range", m_BaseRange, GetEntityId()); 127 if (newRange == m_Range) 128 return; 129 130 // Update our vision range and broadcast message 131 entity_pos_t oldRange = m_Range; 132 m_Range = newRange; 133 CMessageVisionRangeChanged msg(GetEntityId(), oldRange, newRange); 134 GetSimContext().GetComponentManager().BroadcastMessage(msg); 135 } 136 131 137 virtual entity_pos_t GetRange() 132 138 { 133 139 return m_Range; 134 140 } 135 141 };