mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-21 09:39:10 +00:00
CPlayer header, more CScriptPlatform, renaming
Former-commit-id: 5d9f7afa3b
This commit is contained in:
@@ -256,27 +256,27 @@ CScriptMazeNode::CScriptMazeNode(TUniqueId uid, const rstl::string& name, const
|
||||
|
||||
void CScriptMazeNode::Accept(IVisitor& visitor) { visitor.Visit(*this); }
|
||||
|
||||
static inline TUniqueId GenerateObject(CStateManager& mgr, const TEditorId& eid) {
|
||||
bool wasGeneratingObject = mgr.IsGeneratingObject();
|
||||
mgr.SetIsGeneratingObject(true);
|
||||
TUniqueId objUid = mgr.GenerateObject(eid).second;
|
||||
mgr.SetIsGeneratingObject(wasGeneratingObject);
|
||||
return objUid;
|
||||
}
|
||||
// static inline TUniqueId GenerateObject(CStateManager& mgr, const TEditorId& eid) {
|
||||
// bool wasGeneratingObject = mgr.IsGeneratingObject();
|
||||
// mgr.SetIsGeneratingObject(true);
|
||||
// TUniqueId objUid = mgr.GenerateObject(eid).second;
|
||||
// mgr.SetIsGeneratingObject(wasGeneratingObject);
|
||||
// return objUid;
|
||||
// }
|
||||
|
||||
// TODO non-matching
|
||||
// https://decomp.me/scratch/IvHBz
|
||||
void CScriptMazeNode::GenerateObjects(CStateManager& mgr) {
|
||||
rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin();
|
||||
for (; conn != GetConnectionList().end(); ++conn) {
|
||||
rstl::vector< SConnection >::iterator conn = ConnectionList().begin();
|
||||
for (; conn != ConnectionList().end(); ++conn) {
|
||||
if (conn->x0_state != kSS_MaxReached || conn->x4_msg != kSM_Activate) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CEntity* ent = mgr.ObjectById(mgr.GetIdForScript(conn->x8_objId));
|
||||
CScriptEffect* scriptEffect = TCastToPtr< CScriptEffect >(ent);
|
||||
CScriptActor* scriptActor = TCastToPtr< CScriptActor >(ent);
|
||||
CScriptTrigger* scriptTrigger = TCastToPtr< CScriptTrigger >(ent);
|
||||
const CEntity* ent = mgr.ObjectById(mgr.GetIdForScript(conn->x8_objId));
|
||||
const CScriptEffect* scriptEffect = TCastToConstPtr< CScriptEffect >(ent);
|
||||
const CScriptActor* scriptActor = TCastToConstPtr< CScriptActor >(ent);
|
||||
const CScriptTrigger* scriptTrigger = TCastToConstPtr< CScriptTrigger >(ent);
|
||||
if (!scriptEffect && !scriptActor && !scriptTrigger) {
|
||||
continue;
|
||||
}
|
||||
@@ -434,8 +434,8 @@ void CScriptMazeNode::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C
|
||||
}
|
||||
}
|
||||
CObjectList& list = mgr.GetObjectListById(kOL_All);
|
||||
int objIdx = list.GetFirstObjectIndex();
|
||||
while (objIdx != -1) {
|
||||
for (int objIdx = list.GetFirstObjectIndex(); objIdx != -1;
|
||||
objIdx = list.GetNextObjectIndex(objIdx)) {
|
||||
if (CScriptMazeNode* node = TCastToPtr< CScriptMazeNode >(list[objIdx])) {
|
||||
if (node->xe8_col == xe8_col - 1 && node->xec_row == xec_row &&
|
||||
node->xf0_side == CMazeState::kS_Right) {
|
||||
@@ -474,7 +474,6 @@ void CScriptMazeNode::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C
|
||||
}
|
||||
}
|
||||
}
|
||||
objIdx = list.GetNextObjectIndex(objIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "MetroidPrime/CActorParameters.hpp"
|
||||
#include "MetroidPrime/CAnimData.hpp"
|
||||
#include "MetroidPrime/CGameCollision.hpp"
|
||||
#include "MetroidPrime/Player/CPlayer.hpp"
|
||||
#include "MetroidPrime/ScriptObjects/CScriptWaypoint.hpp"
|
||||
|
||||
#include "Kyoto/Graphics/CGX.hpp"
|
||||
@@ -143,7 +145,8 @@ void CScriptPlatform::AddRider(rstl::vector< SRiders >& riders, TUniqueId riderI
|
||||
SRiders rider(riderId);
|
||||
if (CPhysicsActor* act = TCastToPtr< CPhysicsActor >(mgr.ObjectById(riderId))) {
|
||||
CVector3f rideePos = ridee->GetTranslation();
|
||||
rider.x8_transform.SetTranslation(ridee->GetTransform().TransposeRotate(act->GetTranslation() - rideePos));
|
||||
rider.x8_transform.SetTranslation(
|
||||
ridee->GetTransform().TransposeRotate(act->GetTranslation() - rideePos));
|
||||
mgr.SendScriptMsg(act, ridee->GetUniqueId(), kSM_AddPlatformRider);
|
||||
}
|
||||
riders.reserve(riders.size() + 1);
|
||||
@@ -152,3 +155,78 @@ void CScriptPlatform::AddRider(rstl::vector< SRiders >& riders, TUniqueId riderI
|
||||
it->x4_decayTimer = 1.f / 6.f;
|
||||
}
|
||||
}
|
||||
|
||||
TEntityList CScriptPlatform::BuildNearListFromRiders(CStateManager& mgr,
|
||||
const rstl::vector< SRiders >& riders) {
|
||||
TEntityList result;
|
||||
rstl::vector< SRiders >::const_iterator it = riders.begin();
|
||||
for (; it != riders.end(); ++it) {
|
||||
if (CActor* actor = TCastToPtr< CActor >(mgr.ObjectById(it->x0_uid))) {
|
||||
result.push_back(actor->GetUniqueId());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CScriptPlatform::DecayRiders(rstl::vector< SRiders >& riders, f32 dt, CStateManager& mgr) {
|
||||
rstl::vector< SRiders >::iterator it = riders.begin();
|
||||
while (it != riders.end()) {
|
||||
it->x4_decayTimer -= dt;
|
||||
if (it->x4_decayTimer <= 0.f) {
|
||||
mgr.SendScriptMsgAlways(it->x0_uid, kInvalidUniqueId, kSM_AddPlatformRider);
|
||||
#ifdef NON_MATCHING
|
||||
it = riders.erase(it);
|
||||
#else
|
||||
// Oops, forgot to reassign the iterator
|
||||
riders.erase(it);
|
||||
#endif
|
||||
} else {
|
||||
it = it + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: minor regswap
|
||||
void CScriptPlatform::MoveRiders(CStateManager& mgr, f32 dt, bool active,
|
||||
rstl::vector< SRiders >& riders,
|
||||
rstl::vector< SRiders >& collidedRiders, const CTransform4f& oldXf,
|
||||
const CTransform4f& newXf, const CVector3f& dragDelta,
|
||||
CQuaternion rotDelta) {
|
||||
rstl::vector< SRiders >::iterator it = riders.begin();
|
||||
while (it != riders.end()) {
|
||||
if (active) {
|
||||
CPhysicsActor* act = TCastToPtr< CPhysicsActor >(mgr.ObjectById(it->x0_uid));
|
||||
if (act == nullptr || !act->GetActive()) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
const CTransform4f& xf = it->x8_transform;
|
||||
CVector3f diff = newXf.Rotate(xf.GetTranslation()) - oldXf.Rotate(xf.GetTranslation());
|
||||
diff.SetZ(0.f);
|
||||
CVector3f delta = dragDelta + diff;
|
||||
CVector3f newPos = act->GetTranslation() + delta;
|
||||
act->MoveCollisionPrimitive(delta);
|
||||
bool collision = CGameCollision::DetectStaticCollisionBoolean(
|
||||
mgr, *act->GetCollisionPrimitive(), act->GetPrimitiveTransform(),
|
||||
act->GetMaterialFilter());
|
||||
act->MoveCollisionPrimitive(CVector3f::Zero());
|
||||
if (collision) {
|
||||
AddRider(collidedRiders, act->GetUniqueId(), act, mgr);
|
||||
#ifdef NON_MATCHING
|
||||
it = riders.erase(it);
|
||||
#else
|
||||
// Oops, forgot to reassign the iterator (again)
|
||||
riders.erase(it);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
act->SetTranslation(newPos);
|
||||
const CPlayer* player = TCastToConstPtr< CPlayer >(*act);
|
||||
if (player == nullptr || player->GetOrbitState() == CPlayer::kOS_NoOrbit) {
|
||||
const CQuaternion& rot = rotDelta * CQuaternion::FromMatrix(act->GetTransform());
|
||||
act->SetTransform(rot.BuildTransform4f(act->GetTranslation()));
|
||||
}
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,6 @@ CMain::CMain()
|
||||
|
||||
CMain::~CMain() {}
|
||||
|
||||
#define ALIGN_UP(x, a) (((x) + (a - 1)) & ~(a - 1))
|
||||
#define UNUSED_STACK_VAL 0x7337D00D
|
||||
|
||||
void CMain::InitializeSubsystems() {
|
||||
|
||||
Reference in New Issue
Block a user