2023-06-29 04:10:08 -04:00
|
|
|
#include "jukeboxentity.h"
|
|
|
|
|
2024-02-14 11:48:39 -05:00
|
|
|
#include "isle.h"
|
2024-03-18 15:00:58 -04:00
|
|
|
#include "isle_actions.h"
|
2024-02-14 11:48:39 -05:00
|
|
|
#include "islepathactor.h"
|
2024-03-18 15:00:58 -04:00
|
|
|
#include "jukebox_actions.h"
|
2024-02-14 11:48:39 -05:00
|
|
|
#include "jukeboxstate.h"
|
|
|
|
#include "legogamestate.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "legoutils.h"
|
|
|
|
#include "misc.h"
|
2024-02-14 11:48:39 -05:00
|
|
|
#include "mxbackgroundaudiomanager.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "mxmisc.h"
|
2024-02-14 11:48:39 -05:00
|
|
|
#include "mxnotificationmanager.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "mxnotificationparam.h"
|
2024-02-14 11:48:39 -05:00
|
|
|
#include "mxtransitionmanager.h"
|
2024-05-04 08:06:32 -04:00
|
|
|
#include "scripts.h"
|
2024-02-14 11:48:39 -05:00
|
|
|
|
2024-03-22 21:30:58 -04:00
|
|
|
DECOMP_SIZE_ASSERT(JukeBoxEntity, 0x6c)
|
|
|
|
|
2024-02-14 11:48:39 -05:00
|
|
|
// FUNCTION: LEGO1 0x10085bc0
|
2023-06-29 04:10:08 -04:00
|
|
|
JukeBoxEntity::JukeBoxEntity()
|
|
|
|
{
|
2024-02-14 11:48:39 -05:00
|
|
|
NotificationManager()->Register(this);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2024-02-14 11:48:39 -05:00
|
|
|
// FUNCTION: LEGO1 0x10085dd0
|
2023-06-29 04:10:08 -04:00
|
|
|
JukeBoxEntity::~JukeBoxEntity()
|
|
|
|
{
|
2024-02-14 11:48:39 -05:00
|
|
|
NotificationManager()->Unregister(this);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
|
2024-02-14 11:48:39 -05:00
|
|
|
// FUNCTION: LEGO1 0x10085e40
|
2024-01-20 18:04:46 -05:00
|
|
|
MxLong JukeBoxEntity::Notify(MxParam& p_param)
|
|
|
|
{
|
2024-02-14 11:48:39 -05:00
|
|
|
if (((MxNotificationParam&) p_param).GetType() == c_notificationType11) {
|
|
|
|
if (!FUN_1003ef60()) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-02-26 11:19:16 -05:00
|
|
|
if (CurrentActor()->GetActorId() != GameState()->GetActorId()) {
|
|
|
|
CurrentActor()->VTable0xe4();
|
2024-02-14 11:48:39 -05:00
|
|
|
}
|
|
|
|
|
2024-03-17 13:01:47 -04:00
|
|
|
((Isle*) FindWorld(*g_isleScript, 0))->SetDestLocation(LegoGameState::e_jukeboxw);
|
2024-03-11 04:57:58 -04:00
|
|
|
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
|
2024-02-14 11:48:39 -05:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-01-20 18:04:46 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2024-02-14 11:48:39 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10085ed0
|
|
|
|
void JukeBoxEntity::StartAction()
|
|
|
|
{
|
|
|
|
MxDSAction action;
|
|
|
|
BackgroundAudioManager()->Stop();
|
|
|
|
JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState");
|
|
|
|
state->SetActive(TRUE);
|
|
|
|
|
|
|
|
switch (state->GetState()) {
|
|
|
|
case 0:
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz001bd_RunAnim, NULL);
|
|
|
|
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic1);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
|
|
|
case 1:
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz006bd_RunAnim, NULL);
|
|
|
|
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic2);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
|
|
|
case 2:
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz003bd_RunAnim, NULL);
|
|
|
|
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic3);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
|
|
|
case 3:
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz002bd_RunAnim, NULL);
|
|
|
|
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic4);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
|
|
|
case 4:
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz007bd_RunAnim, NULL);
|
|
|
|
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic5);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
|
|
|
case 5:
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz004bd_RunAnim, NULL);
|
|
|
|
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic6);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
action.SetAtomId(*g_jukeboxScript);
|
|
|
|
action.SetObjectId(GameState()->GetUnknown0x41c());
|
|
|
|
|
|
|
|
m_audioEnabled = BackgroundAudioManager()->GetEnabled();
|
|
|
|
if (!m_audioEnabled) {
|
|
|
|
BackgroundAudioManager()->Enable(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
BackgroundAudioManager()->PlayMusic(action, 5, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100860f0
|
2024-03-18 15:00:58 -04:00
|
|
|
void JukeBoxEntity::StopAction(JukeboxScript::Script p_script)
|
2024-02-14 11:48:39 -05:00
|
|
|
{
|
|
|
|
JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState");
|
|
|
|
|
|
|
|
if (state && state->IsActive()) {
|
2024-03-18 15:00:58 -04:00
|
|
|
switch (p_script) {
|
|
|
|
case JukeboxScript::c_JBMusic1:
|
2024-02-14 11:48:39 -05:00
|
|
|
state->SetActive(FALSE);
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz001bd_RunAnim, NULL);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
2024-03-18 15:00:58 -04:00
|
|
|
case JukeboxScript::c_JBMusic2:
|
2024-02-14 11:48:39 -05:00
|
|
|
state->SetActive(FALSE);
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz006bd_RunAnim, NULL);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
2024-03-18 15:00:58 -04:00
|
|
|
case JukeboxScript::c_JBMusic3:
|
2024-02-14 11:48:39 -05:00
|
|
|
state->SetActive(FALSE);
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz003bd_RunAnim, NULL);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
2024-03-18 15:00:58 -04:00
|
|
|
case JukeboxScript::c_JBMusic4:
|
2024-02-14 11:48:39 -05:00
|
|
|
state->SetActive(FALSE);
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz002bd_RunAnim, NULL);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
2024-03-18 15:00:58 -04:00
|
|
|
case JukeboxScript::c_JBMusic5:
|
2024-02-14 11:48:39 -05:00
|
|
|
state->SetActive(FALSE);
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz007bd_RunAnim, NULL);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
2024-03-18 15:00:58 -04:00
|
|
|
case JukeboxScript::c_JBMusic6:
|
2024-02-14 11:48:39 -05:00
|
|
|
state->SetActive(FALSE);
|
2024-03-18 15:00:58 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz004bd_RunAnim, NULL);
|
2024-02-14 11:48:39 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
BackgroundAudioManager()->Enable(IsBackgroundAudioEnabled());
|
|
|
|
}
|
|
|
|
}
|