From 18ebd4146e7c063c080cb4a38140db94e4130ff6 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Fri, 21 Oct 2022 18:13:34 +0300 Subject: [PATCH] Almost match CScriptSpiderBallAttractionSurface --- .../CScriptSpiderBallAttractionSurface.s | 12 +++---- configure.py | 2 +- .../CScriptSpiderBallAttractionSurface.hpp | 24 +++++++++++++ .../CScriptSpiderBallAttractionSurface.cpp | 36 +++++++++++++++++++ tools/metaforce_renames.sh | 1 + 5 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 include/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.hpp create mode 100644 src/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.cpp diff --git a/asm/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.s b/asm/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.s index 85327ed8..69ad4f90 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803E2438 -lbl_803E2438: +.global __vt__34CScriptSpiderBallAttractionSurface +__vt__34CScriptSpiderBallAttractionSurface: # ROM: 0x3DF438 .4byte 0 .4byte 0 @@ -158,9 +158,9 @@ __dt__34CScriptSpiderBallAttractionSurfaceFv: /* 8014AED0 00147E30 93 C1 00 08 */ stw r30, 8(r1) /* 8014AED4 00147E34 7C 7E 1B 79 */ or. r30, r3, r3 /* 8014AED8 00147E38 41 82 00 28 */ beq lbl_8014AF00 -/* 8014AEDC 00147E3C 3C A0 80 3E */ lis r5, lbl_803E2438@ha +/* 8014AEDC 00147E3C 3C A0 80 3E */ lis r5, __vt__34CScriptSpiderBallAttractionSurface@ha /* 8014AEE0 00147E40 38 80 00 00 */ li r4, 0 -/* 8014AEE4 00147E44 38 05 24 38 */ addi r0, r5, lbl_803E2438@l +/* 8014AEE4 00147E44 38 05 24 38 */ addi r0, r5, __vt__34CScriptSpiderBallAttractionSurface@l /* 8014AEE8 00147E48 90 1E 00 00 */ stw r0, 0(r30) /* 8014AEEC 00147E4C 4B F0 A8 05 */ bl __dt__6CActorFv /* 8014AEF0 00147E50 7F E0 07 35 */ extsh. r0, r31 @@ -229,9 +229,9 @@ lbl_8014AF00: /* 8014AFDC 00147F3C 38 61 01 00 */ addi r3, r1, 0x100 /* 8014AFE0 00147F40 38 80 FF FF */ li r4, -1 /* 8014AFE4 00147F44 4B FC BA 69 */ bl __dt__10CModelDataFv -/* 8014AFE8 00147F48 3C 60 80 3E */ lis r3, lbl_803E2438@ha +/* 8014AFE8 00147F48 3C 60 80 3E */ lis r3, __vt__34CScriptSpiderBallAttractionSurface@ha /* 8014AFEC 00147F4C C0 42 9C E0 */ lfs f2, lbl_805ABA00@sda21(r2) -/* 8014AFF0 00147F50 38 03 24 38 */ addi r0, r3, lbl_803E2438@l +/* 8014AFF0 00147F50 38 03 24 38 */ addi r0, r3, __vt__34CScriptSpiderBallAttractionSurface@l /* 8014AFF4 00147F54 7F 84 E3 78 */ mr r4, r28 /* 8014AFF8 00147F58 90 1F 00 00 */ stw r0, 0(r31) /* 8014AFFC 00147F5C 38 61 00 68 */ addi r3, r1, 0x68 diff --git a/configure.py b/configure.py index f9b03f92..5a393c27 100755 --- a/configure.py +++ b/configure.py @@ -209,7 +209,7 @@ LIBS = [ "MetroidPrime/BodyState/CBSTaunt", "MetroidPrime/CSortedLists", ["MetroidPrime/ScriptObjects/CScriptDebugCameraWaypoint", True], - "MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface", + ["MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface", False], "MetroidPrime/BodyState/CBSScripted", "MetroidPrime/Enemies/CPuddleToadGamma", ["MetroidPrime/ScriptObjects/CScriptDistanceFog", False], diff --git a/include/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.hpp b/include/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.hpp new file mode 100644 index 00000000..c0bc7a81 --- /dev/null +++ b/include/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.hpp @@ -0,0 +1,24 @@ +#ifndef _CSCRIPTSPIDERBALLATTRACTIONSURFACE +#define _CSCRIPTSPIDERBALLATTRACTIONSURFACE + +#include "MetroidPrime/CActor.hpp" + +class CScriptSpiderBallAttractionSurface : public CActor { + CVector3f xe8_scale; + CAABox xf4_aabb; + +public: + CScriptSpiderBallAttractionSurface(TUniqueId uid, const rstl::string& name, + const CEntityInfo& info, const CTransform4f& xf, + const CVector3f& scale, bool active); + ~CScriptSpiderBallAttractionSurface(); + + void Accept(IVisitor& visitor) override; + void Think(float dt, CStateManager& mgr) override; + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override; + rstl::optional_object< CAABox > GetTouchBounds() const override; + void Touch(CActor& actor, CStateManager& mgr) override; + const CVector3f& GetScale() const { return xe8_scale; } +}; + +#endif // _CSCRIPTSPIDERBALLATTRACTIONSURFACE diff --git a/src/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.cpp b/src/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.cpp new file mode 100644 index 00000000..c7b2fd1e --- /dev/null +++ b/src/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.cpp @@ -0,0 +1,36 @@ +#include "MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.hpp" + +#include "MetroidPrime/CActorParameters.hpp" + +CScriptSpiderBallAttractionSurface::CScriptSpiderBallAttractionSurface( + TUniqueId uid, const rstl::string& name, const CEntityInfo& info, const CTransform4f& xf, + const CVector3f& scale, bool active) +: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(kMT_NoStepLogic), + CActorParameters::None(), kInvalidUniqueId) +, xe8_scale(scale) +, xf4_aabb(CAABox(-(scale * 0.5f), scale * 0.5f).GetTransformedAABox(xf.GetRotation())) {} + +CScriptSpiderBallAttractionSurface::~CScriptSpiderBallAttractionSurface() {} + +void CScriptSpiderBallAttractionSurface::Touch(CActor& actor, CStateManager& mgr) { + // Empty +} + +rstl::optional_object< CAABox > CScriptSpiderBallAttractionSurface::GetTouchBounds() const { + if (GetActive()) { + return CAABox(xf4_aabb.GetMinPoint() + GetTranslation(), + xf4_aabb.GetMaxPoint() + GetTranslation()); + } + return rstl::optional_object_null(); +} + +void CScriptSpiderBallAttractionSurface::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, + CStateManager& mgr) { + CActor::AcceptScriptMsg(msg, sender, mgr); +} + +void CScriptSpiderBallAttractionSurface::Think(float dt, CStateManager& mgr) { + // Empty +} + +void CScriptSpiderBallAttractionSurface::Accept(IVisitor& visitor) { visitor.Visit(*this); } diff --git a/tools/metaforce_renames.sh b/tools/metaforce_renames.sh index e047c892..a449d1a4 100644 --- a/tools/metaforce_renames.sh +++ b/tools/metaforce_renames.sh @@ -5,6 +5,7 @@ path=$1 sed -i "s/std::string_view/const rstl::string\&/g" "$path" sed -i "s/std::optional/rstl::optional_object/g" "$path" +sed -i "s/std::nullopt/rstl::optional_object_null()/g" "$path" sed -i "s/zeus::CTransform/CTransform4f/g" "$path" sed -i "s/zeus::skZero2f/CVector2f(0.f, 0.f)/g" "$path" sed -i "s/zeus::skZero3f/CVector3f::Zero()/g" "$path"