Link CScriptMazeNode

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

View File

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

View File

@ -219,7 +219,7 @@ public:
// TODO ?
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 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(T* begin) : const_pointer_iterator< T, Vec, Alloc >(begin) {}
void operator=(const T& other) { rstl::construct(this->current, other); }
T& operator*() const { return *this->current; }
T* operator->() const { return this->current; }
T& operator*() { return *this->current; }
// TODO map says const, but breaks CScriptMazeNode::GenerateObjects
T* operator->() { return this->current; }
pointer_iterator& operator++() {
++this->current;
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 {
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) {
int tmp = rand.Next();
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); }
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) {
rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin();
for (; conn != GetConnectionList().end(); ++conn) {
rstl::vector< SConnection >::iterator conn = ConnectionList().begin();
for (; conn != ConnectionList().end(); ++conn) {
if (conn->x0_state != kSS_MaxReached || conn->x4_msg != kSM_Activate) {
continue;
}
@ -291,12 +274,10 @@ void CScriptMazeNode::GenerateObjects(CStateManager& mgr) {
continue;
}
TUniqueId objUid = GenerateObject(mgr, conn->x8_objId);
// TUniqueId objUid = kInvalidUniqueId;
// bool wasGeneratingObject = mgr.IsGeneratingObject();
// mgr.SetIsGeneratingObject(true);
// TUniqueId objUid = mgr.GenerateObject(conn->x8_objId).second;
// mgr.SetIsGeneratingObject(wasGeneratingObject);
bool wasGeneratingObject = mgr.IsGeneratingObject();
mgr.SetIsGeneratingObject(true);
TUniqueId objUid = mgr.GenerateObject(conn->x8_objId).second;
mgr.SetIsGeneratingObject(wasGeneratingObject);
if (CActor* actor = static_cast< CActor* >(mgr.ObjectById(objUid))) {
mgr.SendScriptMsg(actor, GetUniqueId(), kSM_Activate);
@ -379,7 +360,6 @@ void CScriptMazeNode::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C
continue;
}
// TUniqueId genObj = GenerateObject(mgr, conn->x8_objId);
bool wasGeneratingObject = mgr.IsGeneratingObject();
mgr.SetIsGeneratingObject(true);
TUniqueId genObj = mgr.GenerateObject(conn->x8_objId).second;