From 68023379d83c0efe4356ab72c641a4106d4e252f Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 16 Jun 2024 09:54:40 -0400 Subject: [PATCH] Implement/match Bike (#1036) --- LEGO1/lego/legoomni/include/bike.h | 2 +- LEGO1/lego/legoomni/src/actors/bike.cpp | 82 +++++++++++++++++++++---- LEGO1/lego/legoomni/src/worlds/isle.cpp | 2 +- 3 files changed, 72 insertions(+), 14 deletions(-) diff --git a/LEGO1/lego/legoomni/include/bike.h b/LEGO1/lego/legoomni/include/bike.h index a77156b5..ea12ff1d 100644 --- a/LEGO1/lego/legoomni/include/bike.h +++ b/LEGO1/lego/legoomni/include/bike.h @@ -28,7 +28,7 @@ class Bike : public IslePathActor { MxLong HandleControl(LegoControlManagerEvent& p_param) override; // vtable+0xd4 void Exit() override; // vtable+0xe4 - void FUN_10076b60(); + void ActivateSceneActions(); // SYNTHETIC: LEGO1 0x10076880 // Bike::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/src/actors/bike.cpp b/LEGO1/lego/legoomni/src/actors/bike.cpp index 52401e28..11096d0c 100644 --- a/LEGO1/lego/legoomni/src/actors/bike.cpp +++ b/LEGO1/lego/legoomni/src/actors/bike.cpp @@ -1,11 +1,16 @@ #include "bike.h" +#include "isle.h" #include "isle_actions.h" +#include "jukebox_actions.h" +#include "legoanimationmanager.h" #include "legocontrolmanager.h" #include "legogamestate.h" #include "legoutils.h" #include "legoworld.h" #include "misc.h" +#include "mxsoundpresenter.h" +#include "mxtransitionmanager.h" #include "scripts.h" DECOMP_SIZE_ASSERT(Bike, 0x164) @@ -13,9 +18,9 @@ DECOMP_SIZE_ASSERT(Bike, 0x164) // FUNCTION: LEGO1 0x10076670 Bike::Bike() { - this->m_maxLinearVel = 20.0; - this->m_unk0x150 = 3.0; - this->m_unk0x148 = 1; + m_maxLinearVel = 20.0; + m_unk0x150 = 3.0; + m_unk0x148 = 1; } // FUNCTION: LEGO1 0x100768f0 @@ -44,22 +49,75 @@ void Bike::Exit() ControlManager()->Unregister(this); } -// STUB: LEGO1 0x100769a0 +// FUNCTION: LEGO1 0x100769a0 MxLong Bike::HandleClick() { - // TODO - return 0; + if (FUN_1003ef60()) { + Act1State* state = (Act1State*) GameState()->GetState("Act1State"); + FUN_10015820(TRUE, 0); + + ((Isle*) CurrentWorld())->SetDestLocation(LegoGameState::Area::e_bike); + TransitionManager()->StartTransition(MxTransitionManager::TransitionType::e_mosaic, 50, FALSE, TRUE); + + if (GameState()->GetActorId() != UserActor()->GetActorId()) { + ((IslePathActor*) UserActor())->Exit(); + } + + Enter(); + InvokeAction(Extra::ActionType::e_start, *g_isleScript, IsleScript::c_BikeDashboard, NULL); + GetCurrentAction().SetObjectId(-1); + + Vector3 position = m_roi->GetWorldPosition(); + AnimationManager()->FUN_10064670(&position); + AnimationManager()->FUN_10064740(&position); + ControlManager()->Register(this); + } + + return 1; } -// STUB: LEGO1 0x10076aa0 +// FUNCTION: LEGO1 0x10076aa0 MxLong Bike::HandleControl(LegoControlManagerEvent& p_param) { - // TODO - return 0; + MxLong result = 0; + + if (p_param.GetUnknown0x28() == 1) { + switch (p_param.GetClickedObjectId()) { + case IsleScript::c_BikeArms_Ctl: + Exit(); + GameState()->m_currentArea = LegoGameState::e_unk66; + result = 1; + break; + case IsleScript::c_BikeInfo_Ctl: + ((Isle*) CurrentWorld())->SetDestLocation(LegoGameState::e_infomain); + TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); + Exit(); + result = 1; + break; + case IsleScript::c_BikeHorn_Ctl: + MxSoundPresenter* presenter = + (MxSoundPresenter*) CurrentWorld()->Find("MxSoundPresenter", "BikeHorn_Sound"); + presenter->Enable(p_param.GetUnknown0x28()); + break; + } + } + + return result; } -// STUB: LEGO1 0x10076b60 -void Bike::FUN_10076b60() +// FUNCTION: LEGO1 0x10076b60 +void Bike::ActivateSceneActions() { - // TODO + PlayMusic(JukeboxScript::c_InformationCenter_Music); + + Act1State* act1state = (Act1State*) GameState()->GetState("Act1State"); + if (!act1state->m_unk0x022) { + act1state->m_unk0x022 = TRUE; + + MxMatrix mat(UserActor()->GetROI()->GetLocal2World()); + mat.TranslateBy(mat[2][0] * 2.5, mat[2][1] + 0.7, mat[2][2] * 2.5); + + AnimationManager() + ->FUN_10060dc0(IsleScript::c_sns006in_RunAnim, &mat, TRUE, FALSE, NULL, FALSE, TRUE, TRUE, TRUE); + } } diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index b542afac..b15cfc70 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -990,7 +990,7 @@ MxLong Isle::HandleTransitionEnd() FUN_10032d30(IsleScript::c_BikeDashboard_Bitmap, JukeboxScript::c_MusicTheme1, NULL, TRUE); if (!m_act1state->m_unk0x01f) { - m_bike->FUN_10076b60(); + m_bike->ActivateSceneActions(); } break; case LegoGameState::e_dunecar: