2016-04-17 22:38:05 +00:00
|
|
|
#ifndef __URDE_CWORLD_HPP__
|
|
|
|
#define __URDE_CWORLD_HPP__
|
|
|
|
|
2016-04-19 00:17:49 +00:00
|
|
|
#include "RetroTypes.hpp"
|
2016-04-23 18:04:49 +00:00
|
|
|
#include "ScriptObjectSupport.hpp"
|
2016-07-23 21:41:18 +00:00
|
|
|
#include "CGameArea.hpp"
|
2016-07-24 04:46:32 +00:00
|
|
|
#include "Graphics/CModel.hpp"
|
2017-07-07 12:23:20 +00:00
|
|
|
#include "Audio/CSfxManager.hpp"
|
2016-07-24 06:05:12 +00:00
|
|
|
#include "AutoMapper/CMapWorld.hpp"
|
2017-08-22 03:20:22 +00:00
|
|
|
#include "CEnvFxManager.hpp"
|
2016-04-19 00:17:49 +00:00
|
|
|
|
2016-04-17 22:38:05 +00:00
|
|
|
namespace urde
|
|
|
|
{
|
2016-04-19 00:17:49 +00:00
|
|
|
class CGameArea;
|
2016-04-23 18:04:49 +00:00
|
|
|
class IObjectStore;
|
|
|
|
class CResFactory;
|
2016-07-23 21:41:18 +00:00
|
|
|
class IGameArea;
|
2016-07-24 22:51:15 +00:00
|
|
|
class CAudioGroupSet;
|
2016-04-17 22:38:05 +00:00
|
|
|
|
2016-07-23 21:41:18 +00:00
|
|
|
class IWorld
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IWorld() = default;
|
2017-08-13 05:26:14 +00:00
|
|
|
virtual CAssetId IGetWorldAssetId() const=0;
|
|
|
|
virtual CAssetId IGetStringTableAssetId() const=0;
|
|
|
|
virtual CAssetId IGetSaveWorldAssetId() const=0;
|
2016-07-23 21:41:18 +00:00
|
|
|
virtual const CMapWorld* IGetMapWorld() const=0;
|
|
|
|
virtual CMapWorld* IMapWorld()=0;
|
2017-04-22 06:42:32 +00:00
|
|
|
virtual const IGameArea* IGetAreaAlways(TAreaId id) const=0;
|
2016-07-24 04:46:32 +00:00
|
|
|
virtual TAreaId IGetCurrentAreaId() const=0;
|
2017-08-13 05:26:14 +00:00
|
|
|
virtual TAreaId IGetAreaId(CAssetId id) const=0;
|
2016-07-23 21:41:18 +00:00
|
|
|
virtual bool ICheckWorldComplete()=0;
|
|
|
|
virtual std::string IGetDefaultAudioTrack() const=0;
|
|
|
|
virtual int IGetAreaCount() const=0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CDummyWorld : public IWorld
|
|
|
|
{
|
|
|
|
bool x4_loadMap;
|
|
|
|
enum class Phase
|
|
|
|
{
|
|
|
|
Loading,
|
|
|
|
LoadingMap,
|
|
|
|
LoadingMapAreas,
|
|
|
|
Done,
|
|
|
|
} x8_phase = Phase::Loading;
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId xc_mlvlId;
|
|
|
|
CAssetId x10_strgId;
|
2017-11-15 04:12:13 +00:00
|
|
|
CAssetId x14_savwId;
|
2016-07-23 21:41:18 +00:00
|
|
|
std::vector<CDummyGameArea> x18_areas;
|
2017-11-15 04:12:13 +00:00
|
|
|
CAssetId x28_mapWorldId;
|
2016-07-24 04:46:32 +00:00
|
|
|
TLockedToken<CMapWorld> x2c_mapWorld;
|
2017-10-28 07:08:48 +00:00
|
|
|
std::shared_ptr<IDvdRequest> x30_loadToken;
|
2016-07-23 21:41:18 +00:00
|
|
|
std::unique_ptr<uint8_t[]> x34_loadBuf;
|
|
|
|
//u32 x38_bufSz;
|
2016-07-24 04:46:32 +00:00
|
|
|
TAreaId x3c_curAreaId = kInvalidAreaId;
|
2016-07-23 21:41:18 +00:00
|
|
|
public:
|
2017-08-13 05:26:14 +00:00
|
|
|
CDummyWorld(CAssetId mlvlId, bool loadMap);
|
2018-05-08 05:10:24 +00:00
|
|
|
~CDummyWorld();
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId IGetWorldAssetId() const;
|
|
|
|
CAssetId IGetStringTableAssetId() const;
|
|
|
|
CAssetId IGetSaveWorldAssetId() const;
|
2016-07-23 21:41:18 +00:00
|
|
|
const CMapWorld* IGetMapWorld() const;
|
|
|
|
CMapWorld* IMapWorld();
|
2016-07-24 04:46:32 +00:00
|
|
|
const IGameArea* IGetAreaAlways(TAreaId id) const;
|
|
|
|
TAreaId IGetCurrentAreaId() const;
|
2017-08-13 05:26:14 +00:00
|
|
|
TAreaId IGetAreaId(CAssetId id) const;
|
2016-07-23 21:41:18 +00:00
|
|
|
bool ICheckWorldComplete();
|
|
|
|
std::string IGetDefaultAudioTrack() const;
|
|
|
|
int IGetAreaCount() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CWorld : public IWorld
|
2016-04-17 22:38:05 +00:00
|
|
|
{
|
2016-08-14 03:00:58 +00:00
|
|
|
friend class CStateManager;
|
2016-05-03 08:27:28 +00:00
|
|
|
public:
|
|
|
|
class CRelay
|
|
|
|
{
|
|
|
|
TEditorId x0_relay = kInvalidEditorId;
|
|
|
|
TEditorId x4_target = kInvalidEditorId;
|
|
|
|
s16 x8_msg = -1;
|
|
|
|
bool xa_active = false;
|
|
|
|
public:
|
|
|
|
CRelay() = default;
|
|
|
|
CRelay(CInputStream& in);
|
|
|
|
|
|
|
|
TEditorId GetRelayId() const { return x0_relay; }
|
|
|
|
TEditorId GetTargetId() const { return x4_target; }
|
|
|
|
s16 GetMessage() const { return x8_msg; }
|
|
|
|
bool GetActive() const { return xa_active; }
|
2016-07-24 04:46:32 +00:00
|
|
|
|
|
|
|
static std::vector<CWorld::CRelay> ReadMemoryRelays(athena::io::MemoryReader& r);
|
|
|
|
};
|
|
|
|
|
2016-07-24 22:51:15 +00:00
|
|
|
struct CSoundGroupData
|
2016-07-24 04:46:32 +00:00
|
|
|
{
|
2016-07-24 22:51:15 +00:00
|
|
|
int x0_groupId;
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId x4_agscId;
|
2016-07-24 22:51:15 +00:00
|
|
|
std::string xc_name;
|
|
|
|
TCachedToken<CAudioGroupSet> x1c_groupData;
|
2016-07-24 04:46:32 +00:00
|
|
|
public:
|
2017-08-13 05:26:14 +00:00
|
|
|
CSoundGroupData(int grpId, CAssetId agsc);
|
2016-05-03 08:27:28 +00:00
|
|
|
};
|
2016-07-24 04:46:32 +00:00
|
|
|
|
2016-05-03 08:27:28 +00:00
|
|
|
private:
|
2017-01-07 01:58:05 +00:00
|
|
|
static constexpr CGameArea* skGlobalEnd = nullptr;
|
|
|
|
static constexpr CGameArea* skGlobalNonConstEnd = nullptr;
|
2016-07-24 04:46:32 +00:00
|
|
|
enum class Phase
|
|
|
|
{
|
|
|
|
Loading,
|
|
|
|
LoadingMap,
|
|
|
|
LoadingMapAreas,
|
2016-07-24 22:51:15 +00:00
|
|
|
LoadingSkyBox,
|
|
|
|
LoadingSoundGroups,
|
2016-07-24 04:46:32 +00:00
|
|
|
Done,
|
|
|
|
} x4_phase = Phase::Loading;
|
2017-11-15 04:12:13 +00:00
|
|
|
CAssetId x8_mlvlId;
|
|
|
|
CAssetId xc_strgId;
|
|
|
|
CAssetId x10_savwId;
|
2016-07-24 04:46:32 +00:00
|
|
|
std::vector<std::unique_ptr<CGameArea>> x18_areas;
|
2017-11-15 04:12:13 +00:00
|
|
|
CAssetId x24_mapwId;
|
2016-07-24 04:46:32 +00:00
|
|
|
TLockedToken<CMapWorld> x28_mapWorld;
|
|
|
|
std::vector<CRelay> x2c_relays;
|
|
|
|
//AsyncTask x3c_loadToken;
|
|
|
|
std::unique_ptr<uint8_t[]> x40_loadBuf;
|
|
|
|
//u32 x44_bufSz;
|
|
|
|
u32 x48_chainCount = 0;
|
|
|
|
CGameArea* x4c_chainHeads[5] = {};
|
|
|
|
|
|
|
|
IObjectStore& x60_objectStore;
|
|
|
|
IFactory& x64_resFactory;
|
|
|
|
TAreaId x68_curAreaId = kInvalidAreaId;
|
2017-11-27 05:06:53 +00:00
|
|
|
u32 x6c_loadedAudioGrpCount = 0;
|
2016-04-23 18:04:49 +00:00
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2017-04-13 19:28:31 +00:00
|
|
|
bool x70_24_currentAreaNeedsAllocation : 1;
|
2018-05-27 04:22:38 +00:00
|
|
|
bool x70_25_loadPaused : 1;
|
2017-11-12 05:14:57 +00:00
|
|
|
bool x70_26_skyboxActive : 1;
|
|
|
|
bool x70_27_skyboxVisible : 1;
|
2016-04-23 18:04:49 +00:00
|
|
|
};
|
2017-11-12 05:14:57 +00:00
|
|
|
u32 dummy = 0;
|
2016-04-23 18:04:49 +00:00
|
|
|
};
|
2016-07-24 04:46:32 +00:00
|
|
|
std::vector<CSoundGroupData> x74_soundGroupData;
|
|
|
|
std::string x84_defAudioTrack;
|
2017-11-12 05:14:57 +00:00
|
|
|
TLockedToken<CModel> x94_skyboxWorld;
|
|
|
|
TLockedToken<CModel> xa4_skyboxWorldLoaded;
|
|
|
|
TLockedToken<CModel> xb4_skyboxOverride;
|
2017-08-22 03:20:22 +00:00
|
|
|
EEnvFxType xc4_neededFx = EEnvFxType::None;
|
2017-11-27 05:06:53 +00:00
|
|
|
rstl::reserved_vector<CSfxHandle, 10> xc8_globalSfxHandles;
|
2016-07-24 22:51:15 +00:00
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
void LoadSoundGroup(int groupId, CAssetId agscId, CSoundGroupData& data);
|
2016-07-24 22:51:15 +00:00
|
|
|
void LoadSoundGroups();
|
2017-11-27 05:06:53 +00:00
|
|
|
void UnloadSoundGroups();
|
|
|
|
void StopSounds();
|
2016-04-23 18:04:49 +00:00
|
|
|
|
2016-05-03 08:27:28 +00:00
|
|
|
public:
|
2016-04-23 18:04:49 +00:00
|
|
|
|
2016-07-24 04:46:32 +00:00
|
|
|
void MoveToChain(CGameArea* area, EChain chain);
|
2017-11-12 05:14:57 +00:00
|
|
|
void MoveAreaToAliveChain(TAreaId aid);
|
2017-08-13 05:26:14 +00:00
|
|
|
bool CheckWorldComplete(CStateManager* mgr, TAreaId id, CAssetId mreaId);
|
2017-03-30 22:36:18 +00:00
|
|
|
CGameArea::CChainIterator GetChainHead(EChain chain) { return {x4c_chainHeads[int(chain)]}; }
|
|
|
|
CGameArea::CConstChainIterator GetChainHead(EChain chain) const { return {x4c_chainHeads[int(chain)]}; }
|
|
|
|
CGameArea::CChainIterator begin() { return GetChainHead(EChain::Alive); }
|
|
|
|
CGameArea::CChainIterator end() { return AliveAreasEnd(); }
|
|
|
|
CGameArea::CConstChainIterator begin() const { return GetChainHead(EChain::Alive); }
|
|
|
|
CGameArea::CConstChainIterator end() const { return GetAliveAreasEnd(); }
|
2016-08-14 03:00:58 +00:00
|
|
|
bool ScheduleAreaToLoad(CGameArea* area, CStateManager& mgr);
|
|
|
|
void TravelToArea(TAreaId aid, CStateManager& mgr, bool);
|
2018-05-27 04:22:38 +00:00
|
|
|
void SetLoadPauseState(bool paused);
|
|
|
|
void CycleLoadPauseState();
|
2016-07-24 04:46:32 +00:00
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
CWorld(IObjectStore& objStore, IFactory& resFactory, CAssetId mlvlId);
|
2017-11-27 05:06:53 +00:00
|
|
|
~CWorld();
|
2016-04-24 02:46:13 +00:00
|
|
|
bool DoesAreaExist(TAreaId area) const;
|
2017-05-31 02:51:38 +00:00
|
|
|
const std::vector<std::unique_ptr<CGameArea>>& GetGameAreas() const { return x18_areas; }
|
2016-07-23 21:41:18 +00:00
|
|
|
|
2017-04-15 05:32:25 +00:00
|
|
|
const CMapWorld* GetMapWorld() const { return x28_mapWorld.GetObj(); }
|
2016-07-24 23:14:58 +00:00
|
|
|
u32 GetRelayCount() const { return x2c_relays.size(); }
|
|
|
|
CRelay GetRelay(u32 idx) const { return x2c_relays[idx]; }
|
2016-07-24 04:46:32 +00:00
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId IGetWorldAssetId() const;
|
|
|
|
CAssetId IGetStringTableAssetId() const;
|
|
|
|
CAssetId IGetSaveWorldAssetId() const;
|
2016-07-23 21:41:18 +00:00
|
|
|
const CMapWorld* IGetMapWorld() const;
|
|
|
|
CMapWorld* IMapWorld();
|
2016-08-09 03:58:19 +00:00
|
|
|
const CGameArea* GetAreaAlways(TAreaId) const;
|
|
|
|
CGameArea* GetArea(TAreaId);
|
2017-01-04 04:08:30 +00:00
|
|
|
s32 GetNumAreas() const { return x18_areas.size(); }
|
2016-07-24 04:46:32 +00:00
|
|
|
const IGameArea* IGetAreaAlways(TAreaId id) const;
|
|
|
|
TAreaId IGetCurrentAreaId() const;
|
2017-04-16 05:52:43 +00:00
|
|
|
TAreaId GetCurrentAreaId() const { return x68_curAreaId; }
|
2017-08-13 05:26:14 +00:00
|
|
|
TAreaId IGetAreaId(CAssetId id) const;
|
2016-07-23 21:41:18 +00:00
|
|
|
bool ICheckWorldComplete();
|
|
|
|
std::string IGetDefaultAudioTrack() const;
|
|
|
|
int IGetAreaCount() const;
|
2017-01-07 01:58:05 +00:00
|
|
|
|
|
|
|
static void PropogateAreaChain(CGameArea::EOcclusionState, CGameArea*, CWorld*);
|
2017-03-30 22:36:18 +00:00
|
|
|
static CGameArea::CConstChainIterator GetAliveAreasEnd() { return {skGlobalEnd}; }
|
|
|
|
static CGameArea::CChainIterator AliveAreasEnd() { return {skGlobalNonConstEnd}; }
|
2017-03-03 07:18:12 +00:00
|
|
|
|
2017-03-24 05:30:16 +00:00
|
|
|
void Update(float dt);
|
2017-03-03 07:18:12 +00:00
|
|
|
void PreRender();
|
2017-03-04 04:31:08 +00:00
|
|
|
void TouchSky();
|
|
|
|
void DrawSky(const zeus::CTransform& xf) const;
|
2017-11-27 05:06:53 +00:00
|
|
|
void StopGlobalSound(u16 id);
|
|
|
|
bool HasGlobalSound(u16 id) const;
|
|
|
|
void AddGlobalSound(const CSfxHandle& hnd);
|
2017-08-22 03:20:22 +00:00
|
|
|
EEnvFxType GetNeededEnvFx() const { return xc4_neededFx; }
|
2018-05-20 05:01:17 +00:00
|
|
|
CAssetId GetWorldAssetId() const { return x8_mlvlId; }
|
2018-04-30 03:12:41 +00:00
|
|
|
bool AreSkyNeedsMet() const;
|
2016-07-23 21:41:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CWorldLayers
|
|
|
|
{
|
|
|
|
struct Area
|
|
|
|
{
|
|
|
|
u32 m_startNameIdx;
|
|
|
|
u32 m_layerCount;
|
|
|
|
u64 m_layerBits;
|
|
|
|
};
|
|
|
|
std::vector<Area> m_areas;
|
|
|
|
std::vector<std::string> m_names;
|
2017-08-13 05:26:14 +00:00
|
|
|
static void ReadWorldLayers(athena::io::MemoryReader& r, int version, CAssetId mlvlId);
|
2016-04-17 22:38:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __URDE_CWORLD_HPP__
|
2016-04-23 18:04:49 +00:00
|
|
|
|