mirror of https://github.com/PrimeDecomp/prime.git
parent
f4731daebe
commit
e5dd64ab55
|
@ -252,6 +252,7 @@ public:
|
||||||
|
|
||||||
const CTransform4f& GetTransform() const { return x34_transform; }
|
const CTransform4f& GetTransform() const { return x34_transform; }
|
||||||
CVector3f GetTranslation() const { return x34_transform.GetTranslation(); }
|
CVector3f GetTranslation() const { return x34_transform.GetTranslation(); }
|
||||||
|
void SetTranslation(const CVector3f& vec);
|
||||||
|
|
||||||
/// ????
|
/// ????
|
||||||
bool NullModel() const { return !GetAnimationData() && !GetModelData()->HasNormalModel(); }
|
bool NullModel() const { return !GetAnimationData() && !GetModelData()->HasNormalModel(); }
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
TUniqueId GetUniqueId() const { return x8_uid; }
|
TUniqueId GetUniqueId() const { return x8_uid; }
|
||||||
TAreaId GetAreaId() const;
|
TAreaId GetAreaId() const;
|
||||||
bool GetActive() const { return x30_24_active; }
|
bool GetActive() const { return x30_24_active; }
|
||||||
|
const rstl::vector<SConnection>& GetConnectionList() const { return x20_conns; }
|
||||||
|
|
||||||
static rstl::vector<SConnection> NullConnectionList;
|
static rstl::vector<SConnection> NullConnectionList;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "rstl/auto_ptr.hpp"
|
#include "rstl/auto_ptr.hpp"
|
||||||
#include "rstl/list.hpp"
|
#include "rstl/list.hpp"
|
||||||
|
#include "rstl/pair.hpp"
|
||||||
#include "rstl/rc_ptr.hpp"
|
#include "rstl/rc_ptr.hpp"
|
||||||
#include "rstl/reserved_vector.hpp"
|
#include "rstl/reserved_vector.hpp"
|
||||||
#include "rstl/single_ptr.hpp"
|
#include "rstl/single_ptr.hpp"
|
||||||
|
@ -42,8 +43,11 @@ public:
|
||||||
bool AddDrawableActor(const CActor& actor, const CVector3f& pos, const CAABox& bounds) const;
|
bool AddDrawableActor(const CActor& actor, const CVector3f& pos, const CAABox& bounds) const;
|
||||||
void SetupParticleHook(const CActor& actor) const;
|
void SetupParticleHook(const CActor& actor) const;
|
||||||
void FreeScriptObject(TUniqueId uid);
|
void FreeScriptObject(TUniqueId uid);
|
||||||
|
rstl::pair< TEditorId, TUniqueId > GenerateObject(const TEditorId& eid);
|
||||||
|
|
||||||
CEntity* ObjectById(TUniqueId uid);
|
CEntity* ObjectById(TUniqueId uid);
|
||||||
|
const CEntity* GetObjectById(TUniqueId uid) const;
|
||||||
|
TUniqueId GetIdForScript(TEditorId eid) const;
|
||||||
|
|
||||||
CCameraManager* CameraManager() { return x870_cameraManager; }
|
CCameraManager* CameraManager() { return x870_cameraManager; }
|
||||||
const CCameraManager* GetCameraManager() const { return x870_cameraManager; }
|
const CCameraManager* GetCameraManager() const { return x870_cameraManager; }
|
||||||
|
@ -57,6 +61,9 @@ public:
|
||||||
f32 GetThermalColdScale1() const { return xf24_thermColdScale1; }
|
f32 GetThermalColdScale1() const { return xf24_thermColdScale1; }
|
||||||
f32 GetThermalColdScale2() const { return xf28_thermColdScale2; }
|
f32 GetThermalColdScale2() const { return xf28_thermColdScale2; }
|
||||||
|
|
||||||
|
bool IsGeneratingObject() const { return xf94_26_generatingObject; }
|
||||||
|
void SetIsGeneratingObject(bool gen) { xf94_26_generatingObject = gen; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u16 x0_nextFreeIndex;
|
u16 x0_nextFreeIndex;
|
||||||
rstl::reserved_vector< u16, 1024 > x8_objectIndexArray;
|
rstl::reserved_vector< u16, 1024 > x8_objectIndexArray;
|
||||||
|
@ -83,6 +90,14 @@ private:
|
||||||
u8 pad2[0x658];
|
u8 pad2[0x658];
|
||||||
f32 xf24_thermColdScale1;
|
f32 xf24_thermColdScale1;
|
||||||
f32 xf28_thermColdScale2;
|
f32 xf28_thermColdScale2;
|
||||||
|
u8 pad3[0x6c];
|
||||||
|
bool xf94_24_readyToRender : 1;
|
||||||
|
bool xf94_25_quitGame : 1;
|
||||||
|
bool xf94_26_generatingObject : 1;
|
||||||
|
bool xf94_27_inMapScreen : 1;
|
||||||
|
bool xf94_28_inSaveUI : 1;
|
||||||
|
bool xf94_29_cinematicPause : 1;
|
||||||
|
bool xf94_30_fullThreat : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -81,6 +81,10 @@ public:
|
||||||
|
|
||||||
static void LoadMazeSeeds();
|
static void LoadMazeSeeds();
|
||||||
|
|
||||||
|
inline void SendScriptMsg(CStateManager& mgr, CEntity* to, EScriptObjectMessage msg) {
|
||||||
|
mgr.SendScriptMsg(to, GetUniqueId(), msg);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum ESide {
|
enum ESide {
|
||||||
Invalid = -1,
|
Invalid = -1,
|
||||||
|
|
|
@ -87,7 +87,6 @@ static inline int GetRandom(CRandom16& rand, int offset) {
|
||||||
return tmp - ((tmp / 5) * 5) + offset;
|
return tmp - ((tmp / 5) * 5) + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO non-matching
|
|
||||||
void CMazeState::GenerateObstacles() {
|
void CMazeState::GenerateObstacles() {
|
||||||
if (!x94_24_initialized) {
|
if (!x94_24_initialized) {
|
||||||
Initialize();
|
Initialize();
|
||||||
|
@ -99,13 +98,12 @@ void CMazeState::GenerateObstacles() {
|
||||||
int puddle1Idx = GetRandom(x0_rand, 13);
|
int puddle1Idx = GetRandom(x0_rand, 13);
|
||||||
int puddle2Idx = GetRandom(x0_rand, 29);
|
int puddle2Idx = GetRandom(x0_rand, 29);
|
||||||
|
|
||||||
int row = x88_enterRow;
|
|
||||||
int col = x84_enterCol;
|
|
||||||
int prevRow = x88_enterRow;
|
|
||||||
int prevCol = x84_enterCol;
|
int prevCol = x84_enterCol;
|
||||||
|
int prevRow = x88_enterRow;
|
||||||
ESide side = kS_Invalid;
|
ESide side = kS_Invalid;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
int col = prevCol;
|
||||||
|
int row = prevRow;
|
||||||
|
|
||||||
while (col != x8c_targetCol || row != x90_targetRow) {
|
while (col != x8c_targetCol || row != x90_targetRow) {
|
||||||
if (idx == gate1Idx || idx == gate2Idx || idx == gate3Idx) {
|
if (idx == gate1Idx || idx == gate2Idx || idx == gate3Idx) {
|
||||||
|
@ -129,102 +127,102 @@ void CMazeState::GenerateObstacles() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int nextCol = col;
|
int curCol = col;
|
||||||
int nextRow = row;
|
int curRow = row;
|
||||||
if (row > 1 && side != kS_Bottom && GetCellInline(col, row).x0_24_openTop && GetCellInline(col, row - 1).x1_25_onPath) {
|
if (row > 0 && side != kS_Bottom && GetCellInline(col, row).x0_24_openTop && GetCellInline(col, row - 1).x1_25_onPath) {
|
||||||
side = kS_Top;
|
side = kS_Top;
|
||||||
nextRow--;
|
row--;
|
||||||
} else if (row < skMazeRows - 1 && side != kS_Top && GetCellInline(col, row).x0_26_openBottom &&
|
} else if (row < skMazeRows - 1 && side != kS_Top && GetCellInline(col, row).x0_26_openBottom &&
|
||||||
GetCellInline(col, row + 1).x1_25_onPath) {
|
GetCellInline(col, row + 1).x1_25_onPath) {
|
||||||
side = kS_Bottom;
|
side = kS_Bottom;
|
||||||
nextRow++;
|
row++;
|
||||||
} else if (col > 1 && side != kS_Right && GetCellInline(col, row).x0_27_openLeft && GetCellInline(col - 1, row).x1_25_onPath) {
|
} else if (col > 0 && side != kS_Right && GetCellInline(col, row).x0_27_openLeft && GetCellInline(col - 1, row).x1_25_onPath) {
|
||||||
side = kS_Left;
|
side = kS_Left;
|
||||||
nextCol--;
|
col--;
|
||||||
} else if (col < skMazeRows && side != kS_Left && GetCellInline(col, row).x0_25_openRight && GetCellInline(col + 1, row).x1_25_onPath) {
|
} else if (col < skMazeCols - 1 && side != kS_Left && GetCellInline(col, row).x0_25_openRight &&
|
||||||
|
GetCellInline(col + 1, row).x1_25_onPath) {
|
||||||
side = kS_Right;
|
side = kS_Right;
|
||||||
nextCol++;
|
col++;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GetCellInline(c, r) x4_cells[c + r * skMazeCols]
|
||||||
if (idx == puddle1Idx || idx == puddle2Idx) {
|
if (idx == puddle1Idx || idx == puddle2Idx) {
|
||||||
if (col == 0 || row == 0 || col == skMazeCols - 1 || row == skMazeRows - 1) {
|
if (curCol == 0 || curRow == 0 || curCol == skMazeCols - 1 || curRow == skMazeRows - 1) {
|
||||||
if (idx == puddle1Idx) {
|
if (idx == puddle1Idx) {
|
||||||
puddle1Idx++;
|
puddle1Idx++;
|
||||||
} else {
|
} else {
|
||||||
puddle2Idx++;
|
puddle2Idx++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SMazeCell& cell = GetCellInline(col, row);
|
// SMazeCell& cell = GetCellInline(curCol, curRow);
|
||||||
cell.x1_24_puddle = true;
|
GetCellInline(curCol, curRow).x1_24_puddle = true;
|
||||||
switch (side) {
|
switch (side) {
|
||||||
case kS_Top:
|
case kS_Top:
|
||||||
GetCellInline(nextCol, nextRow).x0_26_openBottom = false;
|
GetCellInline(col, row).x0_26_openBottom = false;
|
||||||
cell.x0_24_openTop = false;
|
GetCellInline(curCol, curRow).x0_24_openTop = false;
|
||||||
break;
|
break;
|
||||||
case kS_Right:
|
case kS_Right:
|
||||||
GetCellInline(nextCol, nextRow).x0_27_openLeft = false;
|
GetCellInline(col, row).x0_27_openLeft = false;
|
||||||
cell.x0_25_openRight = false;
|
GetCellInline(curCol, curRow).x0_25_openRight = false;
|
||||||
break;
|
break;
|
||||||
case kS_Bottom:
|
case kS_Bottom:
|
||||||
GetCellInline(nextCol, nextRow).x0_24_openTop = false;
|
GetCellInline(col, row).x0_24_openTop = false;
|
||||||
cell.x0_26_openBottom = false;
|
GetCellInline(curCol, curRow).x0_26_openBottom = false;
|
||||||
break;
|
break;
|
||||||
case kS_Left:
|
case kS_Left:
|
||||||
GetCellInline(nextCol, nextRow).x0_25_openRight = false;
|
GetCellInline(col, row).x0_25_openRight = false;
|
||||||
cell.x0_27_openLeft = false;
|
GetCellInline(curCol, curRow).x0_27_openLeft = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
prevCol = col;
|
prevCol = curCol;
|
||||||
prevRow = row;
|
prevRow = curRow;
|
||||||
col = nextCol;
|
}
|
||||||
row = nextRow;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO non-matching
|
|
||||||
void CMazeState::Initialize() {
|
void CMazeState::Initialize() {
|
||||||
int path[NUM_MAZE_CELLS];
|
int path[NUM_MAZE_CELLS];
|
||||||
|
int pathIdx = 0;
|
||||||
int targetRow = x90_targetRow;
|
int targetRow = x90_targetRow;
|
||||||
int targetCol = x8c_targetCol;
|
int targetCol = x8c_targetCol;
|
||||||
int cellIdx = x84_enterCol + x88_enterRow * skMazeCols;
|
int cellIdx = x84_enterCol + x88_enterRow * skMazeCols;
|
||||||
path[0] = cellIdx;
|
int max = targetCol + targetRow * skMazeCols;
|
||||||
|
|
||||||
|
path[pathIdx++] = cellIdx;
|
||||||
x4_cells[cellIdx].x1_26_checked = true;
|
x4_cells[cellIdx].x1_26_checked = true;
|
||||||
int pathLength = 1;
|
|
||||||
while (cellIdx != targetCol + targetRow * skMazeCols) {
|
while (cellIdx != max) {
|
||||||
if (x4_cells[cellIdx].x0_24_openTop && !x4_cells[cellIdx - skMazeCols].x1_26_checked) {
|
if (x4_cells[cellIdx].x0_24_openTop && !x4_cells[cellIdx - skMazeCols].x1_26_checked) {
|
||||||
path[pathLength] = cellIdx - skMazeCols;
|
path[pathIdx++] = cellIdx - skMazeCols;
|
||||||
pathLength++;
|
|
||||||
}
|
}
|
||||||
if (x4_cells[cellIdx].x0_25_openRight && !x4_cells[cellIdx + 1].x1_26_checked) {
|
if (x4_cells[cellIdx].x0_25_openRight && !x4_cells[cellIdx + 1].x1_26_checked) {
|
||||||
path[pathLength] = cellIdx + 1;
|
path[pathIdx++] = cellIdx + 1;
|
||||||
pathLength++;
|
|
||||||
}
|
}
|
||||||
if (x4_cells[cellIdx].x0_26_openBottom && !x4_cells[cellIdx + skMazeCols].x1_26_checked) {
|
if (x4_cells[cellIdx].x0_26_openBottom && !x4_cells[cellIdx + skMazeCols].x1_26_checked) {
|
||||||
path[pathLength] = cellIdx + skMazeCols;
|
path[pathIdx++] = cellIdx + skMazeCols;
|
||||||
pathLength++;
|
|
||||||
}
|
}
|
||||||
if (x4_cells[cellIdx].x0_27_openLeft && !x4_cells[cellIdx - 1].x1_26_checked) {
|
if (x4_cells[cellIdx].x0_27_openLeft && !x4_cells[cellIdx - 1].x1_26_checked) {
|
||||||
path[pathLength] = cellIdx - 1;
|
path[pathIdx++] = cellIdx - 1;
|
||||||
pathLength++;
|
|
||||||
}
|
}
|
||||||
if (cellIdx == path[pathLength - 1]) {
|
if (cellIdx == path[pathIdx - 1]) {
|
||||||
pathLength--;
|
pathIdx--;
|
||||||
}
|
}
|
||||||
cellIdx = path[pathLength - 1];
|
cellIdx = path[pathIdx - 1];
|
||||||
x4_cells[cellIdx].x1_26_checked = true;
|
x4_cells[cellIdx].x1_26_checked = true;
|
||||||
}
|
}
|
||||||
for (; pathLength != 0; pathLength--) {
|
|
||||||
int idx = path[pathLength];
|
while (pathIdx--) {
|
||||||
if (x4_cells[idx].x1_26_checked) {
|
cellIdx = path[pathIdx];
|
||||||
x4_cells[idx].x1_25_onPath = true;
|
if (x4_cells[cellIdx].x1_26_checked) {
|
||||||
|
x4_cells[cellIdx].x1_25_onPath = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x94_24_initialized = true;
|
x94_24_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,8 +247,49 @@ 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 SConnection& conn) {
|
||||||
|
bool wasGeneratingObject = mgr.IsGeneratingObject();
|
||||||
|
mgr.SetIsGeneratingObject(true);
|
||||||
|
TUniqueId objUid = mgr.GenerateObject(conn.x8_objId).second;
|
||||||
|
mgr.SetIsGeneratingObject(wasGeneratingObject);
|
||||||
|
return objUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO non-matching
|
||||||
|
// https://decomp.me/scratch/IvHBz
|
||||||
void CScriptMazeNode::GenerateObjects(CStateManager& mgr) {
|
void CScriptMazeNode::GenerateObjects(CStateManager& mgr) {
|
||||||
// TODO
|
rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin();
|
||||||
|
for (; conn != GetConnectionList().end(); ++conn) {
|
||||||
|
if (conn->x0_state != kSS_MaxReached || conn->x4_msg != kSM_Activate) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CEntity* ent = mgr.ObjectById(mgr.GetIdForScript(conn->x8_objId));
|
||||||
|
CScriptEffect* scriptEffect = TCastToPtr< CScriptEffect >(ent);
|
||||||
|
CScriptActor* scriptActor = TCastToPtr< CScriptActor >(ent);
|
||||||
|
CScriptTrigger* scriptTrigger = TCastToPtr< CScriptTrigger >(ent);
|
||||||
|
if ((scriptEffect || scriptActor || scriptTrigger) && (!scriptEffect || !x13c_25_hasGate)) {
|
||||||
|
// TUniqueId objUid = GenerateObject(mgr, *conn);
|
||||||
|
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);
|
||||||
|
if (scriptEffect) {
|
||||||
|
actor->SetTranslation(GetTranslation() + x120_effectPos);
|
||||||
|
x11c_effectId = objUid;
|
||||||
|
}
|
||||||
|
if (scriptActor) {
|
||||||
|
actor->SetTranslation(GetTranslation() + x100_actorPos);
|
||||||
|
xfc_actorId = objUid;
|
||||||
|
}
|
||||||
|
if (scriptTrigger) {
|
||||||
|
actor->SetTranslation(GetTranslation() + x110_triggerPos);
|
||||||
|
x10c_triggerId = objUid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptMazeNode::Reset(CStateManager& mgr) {
|
void CScriptMazeNode::Reset(CStateManager& mgr) {
|
||||||
|
@ -262,6 +301,7 @@ void CScriptMazeNode::Reset(CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO non-matching
|
// TODO non-matching
|
||||||
|
// https://decomp.me/scratch/3F51I
|
||||||
void CScriptMazeNode::SendScriptMsgs(CStateManager& mgr, EScriptObjectMessage msg) {
|
void CScriptMazeNode::SendScriptMsgs(CStateManager& mgr, EScriptObjectMessage msg) {
|
||||||
mgr.SendScriptMsg(mgr.ObjectById(x11c_effectId), GetUniqueId(), msg);
|
mgr.SendScriptMsg(mgr.ObjectById(x11c_effectId), GetUniqueId(), msg);
|
||||||
mgr.SendScriptMsg(mgr.ObjectById(xfc_actorId), GetUniqueId(), msg);
|
mgr.SendScriptMsg(mgr.ObjectById(xfc_actorId), GetUniqueId(), msg);
|
||||||
|
|
Loading…
Reference in New Issue