Ticket #2243: actorTech.diff

File actorTech.diff, 6.1 KB (added by sanderd17, 11 years ago)
  • binaries/data/mods/public/simulation/components/TechnologyManager.js

     
    355355    {
    356356        var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
    357357        var templateName = cmpTemplateManager.GetCurrentTemplateName(ent);
    358         // Ensure that preview entites have the same properties as the final building
     358        // Ensure that preview and construction entites have the same properties as the final building
    359359        if (templateName.indexOf("preview|") != -1)
    360360            templateName = templateName.slice(8);
     361        if (templateName.indexOf("construction|") != -1)
     362            templateName = templateName.slice(13);
    361363        this.modificationCache[valueName][ent] = GetTechModifiedProperty(this.modifications, cmpTemplateManager.GetTemplate(templateName), valueName, curValue);
    362364    }
    363365   
  • binaries/data/mods/public/simulation/data/technologies/phase_town.json

     
    22    "genericName": "Town Phase",
    33    "requirements": { "any": [{"tech":"phase_town_generic"}, {"tech":"phase_town_athen"}]},
    44    "autoResearch": true,
    5     "modifications": [{"value": "TerritoryInfluence/Radius", "multiplier": 1.30}],
     5    "modifications": [{"value": "TerritoryInfluence/Radius", "multiplier": 1.30},{"value": "VisualActor/Actor", "replace":"structures/athenians/gymnasion.xml"}],
    66    "affects": ["CivCentre"],
    77    "soundComplete": "interface/alarm/alarm_phase.xml"
    88}
  • source/simulation2/components/CCmpVisualActor.cpp

     
    3030#include "ICmpTemplateManager.h"
    3131#include "ICmpTerrain.h"
    3232#include "ICmpUnitMotion.h"
     33#include "ICmpValueModificationManager.h"
    3334#include "ICmpVision.h"
    3435
    3536#include "graphics/Decal.h"
     
    5657        componentManager.SubscribeToMessageType(MT_Interpolate);
    5758        componentManager.SubscribeToMessageType(MT_RenderSubmit);
    5859        componentManager.SubscribeToMessageType(MT_OwnershipChanged);
     60        componentManager.SubscribeToMessageType(MT_ValueModification);
    5961        componentManager.SubscribeGloballyToMessageType(MT_TerrainChanged);
    6062    }
    6163
     
    6264    DEFAULT_COMPONENT_ALLOCATOR(VisualActor)
    6365
    6466private:
    65     std::wstring m_ActorName;
     67    std::wstring m_OriginalActorName, m_ActorName;
    6668    CUnit* m_Unit;
    6769
    6870    fixed m_R, m_G, m_B; // shading colour
     
    182184        m_Seed = GetEntityId();
    183185
    184186        if (paramNode.GetChild("Foundation").IsOk() && paramNode.GetChild("FoundationActor").IsOk())
     187        {
    185188            m_ActorName = paramNode.GetChild("FoundationActor").ToString();
     189            m_OriginalActorName = L"";
     190        }
    186191        else
    187             m_ActorName = paramNode.GetChild("Actor").ToString();
     192        {
     193            m_OriginalActorName = m_ActorName = paramNode.GetChild("Actor").ToString();
     194        }
    188195
    189196        m_VisibleInAtlasOnly = paramNode.GetChild("VisibleInAtlasOnly").ToBool();
    190197
     
    297304        {
    298305            const CMessageOwnershipChanged& msgData = static_cast<const CMessageOwnershipChanged&> (msg);
    299306            m_Unit->GetModel().SetPlayerID(msgData.to);
     307
     308            // also apply the technology changes to preview models
     309            if (m_OriginalActorName.length() == 0)
     310                break; // don't change foundation actors
     311            CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity());
     312            std::wstring newActorName = cmpValueModificationManager->ApplyModifications(L"VisualActor/Actor", m_OriginalActorName, GetEntityId());
     313            if (newActorName != m_ActorName)
     314            {
     315                m_ActorName = newActorName;
     316                ReloadActor();
     317            }
    300318            break;
    301319        }
    302320        case MT_TerrainChanged:
     
    305323            m_Unit->GetModel().SetTerrainDirty(msgData.i0, msgData.j0, msgData.i1, msgData.j1);
    306324            break;
    307325        }
     326        case MT_ValueModification:
     327        {
     328            const CMessageValueModification& msgData = static_cast<const CMessageValueModification&> (msg);
     329            if (msgData.component == L"VisualActor")
     330            {
     331                if (m_OriginalActorName.length() == 0)
     332                    break; // don't change foundation actors
     333                CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity());
     334                std::wstring newActorName = cmpValueModificationManager->ApplyModifications(L"VisualActor/Actor", m_OriginalActorName, GetEntityId());
     335                if (newActorName != m_ActorName)
     336                {
     337                    m_ActorName = newActorName;
     338                    ReloadActor();
     339                }
     340            }
    308341        }
     342        }
    309343    }
    310344
    311345    virtual CBoundingBoxAligned GetBounds()
  • source/simulation2/components/ICmpValueModificationManager.cpp

     
    3939    {
    4040        return m_Script.Call<u32>("ApplyModifications", valueName, currentValue, entity);
    4141    }
     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    }
    4247};
    4348
    4449REGISTER_COMPONENT_SCRIPT_WRAPPER(ValueModificationManagerScripted)
  • source/simulation2/components/ICmpValueModificationManager.h

     
    3232public:
    3333    virtual fixed ApplyModifications(std::wstring valueName, fixed currentValue, entity_id_t entity) = 0;
    3434    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;
    3536
    3637    DECLARE_INTERFACE_TYPE(ValueModificationManager)
    3738};