Isle
Loading...
Searching...
No Matches
legopathstruct.cpp
Go to the documentation of this file.
1#include "legopathstruct.h"
2
3#include "isle.h"
4#include "jukebox.h"
5#include "jukebox_actions.h"
7#include "legopathactor.h"
8#include "legoutils.h"
9#include "misc.h"
11#include "mxmisc.h"
13#include "scripts.h"
14
17
18// Flags used in isle.cpp
19extern MxU32 g_isleFlags;
20
21// GLOBAL: LEGO1 0x100f119c
22// GLOBAL: BETA10 0x100f119c
24
25// FUNCTION: LEGO1 0x1001b700
26void LegoPathStruct::HandleTrigger(LegoPathActor* p_actor, MxBool p_direction, MxU32 p_data)
27{
28 if (!HandleTrigger(p_actor, p_direction, p_data, FALSE) && g_unk0x100f119c) {
29 HandleTrigger(p_actor, p_direction, p_data, TRUE);
30 }
31}
32
33// FUNCTION: LEGO1 0x1001b740
34// FUNCTION: BETA10 0x100c26c5
35MxBool LegoPathStruct::HandleTrigger(LegoPathActor* p_actor, MxBool p_direction, MxU32 p_data, MxBool p_bool)
36{
37 MxBool triggered = FALSE;
38 MxBool bool2 = p_bool ? !p_direction : p_direction;
39
40 MxU32 flags = bool2 ? c_bit5 : c_bit6;
41 flags |= p_actor->GetCameraFlag() ? c_bit1 : (c_bit2 | c_bit3 | c_bit4);
42
43 if ((m_flags & flags & (c_bit5 | c_bit6 | c_bit7)) && (m_flags & flags & (c_bit1 | c_bit2 | c_bit3 | c_bit4))) {
44 triggered = TRUE;
45
46 switch (m_name[2]) {
47 case c_camAnim:
49 PlayCamAnim(p_actor, bool2, p_data, TRUE);
50 }
51 break;
52 case c_d: {
53 p_actor->VTable0x58(p_data);
54
56 p_actor->Notify(param);
57
58 LegoWorld* world = CurrentWorld();
59 if (world != NULL) {
60 NotificationManager()->Send(world, param);
61 }
62 break;
63 }
64 case c_e:
65 FUN_1001bc40(m_name, p_data, !(p_bool == FALSE));
66 break;
67 case c_g:
68 break;
69 case c_h: {
70 LegoHideAnimPresenter* presenter = m_world->GetHideAnimPresenter();
71 if (presenter != NULL) {
72 presenter->FUN_1006db40(p_data * 100);
73 }
74 break;
75 }
76 case c_music:
78 PlayMusic(p_direction, p_data);
79 }
80 break;
81 case c_s: {
82 LegoWorld* world = CurrentWorld();
83 if (world != NULL) {
85
86 if (world->Notify(param) != 0) {
87 break;
88 }
89 }
90
91 FUN_1001bc40(m_name, p_data, p_bool == FALSE);
92 break;
93 }
94 case c_w: {
95 LegoWorld* world = CurrentWorld();
96 if (world != NULL) {
98 NotificationManager()->Send(world, param);
99 }
100 break;
101 }
102 }
103 }
104
105 return triggered;
106}
107
108// FUNCTION: LEGO1 0x1001bc40
109// FUNCTION: BETA10 0x100c2a6c
110void LegoPathStruct::FUN_1001bc40(const char* p_name, MxU32 p_data, MxBool p_bool)
111{
112 MxDSAction action;
113 action.SetObjectId(p_data);
114 action.SetAtomId(m_atomId);
115
116 if (p_bool) {
117 action.SetUnknown24(-1);
118 Start(&action);
119 }
120 else {
121 action.SetUnknown24(-2);
122 DeleteObject(action);
123 }
124}
125
126// FUNCTION: LEGO1 0x1001bd10
127// FUNCTION: BETA10 0x100c2b4a
128void LegoPathStruct::PlayMusic(MxBool p_direction, MxU32 p_data)
129{
130 JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState");
131 if (state != NULL && state->m_active) {
132 return;
133 }
134
135 JukeboxScript::Script music[] = {
150 };
151
152 MxS16 triggersReff[24][2] = {{11, 10}, {6, 10}, {3, 1}, {4, 1}, {1, 4}, {1, 4}, {13, 2}, {13, 2},
153 {13, 2}, {4, 10}, {11, 9}, {9, 7}, {8, 7}, {8, 5}, {5, 2}, {2, 4},
154 {4, 2}, {4, 5}, {11, 4}, {12, 10}, {10, 12}, {10, 12}, {14, 2}, {14, 2}};
155
156 MxDSAction action;
157 action.SetAtomId(*g_jukeboxScript);
158 action.SetUnknown24(-1);
159
160 if (p_data <= sizeOfArray(triggersReff)) {
161 action.SetObjectId(music[triggersReff[p_data - 1][p_direction == FALSE] - 1]);
162 }
163
164 if (action.GetObjectId() != -1) {
166 }
167}
MxU32 g_isleFlags
Definition: isle.cpp:46
@ c_playMusic
[AI] If set, background music plays.
Definition: isle.h:184
@ c_playCamAnims
[AI] If set, enables camera animation sequences.
Definition: isle.h:183
[AI] Represents the music selection state for the Jukebox in the game.
Definition: jukebox.h:14
MxU32 m_active
[AI] Flag indicating whether the Jukebox is currently active (1=active, 0=inactive)....
Definition: jukebox.h:47
virtual void VTable0x58(MxFloat p_unk0x70)
[AI] Sets a floating point property, unknown usage (possibly animation or audio parameter).
Definition: legoactor.h:71
MxLong Notify(MxParam &p_param) override
[AI] Handles event notification for the entity, most notably user clicks, using polymorphic dispatch.
Definition: legoentity.cpp:466
MxBool GetCameraFlag()
[AI] Returns whether this entity is flagged as camera (affects world/camera synchronization)....
Definition: legoentity.h:167
LegoState * GetState(const char *p_stateName)
Find an existing state (LegoState-derived) object by its registered script/class name.
[AI] Presenter class responsible for controlling animations that hide or show actors based on animati...
void FUN_1006db40(LegoTime p_time)
[AI] Traverses the animation node hierarchy starting at the root and synchronizes visibility flags fo...
[AI] An actor that moves along a predefined path, supporting boundary transitions,...
Definition: legopathactor.h:32
[AI] Specialized notification parameter used for path structure related events in LEGO Island.
[AI] Represents a trigger/control element in the LEGO world's path system, linked logically to the wo...
@ c_camAnim
[AI] Camera animation trigger.
@ c_e
[AI] Event trigger.
@ c_music
[AI] Music control trigger.
@ c_s
[AI] State change trigger.
@ c_d
[AI] Door or passage transition trigger.
@ c_w
[AI] World notification trigger.
@ c_h
[AI] Hide animation trigger.
@ c_g
[AI] Generic placeholder trigger.
virtual void HandleTrigger(LegoPathActor *p_actor, MxBool p_direction, MxU32 p_data)
[AI] Main trigger handler; evaluates flags and name-based script to decide what action to take when a...
Represents the active 3D world, holding all entity, animation, sound, path, and ROI objects.
Definition: legoworld.h:49
LegoHideAnimPresenter * GetHideAnimPresenter()
Gets the animation presenter responsible for hide animations in this world.
Definition: legoworld.h:307
MxLong Notify(MxParam &p_param) override
Notification callback responding to registered events such as EndAction and NewPresenter.
Definition: legoworld.cpp:212
MxResult PlayMusic(MxDSAction &p_action, undefined4 p_speed, MxPresenter::TickleState p_tickleState)
[AI] Initiates playback of a new background music action with specified speed and target tickle state...
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
virtual void SetAtomId(MxAtomId p_atomId)
[AI] Sets the atom id for this object instance, used for indexing or lookup.
Definition: mxdsobject.h:118
void SetUnknown24(MxS16 p_unk0x24)
[AI] Sets the unknown field at 0x24 (possibly version/state).
Definition: mxdsobject.h:151
void SetObjectId(MxU32 p_objectId)
[AI] Sets the object id (for serialization or lookup).
Definition: mxdsobject.h:147
MxU32 GetObjectId()
[AI] Returns the object id numeric value.
Definition: mxdsobject.h:130
MxResult Send(MxCore *p_listener, const MxNotificationParam &p_param)
[AI] Queues a notification to be sent to a specific registered listener.
@ e_repeating
[AI] Presentation is repeating (e.g., looping media).
Definition: mxpresenter.h:28
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define sizeOfArray(arr)
Definition: decomp.h:23
MxU32 g_isleFlags
Definition: isle.cpp:46
MxBool g_unk0x100f119c
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
void PlayCamAnim(LegoPathActor *p_actor, MxBool p_unused, MxU32 p_location, MxBool p_bool)
[AI] Initiates a camera animation for a specific path actor, or falls back to default animation trigg...
Definition: legoutils.cpp:459
LegoGameState * GameState()
[AI] Accessor for the game's central game state controller. [AI]
Definition: misc.cpp:61
MxBackgroundAudioManager * BackgroundAudioManager()
[AI] Accessor for the background audio manager. Used for background music and ambient sounds....
Definition: misc.cpp:37
LegoWorld * CurrentWorld()
[AI] Accessor for the currently active LegoWorld instance. [AI]
Definition: misc.cpp:93
MxResult Start(MxDSAction *p_dsAction)
[AI] Schedules and initiates execution of a script action.
Definition: mxmisc.cpp:97
void DeleteObject(MxDSAction &p_dsAction)
[AI] Deletes the specified action object, removing it from the global action list.
Definition: mxmisc.cpp:105
MxNotificationManager * NotificationManager()
[AI] Returns the notification manager for system-wide state/update notifications.
Definition: mxmisc.cpp:17
@ c_notificationPathStruct
[AI] Data related to a path structure [AI]
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
signed short MxS16
[AI]
Definition: mxtypes.h:26
unsigned int MxU32
[AI]
Definition: mxtypes.h:32
@ c_Quiet_Audio
[AI] Quiet/ambient audio track, likely used to mute or dampen music.
@ c_BeachBlvd_Music
[AI] Music for Beach Boulevard.
@ c_Beach_Music
[AI] Ambient/area music for the beach.
@ c_Hospital_Music
[AI] Background music for the hospital.
@ c_Park_Music
[AI] Music for park environments.
@ c_ResidentalArea_Music
[AI] Music for the residential area environment.
@ c_InformationCenter_Music
[AI] Background music for the information center.
@ c_CentralNorthRoad_Music
[AI] Music for central northern roads.
@ c_PoliceStation_Music
[AI] Music played inside or near the police station.
@ c_Cave_Music
[AI] Music for cave locations.
@ c_RaceTrackRoad_Music
[AI] Music for the racetrack roads.
@ c_Jail_Music
[AI] Background music for the jail area.
@ c_CentralRoads_Music
[AI] Background music for LEGO Island central roads.
@ c_GarageArea_Music
[AI] Music in the garage or vehicle area.
[AI] Contains global script AtomId pointers and utility functions for managing script AtomIds in LEGO...
MxAtomId * g_jukeboxScript
[AI] Script AtomId for the Jukebox entity/event script.
Definition: scripts.cpp:70
[AI] Abstract base describing named, flag-based elements of the LEGO world path system.
MxU32 m_flags
[AI] Bitfield of state and trigger flags for fast matching in trigger logic.
char * m_name
[AI] Dynamically allocated name for this path struct instance (e.g., a label or trigger identifier).
@ c_bit2
[AI] Bitmask for actor direction/state.
@ c_bit7
[AI] Extra bit, typically used for advanced logic/filtering [AI].
@ c_bit4
[AI] Bitmask for extra control/state.
@ c_bit6
[AI] Bitmask for direction or branch 'false' (see HandleTrigger) [AI].
@ c_bit3
[AI] Bitmask for direction filter/type.
@ c_bit5
[AI] Bitmask for direction or branch 'true' (see HandleTrigger) [AI].
@ c_bit1
[AI] Bitmask for camera flag/actor trigger logic.