metaforce/Runtime/World/CEntity.hpp

68 lines
2.0 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2015-08-19 05:48:57 +00:00
#include "RetroTypes.hpp"
#include "ScriptObjectSupport.hpp"
2017-01-30 02:15:21 +00:00
#include "CEntityInfo.hpp"
2015-08-19 05:48:57 +00:00
2018-12-08 05:30:43 +00:00
namespace urde {
2015-08-22 01:58:41 +00:00
class CStateManager;
2017-01-15 03:07:01 +00:00
class IVisitor;
2015-08-19 05:48:57 +00:00
2018-12-08 05:30:43 +00:00
class CEntity {
friend class CStateManager;
friend class CObjectList;
2015-08-19 05:48:57 +00:00
protected:
2018-12-08 05:30:43 +00:00
TAreaId x4_areaId;
TUniqueId x8_uid;
TEditorId xc_editorId;
std::string x10_name;
std::vector<SConnection> x20_conns;
2016-04-20 21:44:18 +00:00
2018-12-08 05:30:43 +00:00
union {
struct {
bool x30_24_active : 1;
bool x30_25_inGraveyard : 1;
bool x30_26_scriptingBlocked : 1;
bool x30_27_inUse : 1;
2016-04-20 21:44:18 +00:00
};
2018-12-08 05:30:43 +00:00
u8 _dummy = 0;
};
2016-04-20 21:44:18 +00:00
2015-08-19 05:48:57 +00:00
public:
2018-12-08 05:30:43 +00:00
static const std::vector<SConnection> NullConnectionList;
virtual ~CEntity() = default;
CEntity(TUniqueId uid, const CEntityInfo& info, bool active, std::string_view name);
virtual void Accept(IVisitor& visitor) = 0;
virtual void PreThink(float, CStateManager&) {}
virtual void Think(float, CStateManager&) {}
virtual void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);
virtual void SetActive(bool active) { x30_24_active = active; }
2018-12-08 05:30:43 +00:00
bool GetActive() const { return x30_24_active; }
void ToggleActive() { x30_24_active ^= 1; }
2015-08-19 05:48:57 +00:00
2018-12-08 05:30:43 +00:00
bool IsInGraveyard() const { return x30_25_inGraveyard; }
void SetIsInGraveyard(bool in) { x30_25_inGraveyard = in; }
bool IsScriptingBlocked() const { return x30_26_scriptingBlocked; }
void SetIsScriptingBlocked(bool blocked) { x30_26_scriptingBlocked = blocked; }
bool IsInUse() const { return x30_27_inUse; }
2018-12-08 05:30:43 +00:00
TAreaId GetAreaId() const {
if (x30_27_inUse)
return x4_areaId;
return kInvalidAreaId;
}
TAreaId GetAreaIdAlways() const { return x4_areaId; }
TUniqueId GetUniqueId() const { return x8_uid; }
TEditorId GetEditorId() const { return xc_editorId; }
void SendScriptMsgs(EScriptObjectState state, CStateManager& stateMgr, EScriptObjectMessage msg);
2018-12-08 05:30:43 +00:00
const std::vector<SConnection>& GetConnectionList() const { return x20_conns; }
std::vector<SConnection>& ConnectionList() { return x20_conns; }
2017-11-26 03:04:25 +00:00
2018-12-08 05:30:43 +00:00
std::string_view GetName() const { return x10_name; }
2015-08-19 05:48:57 +00:00
};
2018-12-08 05:30:43 +00:00
} // namespace urde