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

[AI] Object factory for the LEGO Island game, responsible for instantiating all game-specific entities and presenters via name-based lookup. More...

#include <legoobjectfactory.h>

Inheritance diagram for LegoObjectFactory:
Collaboration diagram for LegoObjectFactory:

Public Member Functions

 LegoObjectFactory ()
 [AI] Constructs a new LegoObjectFactory; initializes all known type names as MxAtomId for rapid lookup. More...
 
MxCoreCreate (const char *p_name) override
 [AI] Creates an object by name. More...
 
void Destroy (MxCore *p_object) override
 [AI] Destroys an object that was previously created by this factory. More...
 
- Public Member Functions inherited from MxObjectFactory
 MxObjectFactory ()
 [AI] Constructs a new MxObjectFactory and initializes atom IDs for all supported presenter classes. More...
 
const char * ClassName () const override
 [AI] Returns the class name. More...
 
MxBool IsA (const char *p_name) const override
 [AI] Determines whether this class is or inherits from the named class. More...
 
virtual MxCoreCreate (const char *p_name)
 [AI] Creates a new instance of the class matching the provided string name. More...
 
virtual void Destroy (MxCore *p_object)
 [AI] Destroys (deletes) a dynamic object created by this factory. 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...
 

Detailed Description

[AI] Object factory for the LEGO Island game, responsible for instantiating all game-specific entities and presenters via name-based lookup.

[AI] LegoObjectFactory maintains a table of MxAtomId objects which provide a fast mapping from class name strings to object type. The Create function uses these mappings to return a new instance of the relevant class or delegates to its base class for unsupported types. All memory management of constructed objects is centralized; deleting via Destroy ensures proper deallocation.

This class centralizes the construction of almost all runtime game objects and presenters (including entities, race actors, presenters for media, and game-state classes). It is used heavily when objects are loaded dynamically from scripts or streamed data.

The object factory is key for extensibility and supporting both new and legacy entity types in a safe manner.

Definition at line 122 of file legoobjectfactory.h.

Constructor & Destructor Documentation

◆ LegoObjectFactory()

LegoObjectFactory::LegoObjectFactory ( )

[AI] Constructs a new LegoObjectFactory; initializes all known type names as MxAtomId for rapid lookup.

[AI] All type name identifiers are constructed with case-exact matching to support correct mapping from incoming script or system requests.

Definition at line 108 of file legoobjectfactory.cpp.

Member Function Documentation

◆ Create()

MxCore * LegoObjectFactory::Create ( const char *  p_name)
overridevirtual

[AI] Creates an object by name.

Parameters
p_nameName of the class/type to instantiate. [AI]

[AI] Looks up the class name in its member MxAtomId table. If a match is found, instantiates the appropriate concrete object and returns a pointer to its base type (MxCore). If not recognized, delegates to the base MxObjectFactory implementation. The return is always non-null; an assertion is triggered otherwise.

Reimplemented from MxObjectFactory.

Definition at line 215 of file legoobjectfactory.cpp.

◆ Destroy()

void LegoObjectFactory::Destroy ( MxCore p_object)
overridevirtual

[AI] Destroys an object that was previously created by this factory.

Parameters
p_objectPointer to the object to delete. [AI]

[AI] Centralized destruction allows maintenance of custom deletion logic, though currently this directly deletes the pointer.

Reimplemented from MxObjectFactory.

Definition at line 530 of file legoobjectfactory.cpp.


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