2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_CSTATEMANAGER_HPP__
|
|
|
|
#define __URDE_CSTATEMANAGER_HPP__
|
2015-08-17 05:26:58 +00:00
|
|
|
|
|
|
|
#include <memory>
|
2016-04-17 22:38:05 +00:00
|
|
|
#include <set>
|
2015-08-17 05:26:58 +00:00
|
|
|
#include "CBasics.hpp"
|
2016-04-18 01:58:13 +00:00
|
|
|
#include "World/ScriptObjectSupport.hpp"
|
2016-04-16 21:49:47 +00:00
|
|
|
#include "GameObjectLists.hpp"
|
|
|
|
#include "Camera/CCameraManager.hpp"
|
2016-04-17 02:50:45 +00:00
|
|
|
#include "Camera/CCameraFilter.hpp"
|
|
|
|
#include "CRandom16.hpp"
|
2016-04-17 05:35:32 +00:00
|
|
|
#include "zeus/CAABox.hpp"
|
|
|
|
#include "CWeaponMgr.hpp"
|
|
|
|
#include "World/CAi.hpp"
|
2016-04-17 22:38:05 +00:00
|
|
|
#include "CToken.hpp"
|
|
|
|
#include "World/ScriptLoader.hpp"
|
2016-08-14 03:00:58 +00:00
|
|
|
#include "Input/CFinalInput.hpp"
|
|
|
|
#include "CSortedLists.hpp"
|
|
|
|
#include "CFluidPlaneManager.hpp"
|
|
|
|
#include "World/CEnvFxManager.hpp"
|
|
|
|
#include "World/CActorModelParticles.hpp"
|
|
|
|
#include "Input/CRumbleManager.hpp"
|
2015-08-17 05:26:58 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-17 22:05:00 +00:00
|
|
|
{
|
2016-07-24 23:14:58 +00:00
|
|
|
class CRelayTracker;
|
2015-08-22 01:58:41 +00:00
|
|
|
class CMapWorldInfo;
|
|
|
|
class CPlayerState;
|
|
|
|
class CWorldTransManager;
|
2016-04-16 21:49:47 +00:00
|
|
|
class CObjectList;
|
2016-04-17 02:50:45 +00:00
|
|
|
class CSortedListManager;
|
|
|
|
class CFluidPlaneManager;
|
|
|
|
class CEnvFxManager;
|
|
|
|
class CActorModelParticles;
|
|
|
|
class CTeamAiTypes;
|
|
|
|
class CRumbleManager;
|
2016-04-17 05:35:32 +00:00
|
|
|
class CActor;
|
|
|
|
class CLight;
|
|
|
|
class CDamageInfo;
|
|
|
|
class CMaterialFilter;
|
|
|
|
class CFinalInput;
|
2016-07-22 19:46:30 +00:00
|
|
|
class CPlayer;
|
2016-04-17 22:38:05 +00:00
|
|
|
class CWorld;
|
|
|
|
class CTexture;
|
|
|
|
|
|
|
|
struct SScriptObjectStream
|
|
|
|
{
|
|
|
|
CEntity* x0_obj;
|
|
|
|
EScriptObjectType x4_type;
|
|
|
|
u32 x8_position;
|
|
|
|
u32 xc_length;
|
|
|
|
};
|
2015-08-17 22:05:00 +00:00
|
|
|
|
2015-08-18 05:54:43 +00:00
|
|
|
class CStateManager
|
2015-08-17 05:26:58 +00:00
|
|
|
{
|
2016-04-16 21:49:47 +00:00
|
|
|
TUniqueId x8_idArr[1024] = {};
|
2016-04-17 22:38:05 +00:00
|
|
|
|
2016-04-16 21:49:47 +00:00
|
|
|
std::unique_ptr<CObjectList> x80c_allObjs;
|
2016-04-17 02:50:45 +00:00
|
|
|
std::unique_ptr<CActorList> x814_actorObjs;
|
|
|
|
std::unique_ptr<CPhysicsActorList> x81c_physActorObjs;
|
|
|
|
std::unique_ptr<CGameCameraList> x824_cameraObjs;
|
|
|
|
std::unique_ptr<CGameLightList> x82c_lightObjs;
|
|
|
|
std::unique_ptr<CListeningAiList> x834_listenAiObjs;
|
|
|
|
std::unique_ptr<CAiWaypointList> x83c_aiWaypointObjs;
|
|
|
|
std::unique_ptr<CPlatformAndDoorList> x844_platformAndDoorObjs;
|
2016-04-17 05:35:32 +00:00
|
|
|
|
2016-07-22 19:46:30 +00:00
|
|
|
std::unique_ptr<CPlayer> x84c_player;
|
2016-04-17 22:38:05 +00:00
|
|
|
std::unique_ptr<CWorld> x850_world;
|
|
|
|
|
2016-04-17 05:35:32 +00:00
|
|
|
/* Used to be a list of 32-element reserved_vectors */
|
|
|
|
std::vector<TUniqueId> x858_objectGraveyard;
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2016-08-14 03:00:58 +00:00
|
|
|
struct CStateManagerContainer
|
|
|
|
{
|
|
|
|
CCameraManager x0_cameraManager;
|
|
|
|
CSortedListManager x3c0_sortedListManager;
|
|
|
|
CWeaponMgr xe3d8_weaponManager;
|
|
|
|
CFluidPlaneManager xe3ec_fluidPlaneManager;
|
|
|
|
CEnvFxManager xe510_envFxManager;
|
|
|
|
CActorModelParticles xf168_actorModelParticles;
|
|
|
|
CRumbleManager xf250_rumbleManager;
|
|
|
|
u32 xf344_ = 0;
|
|
|
|
u32 xf370_ = 0;
|
|
|
|
u32 xf39c_ = 0;
|
|
|
|
};
|
2016-08-14 03:05:50 +00:00
|
|
|
std::unique_ptr<CStateManagerContainer> x86c_stateManagerContainer;
|
2016-08-14 03:00:58 +00:00
|
|
|
CCameraManager* x870_cameraManager = nullptr;
|
|
|
|
CSortedListManager* x874_sortedListManager = nullptr;
|
|
|
|
CWeaponMgr* x878_weaponManager = nullptr;
|
|
|
|
CFluidPlaneManager* x87c_fluidPlaneManager = nullptr;
|
|
|
|
CEnvFxManager* x880_envFxManager = nullptr;
|
|
|
|
CActorModelParticles* x884_actorModelParticles = nullptr;
|
|
|
|
CRumbleManager* x88c_rumbleManager = nullptr;
|
|
|
|
|
|
|
|
std::multimap<TEditorId, TUniqueId> x890_scriptIdMap;
|
2016-04-17 22:38:05 +00:00
|
|
|
std::map<TEditorId, SScriptObjectStream> x8a4_loadedScriptObjects;
|
|
|
|
|
|
|
|
std::shared_ptr<CPlayerState> x8b8_playerState;
|
2016-07-25 06:24:57 +00:00
|
|
|
std::shared_ptr<CRelayTracker> x8bc_relayTracker;
|
2016-04-17 22:38:05 +00:00
|
|
|
std::shared_ptr<CMapWorldInfo> x8c0_mapWorldInfo;
|
|
|
|
std::shared_ptr<CWorldTransManager> x8c4_worldTransManager;
|
|
|
|
|
|
|
|
TAreaId x8c8_currentAreaId;
|
|
|
|
TAreaId x8cc_nextAreaId;
|
2016-08-14 03:00:58 +00:00
|
|
|
TAreaId x8d0_prevAreaId;
|
|
|
|
//u32 x8d0_extFrameIdx = 0;
|
|
|
|
//u32 x8d4_updateFrameIdx = 0;
|
|
|
|
//u32 x8d8_drawFrameIdx = 0;
|
2016-04-17 22:38:05 +00:00
|
|
|
|
|
|
|
std::vector<CLight> x8dc_dynamicLights;
|
|
|
|
|
2016-08-14 03:00:58 +00:00
|
|
|
TLockedToken<CTexture> x8f0_shadowTex; /* DefaultShadow in MiscData */
|
|
|
|
CRandom16 x8fc_random;
|
2016-08-15 01:19:04 +00:00
|
|
|
CRandom16* x900_activeRandom = nullptr;
|
2016-09-16 22:21:19 +00:00
|
|
|
FScriptLoader x90c_loaderFuncs[int(EScriptObjectType::ScriptObjectTypeMAX)] = {};
|
2016-04-17 22:38:05 +00:00
|
|
|
|
|
|
|
bool xab0_worldLoaded = false;
|
|
|
|
|
|
|
|
std::set<std::string> xab4_uniqueInstanceNames;
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2016-08-14 03:00:58 +00:00
|
|
|
enum class InitPhase
|
|
|
|
{
|
|
|
|
LoadWorld,
|
|
|
|
LoadFirstArea,
|
|
|
|
Done
|
|
|
|
} xb3c_initPhase;
|
|
|
|
|
|
|
|
CFinalInput xb54_finalInput;
|
|
|
|
CCameraFilterPass xb84_camFilterPasses[9];
|
|
|
|
CCameraBlurPass xd14_camBlurPasses[9];
|
2016-04-17 02:50:45 +00:00
|
|
|
|
2016-04-17 22:38:05 +00:00
|
|
|
s32 xe60_ = -1;
|
|
|
|
zeus::CVector3f xe64_;
|
|
|
|
|
|
|
|
TUniqueId xe70_ = kInvalidUniqueId;
|
|
|
|
zeus::CVector3f xe74_ = {0.f, 1.f, 1.f};
|
|
|
|
|
|
|
|
s32 xe80_ = 2;
|
|
|
|
TUniqueId xe84_ = kInvalidUniqueId;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool xe86_24_;
|
|
|
|
bool xe86_25_;
|
|
|
|
bool xe86_26_;
|
|
|
|
bool xe86_27_;
|
|
|
|
bool xe86_28_;
|
|
|
|
bool xe86_29_;
|
|
|
|
};
|
|
|
|
u16 _dummy = 0;
|
|
|
|
};
|
2016-09-02 15:26:29 +00:00
|
|
|
s32 xef4_;
|
|
|
|
zeus::CVector2i xef8_;
|
|
|
|
zeus::CVector2i xf00_;
|
2016-07-22 19:46:30 +00:00
|
|
|
float xf24_thermColdScale1 = 0.f;
|
|
|
|
float xf28_thermColdScale2 = 0.f;
|
|
|
|
float xf2c_ = 1.f;
|
|
|
|
float xf30_ = 1.f;
|
|
|
|
|
2016-07-23 00:26:17 +00:00
|
|
|
void UpdateThermalVisor();
|
2016-07-22 19:46:30 +00:00
|
|
|
|
2015-08-17 05:26:58 +00:00
|
|
|
public:
|
2016-09-16 22:21:19 +00:00
|
|
|
/* TODO: Figure out what these are
|
2016-07-26 02:33:32 +00:00
|
|
|
* Public for CScriptRelay
|
|
|
|
*/
|
|
|
|
TUniqueId xf76_ = kInvalidUniqueId;
|
2016-09-16 22:21:19 +00:00
|
|
|
/* TODO: Public for CFirstPersonCamera */
|
|
|
|
u32 x904_;
|
2016-04-17 05:35:32 +00:00
|
|
|
|
2016-07-24 23:14:58 +00:00
|
|
|
CStateManager(const std::weak_ptr<CRelayTracker>&,
|
2015-08-17 05:26:58 +00:00
|
|
|
const std::weak_ptr<CMapWorldInfo>&,
|
|
|
|
const std::weak_ptr<CPlayerState>&,
|
|
|
|
const std::weak_ptr<CWorldTransManager>&);
|
2015-08-19 05:48:57 +00:00
|
|
|
|
2016-08-18 18:34:06 +00:00
|
|
|
bool RenderLast(TUniqueId);
|
2016-04-17 05:35:32 +00:00
|
|
|
void AddDrawableActor(const CActor& actor, const zeus::CVector3f& vec, const zeus::CAABox& aabb) const;
|
|
|
|
void SpecialSkipCinematic();
|
|
|
|
void GetVisAreaId() const;
|
|
|
|
void GetWeaponIdCount(TUniqueId, EWeaponType);
|
|
|
|
void RemoveWeaponId(TUniqueId, EWeaponType);
|
|
|
|
void AddWeaponId(TUniqueId, EWeaponType);
|
|
|
|
void UpdateEscapeSequenceTimer(float);
|
|
|
|
float GetEscapeSequenceTimer() const;
|
|
|
|
void ResetEscapeSequenceTimer(float);
|
|
|
|
void SetupParticleHook(const CActor& actor) const;
|
|
|
|
void MurderScriptInstanceNames();
|
2016-04-18 05:33:23 +00:00
|
|
|
const std::string* HashInstanceName(CInputStream& in);
|
2016-04-17 05:35:32 +00:00
|
|
|
void SetActorAreaId(CActor& actor, TAreaId);
|
|
|
|
void TouchSky() const;
|
|
|
|
void DrawSpaceWarp(const zeus::CVector3f&, float) const;
|
|
|
|
void DrawReflection(const zeus::CVector3f&);
|
|
|
|
void CacheReflection();
|
|
|
|
bool CanCreateProjectile(TUniqueId, EWeaponType, int) const;
|
|
|
|
const CGameLightList* GetDynamicLightList() const;
|
|
|
|
void BuildDynamicLightListForWorld(std::vector<CLight>& listOut) const;
|
|
|
|
void DrawDebugStuff() const;
|
|
|
|
void RenderCamerasAndAreaLights() const;
|
|
|
|
void DrawE3DeathEffect() const;
|
|
|
|
void DrawAdditionalFilters() const;
|
|
|
|
void DrawWorld() const;
|
|
|
|
void SetupFogForArea(const CGameArea& area) const;
|
|
|
|
void PreRender();
|
|
|
|
void GetVisSetForArea(TAreaId, TAreaId) const;
|
|
|
|
void RecursiveDrawTree(TUniqueId) const;
|
2016-08-14 03:00:58 +00:00
|
|
|
void SendScriptMsg(CEntity* dest, TUniqueId src, EScriptObjectMessage msg);
|
2016-07-24 04:46:32 +00:00
|
|
|
void SendScriptMsg(TUniqueId dest, TUniqueId src, EScriptObjectMessage msg);
|
2016-08-14 03:00:58 +00:00
|
|
|
void SendScriptMsg(TUniqueId src, TEditorId dest,
|
|
|
|
EScriptObjectMessage msg, EScriptObjectState state);
|
2016-08-18 18:34:06 +00:00
|
|
|
void SendScriptMsgAlways(TUniqueId dest, TUniqueId src, EScriptObjectMessage);
|
2016-04-17 05:35:32 +00:00
|
|
|
void FreeScriptObjects(TAreaId);
|
|
|
|
void GetBuildForScript(TEditorId) const;
|
2016-04-22 20:22:45 +00:00
|
|
|
TEditorId GetEditorIdForUniqueId(TUniqueId) const;
|
2016-04-17 05:35:32 +00:00
|
|
|
TUniqueId GetIdForScript(TEditorId) const;
|
2016-08-14 03:00:58 +00:00
|
|
|
std::pair<std::multimap<TEditorId, TUniqueId>::const_iterator,
|
|
|
|
std::multimap<TEditorId, TUniqueId>::const_iterator>
|
|
|
|
GetIdListForScript(TEditorId) const;
|
2016-07-24 04:46:32 +00:00
|
|
|
void LoadScriptObjects(TAreaId, CInputStream& in, std::vector<TEditorId>& idsOut);
|
2016-09-16 22:21:19 +00:00
|
|
|
void LoadScriptObject(TAreaId, EScriptObjectType, u32, CInputStream& in);
|
2016-07-24 04:46:32 +00:00
|
|
|
void InitScriptObjects(std::vector<TEditorId>& ids);
|
2016-04-17 05:35:32 +00:00
|
|
|
void InformListeners(const zeus::CVector3f&, EListenNoiseType);
|
|
|
|
void ApplyKnockBack(CActor& actor, const CDamageInfo& info,
|
|
|
|
const CDamageVulnerability&, const zeus::CVector3f&, float);
|
|
|
|
void ApplyDamageToWorld(TUniqueId, const CActor&, const zeus::CVector3f&,
|
|
|
|
const CDamageInfo& info, const CMaterialFilter&);
|
|
|
|
void ProcessRadiusDamage(const CActor&, CActor&, const zeus::CVector3f&,
|
|
|
|
const CDamageInfo& info, const CMaterialFilter&);
|
|
|
|
void ApplyRadiusDamage(const CActor&, const zeus::CVector3f&, CActor&,
|
|
|
|
const CDamageInfo& info);
|
|
|
|
void ApplyLocalDamage(const zeus::CVector3f&, const zeus::CVector3f&, CActor&, float,
|
|
|
|
const CWeaponMode&);
|
|
|
|
void ApplyDamage(TUniqueId, TUniqueId, TUniqueId, const CDamageInfo& info,
|
|
|
|
const CMaterialFilter&);
|
|
|
|
void UpdateAreaSounds();
|
|
|
|
void FrameEnd();
|
|
|
|
void ProcessPlayerInput();
|
|
|
|
void ProcessInput(const CFinalInput& input);
|
|
|
|
void Update(float dt);
|
|
|
|
void UpdateGameState();
|
|
|
|
void FrameBegin();
|
2016-08-14 03:00:58 +00:00
|
|
|
void InitializeState(ResId mlvlId, TAreaId aid, ResId mreaId);
|
2016-04-17 05:35:32 +00:00
|
|
|
void CreateStandardGameObjects();
|
2016-07-25 06:24:57 +00:00
|
|
|
const std::unique_ptr<CObjectList>& GetObjectList() const { return x80c_allObjs; }
|
2016-04-17 05:35:32 +00:00
|
|
|
CObjectList* ObjectListById(EGameObjectList type);
|
|
|
|
const CObjectList* GetObjectListById(EGameObjectList type) const;
|
|
|
|
void RemoveObject(TUniqueId);
|
|
|
|
void UpdateRoomAcoustics(TAreaId);
|
|
|
|
void SetCurrentAreaId(TAreaId);
|
|
|
|
void ClearGraveyard();
|
|
|
|
void DeleteObjectRequest(TUniqueId);
|
|
|
|
CEntity* ObjectById(TUniqueId uid);
|
|
|
|
const CEntity* GetObjectById(TUniqueId uid) const;
|
|
|
|
void AreaUnloaded(TAreaId);
|
|
|
|
void PrepareAreaUnload(TAreaId);
|
|
|
|
void AreaLoaded(TAreaId);
|
|
|
|
void BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOut,
|
|
|
|
const zeus::CVector3f&, const zeus::CVector3f&, float,
|
|
|
|
const CMaterialFilter&, const CActor*) const;
|
|
|
|
void BuildColliderList(rstl::reserved_vector<TUniqueId, 1024>& listOut,
|
|
|
|
const CActor&, const zeus::CAABox&) const;
|
|
|
|
void BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOut,
|
|
|
|
const zeus::CAABox&, const CMaterialFilter&, const CActor*) const;
|
|
|
|
void UpdateActorInSortedLists(CActor&);
|
|
|
|
void UpdateSortedLists();
|
|
|
|
zeus::CAABox CalculateObjectBounds(const CActor&);
|
2016-08-14 03:00:58 +00:00
|
|
|
void AddObject(CEntity&);
|
|
|
|
void AddObject(CEntity*);
|
2016-04-17 05:35:32 +00:00
|
|
|
bool RayStaticIntersection(const zeus::CVector3f&, const zeus::CVector3f&, float,
|
|
|
|
const CMaterialFilter&) const;
|
|
|
|
bool RayWorldIntersection(TUniqueId, const zeus::CVector3f&, const zeus::CVector3f&,
|
|
|
|
float, const CMaterialFilter&,
|
|
|
|
const rstl::reserved_vector<TUniqueId, 1024>& list) const;
|
|
|
|
void UpdateObjectInLists(CEntity&);
|
2016-04-16 21:49:47 +00:00
|
|
|
TUniqueId AllocateUniqueId();
|
2016-04-17 02:50:45 +00:00
|
|
|
|
2016-04-17 05:35:32 +00:00
|
|
|
const std::shared_ptr<CPlayerState>& GetPlayerState() const {return x8b8_playerState;}
|
2016-08-21 20:39:18 +00:00
|
|
|
CRandom16* GetActiveRandom() {return x900_activeRandom;}
|
2016-04-17 02:50:45 +00:00
|
|
|
CRumbleManager& GetRumbleManager() {return *x88c_rumbleManager;}
|
2016-08-14 03:00:58 +00:00
|
|
|
CCameraFilterPass& GetCameraFilterPass(int idx) {return xb84_camFilterPasses[idx];}
|
2016-04-19 00:17:49 +00:00
|
|
|
|
|
|
|
CWorld* GetWorld() {return x850_world.get();}
|
2016-07-25 06:24:57 +00:00
|
|
|
CRelayTracker* GetRelayTracker() { return x8bc_relayTracker.get(); }
|
2016-09-15 07:26:35 +00:00
|
|
|
CCameraManager* GetCameraManager() const { return x870_cameraManager; }
|
2016-04-22 20:22:45 +00:00
|
|
|
|
|
|
|
std::shared_ptr<CMapWorldInfo> MapWorldInfo() { return x8c0_mapWorldInfo; }
|
2016-08-07 00:20:02 +00:00
|
|
|
|
|
|
|
bool IsLayerActive(TAreaId area, int layerIdx) { return false; }
|
2016-08-15 01:19:04 +00:00
|
|
|
|
|
|
|
CPlayer& GetPlayer() const { return *x84c_player; }
|
|
|
|
|
|
|
|
CObjectList& GetAllObjectList() const { return *x80c_allObjs; }
|
|
|
|
CActorList& GetActorObjectList() const { return *x814_actorObjs; }
|
|
|
|
CPhysicsActorList& GetPhysicsActorObjectList() const { return *x81c_physActorObjs; }
|
|
|
|
CGameCameraList& GetCameraObjectList() const { return *x824_cameraObjs; }
|
|
|
|
CGameLightList& GetLightObjectList() const { return *x82c_lightObjs; }
|
|
|
|
CListeningAiList& GetListeningAiObjectList() const { return *x834_listenAiObjs; }
|
|
|
|
CAiWaypointList& GetAiWaypointObjectList() const { return *x83c_aiWaypointObjs; }
|
|
|
|
CPlatformAndDoorList& GetPlatformAndDoorObjectList() const { return *x844_platformAndDoorObjs; }
|
2015-08-17 05:26:58 +00:00
|
|
|
};
|
2015-08-17 22:05:00 +00:00
|
|
|
}
|
|
|
|
|
2015-08-17 05:26:58 +00:00
|
|
|
#endif
|