Isle
Loading...
Searching...
No Matches
legorace.cpp
Go to the documentation of this file.
1#include "legorace.h"
2
3#include "isle.h"
5#include "legonavcontroller.h"
6#include "misc.h"
7#include "mxmisc.h"
9
11DECOMP_SIZE_ASSERT(RaceState::Entry, 0x06)
13
14// Defined in legopathstruct.cpp
16
17// FUNCTION: LEGO1 0x10015aa0
19{
20 m_unk0xf8 = 0;
21 m_unk0xfc = 0;
22 m_unk0x100 = 0;
23 m_unk0x104 = 0;
24 m_unk0x108 = 0;
25 m_unk0x10c = 0;
26 m_raceState = NULL;
27 m_maps[0] = NULL;
28 m_maps[1] = NULL;
29 m_maps[2] = NULL;
30 m_unk0x128 = 0;
31 m_unk0x12c = 0;
32 m_pathActor = 0;
33 m_act1State = NULL;
34 m_destLocation = LegoGameState::e_undefined;
36}
37
38// FUNCTION: LEGO1 0x10015ce0
39// FUNCTION: BETA10 0x100c7a71
41{
42 MxResult result = LegoWorld::Create(p_dsAction);
43
44 if (result == SUCCESS) {
45 m_act1State = (Act1State*) GameState()->GetState("Act1State");
46 ControlManager()->Register(this);
50 }
51
52 return result;
53}
54
55// FUNCTION: LEGO1 0x10015d40
57{
59 if (m_pathActor) {
63 }
64
67}
68
69// FUNCTION: LEGO1 0x10015e00
70// FUNCTION: BETA10 0x100c7b3d
72{
73 LegoWorld::Notify(p_param);
74 MxNotificationParam& param = (MxNotificationParam&) p_param;
75
76 MxLong result = 0;
77 if (m_worldStarted) {
78 switch (param.GetNotification()) {
81 break;
84 break;
86 result = HandleClick((LegoEventNotificationParam&) p_param);
87 break;
90 break;
93 break;
94 }
95 }
96
97 return result;
98}
99
100// FUNCTION: LEGO1 0x10015ed0
101// FUNCTION: BETA10 0x100c7c3f
103{
104 if (GetUnknown0xd0Empty() != p_enable && !p_enable) {
105 Remove(UserActor());
106
107 MxU8 oldActorId = GameState()->GetActorId();
109 GameState()->SetActorId(oldActorId);
110 }
111
112 LegoWorld::Enable(p_enable);
113}
114
115// FUNCTION: LEGO1 0x10015f30
117{
118 m_state[0].m_id = 1;
119 m_state[0].m_unk0x02 = 0;
120 m_state[0].m_score = 0;
121 m_state[1].m_id = 2;
122 m_state[1].m_unk0x02 = 0;
123 m_state[1].m_score = 0;
124 m_state[2].m_id = 3;
125 m_state[2].m_unk0x02 = 0;
126 m_state[2].m_score = 0;
127 m_state[3].m_id = 4;
128 m_state[3].m_unk0x02 = 0;
129 m_state[3].m_score = 0;
130 m_state[4].m_id = 5;
131 m_state[4].m_unk0x02 = 0;
132 m_state[4].m_score = 0;
133 m_unk0x28 = 0;
134}
135
136// FUNCTION: LEGO1 0x10016140
137// FUNCTION: BETA10 0x100c7d9f
139{
140 LegoState::Serialize(p_storage);
141
142 for (MxS16 i = 0; i < 5; i++) {
143 m_state[i].Serialize(p_storage);
144 }
145
146 return SUCCESS;
147}
148
149// FUNCTION: LEGO1 0x10016280
150// FUNCTION: BETA10 0x100c7dfd
152{
153 for (MxS16 i = 0;; i++) {
154 if (i >= 5) {
155 return NULL;
156 }
157
158 if (m_state[i].m_id == p_id) {
159 return m_state + i;
160 }
161 }
162}
[AI] Holds state and transient gameplay data for the first act on Lego Island.
Definition: isle.h:29
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.
virtual void SetWorldSpeed(MxFloat p_worldSpeed)
[AI] Sets the current world speed value for this entity (used to control motion/animation rate).
Definition: legoentity.h:98
Notification parameter class for LEGO event notifications such as mouse events and modifier keys.
void SwitchArea(Area p_area)
Switches the whole game state into a new area/world; manages transitions/scene loads.
void SetActorId(MxU8 p_actorId)
Directly sets the current actor ID (preferred: use SetActor).
MxU8 GetActorId()
Returns the current selected actor ID. [AI].
void RemoveActor()
Removes (and deletes) the current user actor from the world.
LegoState * GetState(const char *p_stateName)
Find an existing state (LegoState-derived) object by its registered script/class name.
@ e_undefined
Undefined or unset area. [AI].
Definition: legogamestate.h:93
void ResetMaxLinearVel(MxFloat p_maxLinearVel)
[AI] Resets the maximum allowed linear velocity and marks controller as using custom parameters.
virtual MxFloat GetMaxLinearVel()
[AI] Gets the maximum allowed navigation speed for this actor.
[AI] Specialized notification parameter used for path structure related events in LEGO Island.
[AI] Base class for all race-type LegoWorlds.
Definition: legorace.h:149
MxResult Create(MxDSAction &p_dsAction) override
[AI] Creates and initializes LegoRace world/logic for a DS action.
Definition: legorace.cpp:40
MxLong Notify(MxParam &p_param) override
[AI] Notification callback, dispatches events to various race handlers (click, end action,...
Definition: legorace.cpp:71
virtual MxLong HandlePathStruct(LegoPathStructNotificationParam &)
[AI] Handles "path struct" notifications (such as map changes or logic triggers for race boundaries).
Definition: legorace.h:197
virtual MxLong HandleEndAction(MxEndActionNotificationParam &)
[AI] Handles "end action" (e.g., finish line reached, cutscene ended) events for the race state logic...
Definition: legorace.h:204
LegoPathActor * m_pathActor
[AI] User's path actor for the race event.
Definition: legorace.h:272
void Enable(MxBool p_enable) override
[AI] Enables or disables the race world and detaches the user actor if switching away.
Definition: legorace.cpp:102
virtual MxLong HandleClick(LegoEventNotificationParam &)=0
[AI] Handles user click events within the race area.
LegoGameState::Area m_destLocation
[AI] Destination location (area to switch to after race/transition).
Definition: legorace.h:271
virtual MxLong HandleType0Notification(MxNotificationParam &)
[AI] Handles notification of type 0 (specific logic event), can be overridden for custom event proces...
Definition: legorace.h:236
Act1State * m_act1State
[AI] Pointer to Act1State (first act/sequence logic).
Definition: legorace.h:273
~LegoRace() override
[AI] Destructor.
Definition: legorace.cpp:56
virtual MxResult Serialize(LegoStorage *p_storage)
[AI] Serialize state to a storage (for save/load).
Definition: legostate.h:141
Abstract base class providing an interface for file-like storage with binary and text read/write oper...
Definition: legostorage.h:16
void Remove(MxCore *p_object)
Removes an object from all relevant world-managed lists or sets, and also detaches if needed.
Definition: legoworld.cpp:508
virtual void Enable(MxBool p_enable)
Enables or disables (pauses) the world and its main components.
Definition: legoworld.cpp:684
MxBool GetUnknown0xd0Empty()
Checks if the 'set0xd0' set is empty.
Definition: legoworld.h:295
MxBool m_worldStarted
Indicates if the world has successfully started and is considered active.
Definition: legoworld.h:388
MxLong Notify(MxParam &p_param) override
Notification callback responding to registered events such as EndAction and NewPresenter.
Definition: legoworld.cpp:212
MxResult Create(MxDSAction &p_dsAction) override
Initializes the world using an action, creating entity and sound lists, and camera controller.
Definition: legoworld.cpp:58
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
[AI] Notification parameter marking the end of an action, specialization of MxActionNotificationParam...
void Unregister(MxCore *p_listener)
[AI] Removes a previously registered listener and flushes any pending notifications for it.
void Register(MxCore *p_listener)
[AI] Registers a listener object to receive notifications.
[AI] Parameter object representing a single notification or event, carrying an identifier and sender ...
NotificationId GetNotification() const
[AI] Retrieves the current notification type of this parameter.
[AI] MxParam serves as a polymorphic base class for parameter passing in event and notification syste...
Definition: mxparam.h:7
[AI] Maintains persistent information about race progress, results, and high scores for up to five ra...
Definition: legorace.h:28
Entry m_state[5]
[AI] Entries for each tracked race/state (IDs 1..5).
Definition: legorace.h:137
MxResult Serialize(LegoStorage *p_storage) override
[AI] Serializes all race state entries to or from the given storage object.
Definition: legorace.cpp:138
undefined4 m_unk0x28
[AI] Unknown extra field, always initialized to zero.
Definition: legorace.h:138
Entry * GetState(MxU8 p_id)
[AI] Fetches a race state entry matching the given entry ID, or NULL if not found in the array.
Definition: legorace.cpp:151
RaceState()
[AI] Constructs a RaceState, initializing all races with default values and IDs (1 through 5).
Definition: legorace.cpp:116
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
MxBool g_unk0x100f119c
MxBool g_unk0x100f119c
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
LegoGameState * GameState()
[AI] Accessor for the game's central game state controller. [AI]
Definition: misc.cpp:61
void SetUserActor(LegoPathActor *p_userActor)
[AI] Sets the user-controlled LegoPathActor in the engine.
Definition: misc.cpp:168
LegoControlManager * ControlManager()
[AI] Accessor for the control manager through the input manager; manages higher-level user/game contr...
Definition: misc.cpp:53
LegoNavController * NavController()
[AI] Accessor for the navigation controller, managing player/camera navigation. [AI]
Definition: misc.cpp:77
LegoPathActor * UserActor()
[AI] Accessor for the user (player-controllable) LegoPathActor. [AI]
Definition: misc.cpp:85
MxNotificationManager * NotificationManager()
[AI] Returns the notification manager for system-wide state/update notifications.
Definition: mxmisc.cpp:17
@ c_notificationTransitioned
[AI] Object has transitioned states or locations [AI]
@ c_notificationType0
[AI] Undefined/Generic notification type [AI]
@ c_notificationEndAction
[AI] Indicates the end of an action [AI]
@ c_notificationClick
[AI] Mouse click event [AI]
@ c_notificationPathStruct
[AI] Data related to a path structure [AI]
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
signed short MxS16
[AI]
Definition: mxtypes.h:26
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
[AI] Entry for an individual race event/state, holding its identifier, unknown field,...
Definition: legorace.h:35
MxS16 m_unk0x02
[AI] Unknown field (usage unclear).
Definition: legorace.h:85
MxU8 m_id
[AI] Unique race or entry ID (1-based, up to 5).
Definition: legorace.h:84
MxResult Serialize(LegoStorage *p_storage)
[AI] Serializes or deserializes the entry using the specified LegoStorage.
Definition: legorace.h:64
MxS16 m_score
[AI] High score for this race/entry.
Definition: legorace.h:86