Implement/match remaining GasStation functions (#1129)

* Implement/match remaining GasStation functions

* Name variables
This commit is contained in:
Christian Semmler 2024-11-03 08:44:07 -07:00 committed by GitHub
parent 4c95d7c887
commit 519d8c570a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 80 additions and 62 deletions

View file

@ -38,19 +38,19 @@ class GasStationState : public LegoState {
// SYNTHETIC: LEGO1 0x10006290
// GasStationState::`scalar deleting destructor'
void FUN_10006430(GarageScript::Script);
void FUN_10006460(GarageScript::Script);
void FUN_10006490();
void PlayAction(GarageScript::Script p_objectId);
void StopAction(GarageScript::Script p_objectId);
void StopActions();
// TODO: Most likely getters/setters are not used according to BETA.
undefined4 m_unk0x08[3]; // 0x08
Unknown0x14 m_unk0x14; // 0x14
MxS16 m_unk0x18; // 0x18
MxS16 m_unk0x1a; // 0x1a
MxS16 m_unk0x1c; // 0x1c
MxS16 m_unk0x1e; // 0x1e
MxS16 m_unk0x20; // 0x20
GarageScript::Script m_actions[3]; // 0x08
Unknown0x14 m_unk0x14; // 0x14
MxS16 m_pepperAction; // 0x18
MxS16 m_mamaAction; // 0x1a
MxS16 m_papaAction; // 0x1c
MxS16 m_nickAction; // 0x1e
MxS16 m_lauraAction; // 0x20
};
// VTABLE: LEGO1 0x100d4650

View file

@ -138,7 +138,7 @@ void GasStation::ReadyWorld()
switch (m_currentActorId) {
case LegoActor::c_pepper:
switch (m_state->m_unk0x18) {
switch (m_state->m_pepperAction) {
case 0:
m_state->m_unk0x14.m_unk0x00 = 5;
PlayAction(GarageScript::c_wgs002nu_RunAnim);
@ -162,14 +162,14 @@ void GasStation::ReadyWorld()
break;
}
if (m_state->m_unk0x18 < 5) {
m_state->m_unk0x18++;
if (m_state->m_pepperAction < 5) {
m_state->m_pepperAction++;
}
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
break;
case LegoActor::c_mama:
switch (m_state->m_unk0x1a) {
switch (m_state->m_mamaAction) {
case 0:
m_state->m_unk0x14.m_unk0x00 = 5;
PlayAction(GarageScript::c_wgs006nu_RunAnim);
@ -188,14 +188,14 @@ void GasStation::ReadyWorld()
break;
}
if (m_state->m_unk0x1a < 5) {
m_state->m_unk0x1a++;
if (m_state->m_mamaAction < 5) {
m_state->m_mamaAction++;
}
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
break;
case LegoActor::c_papa:
switch (m_state->m_unk0x1c) {
switch (m_state->m_papaAction) {
case 0:
m_state->m_unk0x14.m_unk0x00 = 5;
PlayAction(GarageScript::c_wgs012nu_RunAnim);
@ -214,14 +214,14 @@ void GasStation::ReadyWorld()
break;
}
if (m_state->m_unk0x1c < 5) {
m_state->m_unk0x1c++;
if (m_state->m_papaAction < 5) {
m_state->m_papaAction++;
}
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
break;
case LegoActor::c_nick:
switch (m_state->m_unk0x1e) {
switch (m_state->m_nickAction) {
case 0:
m_state->m_unk0x14.m_unk0x00 = 5;
PlayAction(GarageScript::c_wgs009nu_RunAnim);
@ -240,14 +240,14 @@ void GasStation::ReadyWorld()
break;
}
if (m_state->m_unk0x1e < 5) {
m_state->m_unk0x1e++;
if (m_state->m_nickAction < 5) {
m_state->m_nickAction++;
}
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
break;
case LegoActor::c_laura:
switch (m_state->m_unk0x20) {
switch (m_state->m_lauraAction) {
case 0:
m_state->m_unk0x14.m_unk0x00 = 5;
PlayAction(GarageScript::c_wgs020nu_RunAnim);
@ -266,8 +266,8 @@ void GasStation::ReadyWorld()
break;
}
if (m_state->m_unk0x20 < 5) {
m_state->m_unk0x20++;
if (m_state->m_lauraAction < 5) {
m_state->m_lauraAction++;
}
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
@ -288,7 +288,7 @@ inline void GasStation::PlayAction(GarageScript::Script p_objectId)
BackgroundAudioManager()->LowerVolume();
Start(&action);
m_state->FUN_10006430(p_objectId);
m_state->PlayAction(p_objectId);
}
// FUNCTION: BETA10 0x10029f00
@ -297,7 +297,7 @@ inline void GasStation::StopAction(GarageScript::Script p_objectId)
if (p_objectId != GarageScript::c_noneGarage) {
InvokeAction(Extra::e_stop, *g_garageScript, p_objectId, NULL);
BackgroundAudioManager()->RaiseVolume();
m_state->FUN_10006460(p_objectId);
m_state->StopAction(p_objectId);
}
}
@ -310,7 +310,7 @@ MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param)
MxDSAction* action = p_param.GetAction();
if (action->GetAtomId() == m_atomId && action->GetObjectId()) {
m_state->FUN_10006460((GarageScript::Script) action->GetObjectId());
m_state->StopAction((GarageScript::Script) action->GetObjectId());
m_unk0x106 = 0;
switch (m_state->m_unk0x14.m_unk0x00) {
@ -357,7 +357,7 @@ MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param)
MxLong GasStation::HandleKeyPress(MxS8 p_key)
{
if (p_key == VK_SPACE && g_unk0x100f0160 == 0 && m_unk0x106 != 0) {
m_state->FUN_10006490();
m_state->StopActions();
return 1;
}
@ -394,6 +394,7 @@ MxLong GasStation::HandleButtonDown(LegoControlManagerNotificationParam& p_param
}
// FUNCTION: LEGO1 0x10005b20
// FUNCTION: BETA10 0x10029445
MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param)
{
if (p_param.GetUnknown0x28() == 1) {
@ -405,7 +406,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param)
m_state->m_unk0x14.m_unk0x00 = 0;
m_destLocation = LegoGameState::Area::e_garadoor;
m_state->FUN_10006490();
m_state->StopActions();
m_radio.Stop();
BackgroundAudioManager()->Stop();
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
@ -414,7 +415,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param)
m_state->m_unk0x14.m_unk0x00 = 0;
m_destLocation = LegoGameState::Area::e_infomain;
m_state->FUN_10006490();
m_state->StopActions();
m_radio.Stop();
BackgroundAudioManager()->Stop();
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
@ -423,7 +424,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param)
m_state->m_unk0x14.m_unk0x00 = 0;
m_destLocation = LegoGameState::Area::e_dunecarbuild;
m_state->FUN_10006490();
m_state->StopActions();
m_radio.Stop();
BackgroundAudioManager()->Stop();
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
@ -435,6 +436,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param)
}
// FUNCTION: LEGO1 0x10005c40
// FUNCTION: BETA10 0x10029551
void GasStation::Enable(MxBool p_enable)
{
LegoWorld::Enable(p_enable);
@ -451,6 +453,7 @@ void GasStation::Enable(MxBool p_enable)
}
// FUNCTION: LEGO1 0x10005c90
// FUNCTION: BETA10 0x100295c6
MxResult GasStation::Tickle()
{
if (!m_worldStarted) {
@ -495,64 +498,79 @@ MxResult GasStation::Tickle()
MxBool GasStation::Escape()
{
m_radio.Stop();
m_state->FUN_10006490();
m_state->StopActions();
m_state->m_unk0x14.m_unk0x00 = 0;
m_destLocation = LegoGameState::Area::e_infomain;
return TRUE;
}
// FUNCTION: LEGO1 0x10005eb0
// FUNCTION: BETA10 0x100296b8
GasStationState::GasStationState()
{
m_unk0x18 = 0;
m_unk0x1a = 0;
m_unk0x1c = 0;
m_unk0x1e = 0;
m_unk0x20 = 0;
undefined4* unk0x08 = m_unk0x08;
unk0x08[0] = -1;
unk0x08[1] = -1;
unk0x08[2] = -1;
m_pepperAction = 0;
m_mamaAction = 0;
m_papaAction = 0;
m_nickAction = 0;
m_lauraAction = 0;
memset(m_actions, GarageScript::c_noneGarage, sizeof(m_actions));
}
// FUNCTION: LEGO1 0x10006300
// FUNCTION: BETA10 0x10029754
MxResult GasStationState::Serialize(LegoFile* p_file)
{
LegoState::Serialize(p_file);
if (p_file->IsWriteMode()) {
Write(p_file, m_unk0x18);
Write(p_file, m_unk0x1a);
Write(p_file, m_unk0x1c);
Write(p_file, m_unk0x1e);
Write(p_file, m_unk0x20);
Write(p_file, m_pepperAction);
Write(p_file, m_mamaAction);
Write(p_file, m_papaAction);
Write(p_file, m_nickAction);
Write(p_file, m_lauraAction);
}
else if (p_file->IsReadMode()) {
Read(p_file, &m_unk0x18);
Read(p_file, &m_unk0x1a);
Read(p_file, &m_unk0x1c);
Read(p_file, &m_unk0x1e);
Read(p_file, &m_unk0x20);
Read(p_file, &m_pepperAction);
Read(p_file, &m_mamaAction);
Read(p_file, &m_papaAction);
Read(p_file, &m_nickAction);
Read(p_file, &m_lauraAction);
}
return SUCCESS;
}
// STUB: LEGO1 0x10006430
void GasStationState::FUN_10006430(GarageScript::Script)
// FUNCTION: LEGO1 0x10006430
void GasStationState::PlayAction(GarageScript::Script p_objectId)
{
// TODO
for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_actions); i++) {
if (m_actions[i] == GarageScript::c_noneGarage) {
m_actions[i] = p_objectId;
return;
}
}
}
// STUB: LEGO1 0x10006460
void GasStationState::FUN_10006460(GarageScript::Script)
// FUNCTION: LEGO1 0x10006460
void GasStationState::StopAction(GarageScript::Script p_objectId)
{
// TODO
for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_actions); i++) {
if (m_actions[i] == p_objectId) {
m_actions[i] = GarageScript::c_noneGarage;
return;
}
}
}
// STUB: LEGO1 0x10006490
void GasStationState::FUN_10006490()
// FUNCTION: LEGO1 0x10006490
void GasStationState::StopActions()
{
// TODO
for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_actions); i++) {
if (m_actions[i] != GarageScript::c_noneGarage) {
InvokeAction(Extra::e_stop, *g_garageScript, m_actions[i], NULL);
m_actions[i] = GarageScript::c_noneGarage;
}
}
BackgroundAudioManager()->RaiseVolume();
}