diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 0967e0ba..cb1aac2c 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -2015,12 +2015,12 @@ GetTouchBounds__5CBombCFv = .text:0x8008FBA4; // type:function size:0x1BC scope: AcceptScriptMsg__5CBombF20EScriptObjectMessage9TUniqueIdR13CStateManager = .text:0x8008FD60; // type:function size:0x260 scope:global Accept__5CBombFR8IVisitor = .text:0x8008FFC0; // type:function size:0x38 scope:global Think__5CBombFfR13CStateManager = .text:0x8008FFF8; // type:function size:0x458 scope:global -fn_80090450__5CBombFv = .text:0x80090450; // type:function size:0x4 +Render__5CBombCFRC13CStateManager = .text:0x80090450; // type:function size:0x4 AddToRenderer__5CBombCFRC14CFrustumPlanesRC13CStateManager = .text:0x80090454; // type:function size:0x184 scope:global Touch__5CBombFR6CActorR13CStateManager = .text:0x800905D8; // type:function size:0xC scope:global Explode__5CBombFRC9CVector3fR13CStateManager = .text:0x800905E4; // type:function size:0x10C scope:global __dt__5CBombFv = .text:0x800906F0; // type:function size:0xB4 scope:global -__ct__5CBombF25TToken<15CGenDescription>25TToken<15CGenDescription>9TUniqueId7TAreaId9TUniqueIdfRC12CTransform4fRC11CDamageInfo = .text:0x800907A4; // type:function size:0x3B0 scope:global +__ct__5CBombFRC25TToken<15CGenDescription>RC25TToken<15CGenDescription>9TUniqueId7TAreaId9TUniqueIdfRC12CTransform4fRC11CDamageInfo = .text:0x800907A4; // type:function size:0x3B0 scope:global __ct__10CTweakBallFR12CInputStream = .text:0x80090B54; // type:function size:0x620 scope:global __dt__10CTweakBallFv = .text:0x80091174; // type:function size:0x5C scope:global __dl__24TOneStatic<10CTweakBall>FPv = .text:0x800911D0; // type:function size:0x2C scope:weak diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index b3267e9f..cd873178 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -2020,7 +2020,7 @@ AddToRenderer__5CBombCFRC14CFrustumPlanesRC13CStateManager = .text:0x800904D0; / Touch__5CBombFR6CActorR13CStateManager = .text:0x80090654; // type:function size:0xC scope:global Explode__5CBombFRC9CVector3fR13CStateManager = .text:0x80090660; // type:function size:0x10C scope:global __dt__5CBombFv = .text:0x8009076C; // type:function size:0xB4 scope:global -__ct__5CBombF25TToken<15CGenDescription>25TToken<15CGenDescription>9TUniqueId7TAreaId9TUniqueIdfRC12CTransform4fRC11CDamageInfo = .text:0x80090820; // type:function size:0x3B0 scope:global +__ct__5CBombFRC25TToken<15CGenDescription>RC25TToken<15CGenDescription>9TUniqueId7TAreaId9TUniqueIdfRC12CTransform4fRC11CDamageInfo = .text:0x80090820; // type:function size:0x3B0 scope:global __ct__10CTweakBallFR12CInputStream = .text:0x80090BD0; // type:function size:0x620 scope:global __dt__10CTweakBallFv = .text:0x800911F0; // type:function size:0x5C scope:global __dl__24TOneStatic<10CTweakBall>FPv = .text:0x8009124C; // type:function size:0x2C scope:weak diff --git a/include/MetroidPrime/Weapons/CBomb.hpp b/include/MetroidPrime/Weapons/CBomb.hpp index 8b63117f..68ae7198 100644 --- a/include/MetroidPrime/Weapons/CBomb.hpp +++ b/include/MetroidPrime/Weapons/CBomb.hpp @@ -17,7 +17,7 @@ public: void Explode(const CVector3f& pos, CStateManager& mgr); void Touch(CActor& actor, CStateManager& mgr) override; void AddToRenderer(const CFrustumPlanes& frustum, const CStateManager& mgr) const override; - void fn_80090450(); + void Render(const CStateManager& mgr) const override; void Think(float dt, CStateManager& mgr) override; void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override; diff --git a/src/MetroidPrime/Weapons/CBomb.cpp b/src/MetroidPrime/Weapons/CBomb.cpp index ef0b3261..28458a6c 100644 --- a/src/MetroidPrime/Weapons/CBomb.cpp +++ b/src/MetroidPrime/Weapons/CBomb.cpp @@ -10,6 +10,7 @@ #include "MetroidPrime/SFX/Weapons.h" #include "MetroidPrime/TGameTypes.hpp" #include "MetroidPrime/Weapons/CWeapon.hpp" +#include "rstl/math.hpp" #include #include @@ -30,7 +31,7 @@ CBomb::CBomb(const TToken< CGenDescription >& particle1, const TToken< CGenDescr , mParticle1(rs_new CElementGen(particle1)) , mParticle2(rs_new CElementGen(particle2)) , mLightId(kInvalidUniqueId) -, mParticle2Ptr(TToken< CGenDescription >(particle2).GetTag().GetId()) +, mParticle2Ptr(CToken(particle2).GetTag().GetId()) , mIsNotDetonated(true) , mBeingDragged(false) , mDisableFuse(false) { @@ -73,7 +74,7 @@ void CBomb::AddToRenderer(const CFrustumPlanes& frustum, const CStateManager& mg } } -void CBomb::fn_80090450() {} +void CBomb::Render(const CStateManager& mgr) const { } // Equivelant, https://decomp.me/scratch/cr4FM void CBomb::Think(float dt, CStateManager& mgr) { @@ -134,3 +135,57 @@ void CBomb::Think(float dt, CStateManager& mgr) { mParticle1->SetGlobalTranslation(GetTranslation()); mParticle2->SetGlobalTranslation(GetTranslation()); } + +void CBomb::Accept(IVisitor& visitor) { visitor.Visit(*this); } + +void CBomb::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) { + switch (msg) { + case kSM_Registered: { + if (mParticle2->SystemHasLight()) { + mLightId = mgr.AllocateUniqueId(); + const int sourceId = mParticle2Ptr; + mgr.AddObject(rs_new CGameLight( + mLightId, GetCurrentAreaId(), false, rstl::string_l("Bomb_PLight") + GetDebugName(), + GetTransform(), GetUniqueId(), mParticle2->GetLight(), sourceId, 1, 0.f)); + } + mgr.AddWeaponId(GetOwnerId(), GetType()); + CSfxManager::AddEmitter(SFXsam_a_bombset_00, GetTranslation(), CVector3f::Zero(), true); + mgr.InformListeners(GetTranslation(), kLNT_BombExplode); + } break; + case kSM_Deleted: { + if (mLightId != kInvalidUniqueId) { + mgr.DeleteObjectRequest(mLightId); + } + + if (mIsNotDetonated) { + mgr.RemoveWeaponId(GetOwnerId(), GetType()); + } + } break; + default: + break; + } + + CActor::AcceptScriptMsg(msg, sender, mgr); +} + +rstl::optional_object< CAABox > CBomb::GetTouchBounds() const { + float radius = mIsNotDetonated ? 0.2f : x12c_curDamageInfo.GetRadius(); + return CAABox(rstl::min_val(mPrevLocation.GetX(), GetTranslation().GetX()) - radius, + rstl::min_val(mPrevLocation.GetY(), GetTranslation().GetY()) - radius, + rstl::min_val(mPrevLocation.GetZ(), GetTranslation().GetZ()) - radius, + rstl::max_val(mPrevLocation.GetX(), GetTranslation().GetX()) + radius, + rstl::max_val(mPrevLocation.GetY(), GetTranslation().GetY()) + radius, + rstl::max_val(mPrevLocation.GetZ(), GetTranslation().GetZ()) + radius); +} + +void CBomb::UpdateLight(float dt, CStateManager& mgr) { + mParticle2->Update(dt); + if (mLightId == kInvalidUniqueId) { + return; + } + + CGameLight* light = TCastToPtr< CGameLight >(mgr.ObjectById(mLightId)); + if (light && GetActive()) { + light->SetLight(mParticle2->GetLight()); + } +}