Implement/match Ambulance::VTable0x70 (#1027)

This commit is contained in:
Christian Semmler 2024-06-13 11:25:48 -04:00 committed by GitHub
parent cf576ca78f
commit 33c64bb002
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 8 deletions

View file

@ -87,7 +87,7 @@ class Ambulance : public IslePathActor {
MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18
void Destroy(MxBool p_fromDestructor) override; // vtable+0x1c
void VTable0x70(float p_float) override; // vtable+0x70
void VTable0x70(float p_time) override; // vtable+0x70
MxLong HandleClick() override; // vtable+0xcc
MxLong HandleControl(LegoControlManagerEvent& p_param) override; // vtable+0xd4
MxLong HandleNotification19(MxType19NotificationParam& p_param) override; // vtable+0xdc
@ -119,7 +119,7 @@ class Ambulance : public IslePathActor {
MxS16 m_unk0x172; // 0x172
IsleScript::Script m_lastAction; // 0x174
IsleScript::Script m_lastAnimation; // 0x178
MxFloat m_unk0x17c; // 0x17c
MxFloat m_fuel; // 0x17c
MxFloat m_time; // 0x180
};

View file

@ -3,6 +3,7 @@
#include "mxvariable.h"
extern const char* g_varAMBULSPEED;
extern const char* g_varAMBULFUEL;
extern const char* g_varTOWFUEL;
extern const char* g_varVISIBILITY;

View file

@ -7,6 +7,7 @@
#include "legoanimationmanager.h"
#include "legocontrolmanager.h"
#include "legogamestate.h"
#include "legonavcontroller.h"
#include "legoutils.h"
#include "legovariables.h"
#include "legoworld.h"
@ -37,7 +38,7 @@ Ambulance::Ambulance()
m_lastAction = IsleScript::c_noneIsle;
m_unk0x172 = 0;
m_lastAnimation = IsleScript::c_noneIsle;
m_unk0x17c = 1.0;
m_fuel = 1.0;
}
// FUNCTION: LEGO1 0x10035f90
@ -75,16 +76,34 @@ MxResult Ambulance::Create(MxDSAction& p_dsAction)
}
VariableTable()->SetVariable(g_varAMBULFUEL, "1.0");
m_unk0x17c = 1.0;
m_fuel = 1.0;
m_time = Timer()->GetTime();
return result;
}
// STUB: LEGO1 0x10036300
void Ambulance::VTable0x70(float p_float)
// FUNCTION: LEGO1 0x10036300
void Ambulance::VTable0x70(float p_time)
{
// TODO
IslePathActor::VTable0x70(p_float);
IslePathActor::VTable0x70(p_time);
if (UserActor() == this) {
char buf[200];
float speed = abs(m_worldSpeed);
float maxLinearVel = NavController()->GetMaxLinearVel();
sprintf(buf, "%g", speed / maxLinearVel);
VariableTable()->SetVariable(g_varAMBULSPEED, buf);
m_fuel += (p_time - m_time) * -3.333333333e-06f;
if (m_fuel < 0) {
m_fuel = 0;
}
m_time = p_time;
sprintf(buf, "%g", m_fuel);
VariableTable()->SetVariable(g_varAMBULFUEL, buf);
}
}
// FUNCTION: LEGO1 0x100363f0

View file

@ -16,6 +16,10 @@ DECOMP_SIZE_ASSERT(CursorVariable, 0x24)
DECOMP_SIZE_ASSERT(WhoAmIVariable, 0x24)
DECOMP_SIZE_ASSERT(CustomizeAnimFileVariable, 0x24)
// GLOBAL: LEGO1 0x100f39b8
// STRING: LEGO1 0x100f39ac
const char* g_varAMBULSPEED = "ambulSPEED";
// GLOBAL: LEGO1 0x100f39bc
// STRING: LEGO1 0x100f39a0
const char* g_varAMBULFUEL = "ambulFUEL";