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

@@ -71,7 +71,7 @@ void LegoAnimActor::VTable0x74(Matrix4& p_transform)
// FUNCTION: LEGO1 0x1001c290
// FUNCTION: BETA10 0x1003e144
void LegoAnimActor::UpdateState(float p_time)
void LegoAnimActor::Animate(float p_time)
{
assert(m_roi);
@@ -79,7 +79,7 @@ void LegoAnimActor::UpdateState(float p_time)
m_lastTime = p_time - 1.0f;
}
if (m_actorFlags == 0 && !m_userNavFlag && m_worldSpeed <= 0) {
if (m_actorState == c_initial && !m_userNavFlag && m_worldSpeed <= 0) {
if (m_curAnim >= 0) {
MxMatrix matrix(m_unk0xec);
float f;
@@ -90,7 +90,7 @@ void LegoAnimActor::UpdateState(float p_time)
m_lastTime = m_actorTime = p_time;
}
else {
LegoPathActor::UpdateState(p_time);
LegoPathActor::Animate(p_time);
}
}

View File

@@ -50,17 +50,17 @@ LegoExtraActor::~LegoExtraActor()
// FUNCTION: LEGO1 0x1002a720
MxU32 LegoExtraActor::VTable0x90(float p_time, Matrix4& p_transform)
{
switch (m_actorFlags & 0xff) {
case 0:
case 1:
switch (m_actorState & c_maxState) {
case c_initial:
case c_one:
return TRUE;
case 2:
case c_two:
m_scheduledTime = p_time + 2000.0f;
m_actorFlags = 3;
m_actorState = c_three;
m_actorTime += (p_time - m_lastTime) * m_worldSpeed;
m_lastTime = p_time;
return FALSE;
case 3: {
case c_three: {
Vector3 positionRef(p_transform[3]);
p_transform = m_roi->GetLocal2World();
@@ -95,7 +95,7 @@ MxU32 LegoExtraActor::VTable0x90(float p_time, Matrix4& p_transform)
return FALSE;
}
else {
m_actorFlags = 0;
m_actorState = c_initial;
m_scheduledTime = 0.0f;
positionRef -= g_unk0x10104c18;
m_roi->FUN_100a58f0(p_transform);
@@ -192,7 +192,7 @@ inline void LegoExtraActor::FUN_1002ad8a()
// FUNCTION: LEGO1 0x1002aba0
MxResult LegoExtraActor::HitActor(LegoPathActor* p_actor, MxBool p_bool)
{
if (p_actor->GetActorFlags() != 0 || m_actorFlags != 0) {
if (p_actor->GetActorState() != c_initial || m_actorState != c_initial) {
return FAILURE;
}
@@ -237,7 +237,7 @@ MxResult LegoExtraActor::HitActor(LegoPathActor* p_actor, MxBool p_bool)
VTable0xc4();
SetWorldSpeed(0);
m_whichAnim = 1;
m_actorFlags = 0x101;
m_actorState = c_one | c_noCollide;
}
}
@@ -245,7 +245,7 @@ MxResult LegoExtraActor::HitActor(LegoPathActor* p_actor, MxBool p_bool)
LegoROI* roi = m_roi;
SoundManager()->GetCacheSoundManager()->Play("crash5", m_roi->GetName(), FALSE);
VTable0xc4();
m_actorFlags = 0x102;
m_actorState = c_two | c_noCollide;
Mx3DPointFloat dir = p_actor->GetWorldDirection();
MxMatrix matrix3 = MxMatrix(roi->GetLocal2World());
Vector3 positionRef(matrix3[3]);
@@ -328,18 +328,18 @@ void LegoExtraActor::Restart()
}
// FUNCTION: LEGO1 0x1002b440
void LegoExtraActor::UpdateState(float p_time)
void LegoExtraActor::Animate(float p_time)
{
LegoAnimActorStruct* laas = NULL;
switch (m_whichAnim) {
case 0:
LegoAnimActor::UpdateState(p_time);
LegoAnimActor::Animate(p_time);
break;
case 1:
if (m_scheduledTime < p_time) {
m_whichAnim = 2;
m_actorFlags = 0x101;
m_actorState = c_one | c_noCollide;
m_scheduledTime = m_assAnim->GetDuration() + p_time;
break;
}
@@ -350,7 +350,7 @@ void LegoExtraActor::UpdateState(float p_time)
case 2:
if (m_scheduledTime < p_time) {
m_whichAnim = 0;
m_actorFlags = 0;
m_actorState = c_initial;
SetWorldSpeed(m_prevWorldSpeed);
m_roi->FUN_100a58f0(m_unk0x18);
m_lastTime = p_time;
@@ -452,7 +452,7 @@ MxU32 LegoExtraActor::VTable0x6c(
if (plpas.find(*itpa) != plpas.end()) {
LegoPathActor* actor = *itpa;
if (this != actor && !(actor->GetActorFlags() & LegoPathActor::c_noCollide)) {
if (this != actor && !(actor->GetActorState() & LegoPathActor::c_noCollide)) {
LegoROI* roi = actor->GetROI();
if ((roi != NULL && roi->GetVisibility()) || actor->GetCameraFlag()) {

View File

@@ -46,7 +46,7 @@ LegoPathActor::LegoPathActor()
m_lastTime = 0;
m_unk0x7c = 0;
m_userNavFlag = FALSE;
m_actorFlags = 0;
m_actorState = c_initial;
m_grec = NULL;
m_pathController = NULL;
m_collideBox = FALSE;
@@ -235,7 +235,7 @@ MxResult LegoPathActor::VTable0x84(
// FUNCTION: BETA10 0x100b0520
MxS32 LegoPathActor::VTable0x8c(float p_time, Matrix4& p_transform)
{
if (m_userNavFlag && m_actorFlags == 0) {
if (m_userNavFlag && m_actorState == c_initial) {
m_lastTime = p_time;
Mx3DPointFloat p1, p2, p3, p4, p5;
@@ -381,13 +381,13 @@ void LegoPathActor::VTable0x74(Matrix4& p_transform)
// FUNCTION: LEGO1 0x1002e790
// FUNCTION: BETA10 0x100af208
void LegoPathActor::UpdateState(float p_time)
void LegoPathActor::Animate(float p_time)
{
MxMatrix transform;
MxU32 b = FALSE;
while (m_lastTime < p_time) {
if (m_actorFlags != 0 && !VTable0x90(p_time, transform)) {
if (m_actorState != c_initial && !VTable0x90(p_time, transform)) {
return;
}
@@ -458,7 +458,7 @@ MxU32 LegoPathActor::VTable0x6c(
if (plpas.find(*itpa) != plpas.end()) {
LegoPathActor* actor = *itpa;
if (this != actor && !(actor->GetActorFlags() & LegoPathActor::c_noCollide)) {
if (this != actor && !(actor->GetActorState() & LegoPathActor::c_noCollide)) {
LegoROI* roi = actor->GetROI();
if (roi != NULL && (roi->GetVisibility() || actor->GetCameraFlag())) {

View File

@@ -366,8 +366,8 @@ void LegoPathController::FUN_10046970()
LegoPathActor* actor = *itpa;
if (m_actors.find(actor) != m_actors.end()) {
if (!((MxU8) actor->GetActorFlags() & LegoPathActor::c_disable)) {
actor->UpdateState(time);
if (!((MxU8) actor->GetActorState() & LegoPathActor::c_disabled)) {
actor->Animate(time);
}
}
}