2023-06-29 04:10:08 -04:00
|
|
|
#include "gasstation.h"
|
|
|
|
|
2024-04-06 07:48:09 -04:00
|
|
|
#include "garage_actions.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "gasstationstate.h"
|
2024-04-06 07:48:09 -04:00
|
|
|
#include "islepathactor.h"
|
|
|
|
#include "jukebox.h"
|
|
|
|
#include "jukebox_actions.h"
|
2024-02-13 18:40:04 -05:00
|
|
|
#include "legocontrolmanager.h"
|
|
|
|
#include "legogamestate.h"
|
|
|
|
#include "legoinputmanager.h"
|
2024-05-04 08:06:32 -04:00
|
|
|
#include "legomain.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "misc.h"
|
2024-04-06 07:48:09 -04:00
|
|
|
#include "mxbackgroundaudiomanager.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "mxmisc.h"
|
2024-01-17 12:24:42 -05:00
|
|
|
#include "mxnotificationmanager.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "mxstillpresenter.h"
|
2024-02-13 18:40:04 -05:00
|
|
|
#include "mxticklemanager.h"
|
2024-04-06 13:07:57 -04:00
|
|
|
#include "mxtimer.h"
|
|
|
|
#include "mxtransitionmanager.h"
|
|
|
|
#include "radio.h"
|
2024-05-04 08:06:32 -04:00
|
|
|
#include "scripts.h"
|
2024-02-13 18:40:04 -05:00
|
|
|
|
2024-03-22 21:30:58 -04:00
|
|
|
DECOMP_SIZE_ASSERT(GasStation, 0x128)
|
|
|
|
|
2024-02-13 18:40:04 -05:00
|
|
|
// GLOBAL: LEGO1 0x100f0160
|
2024-03-05 03:45:09 -05:00
|
|
|
undefined4 g_unk0x100f0160 = 3;
|
2024-01-17 12:24:42 -05:00
|
|
|
|
2024-04-06 13:07:57 -04:00
|
|
|
// GLOBAL: LEGO1 0x100f0164
|
|
|
|
MxBool g_trackLedEnabled = FALSE;
|
|
|
|
|
2024-01-17 12:24:42 -05:00
|
|
|
// FUNCTION: LEGO1 0x100046a0
|
2023-06-29 04:10:08 -04:00
|
|
|
GasStation::GasStation()
|
|
|
|
{
|
2024-04-06 07:48:09 -04:00
|
|
|
m_currentActorId = 0;
|
2024-02-13 18:40:04 -05:00
|
|
|
m_state = NULL;
|
2024-03-13 13:17:20 -04:00
|
|
|
m_destLocation = LegoGameState::e_undefined;
|
2024-04-06 07:48:09 -04:00
|
|
|
m_trackLedBitmap = NULL;
|
2024-02-04 10:36:47 -05:00
|
|
|
m_unk0x104 = 0;
|
2024-04-06 13:07:57 -04:00
|
|
|
m_unk0x114 = FALSE;
|
2024-02-04 10:36:47 -05:00
|
|
|
m_unk0x106 = 0;
|
|
|
|
m_unk0x10c = 0;
|
2024-04-06 13:07:57 -04:00
|
|
|
m_unk0x115 = FALSE;
|
|
|
|
m_trackLedTimer = 0;
|
2024-01-17 12:24:42 -05:00
|
|
|
|
|
|
|
NotificationManager()->Register(this);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2024-02-07 06:13:20 -05:00
|
|
|
// FUNCTION: LEGO1 0x10004770
|
2024-01-20 18:04:46 -05:00
|
|
|
MxBool GasStation::VTable0x5c()
|
|
|
|
{
|
2024-02-07 06:13:20 -05:00
|
|
|
return TRUE;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-02-13 18:40:04 -05:00
|
|
|
// FUNCTION: LEGO1 0x100048c0
|
2023-06-29 04:10:08 -04:00
|
|
|
GasStation::~GasStation()
|
|
|
|
{
|
2024-02-13 18:40:04 -05:00
|
|
|
InputManager()->UnRegister(this);
|
|
|
|
if (InputManager()->GetWorld() == this) {
|
|
|
|
InputManager()->ClearWorld();
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlManager()->Unregister(this);
|
|
|
|
TickleManager()->UnregisterClient(this);
|
|
|
|
NotificationManager()->Unregister(this);
|
|
|
|
g_unk0x100f0160 = 3;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2024-02-13 18:40:04 -05:00
|
|
|
// FUNCTION: LEGO1 0x10004990
|
2024-01-20 18:04:46 -05:00
|
|
|
MxResult GasStation::Create(MxDSAction& p_dsAction)
|
|
|
|
{
|
2024-02-13 18:40:04 -05:00
|
|
|
MxResult result = LegoWorld::Create(p_dsAction);
|
|
|
|
if (result == SUCCESS) {
|
|
|
|
InputManager()->SetWorld(this);
|
|
|
|
ControlManager()->Register(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
InputManager()->SetCamera(NULL);
|
|
|
|
|
|
|
|
m_state = (GasStationState*) GameState()->GetState("GasStationState");
|
|
|
|
if (!m_state) {
|
|
|
|
m_state = (GasStationState*) GameState()->CreateState("GasStationState");
|
2024-03-13 11:38:38 -04:00
|
|
|
m_state->m_unk0x14.m_unk0x00 = 1;
|
|
|
|
}
|
|
|
|
else if (m_state->m_unk0x14.m_unk0x00 == 4) {
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 4;
|
2024-02-13 18:40:04 -05:00
|
|
|
}
|
|
|
|
else {
|
2024-03-13 11:38:38 -04:00
|
|
|
m_state->m_unk0x14.m_unk0x00 = 3;
|
2024-02-13 18:40:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
GameState()->SetCurrentArea(LegoGameState::e_garage);
|
|
|
|
GameState()->StopArea(LegoGameState::e_previousArea);
|
|
|
|
|
|
|
|
InputManager()->Register(this);
|
|
|
|
SetIsWorldActive(FALSE);
|
|
|
|
return result;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-02-17 12:23:09 -05:00
|
|
|
// FUNCTION: LEGO1 0x10004a60
|
2023-12-13 05:48:14 -05:00
|
|
|
MxLong GasStation::Notify(MxParam& p_param)
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2024-02-17 12:23:09 -05:00
|
|
|
MxResult result = 0;
|
|
|
|
LegoWorld::Notify(p_param);
|
|
|
|
|
|
|
|
if (m_worldStarted) {
|
|
|
|
switch (((MxNotificationParam&) p_param).GetNotification()) {
|
|
|
|
case c_notificationEndAction:
|
|
|
|
result = HandleEndAction((MxEndActionNotificationParam&) p_param);
|
|
|
|
break;
|
|
|
|
case c_notificationKeyPress:
|
|
|
|
result = HandleKeyPress((((LegoEventNotificationParam&) p_param)).GetKey());
|
|
|
|
break;
|
|
|
|
case c_notificationButtonDown:
|
|
|
|
result = HandleButtonDown(((LegoControlManagerEvent&) p_param));
|
|
|
|
break;
|
|
|
|
case c_notificationClick:
|
|
|
|
result = HandleClick((LegoControlManagerEvent&) p_param);
|
|
|
|
break;
|
|
|
|
case c_notificationTransitioned:
|
2024-03-13 13:17:20 -04:00
|
|
|
GameState()->SwitchArea(m_destLocation);
|
2024-02-17 12:23:09 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-06-29 04:10:08 -04:00
|
|
|
|
2024-02-17 12:23:09 -05:00
|
|
|
return result;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2024-04-06 07:48:09 -04:00
|
|
|
// FUNCTION: LEGO1 0x10004b30
|
2024-01-27 15:18:35 -05:00
|
|
|
void GasStation::ReadyWorld()
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-04-06 07:48:09 -04:00
|
|
|
PlayMusic(JukeboxScript::c_JBMusic2);
|
|
|
|
|
|
|
|
m_trackLedBitmap = (MxStillPresenter*) Find("MxStillPresenter", "TrackLed_Bitmap");
|
|
|
|
m_currentActorId = CurrentActor()->GetActorId();
|
|
|
|
|
|
|
|
switch (m_currentActorId) {
|
|
|
|
case 1:
|
|
|
|
switch (m_state->m_unk0x18) {
|
|
|
|
case 0:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs002nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs003nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs004nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 6;
|
|
|
|
PlayAction(GarageScript::c_wgs008nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
m_unk0x104 = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_state->m_unk0x18 < 5) {
|
|
|
|
m_state->m_unk0x18++;
|
|
|
|
}
|
|
|
|
|
|
|
|
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
switch (m_state->m_unk0x1a) {
|
|
|
|
case 0:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs006nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs007nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 6;
|
|
|
|
PlayAction(GarageScript::c_wgs008nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
m_unk0x104 = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_state->m_unk0x1a < 5) {
|
|
|
|
m_state->m_unk0x1a++;
|
|
|
|
}
|
|
|
|
|
|
|
|
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
switch (m_state->m_unk0x1c) {
|
|
|
|
case 0:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs012nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs014nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 6;
|
|
|
|
PlayAction(GarageScript::c_wgs017nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
m_unk0x104 = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_state->m_unk0x1c < 5) {
|
|
|
|
m_state->m_unk0x1c++;
|
|
|
|
}
|
|
|
|
|
|
|
|
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
switch (m_state->m_unk0x1e) {
|
|
|
|
case 0:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs009nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs010nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 6;
|
|
|
|
PlayAction(GarageScript::c_wgs008nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
m_unk0x104 = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_state->m_unk0x1e < 5) {
|
|
|
|
m_state->m_unk0x1e++;
|
|
|
|
}
|
|
|
|
|
|
|
|
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
switch (m_state->m_unk0x20) {
|
|
|
|
case 0:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs020nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 5;
|
|
|
|
PlayAction(GarageScript::c_wgs021nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 6;
|
|
|
|
PlayAction(GarageScript::c_wgs022nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
m_unk0x104 = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_state->m_unk0x20 < 5) {
|
|
|
|
m_state->m_unk0x20++;
|
|
|
|
}
|
|
|
|
|
|
|
|
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10005590
|
|
|
|
inline void GasStation::PlayAction(MxU32 p_objectId)
|
|
|
|
{
|
|
|
|
MxDSAction action;
|
|
|
|
action.SetAtomId(*g_garageScript);
|
|
|
|
action.SetObjectId(p_objectId);
|
|
|
|
|
|
|
|
BackgroundAudioManager()->LowerVolume();
|
|
|
|
Start(&action);
|
|
|
|
m_state->FUN_10006430(p_objectId);
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-02-17 12:23:09 -05:00
|
|
|
// STUB: LEGO1 0x10005660
|
|
|
|
MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-04-06 13:07:57 -04:00
|
|
|
// FUNCTION: LEGO1 0x10005920
|
2024-02-17 12:23:09 -05:00
|
|
|
MxLong GasStation::HandleKeyPress(MxS8 p_key)
|
|
|
|
{
|
2024-04-06 13:07:57 -04:00
|
|
|
if (p_key == ' ' && g_unk0x100f0160 == 0 && this->m_unk0x106 != 0) {
|
|
|
|
m_state->FUN_10006490();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-02-17 12:23:09 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x10005960
|
|
|
|
MxLong GasStation::HandleButtonDown(LegoControlManagerEvent& p_param)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-04-06 13:07:57 -04:00
|
|
|
// FUNCTION: LEGO1 0x10005b20
|
2024-02-17 12:23:09 -05:00
|
|
|
MxLong GasStation::HandleClick(LegoControlManagerEvent& p_param)
|
|
|
|
{
|
2024-04-06 13:07:57 -04:00
|
|
|
if (p_param.GetUnknown0x28() == 1) {
|
|
|
|
MxDSAction action;
|
|
|
|
|
|
|
|
switch (p_param.GetClickedObjectId()) {
|
|
|
|
case GarageScript::c_LeftArrow_Ctl:
|
|
|
|
case GarageScript::c_RightArrow_Ctl:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 0;
|
|
|
|
m_destLocation = LegoGameState::Area::e_garadoor;
|
|
|
|
|
|
|
|
m_state->FUN_10006490();
|
|
|
|
m_radio.Stop();
|
|
|
|
BackgroundAudioManager()->Stop();
|
|
|
|
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
|
|
|
|
break;
|
|
|
|
case GarageScript::c_Info_Ctl:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 0;
|
|
|
|
m_destLocation = LegoGameState::Area::e_infomain;
|
|
|
|
|
|
|
|
m_state->FUN_10006490();
|
|
|
|
m_radio.Stop();
|
|
|
|
BackgroundAudioManager()->Stop();
|
|
|
|
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
|
|
|
|
break;
|
|
|
|
case GarageScript::c_Buggy_Ctl:
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 0;
|
|
|
|
m_destLocation = LegoGameState::Area::e_dunecarbuild;
|
|
|
|
|
|
|
|
m_state->FUN_10006490();
|
|
|
|
m_radio.Stop();
|
|
|
|
BackgroundAudioManager()->Stop();
|
|
|
|
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2024-02-17 12:23:09 -05:00
|
|
|
}
|
|
|
|
|
2024-02-13 18:40:04 -05:00
|
|
|
// FUNCTION: LEGO1 0x10005c40
|
2024-02-02 12:18:46 -05:00
|
|
|
void GasStation::Enable(MxBool p_enable)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-02-13 18:40:04 -05:00
|
|
|
LegoWorld::Enable(p_enable);
|
|
|
|
|
|
|
|
if (p_enable) {
|
|
|
|
InputManager()->SetWorld(this);
|
|
|
|
InputManager()->SetCamera(NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (InputManager()->GetWorld() == this) {
|
|
|
|
InputManager()->ClearWorld();
|
|
|
|
}
|
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-04-06 13:07:57 -04:00
|
|
|
// FUNCTION: LEGO1 0x10005c90
|
2023-09-21 14:51:24 -04:00
|
|
|
MxResult GasStation::Tickle()
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2024-04-06 13:07:57 -04:00
|
|
|
if (!m_worldStarted) {
|
|
|
|
LegoWorld::Tickle();
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_unk0x100f0160 != 0) {
|
|
|
|
g_unk0x100f0160--;
|
|
|
|
}
|
|
|
|
|
|
|
|
MxLong time = Timer()->GetTime();
|
|
|
|
|
|
|
|
if (m_unk0x114) {
|
|
|
|
if (time - m_unk0x10c > 15000) {
|
|
|
|
m_unk0x10c = time;
|
|
|
|
if (m_unk0x104 == 1) {
|
|
|
|
m_unk0x104 = 2;
|
|
|
|
}
|
|
|
|
else if (m_unk0x104 != 0) {
|
|
|
|
m_unk0x104 = 0;
|
|
|
|
MxDSAction action;
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 9;
|
|
|
|
PlayAction(GarageScript::c_wgs031nu_RunAnim);
|
|
|
|
m_unk0x106 = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_unk0x115) {
|
|
|
|
if (time - m_trackLedTimer > 300) {
|
|
|
|
m_trackLedTimer = time;
|
|
|
|
g_trackLedEnabled = !g_trackLedEnabled;
|
|
|
|
m_trackLedBitmap->Enable(g_trackLedEnabled);
|
|
|
|
}
|
|
|
|
}
|
2023-06-29 04:10:08 -04:00
|
|
|
|
2024-02-17 12:23:09 -05:00
|
|
|
return SUCCESS;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
|
2024-04-06 13:07:57 -04:00
|
|
|
// FUNCTION: LEGO1 0x10005e70
|
2024-05-24 20:41:57 -04:00
|
|
|
MxBool GasStation::Escape()
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-04-06 13:07:57 -04:00
|
|
|
m_radio.Stop();
|
|
|
|
m_state->FUN_10006490();
|
|
|
|
m_state->m_unk0x14.m_unk0x00 = 0;
|
|
|
|
m_destLocation = LegoGameState::Area::e_infomain;
|
|
|
|
return TRUE;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|