Isle
Loading...
Searching...
No Matches
act2brick.cpp
Go to the documentation of this file.
1#include "act2brick.h"
2
5#include "legosoundmanager.h"
6#include "legoworld.h"
7#include "misc.h"
8#include "mxmisc.h"
10#include "mxnotificationparam.h"
11#include "mxticklemanager.h"
12#include "mxtimer.h"
13#include "roi/legoroi.h"
14
15#include <assert.h>
16#include <stdio.h>
17#include <vec.h>
18
20
21// GLOBAL: LEGO1 0x100f7a38
22// GLOBAL: BETA10 0x101dc480
23const LegoChar* Act2Brick::g_lodNames[] =
24 {"xchbase1", "xchblad1", "xchseat1", "xchtail1", "xhback1", "xhljet1", "xhmidl1", "xhmotr1", "xhsidl1", "xhsidr1"};
25
26// GLOBAL: LEGO1 0x100f7a60
27MxLong Act2Brick::g_lastHitActorTime = 0;
28
29// FUNCTION: LEGO1 0x1007a2b0
30// FUNCTION: BETA10 0x10012a30
32{
33 m_whistleSound = NULL;
34 m_unk0x164 = 0;
35}
36
37// FUNCTION: LEGO1 0x1007a470
39{
41}
42
43// FUNCTION: LEGO1 0x1007a4e0
44// FUNCTION: BETA10 0x10012ad5
46{
47 if (m_roi != NULL) {
48 return FAILURE;
49 }
50
51 char name[12];
52 sprintf(name, "chbrick%d", p_index);
53
54 m_roi = CharacterManager()->CreateAutoROI(name, g_lodNames[p_index], FALSE);
55 assert(m_roi);
56
57#ifndef BETA10
58 BoundingSphere sphere;
59
60 sphere.Center() = m_roi->GetBoundingSphere().Center();
61 sphere.Center()[1] -= 0.3;
62
63 if (p_index < 6) {
64 sphere.Radius() = m_roi->GetBoundingSphere().Radius() * 0.5f;
65 }
66 else {
67 sphere.Radius() = m_roi->GetBoundingSphere().Radius() * 2.0f;
68 }
69
70 m_roi->SetBoundingSphere(sphere);
71#endif
72
73 m_roi->SetEntity(this);
74 CurrentWorld()->Add(this);
75 m_unk0x164 = 1;
76 return SUCCESS;
77}
78
79// FUNCTION: LEGO1 0x1007a620
80// FUNCTION: BETA10 0x10012ba2
82{
84 CurrentWorld()->Remove(this);
85
86 if (m_roi != NULL) {
88 m_roi = NULL;
89 }
90
91 m_unk0x164 = 0;
92}
93
94// FUNCTION: LEGO1 0x1007a670
95// FUNCTION: BETA10 0x10012c04
96void Act2Brick::FUN_1007a670(MxMatrix& p_param1, MxMatrix& p_param2, LegoPathBoundary* p_boundary)
97{
98 m_unk0x17c = p_param2[3];
99 m_unk0x168 = p_param2[3];
100 m_unk0x168 -= p_param1[3];
101 m_unk0x168 /= 8.0f;
102
103 m_unk0x190 = 0;
104 TickleManager()->RegisterClient(this, 20);
105
106 m_unk0x164 = 2;
107 CurrentWorld()->PlaceActor(this);
108 p_boundary->AddActor(this);
109
111 m_roi->FUN_100a58f0(p_param1);
112 m_roi->VTable0x14();
114}
115
116// FUNCTION: LEGO1 0x1007a750
118{
119 MxLong time = Timer()->GetTime();
120 MxLong diff = time - g_lastHitActorTime;
121
122 if (strcmp(p_actor->GetROI()->GetName(), "pepper")) {
123 return SUCCESS;
124 }
125
126 g_lastHitActorTime = time;
127 if (diff > 1000) {
128 SoundManager()->GetCacheSoundManager()->Play("hitactor", NULL, FALSE);
129 }
130
131 return SUCCESS;
132}
133
134// FUNCTION: LEGO1 0x1007a7f0
135// FUNCTION: BETA10 0x10012d46
137{
138 MxMatrix local2world(m_roi->GetLocal2World());
139 m_unk0x190++;
140
141 if (m_unk0x190 >= 8) {
142 local2world.SetTranslation(m_unk0x17c[0], m_unk0x17c[1], m_unk0x17c[2]);
143 m_unk0x164 = 3;
145 }
146 else {
147 VPV3(local2world[3], local2world[3], m_unk0x168);
148 }
149
150 m_roi->FUN_100a58f0(local2world);
151 m_roi->VTable0x14();
152 return SUCCESS;
153}
154
155// FUNCTION: LEGO1 0x1007a8c0
156// FUNCTION: BETA10 0x10012ec4
158{
159 MxNotificationParam& param = (MxNotificationParam&) p_param;
160
163
164 if (m_whistleSound != NULL) {
166 }
167
170 return 1;
171 }
172
173 assert(0);
174 return 0;
175}
176
177// FUNCTION: LEGO1 0x1007a990
178// FUNCTION: BETA10 0x10012fca
180{
181 if (m_whistleSound == NULL) {
182 m_whistleSound = SoundManager()->GetCacheSoundManager()->Play("xwhistle", m_roi->GetName(), TRUE);
183 }
184}
185
186// FUNCTION: LEGO1 0x1007a9d0
187// FUNCTION: BETA10 0x1001300f
189{
190 if (m_whistleSound != NULL) {
191 SoundManager()->GetCacheSoundManager()->Stop(m_whistleSound);
192 m_whistleSound = NULL;
193 }
194}
195
196// FUNCTION: LEGO1 0x1007aa00
198{
199 if (m_whistleSound != NULL) {
200 m_whistleSound->MuteSilence(p_muted);
201 }
202}
[AI] Represents a special 'brick' object in the LEGO Island "Act 2" sequence, derived from LegoPathAc...
Definition: act2brick.h:12
MxResult Create(MxS32 p_index)
[AI] Instantiates and initializes the brick actor in the world with a specified index/type,...
Definition: act2brick.cpp:45
~Act2Brick() override
[AI] Destructor. Unregisters from the tickle manager and clears up resources.
Definition: act2brick.cpp:38
MxResult HitActor(LegoPathActor *p_actor, MxBool) override
[AI] Called when another actor (typically Pepper) intersects or "hits" this brick.
Definition: act2brick.cpp:117
void FUN_1007a670(MxMatrix &p_param1, MxMatrix &p_param2, LegoPathBoundary *p_boundary)
[AI] Starts the brick motion and animation parameters, registers the object for tickling and places t...
Definition: act2brick.cpp:96
MxResult Tickle() override
[AI] Called periodically when registered with the TickleManager to animate the movement and state cha...
Definition: act2brick.cpp:136
void PlayWhistleSound()
[AI] Begins playback of the looping whistle sound associated with this brick, if not already playing.
Definition: act2brick.cpp:179
void StopWhistleSound()
[AI] Stops the playback of the whistle sound if it is currently playing.
Definition: act2brick.cpp:188
void Mute(MxBool p_muted)
[AI] Mutes or unmutes the whistle sound according to the argument given.
Definition: act2brick.cpp:197
void Remove()
[AI] Removes this brick from the world, releases associated resources, and notifies the character man...
Definition: act2brick.cpp:81
Act2Brick()
[AI] Constructs an Act2Brick. Initializes internal state, including whistle sound and tracking state ...
Definition: act2brick.cpp:31
MxLong Notify(MxParam &p_param) override
[AI] Handles notifications.
Definition: act2brick.cpp:157
[AI] Represents a bounding sphere in 3D space with center and radius.
Definition: roi.h:56
const float & Radius() const
[AI] Const accessor for the sphere radius.
Definition: roi.h:72
const Vector3 & Center() const
[AI] Const accessor for the center of the sphere.
Definition: roi.h:62
LegoCacheSound * Play(const char *p_key, const char *p_name, MxBool p_looping)
[AI] Plays a sound identified by key, with the given playback name and looping flag.
void Stop(LegoCacheSound *&p_sound)
[AI] Stops playback of the specified sound object.
void MuteSilence(MxBool p_muted)
Mutes/unmutes by scaling volume to minimum (muted) or restoring original volume.
LegoROI * CreateAutoROI(const char *p_name, const char *p_lodName, MxBool p_createEntity)
[AI] Creates an "auto" ROI object with the given name, LOD name, and optional entity creation.
void ReleaseActor(const char *p_name)
[AI] Releases a character/ROI by name, decrementing its reference count and deleting if zero.
LegoROI * GetROI()
[AI] Gets the ROI (Realtime Object Instance) associated with this entity. [AI]
Definition: legoentity.h:161
LegoROI * m_roi
[AI] Pointer to this entity's currently assigned ROI (3D instance in the world). [AI]
Definition: legoentity.h:215
[AI] An actor that moves along a predefined path, supporting boundary transitions,...
Definition: legopathactor.h:32
@ c_disabled
[AI] Marks as disabled or inactive for path follow logic. [AI]
Definition: legopathactor.h:41
void SetActorState(MxU32 p_actorState)
[AI] Sets the navigation/path state of the actor.
[AI] Represents a path segment or boundary in the navigation network for actors (vehicles,...
MxResult AddActor(LegoPathActor *p_actor)
[AI] Adds the given actor to this path boundary and sets its boundary pointer.
void SetBoundingSphere(const BoundingSphere &p_sphere)
[AI] Sets the local and world bounding spheres.
Definition: legoroi.h:317
void SetEntity(LegoEntity *p_entity)
[AI] Associates a LegoEntity with this ROI (typically called by parent entity/logic).
Definition: legoroi.h:305
const LegoChar * GetName() const
[AI] Gets this ROI's name.
Definition: legoroi.h:287
BoundingSphere & GetBoundingSphere()
[AI] Accesses the local bounding sphere object.
Definition: legoroi.h:299
LegoCacheSoundManager * GetCacheSoundManager()
[AI] Returns the cache sound manager used to cache and reuse sound effects.
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
MxResult PlaceActor(LegoPathActor *p_actor, const char *p_name, MxS32 p_src, float p_srcScale, MxS32 p_dest, float p_destScale)
Places an actor along a path, from source to destination, using named references and scaling.
Definition: legoworld.cpp:267
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
virtual void SetTranslation(const float &p_x, const float &p_y, const float &p_z)
Overwrites the translation part of the matrix (last column).
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
Definition: mxmatrix.h:16
MxResult Send(MxCore *p_listener, const MxNotificationParam &p_param)
[AI] Queues a notification to be sent to a specific registered listener.
[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
virtual void UnregisterClient(MxCore *p_client)
[AI] Unregisters (marks for destruction) a previously registered client.
virtual void RegisterClient(MxCore *p_client, MxTime p_interval)
[AI] Registers an MxCore object to receive periodic tickles.
MxLong GetTime()
Returns the current timer value in ms, depending on running state.
Definition: mxtimer.h:50
const Matrix4 & GetLocal2World() const
Accessor for the current local-to-world transformation matrix.
virtual void VTable0x14()
[AI] Calls VTable0x1c().
Definition: orientableroi.h:64
void FUN_100a58f0(const Matrix4 &p_transform)
Assigns the given matrix as the local-to-world transformation and enables some internal flags.
unsigned char GetVisibility()
[AI] Returns the visibility flag; true if visible, false if hidden.
Definition: roi.h:228
void SetVisibility(unsigned char p_visible)
[AI] Sets the visibility flag to the provided value.
Definition: roi.h:235
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
char LegoChar
[AI] Alias for char, for use in character/byte data and string handling.
Definition: legotypes.h:83
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
LegoCharacterManager * CharacterManager()
[AI] Accessor for the character manager, which manages in-game characters/NPCs. [AI]
Definition: misc.cpp:101
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
Definition: misc.cpp:22
LegoWorld * CurrentWorld()
[AI] Accessor for the currently active LegoWorld instance. [AI]
Definition: misc.cpp:93
MxTimer * Timer()
[AI] Returns the global simulation timer.
Definition: mxmisc.cpp:33
MxNotificationManager * NotificationManager()
[AI] Returns the notification manager for system-wide state/update notifications.
Definition: mxmisc.cpp:17
MxTickleManager * TickleManager()
[AI] Provides access to the global tickle manager.
Definition: mxmisc.cpp:25
@ c_notificationType22
[AI] Unspecified notification type [AI]
@ c_notificationClick
[AI] Mouse click event [AI]
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
signed int MxS32
[AI]
Definition: mxtypes.h:38
#define VPV3(to, v, w)
Definition: vec.h:370