mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-03-14 00:39:50 -04:00
PoliceState: Create script enum + implement FUN_1005ea40 (#564)
* PoliceState: Create script enum + implement FUN_1005ea40 * Clean up code * Match * Match * Fix type * Fix error * Remove return --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
parent
8aa9d9a8b3
commit
91643d59ba
5 changed files with 59 additions and 10 deletions
|
@ -5,14 +5,20 @@
|
|||
#include "legogamestate.h"
|
||||
#include "legoworld.h"
|
||||
#include "mxdsaction.h"
|
||||
#include "policestate.h"
|
||||
#include "radio.h"
|
||||
|
||||
class PoliceState;
|
||||
|
||||
// VTABLE: LEGO1 0x100d8a80
|
||||
// SIZE 0x110
|
||||
// Radio at 0xf8
|
||||
class Police : public LegoWorld {
|
||||
public:
|
||||
enum PoliceScript {
|
||||
c_nickAnim = 500,
|
||||
c_lauraAnim = 501,
|
||||
};
|
||||
|
||||
Police();
|
||||
~Police() override; // vtable+0x00
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "decomp.h"
|
||||
#include "legostate.h"
|
||||
#include "police.h"
|
||||
|
||||
// VTABLE: LEGO1 0x100d8af0
|
||||
// SIZE 0x10
|
||||
|
@ -32,9 +33,11 @@ public:
|
|||
inline undefined4 GetUnknown0x0c() { return m_unk0x0c; }
|
||||
inline void SetUnknown0x0c(undefined4 p_unk0x0c) { m_unk0x0c = p_unk0x0c; }
|
||||
|
||||
void FUN_1005ea40();
|
||||
|
||||
private:
|
||||
undefined4 m_unk0x08; // 0x08
|
||||
undefined4 m_unk0x0c; // 0x0c
|
||||
Police::PoliceScript m_policeScript; // 0x08
|
||||
undefined4 m_unk0x0c; // 0x0c
|
||||
};
|
||||
|
||||
#endif // POLICESTATE_H
|
||||
|
|
|
@ -103,7 +103,6 @@ void GasStation::Enable(MxBool p_enable)
|
|||
if (p_enable) {
|
||||
InputManager()->SetWorld(this);
|
||||
InputManager()->SetCamera(NULL);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (InputManager()->GetWorld() == this) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "legoinputmanager.h"
|
||||
#include "legoomni.h"
|
||||
#include "mxnotificationmanager.h"
|
||||
#include "policestate.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(Police, 0x110)
|
||||
|
||||
|
@ -123,7 +124,7 @@ MxLong Police::HandleKeyPress(LegoEventNotificationParam& p_param)
|
|||
MxLong result = 0;
|
||||
|
||||
if (p_param.GetKey() == ' ' && m_policeState->GetUnknown0x0c() == 1) {
|
||||
DeleteObjects(&m_atom, 500, 501);
|
||||
DeleteObjects(&m_atom, c_nickAnim, c_lauraAnim);
|
||||
m_policeState->SetUnknown0x0c(0);
|
||||
return 1;
|
||||
}
|
||||
|
@ -150,7 +151,7 @@ void Police::Enable(MxBool p_enable)
|
|||
// FUNCTION: LEGO1 0x1005e790
|
||||
MxBool Police::VTable0x64()
|
||||
{
|
||||
DeleteObjects(&m_atom, 500, 510);
|
||||
DeleteObjects(&m_atom, c_nickAnim, 510);
|
||||
m_transitionDestination = LegoGameState::e_infomain;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#include "policestate.h"
|
||||
|
||||
#include "islepathactor.h"
|
||||
#include "legoomni.h"
|
||||
#include "mxdsaction.h"
|
||||
#include "mxomni.h"
|
||||
#include "police.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(PoliceState, 0x10)
|
||||
|
@ -8,7 +14,7 @@ DECOMP_SIZE_ASSERT(PoliceState, 0x10)
|
|||
PoliceState::PoliceState()
|
||||
{
|
||||
m_unk0x0c = 0;
|
||||
m_unk0x08 = (rand() % 2 == 0) ? 501 : 500;
|
||||
m_policeScript = (rand() % 2 == 0) ? Police::PoliceScript::c_lauraAnim : Police::PoliceScript::c_nickAnim;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1005e990
|
||||
|
@ -19,12 +25,46 @@ MxResult PoliceState::VTable0x1c(LegoFile* p_legoFile)
|
|||
}
|
||||
|
||||
if (p_legoFile->IsReadMode()) {
|
||||
p_legoFile->Read(&m_unk0x08, sizeof(m_unk0x08));
|
||||
p_legoFile->Read(&m_policeScript, sizeof(m_policeScript));
|
||||
}
|
||||
else {
|
||||
undefined4 unk0x08 = m_unk0x08;
|
||||
p_legoFile->Write(&unk0x08, sizeof(m_unk0x08));
|
||||
Police::PoliceScript policeScript = m_policeScript;
|
||||
p_legoFile->Write(&policeScript, sizeof(m_policeScript));
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1005ea40
|
||||
void PoliceState::FUN_1005ea40()
|
||||
{
|
||||
Police::PoliceScript policeScript;
|
||||
|
||||
if (m_unk0x0c == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (CurrentVehicle()->VTable0x60()) {
|
||||
case 4:
|
||||
policeScript = Police::PoliceScript::c_lauraAnim;
|
||||
m_policeScript = policeScript;
|
||||
break;
|
||||
case 5:
|
||||
policeScript = Police::PoliceScript::c_nickAnim;
|
||||
m_policeScript = policeScript;
|
||||
break;
|
||||
default:
|
||||
policeScript = m_policeScript;
|
||||
m_policeScript = policeScript == Police::PoliceScript::c_lauraAnim ? Police::PoliceScript::c_nickAnim
|
||||
: Police::PoliceScript::c_lauraAnim;
|
||||
}
|
||||
|
||||
{
|
||||
MxDSAction action;
|
||||
action.SetObjectId(policeScript);
|
||||
action.SetAtomId(*g_policeScript);
|
||||
Start(&action);
|
||||
}
|
||||
|
||||
m_unk0x0c = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue