diff --git a/include/MetroidPrime/ScriptObjects/CScriptPlatform.hpp b/include/MetroidPrime/ScriptObjects/CScriptPlatform.hpp index 842e30e2..dca0bc46 100644 --- a/include/MetroidPrime/ScriptObjects/CScriptPlatform.hpp +++ b/include/MetroidPrime/ScriptObjects/CScriptPlatform.hpp @@ -26,6 +26,10 @@ struct SRiders { SRiders(TUniqueId uid) : x0_uid(uid), x4_decayTimer(1.f / 6.f), x8_transform(CTransform4f::Identity()) {} + + SRiders(TUniqueId uid, float timer, const CTransform4f& xf) + : x0_uid(uid), x4_decayTimer(timer), x8_transform(xf) {} + bool operator==(const SRiders& other) const { return x0_uid == other.x0_uid; } }; @@ -69,6 +73,7 @@ public: bool IsRider(TUniqueId id) const; bool IsSlave(TUniqueId id) const; + void BuildSlaveList(CStateManager& mgr); void SetControlledAnimation(bool controlled) { x356_25_controlledAnimation = controlled; } diff --git a/src/MetroidPrime/ScriptObjects/CScriptPlatform.cpp b/src/MetroidPrime/ScriptObjects/CScriptPlatform.cpp index 906271dd..686e95cf 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptPlatform.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptPlatform.cpp @@ -276,3 +276,30 @@ void CScriptPlatform::PreThink(float dt, CStateManager& mgr) { } } } + + +void CScriptPlatform::BuildSlaveList(CStateManager& mgr) { + x328_slavesStatic.reserve(GetConnectionList().size()); + rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin(); + for (; conn != GetConnectionList().end(); ++conn) { + if (conn->x0_state == kSS_Play && conn->x4_msg == kSM_Activate) { + if (CActor* act = TCastToPtr(mgr.ObjectById(mgr.GetIdForScript(conn->x8_objId)))) { + act->AddMaterial(kMT_PlatformSlave, mgr); + CTransform4f xf = act->GetTransform(); + xf.SetTranslation(act->GetTranslation() - GetTranslation()); + x328_slavesStatic.push_back(SRiders(act->GetUniqueId(), 0.166667f, xf)); + } + } else if (conn->x0_state == kSS_InheritBounds && conn->x4_msg == kSM_Activate) { + + CStateManager::TIdListResult search = mgr.GetIdListForScript(conn->x8_objId); + CStateManager::TIdList::const_iterator current = search.first; + CStateManager::TIdList::const_iterator end = search.second; + while (current != end) { + if (TCastToConstPtr(mgr.GetObjectById(current->second))) { + x354_boundsTrigger = current->second; + } + ++current; + } + } + } +}