Ticket #2243: actorTech.2.diff
File actorTech.2.diff, 6.7 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/simulation/components/TechnologyManager.js
356 356 this.modificationCache[valueName][ent] = {"origValue": curValue}; 357 357 var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); 358 358 var templateName = cmpTemplateManager.GetCurrentTemplateName(ent); 359 // Ensure that preview entites have the same properties as the final building360 if (templateName.indexOf("preview|") != -1)361 templateName = templateName.slice( 8);359 // Ensure that preview or construction entites have the same properties as the final building 360 if (templateName.indexOf("preview|") > -1 || templateName.indexOf("construction|") > -1 ) 361 templateName = templateName.slice(templateName.indexOf("|") + 1); 362 362 this.modificationCache[valueName][ent].newValue = GetTechModifiedProperty(this.modifications, cmpTemplateManager.GetTemplate(templateName), valueName, curValue); 363 363 } 364 365 364 return this.modificationCache[valueName][ent].newValue; 366 365 }; 367 366 -
binaries/data/mods/public/simulation/data/technologies/phase_town.json
2 2 "genericName": "Town Phase", 3 3 "requirements": { "any": [{"tech":"phase_town_generic"}, {"tech":"phase_town_athen"}]}, 4 4 "autoResearch": true, 5 "modifications": [{"value": "TerritoryInfluence/Radius", "multiply": 1.30} ],5 "modifications": [{"value": "TerritoryInfluence/Radius", "multiply": 1.30},{"value": "VisualActor/Actor", "replace":"structures/athenians/gymnasion.xml"}], 6 6 "affects": ["CivCentre"], 7 7 "soundComplete": "interface/alarm/alarm_phase.xml" 8 8 } -
source/simulation2/components/CCmpVisualActor.cpp
30 30 #include "ICmpTemplateManager.h" 31 31 #include "ICmpTerrain.h" 32 32 #include "ICmpUnitMotion.h" 33 #include "ICmpValueModificationManager.h" 33 34 #include "ICmpVision.h" 34 35 35 36 #include "graphics/Decal.h" … … 56 57 componentManager.SubscribeToMessageType(MT_Interpolate); 57 58 componentManager.SubscribeToMessageType(MT_RenderSubmit); 58 59 componentManager.SubscribeToMessageType(MT_OwnershipChanged); 60 componentManager.SubscribeToMessageType(MT_ValueModification); 59 61 componentManager.SubscribeGloballyToMessageType(MT_TerrainChanged); 60 62 } 61 63 … … 62 64 DEFAULT_COMPONENT_ALLOCATOR(VisualActor) 63 65 64 66 private: 65 std::wstring m_ActorName; 67 std::wstring m_OriginalActorName, m_ActorName; 68 bool m_IsFoundationActor; 66 69 CUnit* m_Unit; 67 70 68 71 fixed m_R, m_G, m_B; // shading colour … … 181 184 182 185 m_Seed = GetEntityId(); 183 186 184 if (paramNode.GetChild("Foundation").IsOk() && paramNode.GetChild("FoundationActor").IsOk()) 185 m_ActorName = paramNode.GetChild("FoundationActor").ToString(); 187 m_IsFoundationActor = paramNode.GetChild("Foundation").IsOk() && paramNode.GetChild("FoundationActor").IsOk(); 188 if (m_IsFoundationActor) 189 m_OriginalActorName = m_ActorName = paramNode.GetChild("FoundationActor").ToString(); 186 190 else 187 m_ ActorName = paramNode.GetChild("Actor").ToString();191 m_OriginalActorName = m_ActorName = paramNode.GetChild("Actor").ToString(); 188 192 189 193 m_VisibleInAtlasOnly = paramNode.GetChild("VisibleInAtlasOnly").ToBool(); 190 194 … … 297 301 { 298 302 const CMessageOwnershipChanged& msgData = static_cast<const CMessageOwnershipChanged&> (msg); 299 303 m_Unit->GetModel().SetPlayerID(msgData.to); 304 305 // also update the actor in case of ownership changes 306 CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity()); 307 std::wstring newActorName; 308 if (m_IsFoundationActor) 309 newActorName = cmpValueModificationManager->ApplyModifications(L"VisualActor/FoundationActor", m_OriginalActorName, GetEntityId()); 310 else 311 newActorName = cmpValueModificationManager->ApplyModifications(L"VisualActor/Actor", m_OriginalActorName, GetEntityId()); 312 if (newActorName != m_ActorName) 313 { 314 m_ActorName = newActorName; 315 ReloadActor(); 316 } 300 317 break; 301 318 } 302 319 case MT_TerrainChanged: … … 305 322 m_Unit->GetModel().SetTerrainDirty(msgData.i0, msgData.j0, msgData.i1, msgData.j1); 306 323 break; 307 324 } 325 case MT_ValueModification: 326 { 327 const CMessageValueModification& msgData = static_cast<const CMessageValueModification&> (msg); 328 if (msgData.component != L"VisualActor") 329 break; 330 CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity()); 331 std::wstring newActorName; 332 if (m_IsFoundationActor) 333 newActorName = cmpValueModificationManager->ApplyModifications(L"VisualActor/FoundationActor", m_OriginalActorName, GetEntityId()); 334 else 335 newActorName = cmpValueModificationManager->ApplyModifications(L"VisualActor/Actor", m_OriginalActorName, GetEntityId()); 336 if (newActorName != m_ActorName) 337 { 338 m_ActorName = newActorName; 339 ReloadActor(); 340 } 341 break; 308 342 } 343 } 309 344 } 310 345 311 346 virtual CBoundingBoxAligned GetBounds() -
source/simulation2/components/ICmpValueModificationManager.cpp
39 39 { 40 40 return m_Script.Call<u32>("ApplyModifications", valueName, currentValue, entity); 41 41 } 42 43 virtual std::wstring ApplyModifications(std::wstring valueName, std::wstring currentValue, entity_id_t entity) 44 { 45 return m_Script.Call<std::wstring>("ApplyModifications", valueName, currentValue, entity); 46 } 42 47 }; 43 48 44 49 REGISTER_COMPONENT_SCRIPT_WRAPPER(ValueModificationManagerScripted) -
source/simulation2/components/ICmpValueModificationManager.h
32 32 public: 33 33 virtual fixed ApplyModifications(std::wstring valueName, fixed currentValue, entity_id_t entity) = 0; 34 34 virtual u32 ApplyModifications(std::wstring valueName, u32 currentValue, entity_id_t entity) = 0; 35 virtual std::wstring ApplyModifications(std::wstring valueName, std::wstring currentValue, entity_id_t entity) = 0; 35 36 36 37 DECLARE_INTERFACE_TYPE(ValueModificationManager) 37 38 };