Entity consists of two variables index and version
and 2 entities considered as equal only when both index and version are equal
Could you please explain why entity identity defined by a combination of two variables?
and what index and version mean?
Internally we store some information about the entity in an array - that is the index. After an entity is destroyed that index can be used by another entity you create - otherwise we would run out of entity ids really quickly if you create and destroy lots of enties - so we also have a version which is increased every time an id is reused. So if the index is identical but the version is different they are not the same entity, one is deleted and a new one happened to get the same index in the internal array.
The fact that it is two variables is mostly an internal implementation detail though, you should just treat the Entity as an opaque identifier and avoid making assumptions about those numbers.
10 Likes
thank you for clear and instant answer