Ticket #2243: actorTech.4.diff
File actorTech.4.diff, 7.6 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/simulation/components/TechnologyManager.js
373 373 this.modificationCache[valueName][ent] = {"origValue": curValue}; 374 374 var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); 375 375 var templateName = cmpTemplateManager.GetCurrentTemplateName(ent); 376 // Ensure that preview entites have the same properties as the final building377 if (templateName.indexOf("preview|") != -1)378 templateName = templateName.slice( 8);376 // Ensure that preview or construction entites have the same properties as the final building 377 if (templateName.indexOf("preview|") > -1 || templateName.indexOf("construction|") > -1 ) 378 templateName = templateName.slice(templateName.indexOf("|") + 1); 379 379 this.modificationCache[valueName][ent].newValue = GetTechModifiedProperty(this.modifications, cmpTemplateManager.GetTemplate(templateName), valueName, curValue); 380 380 } 381 381 -
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" … … 57 58 componentManager.SubscribeToMessageType(MT_Interpolate); 58 59 componentManager.SubscribeToMessageType(MT_RenderSubmit); 59 60 componentManager.SubscribeToMessageType(MT_OwnershipChanged); 61 componentManager.SubscribeToMessageType(MT_ValueModification); 60 62 componentManager.SubscribeGloballyToMessageType(MT_TerrainChanged); 61 63 } 62 64 … … 63 65 DEFAULT_COMPONENT_ALLOCATOR(VisualActor) 64 66 65 67 private: 66 std::wstring m_ActorName; 68 std::wstring m_BaseActorName, m_ActorName; 69 bool m_IsFoundationActor; 67 70 CUnit* m_Unit; 68 71 69 72 fixed m_R, m_G, m_B; // shading colour … … 188 191 189 192 m_Seed = GetEntityId(); 190 193 191 if (paramNode.GetChild("Foundation").IsOk() && paramNode.GetChild("FoundationActor").IsOk()) 192 m_ActorName = paramNode.GetChild("FoundationActor").ToString(); 194 m_IsFoundationActor = paramNode.GetChild("Foundation").IsOk() && paramNode.GetChild("FoundationActor").IsOk(); 195 if (m_IsFoundationActor) 196 m_BaseActorName = m_ActorName = paramNode.GetChild("FoundationActor").ToString(); 193 197 else 194 m_ ActorName = paramNode.GetChild("Actor").ToString();198 m_BaseActorName = m_ActorName = paramNode.GetChild("Actor").ToString(); 195 199 196 200 m_VisibleInAtlasOnly = paramNode.GetChild("VisibleInAtlasOnly").ToBool(); 197 201 m_IsActorOnly = paramNode.GetChild("ActorOnly").IsOk(); … … 228 232 229 233 serialize.NumberU32_Unbounded("seed", m_Seed); 230 234 // TODO: variation/selection strings 235 serialize.String("actor", m_ActorName, 0, 256); 231 236 232 237 serialize.NumberFixed_Unbounded("constructionprogress", m_ConstructionProgress); 233 238 … … 240 245 241 246 if (serialize.IsDebug()) 242 247 { 243 serialize.String(" actor", m_ActorName, 0, 256);248 serialize.String("base actor", m_BaseActorName, 0, 256); 244 249 } 245 250 246 251 SerializeCommon(serialize); … … 254 259 255 260 SerializeCommon(deserialize); 256 261 257 // If we serialized a different seed , reload actor258 if (oldSeed != GetActorSeed() )262 // If we serialized a different seed or different actor, reload actor 263 if (oldSeed != GetActorSeed() || m_BaseActorName != m_ActorName) 259 264 ReloadActor(); 260 265 261 266 fixed repeattime = m_AnimSyncRepeatTime; // save because SelectAnimation overwrites it … … 313 318 m_Unit->GetModel().SetTerrainDirty(msgData.i0, msgData.j0, msgData.i1, msgData.j1); 314 319 break; 315 320 } 321 case MT_ValueModification: 322 { 323 const CMessageValueModification& msgData = static_cast<const CMessageValueModification&> (msg); 324 if (msgData.component != L"VisualActor") 325 break; 326 CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity()); 327 std::wstring newActorName; 328 if (m_IsFoundationActor) 329 newActorName = cmpValueModificationManager->ApplyModifications(L"VisualActor/FoundationActor", m_BaseActorName, GetEntityId()); 330 else 331 newActorName = cmpValueModificationManager->ApplyModifications(L"VisualActor/Actor", m_BaseActorName, GetEntityId()); 332 if (newActorName != m_ActorName) 333 { 334 m_ActorName = newActorName; 335 ReloadActor(); 336 } 337 break; 316 338 } 339 } 317 340 } 318 341 319 342 virtual CBoundingBoxAligned GetBounds() … … 519 542 if (GetSimContext().HasUnitManager()) 520 543 { 521 544 std::set<CStr> selections; 522 m_Unit = GetSimContext().GetUnitManager().CreateUnit(m_ActorName, GetActorSeed(), selections); 545 std::wstring actorName = m_ActorName; 546 if (actorName.find(L".xml") == std::wstring::npos) 547 actorName += L".xml"; 548 m_Unit = GetSimContext().GetUnitManager().CreateUnit(actorName, GetActorSeed(), selections); 523 549 if (m_Unit) 524 550 { 525 551 CModelAbstract& model = m_Unit->GetModel(); … … 637 663 return; 638 664 639 665 std::set<CStr> selections; 640 CUnit* newUnit = GetSimContext().GetUnitManager().CreateUnit(m_ActorName, GetActorSeed(), selections); 666 std::wstring actorName = m_ActorName; 667 if (actorName.find(L".xml") == std::wstring::npos) 668 actorName += L".xml"; 669 CUnit* newUnit = GetSimContext().GetUnitManager().CreateUnit(actorName, GetActorSeed(), selections); 641 670 642 671 if (!newUnit) 643 672 return; -
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 };