metaforce/Runtime/World/CEntity.hpp

92 lines
2.9 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 <string>
#include <vector>
2021-05-27 06:31:38 +00:00
#include <set>
#include "Runtime/RetroTypes.hpp"
#include "Runtime/World/CEntityInfo.hpp"
#include "Runtime/World/ScriptObjectSupport.hpp"
2015-08-19 05:48:57 +00:00
2021-05-26 02:49:24 +00:00
#ifndef ENABLE_IMGUI
#define ENABLE_IMGUI 1
#endif
#if ENABLE_IMGUI
#define IMGUI_ENTITY_PROTOTYPES \
std::string_view ImGuiType() override; \
void ImGuiInspect() override;
#else
#define IMGUI_ENTITY_PROTOTYPES
#endif
2021-05-26 14:00:57 +00:00
#define DEFINE_ENTITY IMGUI_ENTITY_PROTOTYPES
2021-04-10 08:42:06 +00:00
namespace metaforce {
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;
friend class ImGuiConsole;
2018-12-08 05:30:43 +00:00
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;
bool x30_24_active : 1;
bool x30_25_inGraveyard : 1 = false;
bool x30_26_scriptingBlocked : 1 = false;
bool x30_27_inUse : 1;
2016-04-20 21:44:18 +00:00
// Used in ImGuiConsole
bool m_debugSelected = false;
bool m_debugHovered = false;
2021-05-27 06:31:38 +00:00
const std::set<SConnection>* m_incomingConnections = nullptr;
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 dt, CStateManager& mgr) {}
virtual void Think(float dt, CStateManager& mgr) {}
2018-12-08 05:30:43 +00:00
virtual void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);
virtual void SetActive(bool active) { x30_24_active = active; }
2021-05-26 02:49:24 +00:00
// Debugging utilities
virtual std::string_view ImGuiType();
virtual void ImGuiInspect();
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);
std::vector<SConnection>& GetConnectionList() { return x20_conns; }
2018-12-08 05:30:43 +00:00
const std::vector<SConnection>& GetConnectionList() const { 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; }
2021-05-27 06:31:38 +00:00
void SetIncomingConnectionList(const std::set<SConnection>* conns) {
m_incomingConnections = conns;
}
2015-08-19 05:48:57 +00:00
};
2021-04-10 08:42:06 +00:00
} // namespace metaforce