Link CScriptMazeNode

This commit is contained in:
Luke Street 2023-02-06 11:42:48 -05:00
parent 357658defa
commit d43dc0ead2
4 changed files with 13 additions and 32 deletions

View File

@ -350,7 +350,7 @@ LIBS = [
"MetroidPrime/Enemies/CMetroidPrimeEssence", "MetroidPrime/Enemies/CMetroidPrimeEssence",
"MetroidPrime/Enemies/CMetroidPrimeRelay", "MetroidPrime/Enemies/CMetroidPrimeRelay",
"MetroidPrime/Player/CPlayerDynamics", "MetroidPrime/Player/CPlayerDynamics",
["MetroidPrime/ScriptObjects/CScriptMazeNode", False], ["MetroidPrime/ScriptObjects/CScriptMazeNode", True],
["MetroidPrime/Weapons/WeaponTypes", False], ["MetroidPrime/Weapons/WeaponTypes", False],
"MetroidPrime/Enemies/COmegaPirate", "MetroidPrime/Enemies/COmegaPirate",
"MetroidPrime/Enemies/CPhazonPool", "MetroidPrime/Enemies/CPhazonPool",

View File

@ -219,7 +219,7 @@ public:
// TODO ? // TODO ?
void AddThermalColdScale2(float s) { xf28_thermColdScale2 += s; } void AddThermalColdScale2(float s) { xf28_thermColdScale2 += s; }
bool IsGeneratingObject() const { return xf94_26_generatingObject; } const bool IsGeneratingObject() const { return xf94_26_generatingObject; }
void SetIsGeneratingObject(bool gen) { xf94_26_generatingObject = gen; } void SetIsGeneratingObject(bool gen) { xf94_26_generatingObject = gen; }
void ApplyDamageToWorld(TUniqueId, const CActor&, const CVector3f&, const CDamageInfo& info, void ApplyDamageToWorld(TUniqueId, const CActor&, const CVector3f&, const CDamageInfo& info,

View File

@ -80,8 +80,9 @@ public:
pointer_iterator() : const_pointer_iterator< T, Vec, Alloc >(nullptr) {} pointer_iterator() : const_pointer_iterator< T, Vec, Alloc >(nullptr) {}
pointer_iterator(T* begin) : const_pointer_iterator< T, Vec, Alloc >(begin) {} pointer_iterator(T* begin) : const_pointer_iterator< T, Vec, Alloc >(begin) {}
void operator=(const T& other) { rstl::construct(this->current, other); } void operator=(const T& other) { rstl::construct(this->current, other); }
T& operator*() const { return *this->current; } T& operator*() { return *this->current; }
T* operator->() const { return this->current; } // TODO map says const, but breaks CScriptMazeNode::GenerateObjects
T* operator->() { return this->current; }
pointer_iterator& operator++() { pointer_iterator& operator++() {
++this->current; ++this->current;
return *this; return *this;

View File

@ -81,12 +81,12 @@ void CMazeState::Reset(int seed) {
} }
} }
SMazeCell& CMazeState::GetCell(uint col, uint row) { return x4_cells[col + row * skMazeCols]; }
const SMazeCell& CMazeState::GetCell(uint col, uint row) const { const SMazeCell& CMazeState::GetCell(uint col, uint row) const {
return x4_cells[col + row * skMazeCols]; return x4_cells[col + row * skMazeCols];
} }
SMazeCell& CMazeState::GetCell(uint col, uint row) { return x4_cells[col + row * skMazeCols]; }
static inline int GetRandom(CRandom16& rand, int offset) { static inline int GetRandom(CRandom16& rand, int offset) {
int tmp = rand.Next(); int tmp = rand.Next();
return tmp - ((tmp / 5) * 5) + offset; return tmp - ((tmp / 5) * 5) + offset;
@ -256,26 +256,9 @@ CScriptMazeNode::CScriptMazeNode(TUniqueId uid, const rstl::string& name, const
void CScriptMazeNode::Accept(IVisitor& visitor) { visitor.Visit(*this); } void CScriptMazeNode::Accept(IVisitor& visitor) { visitor.Visit(*this); }
static inline TUniqueId GenerateObject(CStateManager& mgr, const TEditorId& eid) {
bool wasGeneratingObject = mgr.IsGeneratingObject();
mgr.SetIsGeneratingObject(true);
TUniqueId objUid = mgr.GenerateObject(eid).second;
mgr.SetIsGeneratingObject(wasGeneratingObject);
return objUid;
}
// struct GenerateObjectGuard {
// GenerateObjectGuard(CStateManager& mgr) : mgr(mgr), wasGenerating(mgr.IsGeneratingObject()) {}
// ~GenerateObjectGuard() { mgr.SetIsGeneratingObject(wasGenerating); }
// CStateManager& mgr;
// bool wasGenerating;
// };
// TODO non-matching
// https://decomp.me/scratch/IvHBz
void CScriptMazeNode::GenerateObjects(CStateManager& mgr) { void CScriptMazeNode::GenerateObjects(CStateManager& mgr) {
rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin(); rstl::vector< SConnection >::iterator conn = ConnectionList().begin();
for (; conn != GetConnectionList().end(); ++conn) { for (; conn != ConnectionList().end(); ++conn) {
if (conn->x0_state != kSS_MaxReached || conn->x4_msg != kSM_Activate) { if (conn->x0_state != kSS_MaxReached || conn->x4_msg != kSM_Activate) {
continue; continue;
} }
@ -291,12 +274,10 @@ void CScriptMazeNode::GenerateObjects(CStateManager& mgr) {
continue; continue;
} }
TUniqueId objUid = GenerateObject(mgr, conn->x8_objId); bool wasGeneratingObject = mgr.IsGeneratingObject();
// TUniqueId objUid = kInvalidUniqueId; mgr.SetIsGeneratingObject(true);
// bool wasGeneratingObject = mgr.IsGeneratingObject(); TUniqueId objUid = mgr.GenerateObject(conn->x8_objId).second;
// mgr.SetIsGeneratingObject(true); mgr.SetIsGeneratingObject(wasGeneratingObject);
// TUniqueId objUid = mgr.GenerateObject(conn->x8_objId).second;
// mgr.SetIsGeneratingObject(wasGeneratingObject);
if (CActor* actor = static_cast< CActor* >(mgr.ObjectById(objUid))) { if (CActor* actor = static_cast< CActor* >(mgr.ObjectById(objUid))) {
mgr.SendScriptMsg(actor, GetUniqueId(), kSM_Activate); mgr.SendScriptMsg(actor, GetUniqueId(), kSM_Activate);
@ -379,7 +360,6 @@ void CScriptMazeNode::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C
continue; continue;
} }
// TUniqueId genObj = GenerateObject(mgr, conn->x8_objId);
bool wasGeneratingObject = mgr.IsGeneratingObject(); bool wasGeneratingObject = mgr.IsGeneratingObject();
mgr.SetIsGeneratingObject(true); mgr.SetIsGeneratingObject(true);
TUniqueId genObj = mgr.GenerateObject(conn->x8_objId).second; TUniqueId genObj = mgr.GenerateObject(conn->x8_objId).second;