Entity
The Entity, an abstract being, equipped with data.
Last updated
Was this helpful?
The Entity, an abstract being, equipped with data.
Last updated
Was this helpful?
In an , an entity is simply a unique ID tag. It represents an object in the game or application, but has no logic or data itself. The data and behavior come from components that are attached to this entity.
An Entity
is nothing more than a simple record struct Entity{ int ID, int WorldId, int Version }
. Either you work directly on this entity and its methods, or you simply use . More on this later.
Creating entities is really simple!
How does it feel to be a god? Now lets step one further.
Changing entities is of course also possible and also very easy.
The safety check using .Has<T>()
is important. Arch does not do this itself because because our mantra is raw performance and we trust you as a developer to know when to check and when not to.
We have now added a component to the entity (the pickaxe) and removed it again immediately. Now let's see how we can do this for several components at the same time.
We can easily reference other entities using the Entity
struct. Even if the entities recycle (and thus the Id of an entity can reappear), each Entity
has an Entity.Version
which functions as a timestamp.
We should always compare the Entity
s directly, never just via the Id!
So you can simply save an Entity
somewhere and use it as a direct reference to access it at any time.
Inspecting entities is also a rather simple task.
There are no hidden costs in Arch, without any black magic under the hood or hidden code slowing down your system. This means that everything is executed directly, without abstraction costs, the only disadvantage is that you have to make sure and check that your action makes sense at that point.
Even if it is possible to create entities during a query, change its structure or destroy it, we recommend these operations and performing them after the query. Take a look at the !