2023-06-29 04:10:08 -04:00
|
|
|
#include "hospital.h"
|
|
|
|
|
2024-03-16 17:02:05 -04:00
|
|
|
#include "islepathactor.h"
|
|
|
|
#include "jukebox.h"
|
2024-03-13 11:45:27 -04:00
|
|
|
#include "legocontrolmanager.h"
|
|
|
|
#include "legoinputmanager.h"
|
2024-03-16 17:02:05 -04:00
|
|
|
#include "legoomni.h"
|
2024-03-13 11:45:27 -04:00
|
|
|
#include "legoutils.h"
|
|
|
|
#include "misc.h"
|
2024-03-16 17:02:05 -04:00
|
|
|
#include "mxbackgroundaudiomanager.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "mxmisc.h"
|
2024-01-01 22:30:50 -05:00
|
|
|
#include "mxnotificationmanager.h"
|
2024-03-13 15:10:53 -04:00
|
|
|
#include "mxticklemanager.h"
|
2024-03-15 19:16:43 -04:00
|
|
|
#include "mxtimer.h"
|
2024-01-01 22:30:50 -05:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(Hospital, 0x12c)
|
|
|
|
|
2024-03-13 15:10:53 -04:00
|
|
|
// GLOBAL: LEGO1 0x100f7918
|
|
|
|
undefined4 g_unk0x100f7918 = 3;
|
|
|
|
|
2024-03-15 19:16:43 -04:00
|
|
|
// GLOBAL: LEGO1 0x100f791c
|
|
|
|
undefined g_unk0x100f791c = 0;
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f7920
|
|
|
|
undefined g_unk0x100f7920 = 0;
|
|
|
|
|
2024-01-01 22:30:50 -05:00
|
|
|
// FUNCTION: LEGO1 0x100745e0
|
2023-06-29 04:10:08 -04:00
|
|
|
Hospital::Hospital()
|
|
|
|
{
|
2024-03-16 17:02:05 -04:00
|
|
|
m_currentActorId = 0;
|
2024-03-13 11:45:27 -04:00
|
|
|
m_unk0x100 = 0;
|
|
|
|
m_hospitalState = NULL;
|
|
|
|
m_unk0x108 = 0;
|
2024-03-13 13:17:20 -04:00
|
|
|
m_destLocation = LegoGameState::e_undefined;
|
2024-03-16 17:02:05 -04:00
|
|
|
m_unk0x10c = HospitalScript::c__StartUp;
|
|
|
|
m_copLedBitmap = NULL;
|
|
|
|
m_pizzaLedBitmap = NULL;
|
2024-03-13 11:45:27 -04:00
|
|
|
m_unk0x118 = 0;
|
|
|
|
m_unk0x11c = 0;
|
|
|
|
m_unk0x120 = 0;
|
|
|
|
m_unk0x128 = 0;
|
2024-01-01 22:30:50 -05:00
|
|
|
NotificationManager()->Register(this);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2024-02-07 06:13:20 -05:00
|
|
|
// FUNCTION: LEGO1 0x100746a0
|
2024-01-20 18:04:46 -05:00
|
|
|
MxBool Hospital::VTable0x5c()
|
|
|
|
{
|
2024-02-07 06:13:20 -05:00
|
|
|
return TRUE;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-03-13 15:10:53 -04:00
|
|
|
// FUNCTION: LEGO1 0x100747f0
|
2023-06-29 04:10:08 -04:00
|
|
|
Hospital::~Hospital()
|
|
|
|
{
|
2024-03-13 15:10:53 -04:00
|
|
|
InputManager()->UnRegister(this);
|
|
|
|
if (InputManager()->GetWorld() == this) {
|
|
|
|
InputManager()->ClearWorld();
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlManager()->Unregister(this);
|
|
|
|
TickleManager()->UnregisterClient(this);
|
|
|
|
|
|
|
|
m_hospitalState->m_unk0x08.m_unk0x00 = 3;
|
|
|
|
|
|
|
|
NotificationManager()->Unregister(this);
|
|
|
|
g_unk0x100f7918 = 3;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2024-03-13 11:45:27 -04:00
|
|
|
// FUNCTION: LEGO1 0x100748c0
|
2024-01-20 18:04:46 -05:00
|
|
|
MxResult Hospital::Create(MxDSAction& p_dsAction)
|
|
|
|
{
|
2024-03-13 11:45:27 -04:00
|
|
|
MxResult result = LegoWorld::Create(p_dsAction);
|
|
|
|
if (result == SUCCESS) {
|
|
|
|
InputManager()->SetWorld(this);
|
|
|
|
ControlManager()->Register(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetIsWorldActive(FALSE);
|
|
|
|
|
|
|
|
m_hospitalState = (HospitalState*) GameState()->GetState("HospitalState");
|
|
|
|
if (!m_hospitalState) {
|
|
|
|
m_hospitalState = (HospitalState*) GameState()->CreateState("HospitalState");
|
|
|
|
m_hospitalState->m_unk0x08.m_unk0x00 = 1;
|
|
|
|
}
|
|
|
|
else if (m_hospitalState->m_unk0x08.m_unk0x00 == 4) {
|
|
|
|
m_hospitalState->m_unk0x08.m_unk0x00 = 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_hospitalState->m_unk0x08.m_unk0x00 = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
GameState()->SetCurrentArea(LegoGameState::e_hospital);
|
|
|
|
GameState()->StopArea(LegoGameState::e_previousArea);
|
|
|
|
|
|
|
|
InputManager()->Register(this);
|
|
|
|
FUN_1003ef00(FALSE);
|
|
|
|
|
|
|
|
return result;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-03-13 16:32:20 -04:00
|
|
|
// FUNCTION: LEGO1 0x10074990
|
2023-12-13 05:48:14 -05:00
|
|
|
MxLong Hospital::Notify(MxParam& p_param)
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2024-03-13 16:32:20 -04:00
|
|
|
MxResult result = SUCCESS;
|
|
|
|
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:
|
|
|
|
if (m_destLocation != LegoGameState::e_undefined) {
|
|
|
|
GameState()->SwitchArea(m_destLocation);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-06-29 04:10:08 -04:00
|
|
|
|
2024-03-13 16:32:20 -04:00
|
|
|
return result;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
|
2024-03-16 17:02:05 -04:00
|
|
|
// FUNCTION: LEGO1 0x10074a60
|
2024-01-27 15:18:35 -05:00
|
|
|
void Hospital::ReadyWorld()
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-03-16 17:02:05 -04:00
|
|
|
PlayMusic(JukeboxScript::c_Hospital_Music);
|
|
|
|
|
|
|
|
m_copLedBitmap = (MxStillPresenter*) Find("MxStillPresenter", "CopLed_Bitmap");
|
|
|
|
m_pizzaLedBitmap = (MxStillPresenter*) Find("MxStillPresenter", "PizzaLed_Bitmap");
|
|
|
|
|
|
|
|
if (CurrentActor() == NULL) {
|
|
|
|
m_currentActorId = 5;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_currentActorId = CurrentActor()->GetActorId();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (m_currentActorId) {
|
|
|
|
case 1:
|
|
|
|
m_hospitalState->m_unk0x0c = m_hospitalState->m_unk0x0e;
|
|
|
|
|
|
|
|
if (m_hospitalState->m_unk0x0e < 5) {
|
|
|
|
m_hospitalState->m_unk0x0e += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
m_hospitalState->m_unk0x0c = m_hospitalState->m_unk0x10;
|
|
|
|
|
|
|
|
if (m_hospitalState->m_unk0x10 < 5) {
|
|
|
|
m_hospitalState->m_unk0x10 += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
m_hospitalState->m_unk0x0c = m_hospitalState->m_unk0x12;
|
|
|
|
|
|
|
|
if (m_hospitalState->m_unk0x12 < 5) {
|
|
|
|
m_hospitalState->m_unk0x12 += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
m_hospitalState->m_unk0x0c = m_hospitalState->m_unk0x14;
|
|
|
|
|
|
|
|
if (m_hospitalState->m_unk0x14 < 5) {
|
|
|
|
m_hospitalState->m_unk0x14 += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
m_hospitalState->m_unk0x0c = m_hospitalState->m_unk0x16;
|
|
|
|
|
|
|
|
if (m_hospitalState->m_unk0x16 < 5) {
|
|
|
|
m_hospitalState->m_unk0x16 += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_hospitalState->m_unk0x0c < 3) {
|
|
|
|
HospitalScript::Script hospitalScript[] = {
|
|
|
|
HospitalScript::c_hho002cl_RunAnim,
|
|
|
|
HospitalScript::c_hho004jk_RunAnim,
|
|
|
|
HospitalScript::c_hho007p1_RunAnim
|
|
|
|
};
|
|
|
|
|
|
|
|
m_hospitalState->m_unk0x08.m_unk0x00 = 5;
|
|
|
|
|
|
|
|
PlayAction(hospitalScript[m_hospitalState->m_unk0x0c]);
|
|
|
|
m_unk0x10c = hospitalScript[m_hospitalState->m_unk0x0c];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_unk0x100 = 1;
|
|
|
|
m_unk0x124 = Timer()->GetTime();
|
|
|
|
|
|
|
|
m_hospitalState->m_unk0x08.m_unk0x00 = 6;
|
|
|
|
|
|
|
|
PlayAction(HospitalScript::c_hho003cl_RunAnim);
|
|
|
|
m_unk0x10c = HospitalScript::c_hho003cl_RunAnim;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_unk0x108 = 1;
|
|
|
|
|
|
|
|
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-03-13 16:32:20 -04:00
|
|
|
// STUB: LEGO1 0x10074dd0
|
|
|
|
MxLong Hospital::HandleKeyPress(MxS8 p_key)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x10074e00
|
|
|
|
MxLong Hospital::HandleEndAction(MxEndActionNotificationParam& p_param)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x10075710
|
|
|
|
MxLong Hospital::HandleButtonDown(LegoControlManagerEvent& p_param)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x10075f90
|
|
|
|
MxBool Hospital::HandleClick(LegoControlManagerEvent& p_param)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
|
|
|
// TODO
|
2024-03-13 16:32:20 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10076220
|
|
|
|
void Hospital::Enable(MxBool p_enable)
|
|
|
|
{
|
|
|
|
LegoWorld::Enable(p_enable);
|
|
|
|
|
|
|
|
if (p_enable) {
|
|
|
|
InputManager()->SetWorld(this);
|
|
|
|
SetIsWorldActive(FALSE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (InputManager()->GetWorld() == this) {
|
|
|
|
InputManager()->ClearWorld();
|
|
|
|
}
|
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-03-16 17:02:05 -04:00
|
|
|
inline void Hospital::PlayAction(MxU32 p_objectId)
|
|
|
|
{
|
|
|
|
MxDSAction action;
|
|
|
|
action.SetAtomId(*g_hospitalScript);
|
|
|
|
action.SetObjectId(p_objectId);
|
|
|
|
|
|
|
|
BackgroundAudioManager()->LowerVolume();
|
|
|
|
Start(&action);
|
|
|
|
}
|
|
|
|
|
2024-03-15 19:16:43 -04:00
|
|
|
// FUNCTION: LEGO1 0x10076270
|
2024-01-20 18:04:46 -05:00
|
|
|
MxResult Hospital::Tickle()
|
|
|
|
{
|
2024-03-15 19:16:43 -04:00
|
|
|
if (!m_worldStarted) {
|
|
|
|
LegoWorld::Tickle();
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_unk0x100f7918 != 0) {
|
|
|
|
g_unk0x100f7918 -= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
MxLong time = Timer()->GetTime();
|
|
|
|
|
|
|
|
if (m_unk0x118 != 0) {
|
|
|
|
if (time - m_unk0x11c > 300) {
|
|
|
|
m_unk0x11c = time;
|
|
|
|
g_unk0x100f791c = !g_unk0x100f791c;
|
2024-03-16 17:02:05 -04:00
|
|
|
m_copLedBitmap->Enable(g_unk0x100f791c);
|
2024-03-15 19:16:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (time - m_unk0x120 > 200) {
|
|
|
|
m_unk0x120 = time;
|
|
|
|
g_unk0x100f7920 = !g_unk0x100f7920;
|
2024-03-16 17:02:05 -04:00
|
|
|
m_pizzaLedBitmap->Enable(g_unk0x100f7920);
|
2024-03-15 19:16:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-20 18:04:46 -05:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2024-03-13 16:32:20 -04:00
|
|
|
// FUNCTION: LEGO1 0x10076330
|
2024-01-20 18:04:46 -05:00
|
|
|
MxBool Hospital::VTable0x64()
|
|
|
|
{
|
2024-03-13 16:32:20 -04:00
|
|
|
DeleteObjects(&m_atom, HospitalScript::c_hho002cl_RunAnim, 999);
|
|
|
|
m_hospitalState->m_unk0x08.m_unk0x00 = 0;
|
|
|
|
|
|
|
|
m_destLocation = LegoGameState::e_infomain;
|
|
|
|
|
|
|
|
return TRUE;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|