Isle
Loading...
Searching...
No Matches
dunebuggy.cpp
Go to the documentation of this file.
1#include "dunebuggy.h"
2
3#include "decomp.h"
4#include "isle.h"
5#include "isle_actions.h"
6#include "jukebox_actions.h"
9#include "legonavcontroller.h"
10#include "legopathstruct.h"
11#include "legoutils.h"
12#include "legovariables.h"
13#include "legoworld.h"
14#include "misc.h"
15#include "mxmisc.h"
16#include "mxsoundpresenter.h"
17#include "mxtimer.h"
18#include "mxtransitionmanager.h"
19#include "mxvariabletable.h"
20
22
23// GLOBAL: LEGO1 0x100f7660
24// STRING: LEGO1 0x100f7634
25const char* g_varDBFRFNY4 = "C_DBFRFNY4";
26
27// FUNCTION: LEGO1 0x10067bb0
29{
30 m_maxLinearVel = 25.0;
31 m_fuel = 1.0;
32}
33
34// FUNCTION: LEGO1 0x10067e30
36{
37 MxResult result = IslePathActor::Create(p_dsAction);
39
40 if (m_world) {
41 m_world->Add(this);
42 }
43
45 m_fuel = 1.0;
46 m_time = Timer()->GetTime();
47 return result;
48}
49
50// FUNCTION: LEGO1 0x10067ec0
51void DuneBuggy::Animate(float p_time)
52{
54
55 char buf[200];
56 float speed = abs(m_worldSpeed);
57 float maxLinearVel = NavController()->GetMaxLinearVel();
58
59 sprintf(buf, "%g", speed / maxLinearVel);
61
62 m_fuel += (p_time - m_time) * -3.333333333e-06f;
63 if (m_fuel < 0) {
64 m_fuel = 0;
65 }
66
67 m_time = p_time;
68
69 sprintf(buf, "%g", m_fuel);
71}
72
73// FUNCTION: LEGO1 0x10067fa0
75{
86}
87
88// FUNCTION: LEGO1 0x10068060
90{
91 if (!FUN_1003ef60()) {
92 return 1;
93 }
94
96
97 ((Isle*) CurrentWorld())->SetDestLocation(LegoGameState::Area::e_dunecar);
99
100 if (GameState()->GetActorId() != UserActor()->GetActorId()) {
101 ((IslePathActor*) UserActor())->Exit();
102 }
103
104 m_time = Timer()->GetTime();
106
110
111 Vector3 position = m_roi->GetWorldPosition();
112 AnimationManager()->FUN_10064670(&position);
113 AnimationManager()->FUN_10064740(&position);
114 Enter();
115 ControlManager()->Register(this);
116 return 1;
117}
118
119// FUNCTION: LEGO1 0x100681b0
121{
122 MxLong result = 0;
123
124 if (p_param.m_unk0x28 == 1) {
125 switch (p_param.m_clickedObjectId) {
127 Exit();
129 result = 1;
130 break;
132 ((Isle*) CurrentWorld())->SetDestLocation(LegoGameState::e_infomain);
134 Exit();
135 result = 1;
136 break;
138 MxSoundPresenter* presenter =
139 (MxSoundPresenter*) CurrentWorld()->Find("MxSoundPresenter", "DuneCarHorn_Sound");
140 presenter->Enable(p_param.m_unk0x28);
141 break;
142 }
143 }
144
145 return result;
146}
147
148// FUNCTION: LEGO1 0x10068270
150{
151 // 0x168 corresponds to the path at the gas station
152 if (p_param.GetData() == 0x168) {
153 m_fuel = 1.0f;
154 }
155
156 return 0;
157}
158
159// FUNCTION: LEGO1 0x10068290
160// FUNCTION: BETA10 0x1002765d
161MxS32 DuneBuggy::GetColorOffset(const char* p_variable)
162{
163 MxS32 offset = 1;
164 const char* color = VariableTable()->GetVariable(p_variable);
165 assert(color);
166
167 if (!strcmpi(color, "lego green")) {
168 offset = 1;
169 }
170 else if (!strcmpi(color, "lego red")) {
171 offset = 2;
172 }
173 else if (!strcmpi(color, "lego yellow")) {
174 offset = 3;
175 }
176 else if (!strcmpi(color, "lego black")) {
177 offset = 4;
178 }
179 else if (!strcmpi(color, "lego blue")) {
180 offset = 5;
181 }
182 else if (!strcmpi(color, "lego white")) {
183 offset = 6;
184 }
185
186 return offset;
187}
188
189// FUNCTION: LEGO1 0x10068350
191{
193
194 Act1State* act1state = (Act1State*) GameState()->GetState("Act1State");
195 if (!act1state->m_unk0x022) {
196 act1state->m_unk0x022 = TRUE;
197
198 MxMatrix mat(UserActor()->GetROI()->GetLocal2World());
199 mat.TranslateBy(mat[2][0] * 2.5, mat[2][1] + 0.7, mat[2][2] * 2.5);
200
203 &mat,
204 TRUE,
206 NULL,
207 FALSE,
208 TRUE,
209 TRUE,
210 TRUE
211 );
212 }
213}
[AI] Holds state and transient gameplay data for the first act on Lego Island.
Definition: isle.h:29
MxBool m_unk0x022
[AI] Temporary state variable; persists through serialization, often used for logic gating....
Definition: isle.h:110
[AI] Represents the player-controllable dune buggy vehicle in LEGO Island, inheriting movement and in...
Definition: dunebuggy.h:16
void Animate(float p_time) override
[AI] Advances the animation and updates state variables for the dune buggy, including updating the sp...
Definition: dunebuggy.cpp:51
void ActivateSceneActions()
[AI] Triggers cutscene/cinematic actions associated with the garage/dune buggy scenario ("scene actio...
Definition: dunebuggy.cpp:190
MxLong HandleControl(LegoControlManagerNotificationParam &p_param) override
[AI] Handles control manager notifications (e.g., dashboard button presses) while the dune buggy is a...
Definition: dunebuggy.cpp:120
MxResult Create(MxDSAction &p_dsAction) override
[AI] Creates and initializes the dune buggy from a MxDSAction, also placing it into the current world...
Definition: dunebuggy.cpp:35
MxLong HandleClick() override
[AI] Handles player click interactions on the dune buggy.
Definition: dunebuggy.cpp:89
static MxS32 GetColorOffset(const char *p_variable)
[AI] Determines the color offset index for the dune buggy dashboard based on a variable.
Definition: dunebuggy.cpp:161
MxLong HandlePathStruct(LegoPathStructNotificationParam &p_param) override
[AI] Handles notifications if the dune buggy actor reaches a certain location/path segment (e....
Definition: dunebuggy.cpp:149
void Exit() override
[AI] Exits the dune buggy scenario, cleaning up the HUD, unregistering dashboard elements,...
Definition: dunebuggy.cpp:74
Derived path actor type for handling player transitions and activities on LEGO Island.
Definition: islepathactor.h:23
MxResult Create(MxDSAction &p_dsAction) override
[AI] Initialize this actor from a DSAction.
virtual void Exit()
[AI] Called when the actor is deactivated or moved out of player control, restoring previous actor if...
LegoWorld * m_world
[AI] Pointer to the current world instance actor is existing in. [AI]
virtual void Enter()
[AI] Called when the actor is made active in a new area or context, setting navigation and visibility...
[AI] Represents the main overworld (LEGO Island) in the game, acting as the central hub and state mac...
Definition: isle.h:179
virtual MxU8 GetActorId()
[AI] Gets this actor's numeric ID, corresponding to a known enumeration/actor.
Definition: legoactor.h:77
MxResult FUN_10060dc0(MxU32 p_objectId, MxMatrix *p_matrix, MxBool p_param3, MxU8 p_param4, LegoROI *p_roi, MxBool p_param6, MxBool p_param7, MxBool p_param8, MxBool p_param9)
[AI] Helper for starting a specific animation, including world matrix and camera settings.
@ e_unk0
[AI] Unknown/unspecified play mode
MxResult FUN_10064740(Vector3 *p_position)
[AI] Similar to FUN_10064670, but triggers a different special animation event for secondary location...
MxResult FUN_10064670(Vector3 *p_position)
[AI] Activates special triggered animation in response to player position near given point.
[AI] Notification parameter for the LegoControlManager, used to propagate information about control e...
MxS32 m_clickedObjectId
[AI] Object ID of the clicked control/presenter (or -1 if not set). [AI]
MxS16 m_unk0x28
[AI] Undetermined; settable via SetUnknown0x28. [AI]
void Register(MxCore *p_listener)
[AI] Adds a listener to be notified of control events.
void Unregister(MxCore *p_listener)
[AI] Removes a listener so it no longer receives control events.
LegoROI * GetROI()
[AI] Gets the ROI (Realtime Object Instance) associated with this entity. [AI]
Definition: legoentity.h:161
MxFloat m_worldSpeed
[AI] World-relative speed (can affect animation/movement logic). [AI]
Definition: legoentity.h:212
LegoROI * m_roi
[AI] Pointer to this entity's currently assigned ROI (3D instance in the world). [AI]
Definition: legoentity.h:215
Area m_currentArea
Area/world the player is presently in. [AI].
LegoState * GetState(const char *p_stateName)
Find an existing state (LegoState-derived) object by its registered script/class name.
@ e_infomain
Information Center, main screen. [AI].
Definition: legogamestate.h:96
@ e_unk66
Used for some spawn locations. [AI].
@ e_dunecar
Dune buggy (vehicle, for spawn). [AI].
MxFloat GetMaxLinearVel()
[AI] Returns the current maximum linear velocity (units per sec).
virtual void Animate(float p_time)
[AI] Per-frame animation update.
[AI] Specialized notification parameter used for path structure related events in LEGO Island.
MxS16 GetData()
[AI] Retrieves the supplemental data associated with the notification.
virtual void Add(MxCore *p_object)
Adds an object (entity, presenter, ROI, etc.) to the appropriate world-managed list or set.
Definition: legoworld.cpp:418
MxCore * Find(const char *p_class, const char *p_name)
Finds an object of a given class and name in the world.
Definition: legoworld.cpp:573
virtual void TranslateBy(const float &p_x, const float &p_y, const float &p_z)
Applies translation by amounts along X, Y, Z axes.
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
void SetObjectId(MxU32 p_objectId)
[AI] Sets the object id (for serialization or lookup).
Definition: mxdsobject.h:147
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
Definition: mxmatrix.h:16
void Enable(MxBool p_enable) override
[AI] Enables or disables media stream playback and transitions state as needed.
[AI] Concrete presenter for sound playback and control within the LEGO Island engine.
MxLong GetTime()
Returns the current timer value in ms, depending on running state.
Definition: mxtimer.h:50
MxResult StartTransition(TransitionType p_animationType, MxS32 p_speed, MxBool p_doCopy, MxBool p_playMusicInAnim)
[AI] Begins a new transition animation of type p_animationType at the specified speed,...
@ e_mosaic
[AI] Complex mosaic block-out effect.
const char * GetVariable(const char *p_key)
Returns the value for the variable with a given key, or an empty string if not found.
void SetVariable(const char *p_key, const char *p_value)
Sets a variable by key and value, replacing or updating if it exists.
const float * GetWorldPosition() const
Returns a pointer to the world position from the transformation matrix (translation row).
[AI] 3D vector class, providing vector and cross-product operations in 3D space.
Definition: vector.h:249
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
const char * g_varDBFRFNY4
Definition: dunebuggy.cpp:25
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
void InvokeAction(Extra::ActionType p_actionId, const MxAtomId &p_pAtom, MxS32 p_streamId, LegoEntity *p_sender)
[AI] Dispatches and triggers a game action on the given script or object.
Definition: legoutils.cpp:271
MxBool RemoveFromCurrentWorld(const MxAtomId &p_atomId, MxS32 p_id)
[AI] Removes an entity or presenter with specified AtomId and ID from the current world; triggers End...
Definition: legoutils.cpp:495
MxBool FUN_1003ef60()
[AI] Determines if the current actor can exit their area, based on state/zone/vehicle.
Definition: legoutils.cpp:572
MxAtomId * g_isleScript
[AI] Node used in hierarchical scene graphs and animation trees. [AI]
Definition: scripts.cpp:32
const char * g_varDUNEFUEL
[AI] Global variable key for the dune vehicle's fuel.
const char * g_varDUNESPEED
[AI] Global variable key for the dune vehicle's speed.
LegoGameState * GameState()
[AI] Accessor for the game's central game state controller. [AI]
Definition: misc.cpp:61
LegoAnimationManager * AnimationManager()
[AI] Accessor for the animation manager, which controls Lego character/world animation state....
Definition: misc.cpp:69
MxTransitionManager * TransitionManager()
[AI] Accessor for the MxTransitionManager, handling level transitions, fades, and world changes....
Definition: misc.cpp:208
MxDSAction & GetCurrentAction()
[AI] Accessor for the currently running MxDSAction (e.g.
Definition: misc.cpp:195
LegoControlManager * ControlManager()
[AI] Accessor for the control manager through the input manager; manages higher-level user/game contr...
Definition: misc.cpp:53
LegoWorld * CurrentWorld()
[AI] Accessor for the currently active LegoWorld instance. [AI]
Definition: misc.cpp:93
void FUN_10015820(MxBool p_disable, MxU16 p_flags)
[AI] Utility for enabling or disabling functionality in LegoOmni based on certain flags.
Definition: misc.cpp:143
LegoNavController * NavController()
[AI] Accessor for the navigation controller, managing player/camera navigation. [AI]
Definition: misc.cpp:77
void PlayMusic(JukeboxScript::Script p_objectId)
[AI] Starts music playback by scripting the background audio manager to play the music piece referenc...
Definition: misc.cpp:216
LegoPathActor * UserActor()
[AI] Accessor for the user (player-controllable) LegoPathActor. [AI]
Definition: misc.cpp:85
MxTimer * Timer()
[AI] Returns the global simulation timer.
Definition: mxmisc.cpp:33
MxVariableTable * VariableTable()
[AI] Returns the variable table used for script variables and global key/value state.
Definition: mxmisc.cpp:73
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
signed int MxS32
[AI]
Definition: mxtypes.h:38
@ c_DuneCarFuelMeter
Definition: isle_actions.h:211
@ c_DuneCarHorn_Sound
Definition: isle_actions.h:209
@ c_DuneCarSpeedMeter
Definition: isle_actions.h:199
@ c_DuneCarDashboard
Definition: isle_actions.h:206
@ c_sns005in_RunAnim
Definition: isle_actions.h:876
@ c_GarageArea_Music
[AI] Music in the garage or vehicle area.
@ e_start
[AI] Start an activity or playback [AI]
Definition: extra.h:30