Isle
Loading...
Searching...
No Matches
legocharactermanager.h
Go to the documentation of this file.
1#ifndef LEGOCHARACTERMANAGER_H
2#define LEGOCHARACTERMANAGER_H
3
4#include "decomp.h"
5#include "mxstl/stlcompat.h"
6#include "mxtypes.h"
7#include "mxvariable.h"
8#include "roi/legoroi.h"
9
10class LegoActor;
11class LegoExtraActor;
12class LegoStorage;
13class LegoROI;
14
15#pragma warning(disable : 4237)
16
31 MxBool operator()(const char* const& p_a, const char* const& p_b) const { return strcmpi(p_a, p_b) < 0; }
32};
33
50 {
51 m_roi = p_roi;
52 m_refCount = 1;
53 }
57 ~LegoCharacter() { delete m_roi; }
58
62 void AddRef() { m_refCount++; }
63
69 {
70 if (m_refCount != 0) {
71 m_refCount--;
72 }
73 return m_refCount;
74 }
75
78};
79
89typedef map<char*, LegoCharacter*, LegoCharacterComparator> LegoCharacterMap;
90
103public:
108 CustomizeAnimFileVariable(const char* p_key);
109
115 void SetValue(const char* p_value) override; // vtable+0x04
116};
117
132public:
137
142
149 MxResult Write(LegoStorage* p_storage);
150
157 MxResult Read(LegoStorage* p_storage);
158
164 const char* GetActorName(MxS32 p_index);
165
170
177 LegoROI* GetActorROI(const char* p_name, MxBool p_createEntity);
178
183 void Init();
184
190 static void SetCustomizeAnimFile(const char* p_value);
191
197 static MxBool IsActor(const char* p_name);
198
202 void ReleaseAllActors();
203
209 MxBool Exists(const char* p_name);
210
216 MxU32 GetRefCount(LegoROI* p_roi);
217
222 void ReleaseActor(const char* p_name);
223
228 void ReleaseActor(LegoROI* p_roi);
229
235 void ReleaseAutoROI(LegoROI* p_roi);
236
243 MxBool FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_texture);
244
250 LegoExtraActor* GetExtraActor(const char* p_name);
251
257 LegoActorInfo* GetActorInfo(const char* p_name);
258
265
272 MxBool SwitchColor(LegoROI* p_roi, LegoROI* p_targetROI);
273
280
286 MxBool SwitchSound(LegoROI* p_roi);
287
293 MxBool SwitchMove(LegoROI* p_roi);
294
300 MxBool SwitchMood(LegoROI* p_roi);
301
308
315 MxU32 GetSoundId(LegoROI* p_roi, MxBool p_und);
316
322 MxU8 GetMood(LegoROI* p_roi);
323
331 LegoROI* CreateAutoROI(const char* p_name, const char* p_lodName, MxBool p_createEntity);
332
340
348 LegoROI* FUN_10085a80(const char* p_name, const char* p_lodName, MxBool p_createEntity);
349
354 static const char* GetCustomizeAnimFile() { return g_customizeAnimFile; }
355
356private:
362 LegoROI* CreateActorROI(const char* p_key);
363
368 void RemoveROI(LegoROI* p_roi);
369
376 LegoROI* FindChildROI(LegoROI* p_roi, const char* p_name);
377
378 static char* g_customizeAnimFile;
379 static MxU32 g_maxMove;
380 static MxU32 g_maxSound;
381
382 LegoCharacterMap* m_characters;
383 CustomizeAnimFileVariable* m_customizeAnimFile;
384};
385
386// clang-format off
387// TEMPLATE: LEGO1 0x1001a690
388// list<ROI *,allocator<ROI *> >::_Buynode
389
390// TEMPLATE: LEGO1 0x10035790
391// ?_Construct@@YAXPAPAVROI@@ABQAV1@@Z
392
393// TEMPLATE: LEGO1 0x10082b90
394// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::~_Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >
395
396// TEMPLATE: LEGO1 0x10082c60
397// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::iterator::_Inc
398
399// TEMPLATE: LEGO1 0x10082ca0
400// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::erase
401
402// TEMPLATE: LEGO1 0x100830f0
403// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Erase
404
405// TEMPLATE: LEGO1 0x10083130
406// map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::~map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >
407
408// TEMPLATE: LEGO1 0x10083840
409// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::iterator::_Dec
410
411// TEMPLATE: LEGO1 0x10083890
412// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Insert
413
414// TEMPLATE: LEGO1 0x10085500
415// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::insert
416
417// TEMPLATE: LEGO1 0x10085790
418// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Buynode
419
420// TEMPLATE: LEGO1 0x100857b0
421// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Lrotate
422
423// TEMPLATE: LEGO1 0x10085810
424// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Rrotate
425
426// GLOBAL: LEGO1 0x100fc508
427// _Tree<char *,pair<char * const,LegoCharacter *>,map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Nil
428// clang-format on
429
430#endif // LEGOCHARACTERMANAGER_H
[AI] MxVariable subclass used to represent and propagate changes to the character customization anima...
void SetValue(const char *p_value) override
[AI] Sets the variable value and propagates customization file changes to relevant managers.
[AI] Represents an actor (character) entity in the LEGO Island 3D world, providing specific actor log...
Definition: legoactor.h:12
[AI] Manages reference-counted characters and provides character creation, switching,...
MxBool SwitchMood(LegoROI *p_roi)
[AI] Cycles the mood type for the actor, updating the per-actor info.
LegoCharacterManager()
[AI] Constructs the character manager, initializing tables and the customizable animation variable.
LegoActorInfo * GetActorInfo(const char *p_name)
[AI] Returns the actor info struct for the character of the given name, or NULL if not found.
MxResult Write(LegoStorage *p_storage)
[AI] Writes the persistent character info data to a storage object.
void ReleaseAllActors()
[AI] Releases all actors associated with this manager, unregistering/releasing references until destr...
MxU32 GetNumActors()
[AI] Returns the number of actors registered in global g_actorInfo.
void Init()
[AI] Initializes all actor info structures based on their templates/defaults.
LegoExtraActor * GetExtraActor(const char *p_name)
[AI] Returns an extra actor associated with a given character name, or NULL if not found.
MxU32 GetSoundId(LegoROI *p_roi, MxBool p_und)
[AI] Returns the sound ID for the ROI's current sound/mood selection.
MxResult Read(LegoStorage *p_storage)
[AI] Reads character info data from a storage object.
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.
static void SetCustomizeAnimFile(const char *p_value)
[AI] Sets the value of the customization animation file variable, propagating to all relevant subsyst...
MxU8 GetMood(LegoROI *p_roi)
[AI] Returns the current mood value (0-3) for the actor associated with the ROI.
MxResult FUN_10085870(LegoROI *p_roi)
[AI] Initializes auto-ROI with bounding volume and transformation.
MxU32 GetRefCount(LegoROI *p_roi)
[AI] Returns the reference count for a given LegoROI* tracked by the manager.
static MxBool IsActor(const char *p_name)
[AI] Checks if the given name matches an actor in the global actor table (case-insensitive).
~LegoCharacterManager()
[AI] Destroys the manager, cleaning up all managed characters and animation customization state.
static const char * GetCustomizeAnimFile()
[AI] Gets the value of the customize animation file variable.
void ReleaseActor(const char *p_name)
[AI] Releases a character/ROI by name, decrementing its reference count and deleting if zero.
LegoROI * GetActorROI(const char *p_name, MxBool p_createEntity)
[AI] Returns a LegoROI for the given character name, creating and registering the actor if necessary.
MxBool SwitchColor(LegoROI *p_roi, LegoROI *p_targetROI)
[AI] Changes the color of a part of a character's ROI, updating its part info index and updating ROI ...
MxBool SwitchSound(LegoROI *p_roi)
[AI] Cycles the sound type for the actor, updating the per-actor info.
MxBool FUN_100849a0(LegoROI *p_roi, LegoTextureInfo *p_texture)
[AI] Replaces the head LOD of a character ROI with a new LOD list built using the provided texture.
MxBool SwitchVariant(LegoROI *p_roi)
[AI] Cycles through part variants (e.g.
void ReleaseAutoROI(LegoROI *p_roi)
[AI] Releases an "auto" ROI, used for dynamically created ROI objects by this manager.
MxBool Exists(const char *p_name)
[AI] Returns whether a character with the given name exists in the manager.
LegoROI * FUN_10085a80(const char *p_name, const char *p_lodName, MxBool p_createEntity)
[AI] Helper function that delegates to CreateAutoROI.
MxBool SwitchMove(LegoROI *p_roi)
[AI] Cycles the move type for the actor, updating the per-actor info.
const char * GetActorName(MxS32 p_index)
[AI] Returns the actor name for the given actor index (lookup in global g_actorInfo table).
MxU32 GetAnimationId(LegoROI *p_roi)
[AI] Returns an animation ID corresponding to the ROI's move index.
Represents a special actor in the world with additional animation state machines and complex interact...
[AI] Represents a Real-time Object Instance enriched with LEGO-specific functionality.
Definition: legoroi.h:43
Abstract base class providing an interface for file-like storage with binary and text read/write oper...
Definition: legostorage.h:16
[AI] Contains DirectDraw and Direct3DRM handles and metadata for a texture used in the LEGO Island re...
[AI] Represents a key-value variable as used in the variable table for the LEGO Island engine.
Definition: mxvariable.h:16
map< char *, LegoCharacter *, LegoCharacterComparator > LegoCharacterMap
[AI] Map from character name strings to LegoCharacter pointers.
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
signed int MxS32
[AI]
Definition: mxtypes.h:38
unsigned int MxU32
[AI]
Definition: mxtypes.h:32
[AI] STL compatibility layer header to provide consistent STL (Standard Template Library) types and a...
[AI] Contains information about a single LEGO actor/character, including its name,...
Definition: legoactors.h:13
[AI] Comparator for character names, performing case-insensitive comparison using strcmpi.
MxBool operator()(const char *const &p_a, const char *const &p_b) const
[AI] Function call operator to compare two character name strings case-insensitively.
[AI] Holds a LegoROI pointer and reference count for a character instance managed by LegoCharacterMan...
LegoROI * m_roi
[AI] Pointer to the character's ROI object.
LegoCharacter(LegoROI *p_roi)
[AI] Constructs a LegoCharacter with an initial reference count of 1 and assigns the ROI pointer.
~LegoCharacter()
[AI] Destructor that deletes the associated ROI.
MxU32 m_refCount
[AI] Reference count tracking how many owners the character ROI has.
void AddRef()
[AI] Increments the internal reference count for this character.
MxU32 RemoveRef()
[AI] Decrements the internal reference count.