-
Notifications
You must be signed in to change notification settings - Fork 5
Code of Identifiers
Yuki Shimada edited this page Apr 3, 2022
·
1 revision
In Rhodonite, most objects are assigned IDs so that they can be identified and managed by IDs.
("XXX" in the following explanation means the same element)
- An ID that represents a kind about XXX; the number space is closed within XXX and also unique within it.
- A practical example is
ComponentTID
.
- An ID to identify an entity (multiple generable instances, alive or dead) of "XXX".
- Once an entity is created, all entities are assigned a UniqueID, and the assignment is never changed regardless of whether the entity is alive or dead.
- Examples include
EntityUID
andObjectUID
.
- Basically a unique ID, but the number space is closed within the corresponding TypedID and a unique identification number within it. This means that numbers may overlap between different TypedID ranges.
- A practical example is the
ComponentSID
.
- Even if the same "XXX" is used, UniqueID, ScopedID, and TypeID have a different number space from each other.
- For all types of IDs, the numbering starts from zero. Negative values (especially -1 for operational use) are interpreted as "invalid or not specified.
UniqueID assigned to an instance of Entity. It is often used to retrieve or specify a specific Entity.
const entityRepository = Rn.EntityRepository.getInstance();
const meshEntity = entityRepository.createEntity([Rn.TransformComponent, Rn.SceneGraphComponent]);
console.log(meshEntity.entityUID)
UniqueID assigned to an instance of a class that extends RnObject; since Entity is also a RnObject, Entity has both an entityUID and an objectUID.
const rnObject = new RnObject();
console.log(rnObject.objectUID);
const entityRepository = Rn.EntityRepository.getInstance();
const entity = entityRepository.createEntity([]);
console.log(entity.objectUID);
TypeID representing the type of component. It is also a static ID whose value is fixed at the time of compilation. A typical ComponentTID is [this file in Rhodonite](https://github.com/emadurandal/RhodoniteTS/blob/master/src/foundation/components/ WellKnownComponentTIDs.ts).
ScopedID of the component instance.
const entityRepository = Rn.EntityRepository.getInstance();
const meshEntity = entityRepository.createEntity([Rn.TransformComponent, Rn.SceneGraphComponent]);
const transformComponent = meshEntity.getTransforom();
console.log(transformComponent.componentSID);