User Tools

Site Tools


ientityfactory

This is an old revision of the document!


IEntityFactory

This service's primary responsibility is to create and release Entities. Entity creation is driven by EntityStaticData, with the appropriate runtime Entity implementation and Components resolved through the dependency injection container. Component values marked for initialization from static data are populated automatically during creation. Created Entities are registered with the IEntityRepository, optionally associated with a Chunk, and monitored for destruction so their Components, identifiers and container-managed instances can be released.

Broadcasts Events: EntityCreatedTopic, EntityDestroyedTopic

Methods

Method IEntity CreateInstance(string id, Chunk? chunk, bool suppressInvoke = false)
Description Creates and returns an IEntity using the EntityStaticData associated with specified id. The Entity's configured Components are resolved and initialized from their corresponding component static data before the Entity is registered with the IEntityRepository. If a valid Chunk is supplied and the Entity contains an IChunkTrackingComponent, the Entity is associated with that Chunk. An exception is thrown if no Entity static data exists for the supplied id. If suppressInvoke is false, an EntityCreatedTopic is broadcast after creation.
Method IEntity CreateInstance(string staticDataID, Chunk? chunk, Vector3 position, Quaternion rotation, uint id = 0, bool suppressInvoke = false)
Description Creates and returns an IEntity using the EntityStaticData associated with specified staticDataID, then initializes its position and rotation if it contains an ITransformComponent. If the Entity contains an IEntityIdentifierComponent, the supplied id is assigned and registered when greater than zero; otherwise a new unique identifier is acquired from the IEntityIdentifierRepository. If suppressInvoke is false, an EntityCreatedTopic is broadcast after all additional initialization is complete.
Method IEntity CreateInstance(string staticDataID, Chunk? chunk, uint id, bool suppressInvoke = false)
Description Creates and returns an IEntity using the EntityStaticData associated with specified staticDataID and initializes its identifier if it contains an IEntityIdentifierComponent. The supplied id is assigned and registered when greater than zero; otherwise a new unique identifier is acquired from the IEntityIdentifierRepository. If suppressInvoke is false, an EntityCreatedTopic is broadcast after identifier initialization is complete.
Method void ReleaseAllEntities()
Description Destroys all currently registered Entities. Entity destruction is handled through the factory's destruction subscription, which unregisters the Entity as a broadcaster, releases its Components and Entity instance from the dependency injection container, releases its unique identifier when applicable, unregisters it from the IEntityRepository and broadcasts an EntityDestroyedTopic.
Method void BroadcastEntityCreation(IEntity entity)
Description Manually broadcasts an EntityCreatedTopic for specified IEntity. This can be used when Entity creation broadcasting was previously suppressed and should be invoked after additional initialization has completed.
ientityfactory.1786782464.txt.gz · Last modified: by diviner

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki