Match and link CScriptAiJumpPoint

Former-commit-id: de4370288f
This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-21 19:00:19 +03:00
parent 501ea1c654
commit 75e1e3f144
5 changed files with 103 additions and 8 deletions

View File

@ -3,8 +3,8 @@
.section .data
.balign 8
.global lbl_803E6398
lbl_803E6398:
.global __vt__18CScriptAiJumpPoint
__vt__18CScriptAiJumpPoint:
# ROM: 0x3E3398
.4byte 0
.4byte 0
@ -56,9 +56,9 @@ __dt__18CScriptAiJumpPointFv:
/* 801EF200 001EC160 93 C1 00 08 */ stw r30, 8(r1)
/* 801EF204 001EC164 7C 7E 1B 79 */ or. r30, r3, r3
/* 801EF208 001EC168 41 82 00 3C */ beq lbl_801EF244
/* 801EF20C 001EC16C 3C 60 80 3E */ lis r3, lbl_803E6398@ha
/* 801EF20C 001EC16C 3C 60 80 3E */ lis r3, __vt__18CScriptAiJumpPoint@ha
/* 801EF210 001EC170 34 1E 00 EC */ addic. r0, r30, 0xec
/* 801EF214 001EC174 38 03 63 98 */ addi r0, r3, lbl_803E6398@l
/* 801EF214 001EC174 38 03 63 98 */ addi r0, r3, __vt__18CScriptAiJumpPoint@l
/* 801EF218 001EC178 90 1E 00 00 */ stw r0, 0(r30)
/* 801EF21C 001EC17C 41 82 00 0C */ beq lbl_801EF228
/* 801EF220 001EC180 38 00 00 00 */ li r0, 0
@ -290,9 +290,9 @@ Accept__18CScriptAiJumpPointFR8IVisitor:
/* 801EF524 001EC484 38 61 00 B8 */ addi r3, r1, 0xb8
/* 801EF528 001EC488 38 80 FF FF */ li r4, -1
/* 801EF52C 001EC48C 4B F2 75 21 */ bl __dt__10CModelDataFv
/* 801EF530 001EC490 3C 80 80 3E */ lis r4, lbl_803E6398@ha
/* 801EF530 001EC490 3C 80 80 3E */ lis r4, __vt__18CScriptAiJumpPoint@ha
/* 801EF534 001EC494 38 61 00 38 */ addi r3, r1, 0x38
/* 801EF538 001EC498 38 04 63 98 */ addi r0, r4, lbl_803E6398@l
/* 801EF538 001EC498 38 04 63 98 */ addi r0, r4, __vt__18CScriptAiJumpPoint@l
/* 801EF53C 001EC49C 38 81 00 2C */ addi r4, r1, 0x2c
/* 801EF540 001EC4A0 90 1F 00 00 */ stw r0, 0(r31)
/* 801EF544 001EC4A4 38 A1 00 20 */ addi r5, r1, 0x20

View File

@ -298,7 +298,7 @@ LIBS = [
"MetroidPrime/Enemies/CThardus",
"MetroidPrime/CActorParticles",
"MetroidPrime/Enemies/CWallCrawlerSwarm",
"MetroidPrime/ScriptObjects/CScriptAiJumpPoint",
["MetroidPrime/ScriptObjects/CScriptAiJumpPoint", True],
"MetroidPrime/CMessageScreen",
"MetroidPrime/Enemies/CFlaahgraTentacle",
"MetroidPrime/Weapons/GunController/CGSFidget",

View File

@ -0,0 +1,33 @@
#ifndef _CSCRIPTAIJUMPPOINT
#define _CSCRIPTAIJUMPPOINT
#include "MetroidPrime/CActor.hpp"
class CScriptAiJumpPoint : public CActor {
private:
float xe8_apex;
rstl::optional_object<CAABox> xec_touchBounds;
bool x108_24_inUse : 1;
TUniqueId x10a_occupant;
TUniqueId x10c_currentWaypoint;
TUniqueId x10e_nextWaypoint;
float x110_timeRemaining;
public:
CScriptAiJumpPoint(TUniqueId, const rstl::string&, const CEntityInfo&, const CTransform4f&, bool,
float);
~CScriptAiJumpPoint();
void Accept(IVisitor& visitor) override;
void Think(float, CStateManager&) override;
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
void AddToRenderer(const CFrustumPlanes&, const CStateManager&) const override;
void Render(const CStateManager&) const override;
rstl::optional_object< CAABox > GetTouchBounds() const override;
bool GetInUse(TUniqueId uid) const;
TUniqueId GetJumpPoint() const { return x10c_currentWaypoint; }
TUniqueId GetJumpTarget() const { return x10e_nextWaypoint; }
float GetJumpApex() const { return xe8_apex; }
};
#endif // _CSCRIPTAIJUMPPOINT

View File

@ -263,7 +263,7 @@ METROIDPRIME :=\
$(BUILD_DIR)/asm/MetroidPrime/Enemies/CThardus.o\
$(BUILD_DIR)/asm/MetroidPrime/CActorParticles.o\
$(BUILD_DIR)/asm/MetroidPrime/Enemies/CWallCrawlerSwarm.o\
$(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptAiJumpPoint.o\
$(BUILD_DIR)/src/MetroidPrime/ScriptObjects/CScriptAiJumpPoint.o\
$(BUILD_DIR)/asm/MetroidPrime/CMessageScreen.o\
$(BUILD_DIR)/asm/MetroidPrime/Enemies/CFlaahgraTentacle.o\
$(BUILD_DIR)/asm/MetroidPrime/Weapons/GunController/CGSFidget.o\

View File

@ -0,0 +1,62 @@
#include "MetroidPrime/ScriptObjects/CScriptAiJumpPoint.hpp"
#include "MetroidPrime/CActorParameters.hpp"
#include "MetroidPrime/ScriptObjects/CScriptWaypoint.hpp"
CScriptAiJumpPoint::CScriptAiJumpPoint(TUniqueId uid, const rstl::string& name,
const CEntityInfo& info, const CTransform4f& xf, bool active,
float apex)
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(kMT_NoStepLogic),
CActorParameters::None(), kInvalidUniqueId)
, xe8_apex(apex)
, xec_touchBounds(CAABox(xf.GetTranslation(), xf.GetTranslation()))
, x108_24_inUse(false)
, x10a_occupant(kInvalidUniqueId)
, x10c_currentWaypoint(kInvalidUniqueId)
, x10e_nextWaypoint(kInvalidUniqueId)
, x110_timeRemaining(0.f) {}
void CScriptAiJumpPoint::Accept(IVisitor& visitor) { visitor.Visit(*this); }
void CScriptAiJumpPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other,
CStateManager& mgr) {
CActor::AcceptScriptMsg(msg, other, mgr);
switch (msg) {
case kSM_InitializedInArea:
rstl::vector< SConnection >::const_iterator conn = x20_conns.begin();
for (; conn != x20_conns.end(); ++conn) {
if (conn->x0_state != kSS_Arrived || conn->x4_msg != kSM_Next) {
continue;
}
TUniqueId id = mgr.GetIdForScript(conn->x8_objId);
if (const CScriptWaypoint* wpnt = TCastToConstPtr< CScriptWaypoint >(mgr.GetObjectById(id))) {
x10c_currentWaypoint = id;
x10e_nextWaypoint = wpnt->NextWaypoint(mgr);
return;
}
}
}
}
bool CScriptAiJumpPoint::GetInUse(TUniqueId uid) const {
return x108_24_inUse || x110_timeRemaining > 0.f ||
(x10a_occupant != kInvalidUniqueId && uid != kInvalidUniqueId && uid != x10a_occupant);
}
void CScriptAiJumpPoint::Think(float dt, CStateManager&) {
if (x110_timeRemaining > 0) {
x110_timeRemaining -= dt;
}
}
void CScriptAiJumpPoint::AddToRenderer(const CFrustumPlanes&, const CStateManager&) const override {
}
void CScriptAiJumpPoint::Render(const CStateManager&) const override {}
rstl::optional_object< CAABox > CScriptAiJumpPoint::GetTouchBounds() const {
return xec_touchBounds;
}
CScriptAiJumpPoint::~CScriptAiJumpPoint() {}