49 m_nextObjectId = 50000;
64 if (result ==
FALSE) {
87 while (cursor.
Current(action)) {
89 const char* presenterName;
114 m_list.push_back(presenter);
116 else if (presenter) {
153 for (MxCompositePresenterList::iterator it =
m_list.begin(); it !=
m_list.end(); it++) {
154 if ((*it)->GetCurrentTickleState() ==
e_idle) {
155 (*it)->SetTickleState(
e_ready);
169 if (wdbPath[strlen(wdbPath) - 1] !=
'\\') {
170 strcat(wdbPath,
"\\");
173 strcat(wdbPath,
"lego\\data\\world.wdb");
175 if (access(wdbPath, 4) != 0) {
178 if (wdbPath[strlen(wdbPath) - 1] !=
'\\') {
179 strcat(wdbPath,
"\\");
182 strcat(wdbPath,
"lego\\data\\world.wdb");
184 if (access(wdbPath, 4) != 0) {
190 MxS32 numWorlds, i, j;
193 FILE* wdbFile = fopen(wdbPath,
"rb");
195 if (wdbFile ==
NULL) {
201 for (i = 0; i < numWorlds; i++) {
202 if (!strcmpi(worlds[i].m_worldName, p_worldName)) {
207 if (i == numWorlds) {
212 if (fread(&size,
sizeof(size), 1, wdbFile) != 1) {
216 buff =
new MxU8[size];
217 if (fread(buff, size, 1, wdbFile) != 1) {
227 texturePresenter.
Store();
232 if (fread(&size,
sizeof(size), 1, wdbFile) != 1) {
236 buff =
new MxU8[size];
237 if (fread(buff, size, 1, wdbFile) != 1) {
246 partPresenter.
Store();
262 while (cursor.
Next(part)) {
264 LoadWorldPart(*part, wdbFile) !=
SUCCESS) {
270 if (!strnicmp(worlds[i].m_models[j].m_modelName,
"isle", 4)) {
273 if (strcmpi(worlds[i].m_models[j].m_modelName,
"isle_lo")) {
278 if (strcmpi(worlds[i].m_models[j].m_modelName,
"isle")) {
283 if (strcmpi(worlds[i].m_models[j].m_modelName,
"isle_hi")) {
289 if (worlds[i].m_models[j].m_modelName[4] ==
'3') {
290 if (LoadWorldModel(worlds[i].m_models[j], wdbFile, p_world) !=
SUCCESS) {
294 if (LoadWorldModel(worlds[i].m_models[j - 2], wdbFile, p_world) !=
SUCCESS) {
298 if (LoadWorldModel(worlds[i].m_models[j - 1], wdbFile, p_world) !=
SUCCESS) {
306 if (LoadWorldModel(worlds[i].m_models[j], wdbFile, p_world) !=
SUCCESS) {
332 result = partPresenter.
Read(chunk);
335 partPresenter.
Store();
362 MxU32 objectId = m_nextObjectId;
384 createdEntity->
Create(action);
389 if (createdEntity !=
NULL) {
409 if (!action->
IsA(
"MxDSMediaAction")) {
418 if (!p_presenter->
IsA(
"LegoAnimPresenter") && !p_presenter->
IsA(
"MxControlPresenter") &&
419 !p_presenter->
IsA(
"MxCompositePresenter")) {
433 char extraCopy[1024];
434 memcpy(extraCopy, extraData, extraLength);
435 extraCopy[extraLength] =
'\0';
[AI] Handles presentation logic specific to LegoActor entities, such as their instantiation,...
MxResult LoadWorldInfo(LegoOmni::World p_worldId)
[AI] Loads all world animation and extra info.
void LoadWorldInfo()
[AI] Loads/creates building models for the current world, sets up variants appropriately for current ...
[AI] Presenter responsible for managing the lifecycle, location, and logic for a LegoEntity instance ...
void SetInternalEntity(LegoEntity *p_entity)
[AI] Directly sets the internal LegoEntity pointer without instantiating or taking ownership.
LegoEntity * m_entity
[AI] The entity instance managed by this presenter, typically created based on the current action.
void SetEntityLocation(const Vector3 &p_location, const Vector3 &p_direction, const Vector3 &p_up)
[AI] Sets the entity's world transformation using location, direction, and up vectors.
[AI] Represents an entity that can be placed and managed in the LEGO Island world.
virtual MxResult Create(MxDSAction &p_dsAction)
[AI] Initializes the entity from a DSAction object, typically from a script or file load.
[AI] Presenter class for managing 3D model (ROI) presentation and their relationship with entities in...
MxResult FUN_1007ff70(MxDSChunk &p_chunk, LegoEntity *p_entity, MxBool p_roiVisible, LegoWorld *p_world)
[AI] Loads or associates an ROI for presentation from a chunk, linking it to a LegoEntity or LegoWorl...
void AddWorld(LegoWorld *p_world)
[AI] Appends a LegoWorld to the active world list, acquiring ownership.
@ c_clearScreen
[AI] When set, clears the display surface. [AI]
@ c_disable3d
[AI] When set, disables 3D rendering. [AI]
@ c_disableInput
[AI] When set, disables input processing. [AI]
World
[AI] Identifiers for all unique, script-driven world environments in LEGO Island.
World GetWorldId(const char *p_key)
[AI] Looks up a World enum id from its string key.
[AI] Presents and loads Lego part definitions from SI chunks and manages their installation in ViewLO...
MxResult Read(MxDSChunk &p_chunk)
[AI] Reads Lego part and texture data from a MxDSChunk and builds internal part list.
void Store()
[AI] Transfers all loaded named Lego parts and LODs to the ViewLODListManager.
void LoadWorldInfo(LegoOmni::World p_worldId)
[AI] Loads all plant objects/entities for the requested world, instantiates requisite ROIs and entiti...
[AI] Manages the loading, storage, and management of named textures for the LEGO Island engine.
MxResult Read(MxDSChunk &p_chunk)
[AI] Loads and parses one or more texture objects from a provided serialized data chunk.
MxResult Store()
[AI] Transfers all loaded textures to the global texture container and initializes their info structu...
[AI] Presenter for the entire LEGO world, responsible for loading, parsing, and managing world entiti...
void ReadyTickle() override
[AI] Tickle when in "ready" state: creates the LegoWorld entity, places it into the system,...
LegoWorldPresenter()
[AI] Constructs a LegoWorldPresenter with initial objectId for presented models.
MxResult StartAction(MxStreamController *p_controller, MxDSAction *p_action) override
[AI] Starts the world presentation process: creates child presenters for every sub-action (often part...
MxResult LoadWorld(char *p_worldName, LegoWorld *p_world)
[AI] Loads all data for a named world from the world database (WDB) file, creates all parts and model...
void StartingTickle() override
[AI] Tickle when in "starting" state: signals child presenters to move to "ready" if idle,...
void ParseExtra() override
[AI] Parses extra data attached to the current action, such as selecting which world to load from the...
~LegoWorldPresenter() override
[AI] Destructor; unregisters, cleans up associated world, reverts system managers to previous state,...
void VTable0x60(MxPresenter *p_presenter) override
[AI] Handles completion and composition of a presenter's child (typically model/entity),...
Represents the active 3D world, holding all entity, animation, sound, path, and ROI objects.
[AI] Iterator for traversing ModelDbPartList contents (ModelDbPart pointers).
[AI] Represents a 3D point with floating-point precision, inheriting from Vector3.
[AI] Atomized (unique) string identifier, managed by reference counting.
MxCompositePresenterList m_list
[AI] List of owned child presenters that are managed by this MxCompositePresenter....
virtual void VTable0x60(MxPresenter *p_presenter)
[AI] Advance sequencing for serial multi-actions: promotes the next presenter in sequence to e_ready ...
[AI] Convenience cursor class for iterating over an MxDSActionList.
[AI] A list (collection) of pointers to MxDSAction objects, supporting comparison,...
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
MxU32 GetFlags()
[AI] Returns the flag field for this action (bitmask).
void SetLocation(const Vector3 &p_location)
[AI] Sets the location vector for this action.
void GetExtra(MxU16 &p_extraLength, char *&p_extraData)
[AI] Retrieves the extra data and its length for this action.
MxBool IsA(const char *p_name) const override
[AI] Run-time type check, compares provided name with this or any ancestor type.
void SetDirection(const Vector3 &p_direction)
[AI] Sets the direction vector for this action.
void SetOrigin(MxCore *p_origin)
[AI] Sets the origin core pointer for this action, if spatially transforming/localizing this action.
const Vector3 & GetLocation()
[AI] Gets the location vector for this action (world or local space).
void SetFlags(MxU32 p_flags)
[AI] Sets the flag bitmask controlling action logic (enabled, looping, etc).
const Vector3 & GetUp()
[AI] Gets the up vector for this action (global or local).
const Vector3 & GetDirection()
[AI] Gets the direction vector (typically forward vector) for this action.
virtual MxLong GetDuration()
[AI] Gets the duration for which this action is intended to run.
void SetUp(const Vector3 &p_up)
[AI] Sets the up vector for this action.
@ c_looping
[AI] Action or media should repeat in a loop [AI]
@ c_bit3
[AI] Unknown - possibly reserved [AI]
[AI] Represents a chunk of data extracted from a stream (typically from a Mindscape/Mx SI file or str...
void SetData(MxU8 *p_data)
[AI] Sets the pointer to the raw payload data (may or may not be owned by chunk object).
void SetLength(MxU32 p_length)
[AI] Sets the payload data length for this chunk.
[AI] Represents a container for multiple MxDSAction objects, facilitating the grouping and management...
virtual void SetAtomId(MxAtomId p_atomId)
[AI] Sets the atom id for this object instance, used for indexing or lookup.
void SetObjectId(MxU32 p_objectId)
[AI] Sets the object id (for serialization or lookup).
MxBool Current(T &p_obj)
[AI]
MxResult Send(MxCore *p_listener, const MxNotificationParam &p_param)
[AI] Queues a notification to be sent to a specific registered listener.
[AI] Parameter object representing a single notification or event, carrying an identifier and sender ...
[AI] Forward declaration for the factory responsible for constructing core objects from atom or type ...
virtual MxCore * Create(const char *p_name)
[AI] Creates a new instance of the class matching the provided string name.
static const char * GetCD()
[AI] Retrieves the configured CD-ROM media path string used for resource location.
static const char * GetHD()
[AI] Retrieves the configured hard disk media path string used for resource location.
[AI] Abstract base class for all presenter types in the LEGO Island engine, responsible for managing ...
virtual void SetTickleState(TickleState p_tickleState)
[AI] Forces the tickle state, advancing to the requested lifecycle stage.
void ProgressTickleState(TickleState p_tickleState)
[AI] Helper for advancing the presenter's tickle state and updating transition history.
virtual MxResult StartAction(MxStreamController *, MxDSAction *)
[AI] Initiates presenter for a new action, setting up context and state.
MxDSAction * m_action
[AI] The associated action currently being presented by this presenter.
MxS32 GetCurrentTickleState() const
[AI] Returns the current tickle state.
void SetAction(MxDSAction *p_action)
[AI] Sets the action associated with this presenter.
MxEntity * CreateEntity(const char *p_defaultName)
[AI] Creates an entity based on action 'extra' data, or uses the provided default name.
@ e_idle
[AI] Not processing an action.
@ e_ready
[AI] Prepared to start processing an action.
@ e_starting
[AI] In the process of starting playback/presentation.
@ e_streaming
[AI] Streaming or rendering actively.
MxCriticalSection m_criticalSection
[AI] Thread synchronization for presenter state and data.
MxBool IsA(const char *p_name) const override
[AI] Determines if this object is of (or inherits) the specified named class.
virtual MxResult AddToManager()
[AI] Optional registration with a manager (such as TickleManager); by default does nothing.
void SendToCompositePresenter(MxOmni *p_omni)
[AI] Notifies a composite presenter (if one exists) that this presenter wishes to join a group.
void SetCompositePresenter(MxCompositePresenter *p_compositePresenter)
[AI] Sets the composite presenter to notify/join on completion.
MxDSAction * GetAction() const
[AI] Returns the current action being presented.
[AI] Controller for streaming and managing multimedia resources and actions during gameplay.
char * GetData() const
Returns a pointer to the internal character buffer.
#define DECOMP_SIZE_ASSERT(T, S)
const char * g_parseExtraTokens
[AI] Delimiter tokens for parsing extra parameters in scripts or command strings.
const char * g_strWORLD
[AI] Symbolic name used to reference a "WORLD" entity or property in scripts and object definitions.
#define NULL
[AI] Null pointer value (C/C++ semantics).
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
MxS32 g_legoWorldPresenterQuality
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
LegoAnimationManager * AnimationManager()
[AI] Accessor for the animation manager, which controls Lego character/world animation state....
LegoBuildingManager * BuildingManager()
[AI] Accessor for the building manager, handles constructible buildings and structures....
ViewLODListManager * GetViewLODListManager()
[AI] Returns the global ViewLODListManager for view LOD (Level of Detail) resources....
LegoPlantManager * PlantManager()
[AI] Accessor for the plant manager, handling in-game foliage and plants. [AI]
void FUN_10015820(MxBool p_disable, MxU16 p_flags)
[AI] Utility for enabling or disabling functionality in LegoOmni based on certain flags.
LegoOmni * Lego()
[AI] Retrieves the global LegoOmni singleton instance, providing access to core subsystems.
MxResult ReadModelDbWorlds(FILE *p_file, ModelDbWorld *&p_worlds, MxS32 &p_numWorlds)
[AI] Reads the collection of worlds (ModelDbWorld) from a model database file.
void FreeModelDbWorlds(ModelDbWorld *&p_worlds, MxS32 p_numWorlds)
[AI] Frees all resources related to ModelDbWorlds previously allocated by ReadModelDbWorlds.
#define AUTOLOCK(CS)
[AI] Macro for automatic locking using the MxAutoLock class. This macro instantiates an MxAutoLock ob...
MxObjectFactory * ObjectFactory()
[AI] Returns the factory for creating core engine objects from atom/type ids.
MxNotificationManager * NotificationManager()
[AI] Returns the notification manager for system-wide state/update notifications.
@ c_notificationNewPresenter
[AI] Notification about a new Presenter object [AI]
const char * PresenterNameDispatch(const MxDSAction &)
[AI] Provides a mapping from action object/type to the correct presenter handler class name based on ...
MxBool KeyValueStringParse(char *, const char *, const char *)
Searches p_string for a key command and copies its associated value to p_output.
[AI] STL compatibility layer header to provide consistent STL (Standard Template Library) types and a...
[AI] Represents a 3D model entry in a model database, including metadata and spatial transform info.
char * m_presenterName
[AI] Name of the presenter/handler class used for this model, dynamically allocated....
MxU32 m_modelDataLength
[AI] Length of the model's raw data in the file, in bytes. [AI]
undefined m_unk0x34
[AI] Unknown field, possibly additional flags or type (purpose currently unknown)....
float m_location[3]
[AI] World-space position of the model origin (as a 3D vector). [AI]
float m_up[3]
[AI] World-space up vector (indicates model "up" orientation). [AI]
MxU32 m_modelDataOffset
[AI] File offset to the model's raw data. [AI]
float m_direction[3]
[AI] World-space direction vector (indicates model "forward" direction). [AI]
[AI] Represents a single part within a 3D model database entry, including its name and data offsets i...
MxString m_roiName
[AI] Name of the part/ROI this entry represents. [AI]
undefined4 m_partDataOffset
[AI] Offset within the file to the part's data. [AI]
undefined4 m_partDataLength
[AI] Length of binary part data in the file (in bytes). [AI]
[AI] Represents a world/scene in the model database, containing its parts and models.
MxS32 m_numModels
[AI] Number of models in the array m_models. [AI]