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

[AI] Manages the lifecycle, state, and properties for all plant objects (flowers, trees, bushes, palms) on LEGO Island. More...

#include <legoplantmanager.h>

Inheritance diagram for LegoPlantManager:
Collaboration diagram for LegoPlantManager:

Classes

struct  AnimEntry
 [AI] Structure for scheduling plant ROI/entity animations (i.e. More...
 

Public Member Functions

 LegoPlantManager ()
 [AI] Constructs the plant manager and initializes its bookkeeping to match the plant info array. More...
 
 ~LegoPlantManager () override
 [AI] Destructor. More...
 
MxResult Tickle () override
 [AI] Tickle handler for processing scheduled plant animation entries. More...
 
const char * ClassName () const override
 [AI] Returns the class name "LegoPlantManager". More...
 
void Init ()
 [AI] Zeroes out state, resets world ID, and copies default plant info to runtime plant info array. More...
 
void LoadWorldInfo (LegoOmni::World p_worldId)
 [AI] Loads all plant objects/entities for the requested world, instantiates requisite ROIs and entities. More...
 
void Reset (LegoOmni::World p_worldId)
 [AI] Completely resets (removes) all plant objects for the supplied world. More...
 
MxResult Write (LegoStorage *p_storage)
 [AI] Serializes persistent plant state (color, variant, mood, animation, etc) to storage for save games or transitions. More...
 
MxResult Read (LegoStorage *p_storage)
 [AI] Rehydrates plant state from storage, restoring color/variant/mood/move properties. More...
 
MxS32 GetNumPlants ()
 [AI] Returns the total number of plant records referenced by this manager. More...
 
MxBool SwitchColor (LegoEntity *p_entity)
 [AI] Cycles the color attribute for the plant and updates its LOD/appearance. More...
 
MxBool SwitchVariant (LegoEntity *p_entity)
 [AI] Cycles the variant/type for a plant (flower, tree, bush, palm) and updates appearance. More...
 
MxBool SwitchSound (LegoEntity *p_entity)
 [AI] Cycles the sound effect variant for a plant. More...
 
MxBool SwitchMove (LegoEntity *p_entity)
 [AI] Cycles the movement/animation type for a plant. More...
 
MxBool SwitchMood (LegoEntity *p_entity)
 [AI] Cycles the plant's "mood" state property (e.g., for appearance/hidden states) [AI] More...
 
MxU32 GetAnimationId (LegoEntity *p_entity)
 [AI] Returns the current animation ID for the given plant, based on its variant and move type. More...
 
MxU32 GetSoundId (LegoEntity *p_entity, MxBool p_state)
 [AI] Returns the sound ID for a plant, used for localized SFX depending on mood/state. More...
 
LegoPlantInfoGetInfoArray (MxS32 &p_length)
 [AI] Returns pointer to plant info array and populates its size. More...
 
LegoEntityCreatePlant (MxS32 p_index, LegoWorld *p_world, LegoOmni::World p_worldId)
 [AI] Instantiates an entity and ROI for the plant at given index in world (if appropriate). More...
 
MxBool FUN_10026c50 (LegoEntity *p_entity)
 [AI] Triggers a growth decrement or similar on a plant entity, and updates accordingly if possible. More...
 
void ScheduleAnimation (LegoEntity *p_entity, MxLong p_length)
 [AI] Schedules an animation for the given plant, adding an entry to the internal tickle array. More...
 
MxResult FUN_10026410 ()
 [AI] Repairs/updates all plant boundary references and vertical position to match world boundaries/planes. More...
 
void FUN_10027120 ()
 [AI] Resets all growth/activity/animation state for all plants in the manager. More...
 
void FUN_10027200 ()
 [AI] Propagates all plants' current growth/activity state to their restore points. 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 SetCustomizeAnimFile (const char *p_value)
 [AI] Sets the global file path or name to use for plant customization animations. More...
 
static const char * GetCustomizeAnimFile ()
 [AI] Gets the current file name/path for plant customization animation file. More...
 

Detailed Description

[AI] Manages the lifecycle, state, and properties for all plant objects (flowers, trees, bushes, palms) on LEGO Island.

This class handles creation, removal, animation scheduling, color/variant/mood/sound switching, serialization, and in-world management of plants/entities considered as static environmental decorations, but with some interactability and state.

It also provides support functions for customizing and storing their state, and integrates with tickle management for scheduled behavior.

[AI] The manager is responsible for all plants present in the current world, ties plant information with entity/ROI, schedules animations (growth, custom actions), and facilitates saving/loading plant state.

Definition at line 30 of file legoplantmanager.h.

Constructor & Destructor Documentation

◆ LegoPlantManager()

LegoPlantManager::LegoPlantManager ( )

[AI] Constructs the plant manager and initializes its bookkeeping to match the plant info array.

Definition at line 63 of file legoplantmanager.cpp.

◆ ~LegoPlantManager()

LegoPlantManager::~LegoPlantManager ( )
override

[AI] Destructor.

Cleans up any allocated entries and resets static animation file string.

Definition at line 70 of file legoplantmanager.cpp.

Member Function Documentation

◆ ClassName()

const char * LegoPlantManager::ClassName ( ) const
inlineoverridevirtual

[AI] Returns the class name "LegoPlantManager".

Used for RTTI and debugging.

Reimplemented from MxCore.

Definition at line 69 of file legoplantmanager.h.

◆ CreatePlant()

LegoEntity * LegoPlantManager::CreatePlant ( MxS32  p_index,
LegoWorld p_world,
LegoOmni::World  p_worldId 
)

[AI] Instantiates an entity and ROI for the plant at given index in world (if appropriate).

Parameters
p_indexThe index into the plant info array. [AI]
p_worldTarget world pointer for this plant's entity. [AI]
p_worldIdWorld enum/ID for filtering plants that exist in this world. [AI]

[AI] Creates only if plant meets world and activation criteria and hasn't already been made.

Definition at line 213 of file legoplantmanager.cpp.

◆ FUN_10026410()

MxResult LegoPlantManager::FUN_10026410 ( )

[AI] Repairs/updates all plant boundary references and vertical position to match world boundaries/planes.

[AI] Used to synchronize per-plant Y position against world boundaries (for collision/placement correction).

Definition at line 127 of file legoplantmanager.cpp.

◆ FUN_10026c50()

MxBool LegoPlantManager::FUN_10026c50 ( LegoEntity p_entity)

[AI] Triggers a growth decrement or similar on a plant entity, and updates accordingly if possible.

Parameters
p_entityPlant entity to update. [AI]
Returns
If the underlying property could be decremented and plant was updated. [AI]

[AI] Underlying plant property is likely its 'growth' counter or health, using index lookup.

Definition at line 553 of file legoplantmanager.cpp.

◆ FUN_10027120()

void LegoPlantManager::FUN_10027120 ( )

[AI] Resets all growth/activity/animation state for all plants in the manager.

[AI] Used to return plants to their initial/hidden or unevolved states, e.g. on world load.

Definition at line 702 of file legoplantmanager.cpp.

◆ FUN_10027200()

void LegoPlantManager::FUN_10027200 ( )

[AI] Propagates all plants' current growth/activity state to their restore points.

[AI] Used for state rollback or prepping snapshot for future restoration.

Definition at line 742 of file legoplantmanager.cpp.

◆ GetAnimationId()

MxU32 LegoPlantManager::GetAnimationId ( LegoEntity p_entity)

[AI] Returns the current animation ID for the given plant, based on its variant and move type.

[AI]

Parameters
p_entityTarget plant entity. [AI]

Definition at line 503 of file legoplantmanager.cpp.

◆ GetCustomizeAnimFile()

static const char * LegoPlantManager::GetCustomizeAnimFile ( )
inlinestatic

[AI] Gets the current file name/path for plant customization animation file.

[AI]

Returns
String pointer; NULL if unset. [AI]

Definition at line 237 of file legoplantmanager.h.

◆ GetInfoArray()

LegoPlantInfo * LegoPlantManager::GetInfoArray ( MxS32 p_length)

[AI] Returns pointer to plant info array and populates its size.

Triggers boundary check/correction if needed.

Parameters
p_lengthSet to array length on output. [AI]

[AI] Ensures boundary/plane alignment check is performed before returning the array. [AI]

Definition at line 201 of file legoplantmanager.cpp.

◆ GetNumPlants()

MxS32 LegoPlantManager::GetNumPlants ( )

[AI] Returns the total number of plant records referenced by this manager.

Definition at line 354 of file legoplantmanager.cpp.

◆ GetSoundId()

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

[AI] Returns the sound ID for a plant, used for localized SFX depending on mood/state.

[AI]

Parameters
p_entityTarget plant entity. [AI]
p_stateSelects sound type (mood vs sound property). [AI]

[AI] Picks sound based on whether it is state-dependent or not.

Definition at line 516 of file legoplantmanager.cpp.

◆ Init()

void LegoPlantManager::Init ( )

[AI] Zeroes out state, resets world ID, and copies default plant info to runtime plant info array.

[AI] Also called from constructor to ensure fresh state across world loads/restarts.

Definition at line 77 of file legoplantmanager.cpp.

◆ LoadWorldInfo()

void LegoPlantManager::LoadWorldInfo ( LegoOmni::World  p_worldId)

[AI] Loads all plant objects/entities for the requested world, instantiates requisite ROIs and entities.

Parameters
p_worldIdIndex of the current world. [AI]

[AI] For each entry in the plant info array, creates an entity and links it for in-world presence if the plant exists in that world. Sets up pointers and registers initial state.

Definition at line 92 of file legoplantmanager.cpp.

◆ Read()

MxResult LegoPlantManager::Read ( LegoStorage p_storage)

[AI] Rehydrates plant state from storage, restoring color/variant/mood/move properties.

Parameters
p_storageSource of the plant save data. [AI]

[AI] After reading, also recalculates each plant position based on variant/growth state.

Definition at line 301 of file legoplantmanager.cpp.

◆ Reset()

void LegoPlantManager::Reset ( LegoOmni::World  p_worldId)

[AI] Completely resets (removes) all plant objects for the supplied world.

Parameters
p_worldIdWorld which is being reset. [AI]

[AI] Destroys any entities/ROIs for plants in the specified world and reverts world ID.

Definition at line 106 of file legoplantmanager.cpp.

◆ ScheduleAnimation()

void LegoPlantManager::ScheduleAnimation ( LegoEntity p_entity,
MxLong  p_length 
)

[AI] Schedules an animation for the given plant, adding an entry to the internal tickle array.

Parameters
p_entityPlant to animate. [AI]
p_lengthLength (ms) that the animation should persist. [AI]

[AI] Will register itself to tickle manager if first animation entry.

Definition at line 608 of file legoplantmanager.cpp.

◆ SetCustomizeAnimFile()

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

[AI] Sets the global file path or name to use for plant customization animations.

Parameters
p_valueString containing file name/path for custom animation. Can be null to clear. [AI]

[AI] String is copied and managed as a global static resource.

Definition at line 533 of file legoplantmanager.cpp.

◆ SwitchColor()

MxBool LegoPlantManager::SwitchColor ( LegoEntity p_entity)

[AI] Cycles the color attribute for the plant and updates its LOD/appearance.

Parameters
p_entityTarget plant entity. [AI]

[AI] Updates color value modulo the possible color variants (white, black, yellow, red, green), reconstructs LOD and visuals accordingly.

Definition at line 380 of file legoplantmanager.cpp.

◆ SwitchMood()

MxBool LegoPlantManager::SwitchMood ( LegoEntity p_entity)

[AI] Cycles the plant's "mood" state property (e.g., for appearance/hidden states) [AI]

Parameters
p_entityTarget plant entity. [AI]

[AI] Rolls through mood values 0..3.

Definition at line 483 of file legoplantmanager.cpp.

◆ SwitchMove()

MxBool LegoPlantManager::SwitchMove ( LegoEntity p_entity)

[AI] Cycles the movement/animation type for a plant.

[AI]

Parameters
p_entityTarget plant entity. [AI]

[AI] Increments the move index (i.e. animation), wraps at maximum allowed for current variant.

Definition at line 463 of file legoplantmanager.cpp.

◆ SwitchSound()

MxBool LegoPlantManager::SwitchSound ( LegoEntity p_entity)

[AI] Cycles the sound effect variant for a plant.

[AI]

Parameters
p_entityTarget plant entity. [AI]

[AI] Increments sound index for this plant, wraps around if exceeding max.

Definition at line 443 of file legoplantmanager.cpp.

◆ SwitchVariant()

MxBool LegoPlantManager::SwitchVariant ( LegoEntity p_entity)

[AI] Cycles the variant/type for a plant (flower, tree, bush, palm) and updates appearance.

Parameters
p_entityTarget plant entity. [AI]

[AI] Only allow variant switch if plant 'growth' state allows, reassigns LOD after.

Definition at line 409 of file legoplantmanager.cpp.

◆ Tickle()

MxResult LegoPlantManager::Tickle ( )
overridevirtual

[AI] Tickle handler for processing scheduled plant animation entries.

Periodically animates plants by updating their transformation matrices and visibility, synchronizing with the tickle system.

[AI] If all current entries complete, unregisters from tickle.

Reimplemented from MxCore.

Definition at line 630 of file legoplantmanager.cpp.

◆ Write()

MxResult LegoPlantManager::Write ( LegoStorage p_storage)

[AI] Serializes persistent plant state (color, variant, mood, animation, etc) to storage for save games or transitions.

Parameters
p_storageWhere to write the serialized plant property data. [AI]

[AI] Loops over all plants and saves only the relevant dynamic state, not entity or ROI objects.

Definition at line 266 of file legoplantmanager.cpp.


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