2022-09-13 04:26:54 +00:00
|
|
|
#ifndef _CSCRIPTMAZENODE_HPP
|
|
|
|
#define _CSCRIPTMAZENODE_HPP
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
#include "MetroidPrime/CActor.hpp"
|
|
|
|
|
2022-09-14 05:24:12 +00:00
|
|
|
#include "Kyoto/CRandom16.hpp"
|
|
|
|
#include "Kyoto/Math/CVector3f.hpp"
|
|
|
|
|
|
|
|
#include "rstl/vector.hpp"
|
|
|
|
|
|
|
|
#define skMazeCols 9
|
|
|
|
#define skMazeRows 7
|
|
|
|
#define skEnterCol 4
|
|
|
|
#define skEnterRow 4
|
|
|
|
#define skTargetCol 5
|
|
|
|
#define skTargetRow 3
|
|
|
|
|
|
|
|
#define NUM_MAZE_CELLS (skMazeRows * skMazeCols)
|
|
|
|
|
|
|
|
struct SMazeCell {
|
|
|
|
bool x0_24_openTop : 1;
|
|
|
|
bool x0_25_openRight : 1;
|
|
|
|
bool x0_26_openBottom : 1;
|
|
|
|
bool x0_27_openLeft : 1;
|
|
|
|
bool x0_28_gateTop : 1;
|
|
|
|
bool x0_29_gateRight : 1;
|
|
|
|
bool x0_30_gateBottom : 1;
|
|
|
|
bool x0_31_gateLeft : 1;
|
|
|
|
bool x1_24_puddle : 1;
|
|
|
|
bool x1_25_onPath : 1;
|
|
|
|
bool x1_26_checked : 1;
|
|
|
|
|
|
|
|
SMazeCell() {
|
2022-09-18 06:05:46 +00:00
|
|
|
x0_24_openTop = x0_25_openRight = x0_26_openBottom = x0_27_openLeft = x0_28_gateTop =
|
|
|
|
x0_29_gateRight = x0_30_gateBottom = x0_31_gateLeft = x1_24_puddle = x1_25_onPath =
|
|
|
|
x1_26_checked = false;
|
2022-09-14 05:24:12 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 06:05:46 +00:00
|
|
|
inline bool IsClosed() const {
|
|
|
|
return !x0_24_openTop && !x0_25_openRight && !x0_26_openBottom && !x0_27_openLeft;
|
|
|
|
}
|
2022-09-14 05:24:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CMazeState {
|
|
|
|
CRandom16 x0_rand;
|
|
|
|
SMazeCell x4_cells[skMazeRows * skMazeCols];
|
|
|
|
int x84_enterCol;
|
|
|
|
int x88_enterRow;
|
|
|
|
int x8c_targetCol;
|
|
|
|
int x90_targetRow;
|
|
|
|
bool x94_24_initialized : 1;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum ESide {
|
|
|
|
kS_Invalid = -1,
|
|
|
|
kS_Top = 0,
|
|
|
|
kS_Right = 1,
|
|
|
|
kS_Bottom = 2,
|
|
|
|
kS_Left = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
CMazeState(int enterCol, int enterRow, int targetCol, int targetRow);
|
|
|
|
void Reset(int seed);
|
|
|
|
void Initialize();
|
|
|
|
void GenerateObstacles();
|
|
|
|
|
|
|
|
SMazeCell& GetCell(uint col, uint row);
|
2022-09-18 05:55:13 +00:00
|
|
|
const SMazeCell& GetCell(uint col, uint row) const;
|
2022-09-14 05:24:12 +00:00
|
|
|
SMazeCell& GetCellInline(uint col, uint row) { return x4_cells[col + row * skMazeCols]; } // ????
|
|
|
|
inline SMazeCell& GetCell(uint idx) { return x4_cells[idx]; }
|
|
|
|
};
|
|
|
|
|
2022-09-13 04:26:54 +00:00
|
|
|
class CScriptMazeNode : public CActor {
|
|
|
|
public:
|
2022-09-18 06:05:46 +00:00
|
|
|
CScriptMazeNode(TUniqueId uid, const rstl::string& name, const CEntityInfo& info,
|
|
|
|
const CTransform4f& xf, bool active, int col, int row, int side,
|
|
|
|
const CVector3f& actorPos, const CVector3f& triggerPos,
|
|
|
|
const CVector3f& effectPos);
|
2022-09-14 05:24:12 +00:00
|
|
|
~CScriptMazeNode() override;
|
|
|
|
|
|
|
|
void Accept(IVisitor& visitor) override;
|
|
|
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
|
2022-09-18 05:55:13 +00:00
|
|
|
void Think(f32 dt, CStateManager& mgr) override;
|
2022-09-14 05:24:12 +00:00
|
|
|
|
2022-09-13 04:26:54 +00:00
|
|
|
static void LoadMazeSeeds();
|
2022-09-14 05:24:12 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum ESide {
|
|
|
|
Invalid = -1,
|
|
|
|
Top = 0,
|
|
|
|
Right = 1,
|
|
|
|
Bottom = 2,
|
|
|
|
Left = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
int xe8_col;
|
|
|
|
int xec_row;
|
|
|
|
ESide xf0_side;
|
|
|
|
TUniqueId xf4_gateEffectId;
|
2022-09-18 05:55:13 +00:00
|
|
|
f32 xf8_msgTimer;
|
2022-09-14 05:24:12 +00:00
|
|
|
TUniqueId xfc_actorId;
|
|
|
|
CVector3f x100_actorPos;
|
|
|
|
TUniqueId x10c_triggerId;
|
|
|
|
CVector3f x110_triggerPos;
|
|
|
|
TUniqueId x11c_effectId;
|
|
|
|
CVector3f x120_effectPos;
|
|
|
|
rstl::vector< TUniqueId > x12c_puddleObjectIds;
|
|
|
|
bool x13c_24_hasPuddle : 1;
|
|
|
|
bool x13c_25_hasGate : 1;
|
|
|
|
bool x13c_26_gateActive : 1;
|
|
|
|
|
|
|
|
void GenerateObjects(CStateManager& mgr);
|
|
|
|
void Reset(CStateManager& mgr);
|
|
|
|
void SendScriptMsgs(CStateManager& mgr, EScriptObjectMessage msg);
|
|
|
|
|
|
|
|
static uint sMazeSeeds[300];
|
2022-09-13 04:26:54 +00:00
|
|
|
};
|
|
|
|
|
2022-09-16 04:30:20 +00:00
|
|
|
#endif
|