metaforce/Runtime/CGameState.hpp

103 lines
3.1 KiB
C++
Raw Normal View History

2016-04-12 23:07:23 -07:00
#ifndef __URDE_CGAMESTATE_HPP__
#define __URDE_CGAMESTATE_HPP__
2015-08-16 22:26:58 -07:00
2015-08-17 13:33:58 -07:00
#include <memory>
2015-08-19 19:52:07 -07:00
#include "CBasics.hpp"
2015-08-17 13:33:58 -07:00
#include "CPlayerState.hpp"
#include "CGameOptions.hpp"
#include "CRelayTracker.hpp"
2016-04-16 16:48:29 -07:00
#include "World/CWorldTransManager.hpp"
#include "AutoMapper/CMapWorldInfo.hpp"
2016-10-09 00:45:04 -07:00
#include "World/CWorld.hpp"
#include "DataSpec/DNACommon/DNACommon.hpp"
2016-03-04 15:04:53 -08:00
namespace urde
{
2016-09-24 18:58:20 -07:00
class CSaveWorldMemory;
2016-10-09 00:45:04 -07:00
class CWorldLayerState
2016-09-24 18:58:20 -07:00
{
friend class CSaveWorldIntermediate;
2016-10-09 00:45:04 -07:00
std::vector<CWorldLayers::Area> x0_areaLayers;
DataSpec::WordBitmap x10_saveLayers;
2016-09-24 18:58:20 -07:00
public:
2016-10-09 00:45:04 -07:00
CWorldLayerState() = default;
CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& saveWorld);
bool IsLayerActive(int areaIdx, int layerIdx) const
2016-09-24 18:58:20 -07:00
{
2016-10-09 00:45:04 -07:00
return (x0_areaLayers[areaIdx].m_layerBits >> layerIdx) & 1;
}
2016-09-24 18:58:20 -07:00
2016-10-09 00:45:04 -07:00
void SetLayerActive(int areaIdx, int layerIdx, bool active)
{
if (active)
x0_areaLayers[areaIdx].m_layerBits |= 1 << layerIdx;
else
x0_areaLayers[areaIdx].m_layerBits &= ~(1 << layerIdx);
2016-09-24 18:58:20 -07:00
}
2016-10-09 00:45:04 -07:00
void InitializeWorldLayers(const std::vector<CWorldLayers::Area>& layers);
2016-09-24 18:58:20 -07:00
};
class CWorldState
{
ResId x0_mlvlId;
2016-09-24 18:58:20 -07:00
TAreaId x4_areaId = kInvalidAreaId;
std::shared_ptr<CRelayTracker> x8_relayTracker;
std::shared_ptr<CMapWorldInfo> xc_mapWorldInfo;
2016-09-24 18:58:20 -07:00
u32 x10_;
2016-10-09 00:45:04 -07:00
std::shared_ptr<CWorldLayerState> x14_layerState;
public:
CWorldState(ResId id);
2016-09-24 18:58:20 -07:00
CWorldState(CBitStreamReader& reader, ResId mlvlId, const CSaveWorld& saveWorld);
ResId GetWorldAssetId() const {return x0_mlvlId;}
void SetAreaId(TAreaId aid) { x4_areaId = aid; }
TAreaId GetCurrentAreaId() const { return x4_areaId; }
const std::shared_ptr<CRelayTracker>& RelayTracker() const { return x8_relayTracker; }
const std::shared_ptr<CMapWorldInfo>& MapWorldInfo() const { return xc_mapWorldInfo; }
2016-10-09 00:45:04 -07:00
const std::shared_ptr<CWorldLayerState>& GetLayerState() const { return x14_layerState; }
};
2015-08-16 22:26:58 -07:00
class CGameState
{
friend class CStateManager;
2016-08-15 13:58:07 -07:00
bool x0_[128] = {};
ResId x84_mlvlId = -1;
std::vector<CWorldState> x88_worldStates;
2016-08-15 13:58:07 -07:00
std::shared_ptr<CPlayerState> x98_playerState;
std::shared_ptr<CWorldTransManager> x9c_transManager;
2016-03-28 01:54:02 -07:00
double xa0_playTime;
2016-09-24 18:58:20 -07:00
CPersistentOptions xa8_systemOptions;
2016-09-07 19:01:29 -07:00
CGameOptions x17c_gameOptions;
2016-09-24 18:58:20 -07:00
CHintOptions x1f8_hintOptions;
union
{
struct
{
bool x228_24_;
bool x228_25_deferPowerupInit;
};
u8 _dummy = 0;
};
2016-09-24 18:58:20 -07:00
2015-08-17 13:33:58 -07:00
public:
CGameState();
2016-03-19 12:19:43 -07:00
CGameState(CBitStreamReader& stream);
void SetCurrentWorldId(unsigned int id);
2016-08-16 15:49:19 -07:00
std::shared_ptr<CPlayerState> GetPlayerState() {return x98_playerState;}
std::shared_ptr<CWorldTransManager> GetWorldTransitionManager() {return x9c_transManager;}
2016-03-28 01:54:02 -07:00
void SetTotalPlayTime(float time);
2016-09-24 18:58:20 -07:00
CPersistentOptions& SystemOptions() { return xa8_systemOptions; }
CGameOptions& GameOptions() { return x17c_gameOptions; }
CWorldState& StateForWorld(ResId mlvlId);
CWorldState& CurrentWorldState() { return StateForWorld(x84_mlvlId); }
2016-08-15 13:58:07 -07:00
ResId CurrentWorldAssetId() const { return x84_mlvlId; }
2015-08-16 22:26:58 -07:00
};
}
2016-04-12 23:07:23 -07:00
#endif // __URDE_CGAMESTATE_HPP__