Isle
Loading...
Searching...
No Matches
legoraceactor.cpp
Go to the documentation of this file.
1#include "legoraceactor.h"
2
3#include "define.h"
5#include "legosoundmanager.h"
6#include "misc.h"
7#include "mxmisc.h"
8#include "mxtimer.h"
9#include "mxvariabletable.h"
10#include "roi/legoroi.h"
11
13
14// Initialized at LEGO1 0x100145a0
15// GLOBAL: LEGO1 0x10102b08
16// GLOBAL: BETA10 0x102114a8
17Mx3DPointFloat LegoRaceActor::g_unk0x10102b08 = Mx3DPointFloat(0.0, 2.0, 0.0);
18
19// FUNCTION: LEGO1 0x100145d0
21{
22 m_unk0x70 = 0;
23 m_unk0x08 = 0;
24}
25
26// FUNCTION: LEGO1 0x10014750
27// FUNCTION: BETA10 0x100c9bba
29{
30 MxS32 result = LegoPathActor::VTable0x68(p_v1, p_v2, p_v3);
31
32 if (m_userNavFlag && result) {
33 MxLong time = Timer()->GetTime();
34 if (time - g_unk0x100f3308 > 1000) {
35 g_unk0x100f3308 = time;
36 const char* soundKey = VariableTable()->GetVariable(g_strHIT_ACTOR_SOUND);
37
38 if (soundKey && *soundKey) {
40 }
41 }
42 }
43
44 return result;
45}
46
47// FUNCTION: LEGO1 0x100147f0
48// FUNCTION: BETA10 0x100c9c93
49MxU32 LegoRaceActor::VTable0x90(float p_time, Matrix4& p_transform)
50{
51 // Note: Code duplication with LegoExtraActor::VTable0x90
52 switch (m_actorState) {
53 case c_initial:
54 case c_one:
55 return TRUE;
56 case c_two:
57 m_unk0x08 = p_time + 2000.0f;
59 m_actorTime += (p_time - m_lastTime) * m_worldSpeed;
60 m_lastTime = p_time;
61 return FALSE;
62 case c_three:
63 assert(!m_userNavFlag);
64 Vector3 positionRef(p_transform[3]);
65
66 p_transform = m_roi->GetLocal2World();
67
68 if (m_unk0x08 > p_time) {
69 Mx3DPointFloat position;
70
71 position = positionRef;
72 positionRef.Clear();
73 p_transform.RotateX(0.6);
74 positionRef = position;
75
76 m_actorTime += (p_time - m_lastTime) * m_worldSpeed;
77 m_lastTime = p_time;
78
79 VTable0x74(p_transform);
80 return FALSE;
81 }
82 else {
84 m_unk0x08 = 0;
85
86 positionRef -= g_unk0x10102b08;
87 m_roi->FUN_100a58f0(p_transform);
88 return TRUE;
89 }
90 }
91
92 return FALSE;
93}
94
95// FUNCTION: LEGO1 0x10014a00
96// FUNCTION: BETA10 0x100c9f5c
98{
99 if (!p_actor->GetUserNavFlag()) {
100 if (p_actor->GetActorState() != c_initial) {
101 return FAILURE;
102 }
103
104 if (p_bool) {
105 MxMatrix matr;
106 LegoROI* roi = p_actor->GetROI(); // name verified by BETA10 0x100c9fcf
107 assert(roi);
108 matr = roi->GetLocal2World();
109
110 Vector3(matr[3]) += g_unk0x10102b08;
111
112 roi->FUN_100a58f0(matr);
113
114 p_actor->SetActorState(c_two);
115 }
116 }
117
118 return SUCCESS;
119}
120
121// FUNCTION: LEGO1 0x10014aa0
122// FUNCTION: BETA10 0x100ca038
124{
125 return SUCCESS;
126}
void VTable0x74(Matrix4 &p_transform) override
[AI] Applies the current animation's transforms to the provided matrix, propagates to mesh hierarchie...
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.
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
[AI] An actor that moves along a predefined path, supporting boundary transitions,...
Definition: legopathactor.h:32
MxFloat m_actorTime
[AI] Animation time for current path segment. [AI]
MxU32 GetActorState()
[AI] Gets the current navigation/animation state of the actor.
virtual MxBool GetUserNavFlag()
[AI] Returns user navigation state (whether actor follows player input).
MxU32 m_actorState
[AI] State and flags bitfield for path following logic. [AI]
@ c_initial
[AI] Default state upon creation or reset. [AI]
Definition: legopathactor.h:37
MxBool m_userNavFlag
[AI] TRUE if this actor is currently user/player controlled. [AI]
virtual MxS32 VTable0x68(Vector3 &p_v1, Vector3 &p_v2, Vector3 &p_v3)
[AI] Checks for collision/intersection with boundaries, geometry, and other actors along a traced seg...
MxFloat m_lastTime
[AI] Time of last update (used for delta calculations). [AI]
void SetActorState(MxU32 p_actorState)
[AI] Sets the navigation/path state of the actor.
[AI] Represents a Real-time Object Instance enriched with LEGO-specific functionality.
Definition: legoroi.h:43
[AI] Represents an actor that participates in races (usually vehicles or racers) on LEGO Island.
Definition: legoraceactor.h:22
MxResult HitActor(LegoPathActor *p_actor, MxBool p_bool) override
[AI] Handles logic when this actor is hit by another actor (e.g., collision interaction).
virtual MxResult FUN_10014aa0()
[AI] Additional race-specific behavior stub.
MxU32 VTable0x90(float p_time, Matrix4 &p_matrix) override
[AI] Updates the actor's state and transformation for a given simulation time.
MxS32 VTable0x68(Vector3 &p_v1, Vector3 &p_v2, Vector3 &p_v3) override
[AI] Handles collision/interaction queries between the actor and the environment or other actors.
LegoCacheSoundManager * GetCacheSoundManager()
[AI] Returns the cache sound manager used to cache and reuse sound effects.
4x4 Matrix class with virtual interface for manipulation and transformation.
Definition: matrix.h:24
void RotateX(const float &p_angle)
Applies a rotation (in radians or degrees, depending on implementation) about the X axis.
[AI] Represents a 3D point with floating-point precision, inheriting from Vector3.
Definition: mxgeometry3d.h:14
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
Definition: mxmatrix.h:16
MxLong GetTime()
Returns the current timer value in ms, depending on running state.
Definition: mxtimer.h:50
const char * GetVariable(const char *p_key)
Returns the value for the variable with a given key, or an empty string if not found.
const Matrix4 & GetLocal2World() const
Accessor for the current local-to-world transformation matrix.
void FUN_100a58f0(const Matrix4 &p_transform)
Assigns the given matrix as the local-to-world transformation and enables some internal flags.
[AI] 3D vector class, providing vector and cross-product operations in 3D space.
Definition: vector.h:249
void Clear() override
[AI] Sets every coordinate (x, y, z) to zero.
#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_strHIT_ACTOR_SOUND
[AI] Key for specifying or triggering sounds to play when an actor is hit.
Definition: define.cpp:145
MxLong g_unk0x100f3308
[AI] Timer for wall hit sound playback throttling in navigation [AI]
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#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
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
Definition: misc.cpp:22
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
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
unsigned int MxU32
[AI]
Definition: mxtypes.h:32