Refactor actor states, define enum (#1220)

* Refactor actor states, define enum

* Revert

* Rename `UpdateState` to `Animate`
This commit is contained in:
Christian Semmler
2024-12-13 12:30:50 -07:00
committed by GitHub
parent ce3f71ea0f
commit 6da2faa48c
44 changed files with 161 additions and 153 deletions

View File

@@ -48,19 +48,17 @@ MxS32 LegoRaceActor::VTable0x68(Vector3& p_v1, Vector3& p_v2, Vector3& p_v3)
MxU32 LegoRaceActor::VTable0x90(float p_time, Matrix4& p_transform)
{
// Note: Code duplication with LegoExtraActor::VTable0x90
switch (m_actorFlags) {
case 0:
case 1:
return 1;
case 2:
switch (m_actorState) {
case c_initial:
case c_one:
return TRUE;
case c_two:
m_unk0x08 = p_time + 2000.0f;
m_actorFlags = 3;
m_actorState = c_three;
m_actorTime += (p_time - m_lastTime) * m_worldSpeed;
m_lastTime = p_time;
return 0;
case 3:
return FALSE;
case c_three:
assert(!m_userNavFlag);
Vector3 positionRef(p_transform[3]);
@@ -78,19 +76,19 @@ MxU32 LegoRaceActor::VTable0x90(float p_time, Matrix4& p_transform)
m_lastTime = p_time;
VTable0x74(p_transform);
return 0;
return FALSE;
}
else {
m_actorFlags = 0;
m_actorState = c_initial;
m_unk0x08 = 0;
positionRef -= g_unk0x10102b08;
m_roi->FUN_100a58f0(p_transform);
return 1;
return TRUE;
}
}
return 0;
return FALSE;
}
// FUNCTION: LEGO1 0x10014a00
@@ -98,7 +96,7 @@ MxU32 LegoRaceActor::VTable0x90(float p_time, Matrix4& p_transform)
MxResult LegoRaceActor::HitActor(LegoPathActor* p_actor, MxBool p_bool)
{
if (!p_actor->GetUserNavFlag()) {
if (p_actor->GetActorFlags()) {
if (p_actor->GetActorState() != c_initial) {
return FAILURE;
}
@@ -112,7 +110,7 @@ MxResult LegoRaceActor::HitActor(LegoPathActor* p_actor, MxBool p_bool)
roi->FUN_100a58f0(matr);
p_actor->SetActorFlags(2);
p_actor->SetActorState(c_two);
}
}

View File

@@ -377,14 +377,14 @@ MxU32 LegoRaceCar::HandleSkeletonKicks(float p_param1)
// FUNCTION: LEGO1 0x100131f0
// FUNCTION: BETA10 0x100cb88a
void LegoRaceCar::UpdateState(float p_time)
void LegoRaceCar::Animate(float p_time)
{
if (m_userNavFlag && (m_userState == LEGORACECAR_KICK1 || m_userState == LEGORACECAR_KICK2)) {
FUN_10012ff0(p_time);
return;
}
LegoCarRaceActor::UpdateState(p_time);
LegoCarRaceActor::Animate(p_time);
if (m_userNavFlag && m_userState == LEGORACECAR_UNKNOWN_1) {
if (HandleSkeletonKicks(p_time)) {
@@ -438,7 +438,7 @@ MxResult LegoRaceCar::HitActor(LegoPathActor* p_actor, MxBool p_bool)
{
// Note: Code duplication with LegoRaceActor::HitActor
if (!p_actor->GetUserNavFlag()) {
if (p_actor->GetActorFlags()) {
if (p_actor->GetActorState() != c_initial) {
return FAILURE;
}
@@ -451,7 +451,7 @@ MxResult LegoRaceCar::HitActor(LegoPathActor* p_actor, MxBool p_bool)
Vector3(matr[3]) += g_unk0x10102af0;
roi->FUN_100a58f0(matr);
p_actor->SetActorFlags(2);
p_actor->SetActorState(c_two);
}
if (m_userNavFlag) {
@@ -587,9 +587,9 @@ void LegoJetski::FUN_100136f0(float p_worldSpeed)
// FUNCTION: LEGO1 0x10013740
// FUNCTION: BETA10 0x100cc0ae
void LegoJetski::UpdateState(float p_time)
void LegoJetski::Animate(float p_time)
{
LegoJetskiRaceActor::UpdateState(p_time);
LegoJetskiRaceActor::Animate(p_time);
if (LegoCarRaceActor::m_unk0x0c == 1) {
FUN_1005d4b0();

View File

@@ -113,7 +113,7 @@ MxS32 LegoCarRaceActor::VTable0x1c(LegoPathBoundary* p_boundary, LegoEdge* p_edg
Mx3DPointFloat destEdgeUnknownVector;
Mx3DPointFloat crossProduct;
if (m_actorFlags == 1) {
if (m_actorState == c_one) {
m_boundary = NULL;
// Not sure where the upper bound of 11 comes from, the underlying array has a size of 16
@@ -126,7 +126,7 @@ MxS32 LegoCarRaceActor::VTable0x1c(LegoPathBoundary* p_boundary, LegoEdge* p_edg
assert(m_boundary);
m_actorFlags = 0;
m_actorState = c_initial;
m_unk0x7c = 0;
if (m_userNavFlag) {
@@ -140,7 +140,7 @@ MxS32 LegoCarRaceActor::VTable0x1c(LegoPathBoundary* p_boundary, LegoEdge* p_edg
else {
for (MxS32 i = 0; i < 11; i += 2) {
if (LegoPathController::GetControlEdgeA(i) == p_edge) {
m_actorFlags = 1;
m_actorState = c_one;
if (m_worldSpeed < g_unk0x100f7aec) {
m_worldSpeed = g_unk0x100f7aec;
@@ -152,7 +152,7 @@ MxS32 LegoCarRaceActor::VTable0x1c(LegoPathBoundary* p_boundary, LegoEdge* p_edg
}
}
if (m_actorFlags == 1) {
if (m_actorState == c_one) {
if (m_userNavFlag) {
m_unk0xe4 = 0.5f;
}
@@ -214,7 +214,7 @@ void LegoCarRaceActor::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown
// FUNCTION: LEGO1 0x10080b70
// FUNCTION: BETA10 0x100cdbae
void LegoCarRaceActor::UpdateState(float p_time)
void LegoCarRaceActor::Animate(float p_time)
{
// m_unk0x0c is not an MxBool, there are places where it is set to 2 or higher
if (m_unk0x0c == 0) {
@@ -228,7 +228,7 @@ void LegoCarRaceActor::UpdateState(float p_time)
}
if (m_unk0x0c == 1) {
LegoAnimActor::UpdateState(p_time);
LegoAnimActor::Animate(p_time);
}
}