NameComponent - UQcsse3200/2024-studio-1 GitHub Wiki
The NameComponent
is a component used to name an entity,
this can be used by other systems for any number of reasons, identifying an entity, debugging that requires knowing what entities are spawned, etc.
A NameComponent can be added to an entity as such:
public Entity create(){
return new Entity().addComponent(new NameComponent("test name"));
}
If you need your name to be variable you can also supply a function.
private String entityToString(Entity entity){
return entity.getComponent(...).toString();
}
public Entity create(){
Entity entity = new Entity();
entity.addComponent(new NameComponent(() -> entityToString(entity))
.addComponent(new MyComponent());
}