-
-
Notifications
You must be signed in to change notification settings - Fork 101
Utility Features
genar edited this page Mar 5, 2023
·
15 revisions
In some cases, you may want to reference entities among themselves.
Instead of an Entity
you should refer to an EntityReference
instead. This references an entity and also stores a version to check if the original entity still exists.
using var world = World.Create();
var entity = world.Create(_entityGroup);
var reference = world.Reference(entity); // This should be stored in your component ( entity.Reference() is also available. )
// Checks if the entity is the same as before by comparing the version and its id
if(reference.IsAlive()) {
var cmps = reference.Entity.Get(...);
}