-
Notifications
You must be signed in to change notification settings - Fork 24
What is an EntityFactory
What is an EntityFactory?
An EntityFactory is used to create and manage entities and EntityContainers. It provides methods to create, kill, import, export and move between in-tree containers. JALSE provides a default implementation - DefaultEntityFactory!
Why is an EntityFactory needed?
An EntityFactory is needed to create and maintain entity instances (since Entity is an interface the factory will deal with its implementation). A factory can be used to maintain an entire tree (or sub-tree) as EntityContainer only moves in one direction (container -> entity -> container).
A factory can be used to create a different Entity system or just to use single entities.
Creating an Entity
EntityFactory has newEntity(UUID, EntityContainer) and should create the entity instance with the parent as the supplied target container.
Killing an Entity
EntityFactory hastryKillEntity(Entity) and this should be used to tell if the entity could actually be killed (immortal).
Internal Entity transfers
EntityFactory has withinSameTree(EntityContainer, EntityContainer) and this should be used to tell if the two containers are within the same tree. If two containers are within the same tree a internal transfer should be tried first with tryTakeFromTree(Entity, EntityContainer) (which may not be possible and require an import).
External Entity transfers
EntityFactory has exportEntity(Entity) which removes all references the Entity has to its container making it ready for transfer to a entirely different tree. If an entity is alive but has no parent association tryImportEntity can be called to try and import the entity into the tree (and all child entities).
Check out the Example projects and Code snippets!
Getting Started
- Getting the latest release
- Building from source
- Example projects
- Code snippets
- How to contribute
- Have bugs or questions?
How To Use
- JALSE
- Entities
- Attributes
- Actions
- Tags
Misc