Method Exists
Exists(Entity)
Reports whether an Entity object is still valid.
Declaration
public bool Exists(Entity entity)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The Entity object to check. |
Returns
Type | Description |
---|---|
Boolean | True, if Version matches the version of the current entity at Index in the entities array. |
Remarks
An Entity object does not contain a reference to its entity. Instead, the Entity struct contains an index and a generational version number. When an entity is destroyed, the EntityManager increments the version of the entity within the internal array of entities. The index of a destroyed entity is recycled when a new entity is created.
After an entity is destroyed, any existing Entity objects will still contain the older version number. This function compares the version numbers of the specified Entity object and the current version of the entity recorded in the entities array. If the versions are different, the Entity object no longer refers to an existing entity and cannot be used.