Isle
|
[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>
Public Member Functions | |
LegoObjectFactory () | |
[AI] Constructs a new LegoObjectFactory; initializes all known type names as MxAtomId for rapid lookup. More... | |
MxCore * | Create (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... | |
![]() | |
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 MxCore * | Create (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... | |
![]() | |
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... | |
[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.
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.
|
overridevirtual |
[AI] Creates an object by name.
p_name | Name 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.
|
overridevirtual |
[AI] Destroys an object that was previously created by this factory.
p_object | Pointer 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.