Implement/Match JukeboxEntity

This commit is contained in:
Nathan 2024-02-13 19:48:13 -05:00
parent eb3b339454
commit 7805840b23
4 changed files with 122 additions and 7 deletions

View File

@ -25,8 +25,16 @@ class JukeBoxEntity : public LegoEntity {
return !strcmp(p_name, JukeBoxEntity::ClassName()) || LegoEntity::IsA(p_name);
}
void StartAction();
void StopAction(MxU32 p_state);
inline MxBool IsBackgroundAudioEnabled() { return m_enableBGA; }
// SYNTHETIC: LEGO1 0x10085db0
// JukeBoxEntity::`scalar deleting destructor'
protected:
MxBool m_enableBGA; // 0x68
};
#endif // JUKEBOXENTITY_H

View File

@ -22,8 +22,16 @@ class JukeBoxState : public LegoState {
MxBool VTable0x14() override; // vtable+0x14
inline MxU32 IsActive() { return m_active; }
inline void SetActive(MxBool p_active) { m_active = p_active; }
inline MxU32 GetState() { return m_state; }
// SYNTHETIC: LEGO1 0x1000f3d0
// JukeBoxState::`scalar deleting destructor'
protected:
MxU32 m_state; // 0x8
MxU32 m_active; // 0xc
};
#endif // JUKEBOXSTATE_H

View File

@ -107,12 +107,14 @@ class LegoGameState {
inline Act GetLoadedAct() { return m_loadedAct; }
inline Area GetCurrentArea() { return m_currentArea; }
inline Area GetPreviousArea() { return m_previousArea; }
inline MxU32 GetUnknown0x41c() { return m_unk0x41c; }
inline Area GetUnknown0x42c() { return m_unk0x42c; }
inline void SetDirty(MxBool p_dirty) { m_isDirty = p_dirty; }
inline void SetCurrentArea(Area p_currentArea) { m_currentArea = p_currentArea; }
inline void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; }
inline void SetUnknown0x0c(MxU8 p_unk0x0c) { m_unk0x0c = p_unk0x0c; }
inline void SetUnknown0x41c(undefined4 p_unk0x41c) { m_unk0x41c = p_unk0x41c; }
inline void SetUnknown0x42c(Area p_unk0x42c) { m_unk0x42c = p_unk0x42c; }
void SetCurrentAct(Act p_currentAct);
@ -147,7 +149,8 @@ class LegoGameState {
MxU16 m_unk0x24; // 0x24
undefined m_unk0x28[128]; // 0x28
ScoreStruct m_unk0xa6; // 0xa6
undefined m_unk0x41a[8]; // 0x41a - might be part of the structure at 0xa6
undefined m_unk0x41a[2]; // 0x41a - might be part of the structure at 0xa6
undefined4 m_unk0x41c; // 0x41c
MxBool m_isDirty; // 0x420
Area m_currentArea; // 0x424
Area m_previousArea; // 0x428

View File

@ -1,20 +1,116 @@
#include "jukeboxentity.h"
// STUB: LEGO1 0x10085bc0
#include "isle.h"
#include "islepathactor.h"
#include "jukeboxstate.h"
#include "legogamestate.h"
#include "legoutil.h"
#include "mxbackgroundaudiomanager.h"
#include "mxnotificationmanager.h"
#include "mxtransitionmanager.h"
// FUNCTION: LEGO1 0x10085bc0
JukeBoxEntity::JukeBoxEntity()
{
// TODO
NotificationManager()->Register(this);
}
// STUB: LEGO1 0x10085dd0
// FUNCTION: LEGO1 0x10085dd0
JukeBoxEntity::~JukeBoxEntity()
{
// TODO
NotificationManager()->Unregister(this);
}
// STUB: LEGO1 0x10085e40
// FUNCTION: LEGO1 0x10085e40
MxLong JukeBoxEntity::Notify(MxParam& p_param)
{
// TODO
if (((MxNotificationParam&) p_param).GetType() == 0xb) {
if (!FUN_1003ef60()) {
return 1;
}
if (CurrentVehicle()->VTable0x60() != GameState()->GetUnknownC()) {
CurrentVehicle()->VTable0xe4();
}
((Isle*) FindWorld(*g_isleScript, 0))->SetUnknown13c(0x35);
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE);
return 1;
}
return 0;
}
// FUNCTION: LEGO1 0x10085ed0
void JukeBoxEntity::StartAction()
{
MxDSAction action;
BackgroundAudioManager()->Stop();
JukeBoxState* jbs = (JukeBoxState*) GameState()->GetState("JukeBoxState");
jbs->SetActive(TRUE);
switch (jbs->GetState()) {
case 0:
InvokeAction(Extra::e_start, *g_isleScript, 0x319, NULL);
GameState()->SetUnknown0x41c(0x37);
break;
case 1:
InvokeAction(Extra::e_start, *g_isleScript, 0x31e, NULL);
GameState()->SetUnknown0x41c(0x38);
break;
case 2:
InvokeAction(Extra::e_start, *g_isleScript, 0x31b, NULL);
GameState()->SetUnknown0x41c(0x39);
break;
case 3:
InvokeAction(Extra::e_start, *g_isleScript, 0x31a, NULL);
GameState()->SetUnknown0x41c(0x3a);
break;
case 4:
InvokeAction(Extra::e_start, *g_isleScript, 0x31f, NULL);
GameState()->SetUnknown0x41c(0x3b);
break;
case 5:
InvokeAction(Extra::e_start, *g_isleScript, 0x31c, NULL);
GameState()->SetUnknown0x41c(0x3c);
break;
}
action.SetAtomId(*g_jukeboxScript);
action.SetObjectId(GameState()->GetUnknown0x41c());
m_enableBGA = BackgroundAudioManager()->GetMusicEnabled();
if (!m_enableBGA) {
BackgroundAudioManager()->Enable(TRUE);
}
BackgroundAudioManager()->PlayMusic(action, 5, 4);
}
// FUNCTION: LEGO1 0x100860f0
void JukeBoxEntity::StopAction(MxU32 p_state)
{
JukeBoxState* jbs = (JukeBoxState*) GameState()->GetState("JukeBoxState");
if (jbs && jbs->IsActive()) {
switch (p_state) {
case 0x37:
jbs->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x319, NULL);
break;
case 0x38:
jbs->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x31e, NULL);
break;
case 0x39:
jbs->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x31b, NULL);
break;
case 0x3a:
jbs->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x31a, NULL);
break;
case 0x3b:
jbs->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x31f, NULL);
break;
case 0x3c:
jbs->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x31c, NULL);
break;
}
BackgroundAudioManager()->Enable(IsBackgroundAudioEnabled());
}
}