2022-08-09 23:03:51 +00:00
|
|
|
#ifndef _CSTATEMANAGER_HPP
|
|
|
|
#define _CSTATEMANAGER_HPP
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
2022-10-02 10:13:35 +00:00
|
|
|
#include "Kyoto/CObjectReference.hpp"
|
2022-09-18 05:55:13 +00:00
|
|
|
#include "Kyoto/CRandom16.hpp"
|
2022-10-02 10:13:35 +00:00
|
|
|
#include "Kyoto/Math/CVector2i.hpp"
|
|
|
|
#include "Kyoto/TToken.hpp"
|
2022-08-13 01:26:00 +00:00
|
|
|
#include "MetroidPrime/CEntityInfo.hpp"
|
2022-09-18 05:55:13 +00:00
|
|
|
#include "MetroidPrime/CObjectList.hpp"
|
2022-08-13 01:26:00 +00:00
|
|
|
#include "MetroidPrime/TGameTypes.hpp"
|
|
|
|
|
|
|
|
#include "rstl/auto_ptr.hpp"
|
|
|
|
#include "rstl/list.hpp"
|
2022-09-15 04:08:47 +00:00
|
|
|
#include "rstl/pair.hpp"
|
2022-08-16 02:14:28 +00:00
|
|
|
#include "rstl/rc_ptr.hpp"
|
2022-08-13 01:26:00 +00:00
|
|
|
#include "rstl/reserved_vector.hpp"
|
|
|
|
#include "rstl/single_ptr.hpp"
|
|
|
|
|
2022-08-16 02:14:28 +00:00
|
|
|
class CAABox;
|
|
|
|
class CActor;
|
2022-08-13 02:48:34 +00:00
|
|
|
class CActorModelParticles;
|
|
|
|
class CCameraManager;
|
|
|
|
class CEnvFxManager;
|
|
|
|
class CFluidPlaneManager;
|
2022-08-16 02:14:28 +00:00
|
|
|
class CMapWorldInfo;
|
2022-08-13 01:26:00 +00:00
|
|
|
class CObjectList;
|
|
|
|
class CPlayer;
|
2022-08-16 02:14:28 +00:00
|
|
|
class CPlayerState;
|
2022-08-13 02:48:34 +00:00
|
|
|
class CRumbleManager;
|
2022-08-16 02:14:28 +00:00
|
|
|
class CScriptMailbox;
|
2022-08-13 01:26:00 +00:00
|
|
|
class CStateManagerContainer;
|
2022-08-16 02:14:28 +00:00
|
|
|
class CVector3f;
|
2022-08-13 02:48:34 +00:00
|
|
|
class CWeaponMgr;
|
|
|
|
class CWorld;
|
2022-08-16 02:14:28 +00:00
|
|
|
class CWorldTransManager;
|
2022-09-14 05:24:12 +00:00
|
|
|
class CEntity;
|
2022-09-18 05:55:13 +00:00
|
|
|
class CMazeState;
|
2022-09-29 05:30:20 +00:00
|
|
|
class CRayCastResult;
|
2022-09-29 05:31:19 +00:00
|
|
|
class CMaterialFilter;
|
2022-10-02 10:13:35 +00:00
|
|
|
class CScriptLayerManager;
|
|
|
|
class CLight;
|
|
|
|
class CDamageInfo;
|
|
|
|
class CTexture;
|
2022-08-13 02:48:34 +00:00
|
|
|
|
|
|
|
namespace SL {
|
|
|
|
class CSortedListManager;
|
|
|
|
} // namespace SL
|
2022-08-13 01:26:00 +00:00
|
|
|
|
2022-09-19 04:19:46 +00:00
|
|
|
#define kMaxEntities 1024
|
|
|
|
typedef rstl::reserved_vector< TUniqueId, kMaxEntities > TEntityList;
|
|
|
|
|
2022-10-02 10:13:35 +00:00
|
|
|
enum EStateManagerTransition {
|
|
|
|
kSMT_InGame,
|
|
|
|
kSMT_MapScreen,
|
|
|
|
kSMT_PauseGame,
|
|
|
|
kSMT_LogBook,
|
|
|
|
kSMT_SaveGame,
|
|
|
|
kSMT_MessageScreen
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SOnScreenTex {
|
|
|
|
CAssetId x0_id;
|
|
|
|
CVector2i x4_origin;
|
|
|
|
CVector2i xc_extent;
|
|
|
|
};
|
|
|
|
|
2022-08-11 02:33:46 +00:00
|
|
|
class CStateManager {
|
|
|
|
public:
|
2022-10-02 10:13:35 +00:00
|
|
|
void ResetEscapeSequenceTimer(float);
|
2022-09-18 06:05:46 +00:00
|
|
|
void SendScriptMsg(TUniqueId uid, TEditorId target, EScriptObjectMessage msg,
|
|
|
|
EScriptObjectState state);
|
2022-09-14 05:24:12 +00:00
|
|
|
void SendScriptMsg(CEntity* ent, TUniqueId target, EScriptObjectMessage msg);
|
2022-09-19 04:19:46 +00:00
|
|
|
void SendScriptMsgAlways(TUniqueId uid, TUniqueId src, EScriptObjectMessage msg);
|
2022-08-16 02:14:28 +00:00
|
|
|
bool AddDrawableActor(const CActor& actor, const CVector3f& pos, const CAABox& bounds) const;
|
2022-09-13 04:26:54 +00:00
|
|
|
void SetupParticleHook(const CActor& actor) const;
|
2022-09-14 05:24:12 +00:00
|
|
|
void FreeScriptObject(TUniqueId uid);
|
2022-09-15 04:08:47 +00:00
|
|
|
rstl::pair< TEditorId, TUniqueId > GenerateObject(const TEditorId& eid);
|
2022-09-14 05:24:12 +00:00
|
|
|
|
2022-09-29 05:30:20 +00:00
|
|
|
bool RayCollideWorld(const CVector3f& start, const CVector3f& end, const TEntityList& nearList,
|
|
|
|
const CMaterialFilter& filter, const CActor* damagee) const;
|
|
|
|
CRayCastResult RayWorldIntersection(TUniqueId& idOut, const CVector3f& pos, const CVector3f& dir,
|
|
|
|
f32 length, const CMaterialFilter& filter,
|
|
|
|
const TEntityList& list) const;
|
2022-09-29 23:55:38 +00:00
|
|
|
void BuildColliderList(TEntityList& out, const CActor& actor, const CAABox& aabb) const;
|
2022-09-29 05:30:20 +00:00
|
|
|
|
2022-09-14 05:24:12 +00:00
|
|
|
CEntity* ObjectById(TUniqueId uid);
|
2022-09-15 04:08:47 +00:00
|
|
|
const CEntity* GetObjectById(TUniqueId uid) const;
|
|
|
|
TUniqueId GetIdForScript(TEditorId eid) const;
|
2022-10-02 10:13:35 +00:00
|
|
|
// <unk> GetIdListForScript(TEditorId) const;
|
2022-08-13 01:26:00 +00:00
|
|
|
|
2022-09-18 05:55:13 +00:00
|
|
|
CMazeState* CurrentMaze();
|
|
|
|
const CMazeState* GetCurrentMaze() const;
|
2022-09-18 17:51:07 +00:00
|
|
|
void SetCurrentMaze(rstl::single_ptr< CMazeState > maze);
|
2022-09-18 05:55:13 +00:00
|
|
|
|
2022-09-21 05:18:07 +00:00
|
|
|
CPlayer* Player() { return x84c_player; }
|
|
|
|
const CPlayer* GetPlayer() const { return x84c_player; }
|
2022-08-16 02:14:28 +00:00
|
|
|
CCameraManager* CameraManager() { return x870_cameraManager; }
|
|
|
|
const CCameraManager* GetCameraManager() const { return x870_cameraManager; }
|
|
|
|
CPlayerState* PlayerState() { return x8b8_playerState.GetPtr(); }
|
|
|
|
const CPlayerState* GetPlayerState() const { return x8b8_playerState.GetPtr(); }
|
|
|
|
CWorld* World() { return x850_world.get(); }
|
|
|
|
const CWorld* GetWorld() const { return x850_world.get(); }
|
2022-09-13 04:26:54 +00:00
|
|
|
CActorModelParticles* ActorModelParticles() { return x884_actorModelParticles.get(); }
|
2022-09-18 06:05:46 +00:00
|
|
|
const CActorModelParticles* GetActorModelParticles() const {
|
|
|
|
return x884_actorModelParticles.get();
|
|
|
|
}
|
2022-10-02 10:13:35 +00:00
|
|
|
CEnvFxManager* EnvFxManager() { return x880_envFxManager; }
|
|
|
|
const CEnvFxManager* GetEnvFxManager() const { return x880_envFxManager; }
|
|
|
|
|
2022-09-18 05:55:13 +00:00
|
|
|
CRandom16* GetActiveRandom() const { return x900_random; }
|
|
|
|
|
|
|
|
CObjectList& GetObjectListById(EGameObjectList id) { return *x808_objectLists[id]; }
|
2022-09-13 04:26:54 +00:00
|
|
|
|
|
|
|
f32 GetThermalColdScale1() const { return xf24_thermColdScale1; }
|
|
|
|
f32 GetThermalColdScale2() const { return xf28_thermColdScale2; }
|
2022-08-13 02:48:34 +00:00
|
|
|
|
2022-09-15 04:08:47 +00:00
|
|
|
bool IsGeneratingObject() const { return xf94_26_generatingObject; }
|
|
|
|
void SetIsGeneratingObject(bool gen) { xf94_26_generatingObject = gen; }
|
|
|
|
|
2022-09-18 05:55:13 +00:00
|
|
|
inline TUniqueId GenerateObjectInline(TEditorId eid) {
|
|
|
|
bool wasGeneratingObject = IsGeneratingObject();
|
|
|
|
SetIsGeneratingObject(true);
|
|
|
|
TUniqueId objUid = GenerateObject(eid).second;
|
|
|
|
SetIsGeneratingObject(wasGeneratingObject);
|
|
|
|
return objUid;
|
|
|
|
}
|
|
|
|
|
2022-10-02 10:13:35 +00:00
|
|
|
void ApplyDamageToWorld(TUniqueId, const CActor&, const CVector3f&, const CDamageInfo& info,
|
|
|
|
CMaterialFilter&);
|
|
|
|
bool ApplyDamage(TUniqueId damagerId, TUniqueId damageeId, TUniqueId radiusSender,
|
|
|
|
const CDamageInfo& info, const CMaterialFilter& filter,
|
|
|
|
const CVector3f& knockbackVec);
|
|
|
|
|
|
|
|
void DeferStateTransition(EStateManagerTransition t);
|
|
|
|
EStateManagerTransition GetDeferredStateTransition() const { return xf90_deferredTransition; }
|
|
|
|
void SetBossParams(TUniqueId bossId, float maxEnergy, u32 stringIdx);
|
|
|
|
void SetPendingOnScreenTex(CAssetId texId, const CVector2i& origin, const CVector2i& extent) {
|
|
|
|
xef4_pendingScreenTex.x0_id = texId;
|
|
|
|
xef4_pendingScreenTex.x4_origin = origin;
|
|
|
|
xef4_pendingScreenTex.xc_extent = extent;
|
|
|
|
}
|
|
|
|
const SOnScreenTex& GetPendingScreenTex() const { return xef4_pendingScreenTex; }
|
|
|
|
|
|
|
|
void SetShouldQuitGame(bool should) { xf94_25_quitGame = should; }
|
|
|
|
void SetSkipCinematicSpecialFunction(TUniqueId id) { /*xf38_skipCineSpecialFunc = id;*/
|
|
|
|
}
|
|
|
|
void SetInSaveUI(bool b) { xf94_28_inSaveUI = b; }
|
|
|
|
bool GetInSaveUI() const { return xf94_28_inSaveUI; }
|
|
|
|
void SetIsFullThreat(bool v) { xf94_30_fullThreat = v; }
|
|
|
|
u32 GetInputFrameIdx() const { return x8d4_inputFrameIdx; }
|
|
|
|
|
2022-08-13 01:26:00 +00:00
|
|
|
private:
|
|
|
|
u16 x0_nextFreeIndex;
|
|
|
|
rstl::reserved_vector< u16, 1024 > x8_objectIndexArray;
|
|
|
|
rstl::reserved_vector< rstl::auto_ptr< CObjectList >, 8 > x808_objectLists;
|
|
|
|
CPlayer* x84c_player;
|
|
|
|
rstl::single_ptr< CWorld > x850_world;
|
|
|
|
rstl::list< rstl::reserved_vector< TUniqueId, 32 > > x854_graveyard;
|
|
|
|
rstl::single_ptr< CStateManagerContainer > x86c_stateManagerContainer;
|
2022-08-13 02:48:34 +00:00
|
|
|
CCameraManager* x870_cameraManager;
|
|
|
|
SL::CSortedListManager* x874_sortedListManager;
|
|
|
|
CWeaponMgr* x878_weaponMgr;
|
|
|
|
CFluidPlaneManager* x87c_fluidPlaneManager;
|
|
|
|
CEnvFxManager* x880_envFxManager;
|
|
|
|
rstl::auto_ptr< CActorModelParticles > x884_actorModelParticles;
|
|
|
|
CRumbleManager* x88c_rumbleManager;
|
2022-08-16 02:14:28 +00:00
|
|
|
// TODO
|
|
|
|
// rstl::multimap< TEditorId, TUniqueId > x890_scriptIdMap;
|
|
|
|
// rstl::map< TEditorId, SScriptObjectStream > x8a4_loadedScriptObjects;
|
|
|
|
u8 pad[0x28];
|
|
|
|
rstl::rc_ptr< CPlayerState > x8b8_playerState;
|
|
|
|
rstl::rc_ptr< CScriptMailbox > x8bc_mailbox;
|
|
|
|
rstl::rc_ptr< CMapWorldInfo > x8c0_mapWorldInfo;
|
|
|
|
rstl::rc_ptr< CWorldTransManager > x8c4_worldTransManager;
|
2022-10-02 10:13:35 +00:00
|
|
|
rstl::rc_ptr< CScriptLayerManager > x8c8_worldLayerState;
|
|
|
|
|
|
|
|
TAreaId x8cc_nextAreaId;
|
|
|
|
TAreaId x8d0_prevAreaId;
|
|
|
|
u32 x8d4_inputFrameIdx;
|
|
|
|
u32 x8d8_updateFrameIdx;
|
|
|
|
u32 x8dc_objectDrawToken;
|
|
|
|
|
|
|
|
rstl::vector< CLight > x8e0_dynamicLights;
|
|
|
|
|
|
|
|
TLockedToken< CTexture > x8f0_shadowTex;
|
2022-09-18 05:55:13 +00:00
|
|
|
CRandom16* x900_random;
|
2022-10-02 10:13:35 +00:00
|
|
|
|
|
|
|
u8 x904_pad[0x5f0];
|
|
|
|
|
|
|
|
SOnScreenTex xef4_pendingScreenTex;
|
|
|
|
|
|
|
|
u8 xf08_pad[0x1C];
|
|
|
|
|
2022-09-13 04:26:54 +00:00
|
|
|
f32 xf24_thermColdScale1;
|
|
|
|
f32 xf28_thermColdScale2;
|
2022-10-02 10:13:35 +00:00
|
|
|
u8 pad3[0x68];
|
|
|
|
EStateManagerTransition xf90_deferredTransition;
|
2022-09-15 04:08:47 +00:00
|
|
|
bool xf94_24_readyToRender : 1;
|
|
|
|
bool xf94_25_quitGame : 1;
|
|
|
|
bool xf94_26_generatingObject : 1;
|
|
|
|
bool xf94_27_inMapScreen : 1;
|
|
|
|
bool xf94_28_inSaveUI : 1;
|
|
|
|
bool xf94_29_cinematicPause : 1;
|
|
|
|
bool xf94_30_fullThreat : 1;
|
2022-08-11 02:33:46 +00:00
|
|
|
};
|
2022-08-09 23:03:51 +00:00
|
|
|
|
|
|
|
#endif
|