Add CScriptPlatform::BuildSlaveList

Former-commit-id: 4233b999c8
This commit is contained in:
Henrique Gemignani Passos Lima 2022-11-27 14:52:13 +02:00
parent 54e9753e82
commit 4bade5e25e
2 changed files with 32 additions and 0 deletions

View File

@ -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; }

View File

@ -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<CActor>(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<CScriptTrigger>(mgr.GetObjectById(current->second))) {
x354_boundsTrigger = current->second;
}
++current;
}
}
}
}