metaforce/Runtime/World/CEntity.hpp

91 lines
2.9 KiB
C++
Raw Normal View History

2018-10-06 20:42:33 -07:00
#pragma once
2015-08-18 22:48:57 -07:00
#include <string>
#include <vector>
2021-05-26 23:31:38 -07:00
#include <set>
#include "Runtime/RetroTypes.hpp"
#include "Runtime/World/CEntityInfo.hpp"
#include "Runtime/World/ScriptObjectSupport.hpp"
2015-08-18 22:48:57 -07:00
2021-05-25 19:49:24 -07: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 07:00:57 -07:00
#define DEFINE_ENTITY IMGUI_ENTITY_PROTOTYPES
2021-04-10 01:42:06 -07:00
namespace metaforce {
2015-08-21 18:58:41 -07:00
class CStateManager;
2017-01-14 19:07:01 -08:00
class IVisitor;
2015-08-18 22:48:57 -07:00
2018-12-07 21:30:43 -08:00
class CEntity {
friend class CStateManager;
friend class CObjectList;
friend class ImGuiConsole;
2018-12-07 21:30:43 -08:00
2015-08-18 22:48:57 -07:00
protected:
2018-12-07 21:30:43 -08: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 14:44:18 -07:00
// Used in ImGuiConsole
bool m_debugSelected = false;
bool m_debugHovered = false;
2021-05-26 23:31:38 -07:00
const std::set<SConnection>* m_incomingConnections = nullptr;
2021-06-07 12:29:18 -07:00
2015-08-18 22:48:57 -07:00
public:
2018-12-07 21:30:43 -08: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-07 21:30:43 -08:00
virtual void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);
virtual void SetActive(bool active) { x30_24_active = active; }
2021-05-25 19:49:24 -07:00
// Debugging utilities
virtual std::string_view ImGuiType();
virtual void ImGuiInspect();
2018-12-07 21:30:43 -08:00
bool GetActive() const { return x30_24_active; }
void ToggleActive() { x30_24_active ^= 1; }
2015-08-18 22:48:57 -07:00
2018-12-07 21:30:43 -08: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-07 21:30:43 -08: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-07 21:30:43 -08:00
const std::vector<SConnection>& GetConnectionList() const { return x20_conns; }
2017-11-25 19:04:25 -08:00
2018-12-07 21:30:43 -08:00
std::string_view GetName() const { return x10_name; }
2021-06-07 12:29:18 -07:00
void SetIncomingConnectionList(const std::set<SConnection>* conns) { m_incomingConnections = conns; }
2015-08-18 22:48:57 -07:00
};
2021-04-10 01:42:06 -07:00
} // namespace metaforce