mirror of https://github.com/PrimeDecomp/prime.git
Add & link CEntity.cpp
This commit is contained in:
parent
11f69fcb5d
commit
0b6ce7f781
|
@ -95,6 +95,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CTevCombiners::CTevPass CTevPass_805a5ebc;
|
extern CTevCombiners::CTevPass CTevPass_805a5ebc;
|
||||||
|
// TODO move to CGraphics
|
||||||
extern CTevCombiners::CTevPass* PTR_skPassThru_805a8828;
|
extern CTevCombiners::CTevPass* PTR_skPassThru_805a8828;
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -17,11 +17,15 @@ public:
|
||||||
virtual void Accept(IVisitor& visitor) = 0;
|
virtual void Accept(IVisitor& visitor) = 0;
|
||||||
virtual void PreThink(float dt, CStateManager& mgr);
|
virtual void PreThink(float dt, CStateManager& mgr);
|
||||||
virtual void Think(float dt, CStateManager& mgr);
|
virtual void Think(float dt, CStateManager& mgr);
|
||||||
virtual void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);
|
virtual void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr);
|
||||||
virtual void SetActive(bool active);
|
virtual void SetActive(bool active);
|
||||||
|
|
||||||
CEntity(TUniqueId id, const CEntityInfo& info, bool active, const rstl::string& name);
|
CEntity(TUniqueId id, const CEntityInfo& info, bool active, const rstl::string& name);
|
||||||
|
|
||||||
|
void SendScriptMsgs(EScriptObjectState state, CStateManager& mgr, EScriptObjectMessage msg);
|
||||||
|
TUniqueId GetUniqueId() const { return x8_uid; }
|
||||||
|
TAreaId GetAreaId() const;
|
||||||
|
|
||||||
static rstl::vector<SConnection> NullConnectionList;
|
static rstl::vector<SConnection> NullConnectionList;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -33,7 +37,7 @@ protected:
|
||||||
bool x30_24_active : 1;
|
bool x30_24_active : 1;
|
||||||
bool x30_25_inGraveyard : 1;
|
bool x30_25_inGraveyard : 1;
|
||||||
bool x30_26_scriptingBlocked : 1;
|
bool x30_26_scriptingBlocked : 1;
|
||||||
bool x30_27_inUse : 1;
|
bool x30_27_notInArea : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
class CStateManager {};
|
class CStateManager {
|
||||||
|
public:
|
||||||
|
void SendScriptMsg(TUniqueId uid, TEditorId target, EScriptObjectMessage msg, EScriptObjectState state);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,17 +21,33 @@ struct TAreaId {
|
||||||
bool operator==(const TAreaId& other) const { return value == other.value; }
|
bool operator==(const TAreaId& other) const { return value == other.value; }
|
||||||
bool operator!=(const TAreaId& other) const { return value != other.value; }
|
bool operator!=(const TAreaId& other) const { return value != other.value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TEditorId {
|
struct TEditorId {
|
||||||
u32 value;
|
u32 value;
|
||||||
|
|
||||||
TEditorId() : value(-1) {}
|
TEditorId() : value(-1) {}
|
||||||
TEditorId(u32 value) : value(value) {}
|
TEditorId(u32 value) : value(value) {}
|
||||||
|
u32 Value() const { return value; }
|
||||||
|
|
||||||
|
bool operator==(const TEditorId& other) const { return value == other.value; }
|
||||||
|
bool operator!=(const TEditorId& other) const { return value != other.value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TUniqueId {
|
struct TUniqueId {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
u16 version : 6;
|
||||||
|
u16 id : 10;
|
||||||
|
};
|
||||||
u16 value;
|
u16 value;
|
||||||
|
};
|
||||||
|
|
||||||
TUniqueId() : value(-1) {}
|
TUniqueId() : value(-1) {}
|
||||||
TUniqueId(u16 value) : value(value) {}
|
TUniqueId(u16 value) : value(value) {}
|
||||||
|
u16 Value() const { return value; }
|
||||||
|
|
||||||
|
bool operator==(const TUniqueId& other) const { return value == other.value; }
|
||||||
|
bool operator!=(const TUniqueId& other) const { return value != other.value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
CRandom16* CRandom16::gRandomNumber = nullptr;
|
CRandom16* CRandom16::gRandomNumber = nullptr;
|
||||||
CGlobalRandom* CGlobalRandom::gCurrentGlobalRandom = nullptr;
|
CGlobalRandom* CGlobalRandom::gCurrentGlobalRandom = nullptr;
|
||||||
|
|
||||||
CGlobalRandom::CGlobalRandom(CRandom16& rnd) : mRandom(rnd) {
|
CGlobalRandom::CGlobalRandom(CRandom16& rnd) : mRandom(rnd) {
|
||||||
mIsFirst = true;
|
mIsFirst = true;
|
||||||
mPrev = gCurrentGlobalRandom;
|
mPrev = gCurrentGlobalRandom;
|
||||||
|
@ -25,6 +26,7 @@ CGlobalRandom::~CGlobalRandom() {
|
||||||
}
|
}
|
||||||
|
|
||||||
CRandom16* CRandom16::GetRandomNumber() { return gRandomNumber; }
|
CRandom16* CRandom16::GetRandomNumber() { return gRandomNumber; }
|
||||||
|
|
||||||
void CRandom16::_SetRandomNumber(CRandom16* rnd) { gRandomNumber = rnd; }
|
void CRandom16::_SetRandomNumber(CRandom16* rnd) { gRandomNumber = rnd; }
|
||||||
|
|
||||||
CRandom16::CRandom16(u32 seed) : mSeed(seed) {}
|
CRandom16::CRandom16(u32 seed) : mSeed(seed) {}
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
#include "MetroidPrime/CEntity.hpp"
|
||||||
|
|
||||||
|
rstl::vector< SConnection > CEntity::NullConnectionList;
|
||||||
|
|
||||||
|
CEntityInfo::CEntityInfo(TAreaId aid, const rstl::vector< SConnection >& conns, TEditorId eid)
|
||||||
|
: x0_areaId(aid), x4_conns(conns), x14_editorId(eid) {}
|
||||||
|
|
||||||
|
CEntity::CEntity(TUniqueId id, const CEntityInfo& info, bool active, const rstl::string& name)
|
||||||
|
: x4_areaId(info.GetAreaId())
|
||||||
|
, x8_uid(id)
|
||||||
|
, xc_editorId(info.GetEditorId())
|
||||||
|
, x10_name(name)
|
||||||
|
, x20_conns(info.GetConnectionList())
|
||||||
|
, x30_24_active(active)
|
||||||
|
, x30_25_inGraveyard(false)
|
||||||
|
, x30_26_scriptingBlocked(false)
|
||||||
|
, x30_27_notInArea(x4_areaId == kInvalidAreaId) {}
|
||||||
|
|
||||||
|
CEntity::~CEntity() {}
|
||||||
|
|
||||||
|
void CEntity::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
||||||
|
switch (msg) {
|
||||||
|
case kSM_Activate:
|
||||||
|
if (!x30_24_active) {
|
||||||
|
SetActive(true);
|
||||||
|
SendScriptMsgs(kSS_Active, mgr, kSM_None);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kSM_Deactivate:
|
||||||
|
if (x30_24_active) {
|
||||||
|
SetActive(false);
|
||||||
|
SendScriptMsgs(kSS_Inactive, mgr, kSM_None);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kSM_ToggleActive:
|
||||||
|
if (!x30_24_active) {
|
||||||
|
AcceptScriptMsg(kSM_Activate, uid, mgr);
|
||||||
|
} else {
|
||||||
|
AcceptScriptMsg(kSM_Deactivate, uid, mgr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEntity::SendScriptMsgs(EScriptObjectState state, CStateManager& mgr, EScriptObjectMessage skipMsg) {
|
||||||
|
rstl::vector<SConnection>::const_iterator it = x20_conns.begin();
|
||||||
|
for (; it != x20_conns.end(); ++it) {
|
||||||
|
if (it->x0_state == state && it->x4_msg != skipMsg) {
|
||||||
|
mgr.SendScriptMsg(GetUniqueId(), it->x8_objId, it->x4_msg, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEntity::PreThink(float dt, CStateManager& mgr) {}
|
||||||
|
|
||||||
|
void CEntity::Think(float dt, CStateManager& mgr) {}
|
||||||
|
|
||||||
|
void CEntity::SetActive(bool active) { x30_24_active = active; }
|
||||||
|
|
||||||
|
TAreaId CEntity::GetAreaId() const { return x30_27_notInArea ? kInvalidAreaId : x4_areaId; }
|
Loading…
Reference in New Issue