Development
Entity
Various information about entity and entity system.
Entity
An entity is a game object, which can be created or removed.
Create an entity
Example:
var entity = Core.EntitySystem.CreateEntity<CPointWorldText>();This example creates a point_worldtext entity with class CPointWorldText.
You can also use CreateEntityByDesignerName to create an entity by specifying the designer name.
Get existing entities
You can use methods in entity system to get existing entities.
The methods that return multiple entities return an IEnumerable<T> type.
It's recommended to use Linq to query entities, to avoid too much iteration.
Get all entities
Example:
var entities = Core.EntitySystem.GetAllEntities();Get entities by class
Example:
var entities = Core.EntitySystem.GetEntityByClass<CPointWorldText>();Entity Handle
Entity Handle is a handle to a game entity, which is also a unique identifier for an entity.
It consists of two parts:
- Entity Index (15 bit)
- Serial Number (17 bit)
Combined together, it is a uint32.
Get entity by handle
var entity = handle.Value;The result will be null if the entity is invalid.
Get handle by entity
var handle = Core.EntitySystem.GetRefEHandle(entity);Entity system
See also IEntitySystemService