Implement most of LegoJetski, refactor (#1214)

* Implement most of `LegoJetski`, refactor

* Fix
This commit is contained in:
Christian Semmler
2024-12-12 13:17:25 -07:00
committed by GitHub
parent 894034f9cf
commit 1bfeebd004
11 changed files with 239 additions and 201 deletions

View File

@@ -41,7 +41,6 @@
#include "legoentitypresenter.h"
#include "legoflctexturepresenter.h"
#include "legohideanimpresenter.h"
#include "legojetski.h"
#include "legojetskiraceactor.h"
#include "legoloadcachesoundpresenter.h"
#include "legolocomotionanimpresenter.h"

View File

@@ -1,90 +0,0 @@
#include "legojetski.h"
#include "mxmisc.h"
#include "mxnotificationmanager.h"
DECOMP_SIZE_ASSERT(LegoJetski, 0x1dc)
// STUB: LEGO1 0x100136a0
void LegoJetski::SetWorldSpeed(MxFloat p_worldSpeed)
{
// TODO
}
// FUNCTION: LEGO1 0x100136f0
void LegoJetski::FUN_100136f0(float p_worldSpeed)
{
if (p_worldSpeed < 0) {
LegoCarRaceActor::m_unk0x0c = 2;
m_maxLinearVel = 0;
SetWorldSpeed(0);
}
else {
m_maxLinearVel = p_worldSpeed;
}
}
// STUB: LEGO1 0x10013740
void LegoJetski::VTable0x70(float p_time)
{
// TODO
}
// FUNCTION: LEGO1 0x10013820
LegoJetski::LegoJetski()
{
NotificationManager()->Register(this);
}
// FUNCTION: LEGO1 0x10013aa0
LegoJetski::~LegoJetski()
{
NotificationManager()->Unregister(this);
}
// STUB: LEGO1 0x10013bb0
void LegoJetski::ParseAction(char*)
{
// TODO
}
// STUB: LEGO1 0x10013c30
MxLong LegoJetski::Notify(MxParam& p_param)
{
// TODO
return 0;
}
// STUB: LEGO1 0x10013c40
MxResult LegoJetski::HitActor(LegoPathActor* p_actor, MxBool p_bool)
{
// TODO
return 0;
}
// STUB: LEGO1 0x10014150
MxU32 LegoJetski::VTable0x6c(
LegoPathBoundary* p_boundary,
Vector3& p_v1,
Vector3& p_v2,
float p_f1,
float p_f2,
Vector3& p_v3
)
{
// TODO
return 0;
}
// STUB: LEGO1 0x100141d0
void LegoJetski::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4)
{
// TODO
}
// STUB: LEGO1 0x10014210
MxResult LegoJetski::VTable0x9c()
{
// TODO
return SUCCESS;
}

View File

@@ -154,9 +154,9 @@ MxLong CarRace::HandleEndAction(MxEndActionNotificationParam& p_param)
result = 1;
}
else if (objectId == CarraceScript::c_irtx08ra_PlayWav && m_destLocation == LegoGameState::e_undefined) {
m_unk0x110[0]->Mute(FALSE);
m_unk0x110[1]->Mute(FALSE);
m_unk0x110[2]->Mute(FALSE);
m_maps[0]->Mute(FALSE);
m_maps[1]->Mute(FALSE);
m_maps[2]->Mute(FALSE);
VariableTable()->SetVariable(g_raceState, g_racing);
result = 1;
@@ -200,19 +200,19 @@ MxLong CarRace::HandlePathStruct(LegoPathStructNotificationParam& p_param)
if (g_unk0x100f0c7c == m_unk0xf8) {
VariableTable()->SetVariable(g_raceState, "");
m_unk0x110[0]->Mute(TRUE);
m_unk0x110[1]->Mute(TRUE);
m_unk0x110[2]->Mute(TRUE);
m_maps[0]->Mute(TRUE);
m_maps[1]->Mute(TRUE);
m_maps[2]->Mute(TRUE);
m_unk0x110[0]->SetMaxLinearVel(-1.0);
m_unk0x110[1]->SetMaxLinearVel(-1.0);
m_unk0x110[2]->SetMaxLinearVel(-1.0);
m_maps[0]->SetMaxLinearVel(-1.0);
m_maps[1]->SetMaxLinearVel(-1.0);
m_maps[2]->SetMaxLinearVel(-1.0);
RemoveActor(m_unk0x110[1]);
m_unk0x110[1]->ClearMaps();
RemoveActor(m_maps[1]);
m_maps[1]->ClearMaps();
RemoveActor(m_unk0x110[2]);
m_unk0x110[2]->ClearMaps();
RemoveActor(m_maps[2]);
m_maps[2]->ClearMaps();
MxS32 position;
@@ -273,10 +273,10 @@ MxLong CarRace::HandlePathStruct(LegoPathStructNotificationParam& p_param)
m_unk0xfc++;
if (g_unk0x100f0c7c == m_unk0xfc) {
m_unk0x110[1]->SetMaxLinearVel(-1.0);
RemoveActor(m_unk0x110[1]);
m_unk0x110[1]->ClearMaps();
m_unk0x110[1]->GetROI()->SetVisibility(FALSE);
m_maps[1]->SetMaxLinearVel(-1.0);
RemoveActor(m_maps[1]);
m_maps[1]->ClearMaps();
m_maps[1]->GetROI()->SetVisibility(FALSE);
LegoROI* roi = FindROI("rcblack");
@@ -301,10 +301,10 @@ MxLong CarRace::HandlePathStruct(LegoPathStructNotificationParam& p_param)
m_unk0x100++;
if (g_unk0x100f0c7c == m_unk0x100) {
m_unk0x110[2]->SetMaxLinearVel(-1.0);
RemoveActor(m_unk0x110[2]);
m_unk0x110[2]->ClearMaps();
m_unk0x110[2]->GetROI()->SetVisibility(FALSE);
m_maps[2]->SetMaxLinearVel(-1.0);
RemoveActor(m_maps[2]);
m_maps[2]->ClearMaps();
m_maps[2]->GetROI()->SetVisibility(FALSE);
LegoROI* roi = FindROI("rcgreen");

View File

@@ -109,9 +109,9 @@ MxLong JetskiRace::HandleEndAction(MxEndActionNotificationParam& p_param)
MxLong result = 0;
if ((p_param.GetAction()) && (p_param.GetAction()->GetObjectId() == JetraceScript::c_AirHorn_PlayWav)) {
m_unk0x110[0]->Mute(FALSE);
m_unk0x110[1]->Mute(FALSE);
m_unk0x110[2]->Mute(FALSE);
m_maps[0]->Mute(FALSE);
m_maps[1]->Mute(FALSE);
m_maps[2]->Mute(FALSE);
VariableTable()->SetVariable(g_raceState, g_racing);
result = 1;

View File

@@ -24,9 +24,9 @@ LegoRace::LegoRace()
m_unk0x108 = 0;
m_unk0x10c = 0;
m_raceState = NULL;
m_unk0x110[0] = NULL;
m_unk0x110[1] = NULL;
m_unk0x110[2] = NULL;
m_maps[0] = NULL;
m_maps[1] = NULL;
m_maps[2] = NULL;
m_unk0x128 = 0;
m_unk0x12c = 0;
m_pathActor = 0;

View File

@@ -3,10 +3,12 @@
#include "anim/legoanim.h"
#include "carrace.h"
#include "define.h"
#include "jetskirace.h"
#include "legocachesoundmanager.h"
#include "legocameracontroller.h"
#include "legonavcontroller.h"
#include "legorace.h"
#include "legoracers.h"
#include "legosoundmanager.h"
#include "misc.h"
#include "mxdebug.h"
@@ -20,6 +22,7 @@
DECOMP_SIZE_ASSERT(EdgeReference, 0x08)
DECOMP_SIZE_ASSERT(SkeletonKickPhase, 0x10)
DECOMP_SIZE_ASSERT(LegoRaceCar, 0x200)
DECOMP_SIZE_ASSERT(LegoJetski, 0x1dc)
// GLOBAL: LEGO1 0x100f0a20
// GLOBAL: BETA10 0x101f5e34
@@ -71,6 +74,9 @@ const SkeletonKickPhase LegoRaceCar::g_skeletonKickPhases[] = {
// GLOBAL: LEGO1 0x100f0b10
const char* LegoRaceCar::g_strSpeed = "SPEED";
// GLOBAL: LEGO1 0x100f0b14
const char* LegoRaceCar::g_strJetSpeed = "jetSPEED";
// GLOBAL: LEGO1 0x100f0b18
// GLOBAL: BETA10 0x101f5f28
const char* LegoRaceCar::g_srtsl18to29[] = {
@@ -430,7 +436,7 @@ void LegoRaceCar::VTable0x70(float p_time)
// FUNCTION: BETA10 0x100cbb84
MxResult LegoRaceCar::HitActor(LegoPathActor* p_actor, MxBool p_bool)
{
// Note: Code duplication with LegoRaceActor::VTable0x94
// Note: Code duplication with LegoRaceActor::HitActor
if (!p_actor->GetUserNavFlag()) {
if (p_actor->GetState()) {
return FAILURE;
@@ -550,6 +556,129 @@ void LegoRaceCar::FUN_10013670()
g_unk0x100f0bb0 = uVar1 % 0xc >> 2;
}
// FUNCTION: LEGO1 0x100136a0
// FUNCTION: BETA10 0x100cbf7e
void LegoJetski::SetWorldSpeed(MxFloat p_worldSpeed)
{
if (!m_userNavFlag) {
if (!LegoCarRaceActor::m_unk0x0c) {
m_maxLinearVel = p_worldSpeed;
}
LegoAnimActor::SetWorldSpeed(p_worldSpeed);
}
else {
LegoEntity::SetWorldSpeed(p_worldSpeed);
}
}
// FUNCTION: LEGO1 0x100136f0
// FUNCTION: BETA10 0x100cc01a
void LegoJetski::FUN_100136f0(float p_worldSpeed)
{
if (p_worldSpeed < 0) {
LegoCarRaceActor::m_unk0x0c = 2;
m_maxLinearVel = 0;
SetWorldSpeed(0);
}
else {
m_maxLinearVel = p_worldSpeed;
}
}
// FUNCTION: LEGO1 0x10013740
// FUNCTION: BETA10 0x100cc0ae
void LegoJetski::VTable0x70(float p_time)
{
LegoJetskiRaceActor::VTable0x70(p_time);
if (LegoCarRaceActor::m_unk0x0c == 1) {
FUN_1005d4b0();
if (!m_userNavFlag) {
FUN_10080590(p_time);
return;
}
float absoluteSpeed = abs(m_worldSpeed);
float speedRatio = absoluteSpeed / NavController()->GetMaxLinearVel();
char buffer[200];
sprintf(buffer, "%g", speedRatio);
VariableTable()->SetVariable(LegoRaceCar::g_strJetSpeed, buffer);
if (m_sound) {
m_frequencyFactor = speedRatio * 1.2 + 0.7;
}
}
}
// FUNCTION: LEGO1 0x10013820
LegoJetski::LegoJetski()
{
NotificationManager()->Register(this);
}
// FUNCTION: LEGO1 0x10013aa0
LegoJetski::~LegoJetski()
{
NotificationManager()->Unregister(this);
}
// FUNCTION: LEGO1 0x10013bb0
// FUNCTION: BETA10 0x100cc6df
void LegoJetski::ParseAction(char* p_extra)
{
char buffer[256];
LegoAnimActor::ParseAction(p_extra);
LegoRaceMap::ParseAction(p_extra);
JetskiRace* currentWorld = (JetskiRace*) CurrentWorld();
if (KeyValueStringParse(buffer, g_strCOMP, p_extra) && currentWorld) {
currentWorld->VTable0x7c(this, atoi(buffer));
}
}
// FUNCTION: LEGO1 0x10013c30
// FUNCTION: BETA10 0x100cc76a
MxLong LegoJetski::Notify(MxParam& p_param)
{
return LegoRaceMap::Notify(p_param);
}
// STUB: LEGO1 0x10013c40
MxResult LegoJetski::HitActor(LegoPathActor* p_actor, MxBool p_bool)
{
// very similar to LegoRaceCar::HitActor
return SUCCESS;
}
// FUNCTION: LEGO1 0x10014150
MxU32 LegoJetski::VTable0x6c(
LegoPathBoundary* p_boundary,
Vector3& p_v1,
Vector3& p_v2,
float p_f1,
float p_f2,
Vector3& p_v3
)
{
return LegoJetskiRaceActor::VTable0x6c(p_boundary, p_v1, p_v2, p_f1, p_f2, p_v3);
}
// FUNCTION: LEGO1 0x100141d0
void LegoJetski::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4)
{
LegoJetskiRaceActor::SwitchBoundary(p_boundary, p_edge, p_unk0xe4);
}
// FUNCTION: LEGO1 0x10014210
MxResult LegoJetski::VTable0x9c()
{
return LegoJetskiRaceActor::VTable0x9c();
}
// FUNCTION: LEGO1 0x10014500
// FUNCTION: BETA10 0x100cd5e0
MxU32 LegoRaceCar::VTable0x6c(