Finish JetskiRace (#1158)

* Implement `JetskiRace::HandlePathStruct`

* Implement `JetskiRace::FUN_10016930`

* Cleanup, add BETA10

* Match HandlePathStruct

* Address review comments

* Address another review comment

---------

Co-authored-by: jonschz <jonschz@users.noreply.github.com>
Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
jonschz
2024-11-16 20:24:03 +01:00
committed by GitHub
parent b4b28cf32e
commit fe8e56ba47
6 changed files with 159 additions and 14 deletions

View File

@@ -38,6 +38,9 @@ extern const char* g_strHIT_WALL_SOUND;
DECOMP_SIZE_ASSERT(JetskiRace, 0x144)
// GLOBAL: LEGO1 0x100f0c78
MxS32 JetskiRace::g_unk0x100f0c78 = 2;
// FUNCTION: LEGO1 0x100162c0
// FUNCTION: BETA10 0x100c7e6f
MxResult JetskiRace::Create(MxDSAction& p_dsAction)
@@ -125,6 +128,7 @@ MxLong JetskiRace::HandleEndAction(MxEndActionNotificationParam& p_param)
MxLong JetskiRace::HandleClick(LegoEventNotificationParam& p_param)
{
MxLong result = 0;
if (((LegoControlManagerNotificationParam*) &p_param)->m_unk0x28 == 1) {
switch (((LegoControlManagerNotificationParam*) &p_param)->m_clickedObjectId) {
case JetraceScript::c_JetskiArms_Ctl:
@@ -148,13 +152,139 @@ MxLong JetskiRace::HandleClick(LegoEventNotificationParam& p_param)
break;
}
}
return result;
}
// STUB: LEGO1 0x100166a0
MxLong JetskiRace::HandlePathStruct(LegoPathStructNotificationParam&)
inline MxS32 JetskiRace::PossiblyGetPlaceOfPlayer()
{
return 0;
if (m_unk0xfc < m_unk0xf8 && m_unk0x100 < m_unk0xf8) {
return 3;
}
else if (m_unk0xfc < m_unk0xf8 || m_unk0x100 < m_unk0xf8) {
return 2;
}
return 1;
}
// FUNCTION: LEGO1 0x100166a0
// FUNCTION: BETA10 0x100c8085
MxLong JetskiRace::HandlePathStruct(LegoPathStructNotificationParam& p_param)
{
MxLong result = 0;
MxEntity* sender = (MxEntity*) p_param.GetSender();
if (p_param.GetTrigger() == 68) {
MxS32 paramData = p_param.GetData();
switch (sender->GetEntityId()) {
case 10:
if (paramData <= m_unk0x104 || paramData >= m_unk0x104 + 5) {
break;
}
m_unk0x104 = paramData;
LegoChar buffer[20];
sprintf(buffer, "%g", 0.032 + 0.936 * (m_unk0xf8 * 20.0 + m_unk0x104) / (g_unk0x100f0c78 * 20.0));
VariableTable()->SetVariable("DISTANCE", buffer);
if (m_unk0x104 == 0x14) {
m_unk0x104 = 0;
m_unk0xf8++;
if (g_unk0x100f0c78 == m_unk0xf8) {
MxS16 sVar6 = PossiblyGetPlaceOfPlayer();
VariableTable()->SetVariable(g_raceState, "");
VariableTable()->SetVariable(g_strHIT_WALL_SOUND, "");
LegoRaceCar::FUN_10012de0();
m_raceState->m_unk0x28 = 2;
RaceState::Entry* raceStateEntry = m_raceState->GetState(GameState()->GetActorId());
raceStateEntry->m_unk0x02 = sVar6;
if (raceStateEntry->m_score < sVar6) {
raceStateEntry->m_score = sVar6;
}
m_destLocation = LegoGameState::e_jetrace2;
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
}
result = 1;
}
else if (m_unk0x104 == 0xf) {
m_hideAnim->FUN_1006db40(m_unk0xf8 * 200 + 100);
result = 1;
}
break;
case 11:
if (paramData <= m_unk0x108 || paramData >= m_unk0x108 + 5) {
break;
}
FUN_10016930(0xb, paramData);
m_unk0x108 = paramData;
if (m_unk0x108 == 0x14) {
m_unk0x108 = 0;
m_unk0xfc++;
if (g_unk0x100f0c78 == m_unk0xfc) {
((LegoPathActor*) p_param.GetSender())->SetMaxLinearVel(0.1);
}
}
break;
case 12:
if (paramData <= m_unk0x10c || paramData >= m_unk0x10c + 5) {
break;
}
FUN_10016930(0xc, paramData);
m_unk0x10c = paramData;
if (m_unk0x10c == 0x14) {
m_unk0x10c = 0;
m_unk0x100++;
if (g_unk0x100f0c78 == m_unk0x100) {
((LegoPathActor*) p_param.GetSender())->SetMaxLinearVel(0.1);
}
}
break;
}
}
return result;
}
// FUNCTION: LEGO1 0x10016930
void JetskiRace::FUN_10016930(MxS32 p_param1, MxS16 p_param2)
{
MxS32 local4;
MxStillPresenter* presenter;
MxS32 x, y;
if (p_param1 == 11) {
presenter = m_unk0x128;
local4 = m_unk0xfc;
}
else if (p_param1 == 12) {
presenter = m_unk0x12c;
local4 = m_unk0x100;
}
if (presenter) {
x = m_unk0x130.GetLeft() + 0.5 +
(m_unk0x130.GetRight() - m_unk0x130.GetLeft() + 1) * (local4 * 20.0 + p_param2) / (g_unk0x100f0c78 * 20.0);
y = m_unk0x130.GetTop() + 0.5 +
(m_unk0x130.GetBottom() - m_unk0x130.GetTop() + 1) * (local4 * 20.0 + p_param2) / (g_unk0x100f0c78 * 20.0);
presenter->SetPosition(x, y);
}
}
// FUNCTION: LEGO1 0x10016a10