Class Entity

java.lang.Object
dev.engine.core.scene.Entity

public class Entity extends Object
An entity in the scene — just an ID with component storage.
var entity = scene.createEntity();
entity.add(Transform.at(1, 0, 0));
entity.add(PrimitiveMeshes.cube());    // MeshData IS the component
entity.add(myMaterial);                // Material IS the component

entity.get(Transform.class);           // → Transform
entity.has(MeshData.class);            // → true
entity.get(MaterialData.class).shaderHint(); // → "PBR"
  • Method Details

    • handle

      public Handle<EntityTag> handle()
    • add

      public <T extends Component> Entity add(T component)
      Adds or replaces a component. Uses Component.slotType() as the key — families like MaterialData share one slot.
    • get

      public <T extends Component> T get(Class<T> type)
      Gets a component by slot type, or null.
    • has

      public boolean has(Class<? extends Component> type)
      Checks if entity has a component in the given slot.
    • remove

      public <T extends Component> Entity remove(Class<T> type)
      Removes a component by slot type.
    • update

      public <T extends Component> Entity update(Class<T> type, UnaryOperator<T> fn)
      Updates a component in place: gets current, applies function, re-adds result. Emits a transaction for the change.
      entity.update(Transform.class, t -> t.withPosition(new Vec3(1, 0, 0)));
      entity.update(Transform.class, t -> t.withRotation(myQuat));
      
    • setParent

      public Entity setParent(Entity parent)
    • addChild

      public Entity addChild(Entity child)
    • destroy

      public void destroy()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object