2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-08-14 21:38:05 +00:00
|
|
|
|
2020-04-12 19:23:26 +00:00
|
|
|
#include <array>
|
2020-09-20 20:36:24 +00:00
|
|
|
#include <cassert>
|
2019-09-23 19:00:23 +00:00
|
|
|
#include <string_view>
|
|
|
|
|
2020-09-19 17:30:44 +00:00
|
|
|
#include "Runtime/CRandom16.hpp"
|
2019-09-23 19:00:23 +00:00
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/World/CActor.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2016-08-14 21:38:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2020-09-20 20:36:24 +00:00
|
|
|
constexpr s32 skMazeRows = 7;
|
|
|
|
constexpr s32 skMazeColumns = 9;
|
2020-09-19 19:52:15 +00:00
|
|
|
|
2020-09-19 18:52:43 +00:00
|
|
|
struct CScriptMazeStateCell {
|
2020-09-19 17:30:44 +00:00
|
|
|
bool x0_24_ : 1 = false;
|
|
|
|
bool x0_25_ : 1 = false;
|
|
|
|
bool x0_26_ : 1 = false;
|
|
|
|
bool x0_27_ : 1 = false;
|
|
|
|
bool x0_28_ : 1 = false;
|
|
|
|
bool x0_29_ : 1 = false;
|
|
|
|
bool x0_30_ : 1 = false;
|
|
|
|
bool x0_31_ : 1 = false;
|
|
|
|
bool x1_24_ : 1 = false;
|
|
|
|
bool x1_25_ : 1 = false;
|
|
|
|
bool x1_26_ : 1 = false;
|
|
|
|
};
|
2020-09-19 18:52:43 +00:00
|
|
|
|
|
|
|
class CScriptMazeState {
|
2020-09-19 17:30:44 +00:00
|
|
|
CRandom16 x0_rand{0};
|
2020-09-20 20:36:24 +00:00
|
|
|
std::array<CScriptMazeStateCell, skMazeRows * skMazeColumns> x4_cells{};
|
|
|
|
s32 x84_startCol;
|
|
|
|
s32 x88_startRow;
|
|
|
|
s32 x8c_endCol;
|
|
|
|
s32 x90_endRow;
|
2020-09-19 17:30:44 +00:00
|
|
|
bool x94_24_initialized : 1 = false;
|
|
|
|
|
2020-09-19 18:52:43 +00:00
|
|
|
public:
|
2020-09-20 20:36:24 +00:00
|
|
|
CScriptMazeState(s32 w1, s32 w2, s32 w3, s32 w4) : x84_startCol(w1), x88_startRow(w2), x8c_endCol(w3), x90_endRow(w4) {}
|
2020-09-19 18:52:43 +00:00
|
|
|
void Reset(s32 seed);
|
|
|
|
void Initialize();
|
2020-09-19 19:52:15 +00:00
|
|
|
void sub_802899c8();
|
2020-09-20 05:47:12 +00:00
|
|
|
|
2020-09-20 20:36:24 +00:00
|
|
|
[[nodiscard]] CScriptMazeStateCell& GetCell(u32 col, u32 row) {
|
|
|
|
#ifndef NDEBUG
|
|
|
|
assert(col < skMazeColumns);
|
|
|
|
assert(row < skMazeRows);
|
|
|
|
#endif
|
|
|
|
return x4_cells[col + row * skMazeColumns];
|
|
|
|
}
|
|
|
|
[[nodiscard]] CScriptMazeStateCell& GetCell(u32 idx) {
|
|
|
|
#ifndef NDEBUG
|
|
|
|
assert(idx < x4_cells.size());
|
|
|
|
#endif
|
|
|
|
return x4_cells[idx];
|
2020-09-20 05:47:12 +00:00
|
|
|
}
|
2020-09-19 17:30:44 +00:00
|
|
|
};
|
2020-09-19 18:52:43 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CScriptMazeNode : public CActor {
|
2020-09-20 05:47:12 +00:00
|
|
|
s32 xe8_col;
|
|
|
|
s32 xec_row;
|
2018-12-08 05:30:43 +00:00
|
|
|
s32 xf0_;
|
|
|
|
TUniqueId xf4_ = kInvalidUniqueId;
|
2020-09-20 07:25:56 +00:00
|
|
|
float xf8_msgTimer = 1.f;
|
2020-09-19 17:30:44 +00:00
|
|
|
TUniqueId xfc_actorId = kInvalidUniqueId;
|
|
|
|
zeus::CVector3f x100_actorPos;
|
|
|
|
TUniqueId x10c_triggerId = kInvalidUniqueId;
|
|
|
|
zeus::CVector3f x110_triggerPos;
|
|
|
|
TUniqueId x11c_effectId = kInvalidUniqueId;
|
|
|
|
zeus::CVector3f x120_effectPos;
|
|
|
|
std::vector<TUniqueId> x12c_;
|
2020-09-20 07:25:56 +00:00
|
|
|
bool x13c_24_ : 1 = false;
|
2020-04-20 04:57:50 +00:00
|
|
|
bool x13c_25_ : 1 = false;
|
2020-09-20 07:25:56 +00:00
|
|
|
bool x13c_26_ : 1 = true;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2016-08-14 21:38:05 +00:00
|
|
|
public:
|
2020-09-20 07:25:56 +00:00
|
|
|
CScriptMazeNode(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
|
|
|
bool active, s32 w1, s32 w2, s32 w3, const zeus::CVector3f& actorPos,
|
|
|
|
const zeus::CVector3f& triggerPos, const zeus::CVector3f& effectPos);
|
2016-08-14 21:38:05 +00:00
|
|
|
|
2019-08-09 12:45:18 +00:00
|
|
|
void Accept(IVisitor& visitor) override;
|
2020-09-19 18:52:43 +00:00
|
|
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
|
2020-09-20 05:47:12 +00:00
|
|
|
void Think(float dt, CStateManager& mgr) override;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static void LoadMazeSeeds();
|
2020-09-19 17:30:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void GenerateObjects(CStateManager& mgr);
|
2020-09-19 17:44:32 +00:00
|
|
|
void Reset(CStateManager& mgr);
|
2020-09-20 05:47:12 +00:00
|
|
|
void SendScriptMsgs(CStateManager& mgr, EScriptObjectMessage msg);
|
2016-08-14 21:38:05 +00:00
|
|
|
};
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|