mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-02 12:01:15 +00:00
Some checks are pending
CI / clang-format (push) Waiting to run
CI / ${{ matrix.name }} (false, --toolchain /usr/local/vitasdk/share/vita.toolchain.cmake, false, false, Ninja, Vita, ubuntu-latest, true, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0, false, false, Visual Studio 17 2022, true, Xbox One, windows-latest, amd64, false, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake, false, devkitpro/devkitarm:latest, false, Ninja, true, Nintendo 3DS, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake, false, devkitpro/devkita64:latest, false, Ninja, Nintendo Switch, true, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, emcmake, false, false, true, Ninja, Emscripten, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, false, Ninja, true, MSVC (arm64), windows-latest, amd64_arm64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, true, Ninja, true, MSVC (x86), windows-latest, amd64_x86, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, false, Ninja, true, MSVC (x64), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, true, false, Ninja, true, MSVC (x64 Debug), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, -DCMAKE_SYSTEM_NAME=iOS, false, false, Xcode, true, iOS, macos-15, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, false, Ninja, true, mingw-w64-i686, mingw32, msys2 mingw32, windows-latest, msys2 {0}, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, false, false, Ninja, Android, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, true, false, Ninja, macOS, macos-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, false, Ninja, true, mingw-w64-x86_64, mingw64, msys2 mingw64, windows-latest, msys2 {0}, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux (Debug), ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux, ubuntu-latest, true) (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (aarch64, ubuntu-22.04-arm) (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (x86_64, ubuntu-latest) (push) Waiting to run
CI / C++ (push) Waiting to run
CI / Release (push) Blocked by required conditions
Docker / Publish web port (push) Waiting to run
175 lines
4.1 KiB
C++
175 lines
4.1 KiB
C++
#include "motorcycle.h"
|
|
|
|
#include "isle.h"
|
|
#include "isle_actions.h"
|
|
#include "jukebox_actions.h"
|
|
#include "legoanimationmanager.h"
|
|
#include "legocontrolmanager.h"
|
|
#include "legonavcontroller.h"
|
|
#include "legopathstruct.h"
|
|
#include "legoutils.h"
|
|
#include "legovariables.h"
|
|
#include "legoworld.h"
|
|
#include "misc.h"
|
|
#include "mxmisc.h"
|
|
#include "mxtimer.h"
|
|
#include "mxtransitionmanager.h"
|
|
#include "mxvariabletable.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
DECOMP_SIZE_ASSERT(Motocycle, 0x16c)
|
|
|
|
// FUNCTION: LEGO1 0x100357b0
|
|
Motocycle::Motocycle()
|
|
{
|
|
m_maxLinearVel = 40.0;
|
|
m_linearRotationRatio = 1.75;
|
|
m_canRotate = 1;
|
|
m_fuel = 1.0;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10035a40
|
|
MxResult Motocycle::Create(MxDSAction& p_dsAction)
|
|
{
|
|
MxResult result = IslePathActor::Create(p_dsAction);
|
|
m_world = CurrentWorld();
|
|
|
|
if (m_world) {
|
|
m_world->Add(this);
|
|
}
|
|
|
|
VariableTable()->SetVariable(g_varMOTOFUEL, "1.0");
|
|
m_fuel = 1.0;
|
|
m_time = Timer()->GetTime();
|
|
return result;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10035ad0
|
|
void Motocycle::Animate(float p_time)
|
|
{
|
|
IslePathActor::Animate(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_varMOTOSPEED, 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_varMOTOFUEL, buf);
|
|
}
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10035bc0
|
|
void Motocycle::Exit()
|
|
{
|
|
IslePathActor::Exit();
|
|
GameState()->m_currentArea = LegoGameState::e_motocycle;
|
|
RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_MotoBikeDashboard_Bitmap);
|
|
RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_MotoBikeArms_Ctl);
|
|
RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_MotoBikeInfo_Ctl);
|
|
RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_MotoBikeSpeedMeter);
|
|
RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_MotoBikeFuelMeter);
|
|
ControlManager()->Unregister(this);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10035c50
|
|
MxLong Motocycle::HandleClick()
|
|
{
|
|
if (!CanExit()) {
|
|
return 1;
|
|
}
|
|
|
|
Disable(TRUE, 0);
|
|
|
|
((Isle*) CurrentWorld())->SetDestLocation(LegoGameState::Area::e_motocycle);
|
|
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, TRUE);
|
|
|
|
if (GameState()->GetActorId() != UserActor()->GetActorId()) {
|
|
((IslePathActor*) UserActor())->Exit();
|
|
}
|
|
|
|
m_time = Timer()->GetTime();
|
|
|
|
Enter();
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, IsleScript::c_MotoBikeDashboard, NULL);
|
|
GetCurrentAction().SetObjectId(-1);
|
|
|
|
Vector3 position = m_roi->GetWorldPosition();
|
|
AnimationManager()->FUN_10064670(&position);
|
|
AnimationManager()->FUN_10064740(&position);
|
|
ControlManager()->Register(this);
|
|
return 1;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10035d70
|
|
MxLong Motocycle::HandleControl(LegoControlManagerNotificationParam& p_param)
|
|
{
|
|
MxLong result = 0;
|
|
|
|
if (p_param.m_enabledChild == 1) {
|
|
switch (p_param.m_clickedObjectId) {
|
|
case IsleScript::c_MotoBikeArms_Ctl:
|
|
Exit();
|
|
GameState()->m_currentArea = LegoGameState::e_vehicleExited;
|
|
result = 1;
|
|
break;
|
|
case IsleScript::c_MotoBikeInfo_Ctl:
|
|
((Isle*) CurrentWorld())->SetDestLocation(LegoGameState::e_infomain);
|
|
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
|
|
Exit();
|
|
result = 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10035df0
|
|
MxLong Motocycle::HandlePathStruct(LegoPathStructNotificationParam& p_param)
|
|
{
|
|
// 0x168 corresponds to the path at the gas station
|
|
if (p_param.GetData() == 0x168) {
|
|
m_fuel = 1.0f;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10035e10
|
|
void Motocycle::ActivateSceneActions()
|
|
{
|
|
PlayMusic(JukeboxScript::c_PoliceStation_Music);
|
|
|
|
Act1State* act1state = (Act1State*) GameState()->GetState("Act1State");
|
|
if (!act1state->m_playedExitExplanation) {
|
|
act1state->m_playedExitExplanation = 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,
|
|
LegoAnimationManager::e_unk0,
|
|
NULL,
|
|
FALSE,
|
|
TRUE,
|
|
TRUE,
|
|
TRUE
|
|
);
|
|
}
|
|
}
|