Isle
Loading...
Searching...
No Matches
legoactor.cpp
Go to the documentation of this file.
1#include "legoactor.h"
2
3#include "define.h"
5#include "legosoundmanager.h"
6#include "misc.h"
7#include "mxutilities.h"
8#include "roi/legoroi.h"
9
11
12// GLOBAL: LEGO1 0x100f32d0
13const char* g_actorNames[] = {"none", "pepper", "mama", "papa", "nick", "laura", "The_Brickster!"};
14
15// FUNCTION: LEGO1 0x1002d110
17{
18 m_frequencyFactor = 0.0f;
19 m_sound = NULL;
20 m_unk0x70 = 0.0f;
21 m_unk0x10 = 0;
22 m_actorId = 0;
23}
24
25// FUNCTION: LEGO1 0x1002d320
27{
28 if (m_sound) {
29 m_sound->Stop();
30 }
31}
32
33// FUNCTION: LEGO1 0x1002d390
34void LegoActor::ParseAction(char* p_extra)
35{
36 MxFloat speed = 0.0F;
37 char value[256];
38 value[0] = '\0';
39
40 if (KeyValueStringParse(value, g_strATTACH_CAMERA, p_extra)) {
42
43 if (value[0]) {
44 Mx3DPointFloat location(0.0F, 0.0F, 0.0F);
45 Mx3DPointFloat direction(0.0F, 0.0F, 1.0F);
46 Mx3DPointFloat up(0.0F, 1.0F, 0.0F);
47
48 char* token = strtok(value, g_parseExtraTokens);
49 if (token != NULL) {
50 location[0] = atof(token);
51 }
52
53 token = strtok(NULL, g_parseExtraTokens);
54 if (token != NULL) {
55 location[1] = atof(token);
56 }
57
58 token = strtok(NULL, g_parseExtraTokens);
59 if (token != NULL) {
60 location[2] = atof(token);
61 }
62
63 token = strtok(NULL, g_parseExtraTokens);
64 if (token != NULL) {
65 direction[0] = atof(token);
66 }
67
68 token = strtok(NULL, g_parseExtraTokens);
69 if (token != NULL) {
70 direction[1] = atof(token);
71 }
72
73 token = strtok(NULL, g_parseExtraTokens);
74 if (token != NULL) {
75 direction[2] = atof(token);
76 }
77
78 token = strtok(NULL, g_parseExtraTokens);
79 if (token != NULL) {
80 up[0] = atof(token);
81 }
82
83 token = strtok(NULL, g_parseExtraTokens);
84 if (token != NULL) {
85 up[1] = atof(token);
86 }
87
88 token = strtok(NULL, g_parseExtraTokens);
89 if (token != NULL) {
90 up[2] = atof(token);
91 }
92
93 SetWorldTransform(location, direction, up);
94 }
95 else {
97 }
98 }
99
100 if (KeyValueStringParse(value, g_strSPEED, p_extra)) {
101 speed = atof(value);
102 SetWorldSpeed(speed);
103 }
104
105 if (KeyValueStringParse(value, g_strSOUND, p_extra)) {
106 m_sound = SoundManager()->GetCacheSoundManager()->Play(value, GetROI()->GetName(), TRUE);
107 }
108
109 if (KeyValueStringParse(value, g_strMUTE, p_extra)) {
110 Mute(TRUE);
111 }
112
113 if (KeyValueStringParse(value, g_strVISIBILITY, p_extra)) {
114 GetROI()->SetVisibility(strcmpi(value, "FALSE") != 0);
115 }
116}
117
118// FUNCTION: LEGO1 0x1002d660
120{
121 return g_actorNames[p_id];
122}
123
124// FUNCTION: LEGO1 0x1002d670
125void LegoActor::SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2)
126{
127 if (p_roi) {
128 const char* name = p_roi->GetName();
129
130 for (MxU32 i = 1; i <= sizeOfArray(g_actorNames) - 2; i++) {
131 if (!strcmpi(name, g_actorNames[i])) {
132 m_type = e_actor;
133 m_actorId = i;
134 break;
135 }
136 }
137 }
138
139 LegoEntity::SetROI(p_roi, p_bool1, p_bool2);
140}
141
142// FUNCTION: LEGO1 0x1002d6e0
143// FUNCTION: BETA10 0x1003d6f2
145{
146 if (m_sound != NULL) {
147 m_sound->MuteStop(p_muted);
148 }
149}
[AI] Represents an actor (character) entity in the LEGO Island 3D world, providing specific actor log...
Definition: legoactor.h:12
LegoCacheSound * m_sound
[AI] Pointer to a currently active sound instance played by the actor, if any.
Definition: legoactor.h:95
MxFloat m_unk0x70
[AI] Unknown float property, likely used for advanced audio/animation control. [AI_SUGGESTED_NAME: m_...
Definition: legoactor.h:96
LegoActor()
[AI] Constructs new LegoActor, initializes members.
Definition: legoactor.cpp:16
static const char * GetActorName(MxU8 p_id)
[AI] Gets the static display name of an actor by ID.
Definition: legoactor.cpp:119
MxFloat m_frequencyFactor
[AI] The frequency/pitch scaling factor for the actor's sound (default 0 == normal).
Definition: legoactor.h:94
MxU8 m_actorId
[AI] Unique identifier for this actor, corresponding to enum above.
Definition: legoactor.h:97
void Mute(MxBool p_muted)
[AI] Mutes or unmutes the actor's current sound.
Definition: legoactor.cpp:144
void SetROI(LegoROI *p_roi, MxBool p_bool1, MxBool p_bool2) override
[AI] Sets the Region of Interest (ROI, i.e.
Definition: legoactor.cpp:125
void ParseAction(char *p_extra) override
[AI] Parses an action string and applies parsed behaviors to the actor.
Definition: legoactor.cpp:34
~LegoActor() override
[AI] Cleans up LegoActor; stops sound if active.
Definition: legoactor.cpp:26
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 MuteStop(MxBool p_mute)
Mutes/unmutes by stopping (mute) or resuming playback.
void Stop()
Immediately stops playback and resets buffer, clearing event tag and position cues.
virtual void SetROI(LegoROI *p_roi, MxBool p_bool1, MxBool p_bool2)
[AI] Assigns a 3D ROI (3D object instance) to this entity, controlling how it appears/acts in the wor...
Definition: legoentity.cpp:127
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
LegoROI * GetROI()
[AI] Gets the ROI (Realtime Object Instance) associated with this entity. [AI]
Definition: legoentity.h:161
MxU8 m_type
[AI] The entity type (Type enum value). [AI]
Definition: legoentity.h:221
virtual void ResetWorldTransform(MxBool p_cameraFlag)
[AI] Resets the transformation for this entity (e.g., used with camera transitions).
Definition: legoentity.cpp:41
virtual void SetWorldTransform(const Vector3 &p_location, const Vector3 &p_direction, const Vector3 &p_up)
[AI] Explicitly sets the world transformation (location, direction, up vector) for this entity.
Definition: legoentity.cpp:71
@ e_actor
[AI] Standard character entity controlled by scripts or user [AI]
Definition: legoentity.h:20
MxU8 m_unk0x10
[AI] Unknown state/flag, used mainly to guard against repeated actions or manage animation/sound stat...
Definition: legoentity.h:197
[AI] Represents a Real-time Object Instance enriched with LEGO-specific functionality.
Definition: legoroi.h:43
const LegoChar * GetName() const
[AI] Gets this ROI's name.
Definition: legoroi.h:287
LegoCacheSoundManager * GetCacheSoundManager()
[AI] Returns the cache sound manager used to cache and reuse sound effects.
[AI] Represents a 3D point with floating-point precision, inheriting from Vector3.
Definition: mxgeometry3d.h:14
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 sizeOfArray(arr)
Definition: decomp.h:23
const char * g_strATTACH_CAMERA
[AI] Command for attaching or associating the camera with an entity via script instructions.
Definition: define.cpp:13
const char * g_strSPEED
[AI] Used to read or set speed values for entities/animations via scripts or data files.
Definition: define.cpp:101
const char * g_strMUTE
[AI] Keyword for muting sound or disabling audio for an entity or context.
Definition: define.cpp:97
const char * g_parseExtraTokens
[AI] Delimiter tokens for parsing extra parameters in scripts or command strings.
Definition: define.cpp:141
const char * g_strSOUND
[AI] Symbolic string used to reference sound effects or sound object properties in the scripting syst...
Definition: define.cpp:93
const char * g_strVISIBILITY
[AI] Used when specifying visibility toggles or changes for objects/entities in scripting.
Definition: define.cpp:121
const char * g_actorNames[]
Array of actor names indexed by actor ID. [AI].
Definition: legoactor.cpp:13
const char * g_actorNames[7]
Array of actor names indexed by actor ID. [AI].
Definition: legoactor.cpp:13
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
Definition: misc.cpp:22
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
float MxFloat
[AI]
Definition: mxtypes.h:68
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
unsigned int MxU32
[AI]
Definition: mxtypes.h:32
MxBool KeyValueStringParse(char *, const char *, const char *)
Searches p_string for a key command and copies its associated value to p_output.
Definition: mxutilities.cpp:85