Color legend plain property method
A handle to an entity: an id, and the generation the id had when the entity was created. The entity is nothing more than this handle; its components are in the world’s stores, filed under the id.
A read-only struct that implements IEntity. The entities page shows it in context, with code. Whether a handle is alive only the world can tell: ECSWorld.IsEntityAlive.
Names are colored by what they are: a property or a method; values and fields keep the plain color.
Properties
IsValid →
bool · Read-only. false for a negative id, such as Invalid’s, and true for any other. true doesn’t mean alive: a valid handle may belong to an entity destroyed long ago.
Fields
Generation →
int · Read-only field. The generation the id had when the entity was created. Each destroy of an entity with the id moves the id’s generation on by one, so a handle with an older one is no longer alive.
Id →
int · Read-only field. Where the entity’s components are filed in the stores. Ids start at 0 and are reused after a destroy, the most recently freed first.
Invalid →
Entity · Static, read-only field. A handle that never refers to an entity, id −1 at generation 0, for fields and return values that mean “no entity”. Use it rather than default(Entity), which is the world’s first entity once there is one; see no entity.
Methods
Entity() →
Entity(int id, int generation) · A handle made of the two numbers. The world hands out handles from CreateEntity; a handle made by hand is alive only if it equals one the world handed out and hasn’t destroyed since.
| Parameter | Type | Description |
|---|---|---|
id |
int |
The id. |
generation |
int |
The generation of the id. |
==() →
operator ==(Entity left, Entity right) · True when the ids and the generations are equal. != is its opposite, and Equals compares the same way.
| Parameter | Type | Description |
|---|---|---|
left |
Entity |
The first handle. |
right |
Entity |
The second handle. |
Equals() →
Equals(Entity other) · True when both the id and the generation are equal: a handle to a destroyed entity doesn’t equal the handle of the entity that got its id. From IEntity.
| Parameter | Type | Description |
|---|---|---|
other |
Entity |
The handle to compare with. |
Equals(object obj) · The same, for an obj that is an Entity; false for anything else.
| Parameter | Type | Description |
|---|---|---|
obj |
object |
The object to compare with. |
GetHashCode() →
GetHashCode() · A hash of the id and the generation, so a handle works as a key of a Dictionary or in a HashSet.
ToString() →
ToString() · The id and the generation as text: Entity(3:gen.1), and Entity(-1:gen.0) for Invalid.