Cleanup TLockedToken, initial CScriptEffect

This commit is contained in:
2025-05-23 16:36:20 -07:00
parent 0ff1efc8d2
commit 3ad420bf9d
5 changed files with 114 additions and 10 deletions

View File

@@ -2005,7 +2005,7 @@ GetModulationColor__17CParticleElectricFv = .text:0x8008ED10; // type:function s
GetGlobalScale__17CParticleElectricFv = .text:0x8008ED18; // type:function size:0x8 scope:global GetGlobalScale__17CParticleElectricFv = .text:0x8008ED18; // type:function size:0x8 scope:global
GetGlobalScale__11CElementGenCFv = .text:0x8008ED20; // type:function size:0x8 scope:global GetGlobalScale__11CElementGenCFv = .text:0x8008ED20; // type:function size:0x8 scope:global
Think__13CScriptEffectFfR13CStateManager = .text:0x8008ED28; // type:function size:0x418 scope:global Think__13CScriptEffectFfR13CStateManager = .text:0x8008ED28; // type:function size:0x418 scope:global
__ct__13CScriptEffectF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fRC9CVector3fUiUibbbbbffff = .text:0x8008F140; // type:function size:0x770 scope:global __ct__13CScriptEffectF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fRC9CVector3fUiUibbbbbffffbfffbbbRC16CLightParametersb = .text:0x8008F140; // type:function size:0x770 scope:global
__dt__43TObjOwnerDerivedFromIObj<15CGenDescription>Fv = .text:0x8008F8B0; // type:function size:0x90 scope:global __dt__43TObjOwnerDerivedFromIObj<15CGenDescription>Fv = .text:0x8008F8B0; // type:function size:0x90 scope:global
GetNewDerivedObject__43TObjOwnerDerivedFromIObj<15CGenDescription>FP15CGenDescription = .text:0x8008F940; // type:function size:0x90 scope:global GetNewDerivedObject__43TObjOwnerDerivedFromIObj<15CGenDescription>FP15CGenDescription = .text:0x8008F940; // type:function size:0x90 scope:global
__dt__48TObjOwnerDerivedFromIObj<20CElectricDescription>Fv = .text:0x8008F9D0; // type:function size:0x90 scope:global __dt__48TObjOwnerDerivedFromIObj<20CElectricDescription>Fv = .text:0x8008F9D0; // type:function size:0x90 scope:global

View File

@@ -2005,7 +2005,7 @@ GetModulationColor__17CParticleElectricFv = .text:0x8008ED8C; // type:function s
GetGlobalScale__17CParticleElectricFv = .text:0x8008ED94; // type:function size:0x8 scope:global GetGlobalScale__17CParticleElectricFv = .text:0x8008ED94; // type:function size:0x8 scope:global
GetGlobalScale__11CElementGenCFv = .text:0x8008ED9C; // type:function size:0x8 scope:global GetGlobalScale__11CElementGenCFv = .text:0x8008ED9C; // type:function size:0x8 scope:global
Think__13CScriptEffectFfR13CStateManager = .text:0x8008EDA4; // type:function size:0x418 scope:global Think__13CScriptEffectFfR13CStateManager = .text:0x8008EDA4; // type:function size:0x418 scope:global
__ct__13CScriptEffectF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fRC9CVector3fUiUibbbbbffff = .text:0x8008F1BC; // type:function size:0x770 scope:global __ct__13CScriptEffectF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fRC9CVector3fUiUibbbbbffffbfffbbbRC16CLightParametersb = .text:0x8008F1BC; // type:function size:0x770 scope:global
__dt__43TObjOwnerDerivedFromIObj<15CGenDescription>Fv = .text:0x8008F92C; // type:function size:0x90 scope:global __dt__43TObjOwnerDerivedFromIObj<15CGenDescription>Fv = .text:0x8008F92C; // type:function size:0x90 scope:global
GetNewDerivedObject__43TObjOwnerDerivedFromIObj<15CGenDescription>FP15CGenDescription = .text:0x8008F9BC; // type:function size:0x90 scope:global GetNewDerivedObject__43TObjOwnerDerivedFromIObj<15CGenDescription>FP15CGenDescription = .text:0x8008F9BC; // type:function size:0x90 scope:global
__dt__48TObjOwnerDerivedFromIObj<20CElectricDescription>Fv = .text:0x8008FA4C; // type:function size:0x90 scope:global __dt__48TObjOwnerDerivedFromIObj<20CElectricDescription>Fv = .text:0x8008FA4C; // type:function size:0x90 scope:global

View File

@@ -67,27 +67,25 @@ private:
}; };
template < typename T > template < typename T >
class TLockedToken { class TLockedToken : public TToken< T > {
public: public:
TLockedToken() {} TLockedToken() {}
TLockedToken(const CToken& token) : x0_token(token), x8_item(*x0_token) {} TLockedToken(T* item) : TToken< T >(item), x8_item(item) { CToken::Lock(); }
TLockedToken(const TLockedToken< T >& token) : x0_token(token), x8_item(*token) { TLockedToken(const CToken& token) : TToken< T >(token), x8_item(TToken< T >::GetT()) {}
x0_token.Lock(); TLockedToken(const TLockedToken< T >& token) : TToken< T >(token), x8_item(*token) {
CToken::Lock();
} }
TLockedToken& operator=(const TLockedToken< T >& token) { TLockedToken& operator=(const TLockedToken< T >& token) {
x0_token = token; TToken< T >::operator=(token);
x8_item = *token; x8_item = *token;
return *this; return *this;
} }
operator const TToken< T >&() const { return x0_token; }
T* operator*() const { return x8_item; } T* operator*() const { return x8_item; }
T* operator->() const { return x8_item; } T* operator->() const { return x8_item; }
bool IsLoaded() const { return x0_token.IsLoaded(); }
private: private:
TToken< T > x0_token;
T* x8_item; T* x8_item;
}; };

View File

@@ -0,0 +1,57 @@
#ifndef _CSCRIPTEFFECT
#define _CSCRIPTEFFECT
#include "MetroidPrime/CActor.hpp"
class CLightParameters;
class CElectricDescription;
class CParticleElectric;
class CGenDescription;
class CElementGen;
class CScriptEffect : public CActor {
public:
CScriptEffect(const TUniqueId uid, const rstl::string& name, const CEntityInfo& info,
const CTransform4f& xf, const CVector3f& scale, const CAssetId partId,
const CAssetId elscId, const bool hotInThermal,
const bool noTimerUnlessAreaOccluded, bool rebuildSystemsOnActivate,
const bool active, const bool useRateInverseCamDist, float rateInverseCamDist,
const float rateInverseCamDistRate, const float duration,
const float durationResetWhileVisible, const bool useRateCamDistRange,
const float rateCamDistRangeMin, const float rateCamDistRangeMax,
const float rateCamDistRangeFarRate, const bool combatVisorVisible,
const bool thermalVisorVisible, const bool xrayVisorVisible,
const CLightParameters& lParms, const bool dieWhenSystemsDone);
private:
TLockedToken< CElectricDescription > xe8_electricToken;
rstl::single_ptr< CParticleElectric > xf4_electric;
TLockedToken< CGenDescription > xf8_particleSystemToken;
rstl::single_ptr< CElementGen > x104_particleSystem;
TUniqueId x108_lightId;
CAssetId x10c_partId;
bool x110_24_enable : 1;
bool x110_25_noTimerUnlessAreaOccluded : 1;
bool x110_26_rebuildSystemsOnActivate : 1;
bool x110_27_useRateInverseCamDist : 1;
bool x110_28_combatVisorVisible : 1;
bool x110_29_thermalVisorVisible : 1;
bool x110_30_xrayVisorVisible : 1;
bool x110_31_anyVisorVisible : 1;
bool x111_24_useRateCamDistRange : 1;
bool x111_25_dieWhenSystemsDone : 1;
bool x111_26_canRender : 1;
float x114_rateInverseCamDist;
float x118_rateInverseCamDistSq;
float x11c_rateInverseCamDistRate;
float x120_rateCamDistRangeMin;
float x124_rateCamDistRangeMax;
float x128_rateCamDistRangeFarRate;
float x12c_remTime;
float x130_duration;
float x134_durationResetWhileVisible;
rstl::single_ptr< CActorLights > x138_actorLights;
TUniqueId x13c_triggerId;
float x140_destroyDelayTimer;
};
#endif // _CSCRIPTEFFECT

View File

@@ -0,0 +1,49 @@
#include "MetroidPrime/ScriptObjects/CScriptEffect.hpp"
#include "Collision/CMaterialList.hpp"
#include "Kyoto/Particles/CElectricDescription.hpp"
#include "Kyoto/Particles/CGenDescription.hpp"
#include "Kyoto/SObjectTag.hpp"
#include "MetroidPrime/CActorParameters.hpp"
#include "MetroidPrime/TCastTo.hpp"
CScriptEffect::CScriptEffect(const TUniqueId uid, const rstl::string& name, const CEntityInfo& info,
const CTransform4f& xf, const CVector3f& scale, const CAssetId partId,
const CAssetId elscId, const bool hotInThermal,
const bool noTimerUnlessAreaOccluded, bool rebuildSystemsOnActivate,
const bool active, const bool useRateInverseCamDist,
float rateInverseCamDist, const float rateInverseCamDistRate,
const float duration, const float durationResetWhileVisible,
const bool useRateCamDistRange, const float rateCamDistRangeMin,
const float rateCamDistRangeMax, const float rateCamDistRangeFarRate,
const bool combatVisorVisible, const bool thermalVisorVisible,
const bool xrayVisorVisible, const CLightParameters& lParms,
const bool dieWhenSystemsDone)
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(kMT_NoStepLogic),
CActorParameters::None().HotInThermal(hotInThermal), kInvalidUniqueId)
, xe8_electricToken(nullptr)
, xf8_particleSystemToken(nullptr)
, x108_lightId(kInvalidUniqueId)
, x10c_partId(partId)
, x110_24_enable(active)
, x110_25_noTimerUnlessAreaOccluded(noTimerUnlessAreaOccluded)
, x110_26_rebuildSystemsOnActivate(rebuildSystemsOnActivate)
, x110_27_useRateInverseCamDist(useRateCamDistRange)
, x110_28_combatVisorVisible(combatVisorVisible)
, x110_29_thermalVisorVisible(thermalVisorVisible)
, x110_30_xrayVisorVisible(xrayVisorVisible)
, x110_31_anyVisorVisible(xrayVisorVisible && thermalVisorVisible && combatVisorVisible)
, x111_24_useRateCamDistRange(useRateCamDistRange)
, x111_25_dieWhenSystemsDone(dieWhenSystemsDone)
, x111_26_canRender(false)
, x114_rateInverseCamDist(rateInverseCamDist)
, x118_rateInverseCamDistSq(rateInverseCamDist * rateInverseCamDist)
, x11c_rateInverseCamDistRate(rateInverseCamDistRate)
, x120_rateCamDistRangeMin(rateCamDistRangeMin)
, x124_rateCamDistRangeMax(rateCamDistRangeMax)
, x128_rateCamDistRangeFarRate(rateCamDistRangeFarRate)
, x12c_remTime(duration)
, x130_duration(duration)
, x134_durationResetWhileVisible(durationResetWhileVisible)
, x138_actorLights(lParms.MakeActorLights().release())
, x13c_triggerId(kInvalidUniqueId)
, x140_destroyDelayTimer(0.f) {}