Isle
Loading...
Searching...
No Matches
LegoBuildingManager Class Reference

[AI] Manages LEGO buildings in the world, including their state, animation, switching, saving/loading, and scheduling of animations. More...

#include <legobuildingmanager.h>

Inheritance diagram for LegoBuildingManager:
Collaboration diagram for LegoBuildingManager:

Classes

struct  AnimEntry
 [AI] Tracks and schedules a single animation entry for a building with sound and timer information, for use with the tickling/animation update system. More...
 

Public Member Functions

 LegoBuildingManager ()
 [AI] Constructor. Initializes state and building info array (see Init()). More...
 
 ~LegoBuildingManager () override
 [AI] Destructor. Cleans up scheduled animation file string and resets manager state. More...
 
MxResult Tickle () override
 [AI] Tick updates for scheduled animation: animates buildings scheduled in m_entries, triggers sound, does hiding or motion, then unregisters self if no more animations remain. More...
 
const char * ClassName () const override
 [AI] Returns the runtime class name for this manager. More...
 
void Init ()
 [AI] Initializes all manager fields, resets animation tracking, and loads the default building info array. More...
 
void LoadWorldInfo ()
 [AI] Loads/creates building models for the current world, sets up variants appropriately for current config, and manages building visibility. More...
 
void CreateBuilding (MxS32 p_index, LegoWorld *p_world)
 [AI] Spawns and configures a building entity and its ROI based on world/array index. More...
 
void Reset ()
 [AI] Removes all building-state links to world entities and cancels/cleans any scheduled animation entries. More...
 
MxResult Write (LegoStorage *p_storage)
 [AI] Serializes current building state to the given storage. More...
 
MxResult Read (LegoStorage *p_storage)
 [AI] Restores data from serialized building state in the given storage. More...
 
LegoBuildingInfoGetInfo (LegoEntity *p_entity)
 [AI] Locates the building info entry for a specific building entity. More...
 
MxBool SwitchVariant (LegoEntity *p_entity)
 [AI] Attempts to switch the building variant for the specified entity (e.g. More...
 
MxBool SwitchSound (LegoEntity *p_entity)
 [AI] Cycles the current active sound for a building (if sounds available). More...
 
MxBool SwitchMove (LegoEntity *p_entity)
 [AI] Cycles the current move/animation state for a building (if moves available). More...
 
MxBool SwitchMood (LegoEntity *p_entity)
 [AI] Cycles the current mood state for a building (if moods available, mood in 0..3). More...
 
MxU32 GetAnimationId (LegoEntity *p_entity)
 [AI] Returns the animation id for a building entity, factoring in base animation id and move offset. More...
 
MxU32 GetSoundId (LegoEntity *p_entity, MxBool p_state)
 [AI] Returns the sound id for a building entity, using either mood or active sound state. More...
 
MxBool FUN_10030000 (LegoEntity *p_entity)
 [AI] Attempts to "progress" demolition/animation of a building entity by calling FUN_10030030 on its array index. More...
 
MxBool FUN_10030030 (MxS32 p_index)
 [AI] Internal: progresses the demolition/animation state/counter of the indexed building, moves ROI if appropriate, otherwise hides the entity when done. More...
 
MxBool FUN_10030110 (LegoBuildingInfo *p_data)
 [AI] Forwards to FUN_10030030 with lookup by pointer; used for pointer-based demolition/motion triggers. More...
 
void ScheduleAnimation (LegoEntity *p_entity, MxLong p_length, MxBool p_haveSound, MxBool p_unk0x28)
 [AI] Schedules an animation bounce/effect for a given building entity (updates AnimEntry tracking and triggers Tickle registration). More...
 
void FUN_10030590 ()
 [AI] Resets all buildings' construction/demolition status to "unbuilt" (-1), updates heights/visibilities, and resets entity transform. More...
 
void AdjustHeight (MxS32 p_index)
 [AI] Adjusts (recalculates) a building's world Y position based on its current demo/build counter, which offsets Y lower as more damage occurs. More...
 
MxResult FUN_10030630 ()
 [AI] Performs a boundary existence/consistency check for each building, resolving path boundaries and snapping Y if necessary. More...
 
LegoBuildingInfoGetInfoArray (MxS32 &p_length)
 [AI] Returns the full set of LegoBuildingInfo entries, checks/initializes boundary data if needed. More...
 
void FUN_100307b0 (LegoEntity *p_entity, MxS32 p_adjust)
 [AI] Adjusts the construction/demolition counter for a building entity, incrementing or decrementing by a fixed adjust amount. More...
 
void FUN_10030800 ()
 [AI] Copies the current m_unk0x11 demo/counter into m_initialUnk0x11 for all buildings (for persistent saving). More...
 
- Public Member Functions inherited from MxCore
 MxCore ()
 [AI] Constructs a new MxCore object and assigns it a unique id. More...
 
virtual ~MxCore ()
 [AI] Virtual destructor. Required for correct polymorphic cleanup in derived classes. More...
 
virtual MxLong Notify (MxParam &p_param)
 [AI] Virtual callback notification mechanism. More...
 
virtual MxResult Tickle ()
 [AI] Called by tickle managers to allow the object to update itself. More...
 
virtual const char * ClassName () const
 [AI] Returns the runtime class name of this object. More...
 
virtual MxBool IsA (const char *p_name) const
 [AI] Checks whether this object's class type or parents match the given name. More...
 
MxU32 GetId ()
 [AI] Gets the unique (per-process) id assigned to this object instance. More...
 

Static Public Member Functions

static void configureLegoBuildingManager (MxS32 p_buildingManagerConfig)
 [AI] Configure static settings for the LegoBuildingManager globally. More...
 
static void SetCustomizeAnimFile (const char *p_value)
 [AI] Sets the global filename for a custom "customize animation" SMK/FLC file. More...
 
static const char * GetCustomizeAnimFile ()
 [AI] Gets the current static filename for custom "customize" animations. More...
 

Detailed Description

[AI] Manages LEGO buildings in the world, including their state, animation, switching, saving/loading, and scheduling of animations.

[AI] This manager handles all building-related logic for LEGO Island, providing per-building state storage (via LegoBuildingInfo) and operations for visual/audio/mood switching, construction/demolition sequence, and animation/physics scheduling. It also implements serialization into LegoStorage and exposes relevant configuration and access APIs. [AI]

Definition at line 47 of file legobuildingmanager.h.

Constructor & Destructor Documentation

◆ LegoBuildingManager()

LegoBuildingManager::LegoBuildingManager ( )

[AI] Constructor. Initializes state and building info array (see Init()).

Definition at line 237 of file legobuildingmanager.cpp.

◆ ~LegoBuildingManager()

LegoBuildingManager::~LegoBuildingManager ( )
override

[AI] Destructor. Cleans up scheduled animation file string and resets manager state.

Definition at line 243 of file legobuildingmanager.cpp.

Member Function Documentation

◆ AdjustHeight()

void LegoBuildingManager::AdjustHeight ( MxS32  p_index)

[AI] Adjusts (recalculates) a building's world Y position based on its current demo/build counter, which offsets Y lower as more damage occurs.

Parameters
p_index[AI] The index into g_buildingInfo

Definition at line 403 of file legobuildingmanager.cpp.

◆ ClassName()

const char * LegoBuildingManager::ClassName ( ) const
inlineoverridevirtual

[AI] Returns the runtime class name for this manager.

Reimplemented from MxCore.

Definition at line 70 of file legobuildingmanager.h.

◆ configureLegoBuildingManager()

void LegoBuildingManager::configureLegoBuildingManager ( MxS32  p_buildingManagerConfig)
static

[AI] Configure static settings for the LegoBuildingManager globally.

Parameters
p_buildingManagerConfig[AI] New configuration value (affects switching and initialization behavior).

Definition at line 231 of file legobuildingmanager.cpp.

◆ CreateBuilding()

void LegoBuildingManager::CreateBuilding ( MxS32  p_index,
LegoWorld p_world 
)

[AI] Spawns and configures a building entity and its ROI based on world/array index.

Parameters
p_index[AI] The index into static building info array.
p_world[AI] The LegoWorld to place the building in.

Definition at line 294 of file legobuildingmanager.cpp.

◆ FUN_10030000()

MxBool LegoBuildingManager::FUN_10030000 ( LegoEntity p_entity)

[AI] Attempts to "progress" demolition/animation of a building entity by calling FUN_10030030 on its array index.

Parameters
p_entity[AI] Building entity

Definition at line 590 of file legobuildingmanager.cpp.

◆ FUN_10030030()

MxBool LegoBuildingManager::FUN_10030030 ( MxS32  p_index)

[AI] Internal: progresses the demolition/animation state/counter of the indexed building, moves ROI if appropriate, otherwise hides the entity when done.

Parameters
p_index[AI] Index in the building info array

Definition at line 611 of file legobuildingmanager.cpp.

◆ FUN_10030110()

MxBool LegoBuildingManager::FUN_10030110 ( LegoBuildingInfo p_data)

[AI] Forwards to FUN_10030030 with lookup by pointer; used for pointer-based demolition/motion triggers.

Parameters
p_data[AI] Pointer to LegoBuildingInfo

Definition at line 652 of file legobuildingmanager.cpp.

◆ FUN_10030590()

void LegoBuildingManager::FUN_10030590 ( )

[AI] Resets all buildings' construction/demolition status to "unbuilt" (-1), updates heights/visibilities, and resets entity transform.

Definition at line 777 of file legobuildingmanager.cpp.

◆ FUN_10030630()

MxResult LegoBuildingManager::FUN_10030630 ( )

[AI] Performs a boundary existence/consistency check for each building, resolving path boundaries and snapping Y if necessary.

Returns
[AI] SUCCESS or FAILURE (invalid boundary)

Definition at line 796 of file legobuildingmanager.cpp.

◆ FUN_100307b0()

void LegoBuildingManager::FUN_100307b0 ( LegoEntity p_entity,
MxS32  p_adjust 
)

[AI] Adjusts the construction/demolition counter for a building entity, incrementing or decrementing by a fixed adjust amount.

Parameters
p_entity[AI] Building entity
p_adjust[AI] Value to increment (positive) or decrement (negative)

Definition at line 879 of file legobuildingmanager.cpp.

◆ FUN_10030800()

void LegoBuildingManager::FUN_10030800 ( )

[AI] Copies the current m_unk0x11 demo/counter into m_initialUnk0x11 for all buildings (for persistent saving).

Definition at line 898 of file legobuildingmanager.cpp.

◆ GetAnimationId()

MxU32 LegoBuildingManager::GetAnimationId ( LegoEntity p_entity)

[AI] Returns the animation id for a building entity, factoring in base animation id and move offset.

Parameters
p_entity[AI] Building entity
Returns
[AI] Animation id, or 0 if building doesn't support moves.

Definition at line 538 of file legobuildingmanager.cpp.

◆ GetCustomizeAnimFile()

static const char * LegoBuildingManager::GetCustomizeAnimFile ( )
inlinestatic

[AI] Gets the current static filename for custom "customize" animations.

Returns
[AI] C-string filename, owned by class, or NULL if none set.

Definition at line 188 of file legobuildingmanager.h.

◆ GetInfo()

LegoBuildingInfo * LegoBuildingManager::GetInfo ( LegoEntity p_entity)

[AI] Locates the building info entry for a specific building entity.

Parameters
p_entity[AI] Building entity pointer (LegoEntity)
Returns
[AI] Pointer to the corresponding LegoBuildingInfo, or NULL if not found.

Definition at line 429 of file legobuildingmanager.cpp.

◆ GetInfoArray()

LegoBuildingInfo * LegoBuildingManager::GetInfoArray ( MxS32 p_length)

[AI] Returns the full set of LegoBuildingInfo entries, checks/initializes boundary data if needed.

Parameters
p_length[AI] Set to the count of entries returned.
Returns
[AI] Pointer to building info array (of size p_length)

Definition at line 868 of file legobuildingmanager.cpp.

◆ GetSoundId()

MxU32 LegoBuildingManager::GetSoundId ( LegoEntity p_entity,
MxBool  p_state 
)

[AI] Returns the sound id for a building entity, using either mood or active sound state.

If p_state is TRUE, returns the mood-related sound id, else uses current sound slot.

Parameters
p_entity[AI] Building entity
p_state[AI] TRUE for mood, FALSE for main sound
Returns
[AI] Sound id or 0 if not available.

Definition at line 551 of file legobuildingmanager.cpp.

◆ Init()

void LegoBuildingManager::Init ( )

[AI] Initializes all manager fields, resets animation tracking, and loads the default building info array.

Definition at line 249 of file legobuildingmanager.cpp.

◆ LoadWorldInfo()

void LegoBuildingManager::LoadWorldInfo ( )

[AI] Loads/creates building models for the current world, sets up variants appropriately for current config, and manages building visibility.

Definition at line 264 of file legobuildingmanager.cpp.

◆ Read()

MxResult LegoBuildingManager::Read ( LegoStorage p_storage)

[AI] Restores data from serialized building state in the given storage.

Parameters
p_storage[AI] The storage to read from.
Returns
[AI] SUCCESS or FAILURE

Definition at line 363 of file legobuildingmanager.cpp.

◆ Reset()

void LegoBuildingManager::Reset ( )

[AI] Removes all building-state links to world entities and cancels/cleans any scheduled animation entries.

Definition at line 311 of file legobuildingmanager.cpp.

◆ ScheduleAnimation()

void LegoBuildingManager::ScheduleAnimation ( LegoEntity p_entity,
MxLong  p_length,
MxBool  p_haveSound,
MxBool  p_unk0x28 
)

[AI] Schedules an animation bounce/effect for a given building entity (updates AnimEntry tracking and triggers Tickle registration).

Parameters
p_entity[AI] The entity to animate
p_length[AI] Duration of the animation (in ms)
p_haveSound[AI] Whether sound should play at peak event [AI]
p_unk0x28[AI] Whether to immediately set demolition state to zero at finish.

Definition at line 664 of file legobuildingmanager.cpp.

◆ SetCustomizeAnimFile()

void LegoBuildingManager::SetCustomizeAnimFile ( const char *  p_value)
static

[AI] Sets the global filename for a custom "customize animation" SMK/FLC file.

Parameters
p_value[AI] C-string path, or NULL to clear.

Definition at line 571 of file legobuildingmanager.cpp.

◆ SwitchMood()

MxBool LegoBuildingManager::SwitchMood ( LegoEntity p_entity)

[AI] Cycles the current mood state for a building (if moods available, mood in 0..3).

Parameters
p_entity[AI] Building entity
Returns
[AI] TRUE if mood switched, FALSE otherwise.

Definition at line 518 of file legobuildingmanager.cpp.

◆ SwitchMove()

MxBool LegoBuildingManager::SwitchMove ( LegoEntity p_entity)

[AI] Cycles the current move/animation state for a building (if moves available).

Parameters
p_entity[AI] Building entity
Returns
[AI] TRUE if move switched, FALSE otherwise.

Definition at line 498 of file legobuildingmanager.cpp.

◆ SwitchSound()

MxBool LegoBuildingManager::SwitchSound ( LegoEntity p_entity)

[AI] Cycles the current active sound for a building (if sounds available).

Parameters
p_entity[AI] Building entity
Returns
[AI] TRUE if sound switched, FALSE otherwise.

Definition at line 478 of file legobuildingmanager.cpp.

◆ SwitchVariant()

MxBool LegoBuildingManager::SwitchVariant ( LegoEntity p_entity)

[AI] Attempts to switch the building variant for the specified entity (e.g.

changes type of house). Returns TRUE on success. Does nothing if config disables variants or not eligible.

Parameters
p_entity[AI] Building entity
Returns
[AI] TRUE if switched, FALSE otherwise.

Definition at line 448 of file legobuildingmanager.cpp.

◆ Tickle()

MxResult LegoBuildingManager::Tickle ( )
overridevirtual

[AI] Tick updates for scheduled animation: animates buildings scheduled in m_entries, triggers sound, does hiding or motion, then unregisters self if no more animations remain.

Reimplemented from MxCore.

Definition at line 694 of file legobuildingmanager.cpp.

◆ Write()

MxResult LegoBuildingManager::Write ( LegoStorage p_storage)

[AI] Serializes current building state to the given storage.

Parameters
p_storage[AI] The storage to write to.
Returns
[AI] SUCCESS, or FAILURE on error

Definition at line 330 of file legobuildingmanager.cpp.


The documentation for this class was generated from the following files: