Class Entity

java.lang.Object
rosequartz.ecb.Entity
All Implemented Interfaces:
Serializable

public class Entity extends Object implements Serializable
An ECB Entity. Everything in your game is represented by an Entity. Entities hold components.
See Also:
Component, Serialized Form
  • Constructor Details

    • Entity

      public Entity()
  • Method Details

    • add

      public Entity add(Component... components)
      Adds components to the entity.
      Parameters:
      components - the components to add
      Returns:
      this
    • has

      public <C extends Component> boolean has(Class<C> component)
      Gets if the entity has a Component of the exact same class.
      Parameters:
      component - class of the component to check for
      Returns:
      if the entity has all given components
    • remove

      public Entity remove(Class<? extends Component> component)
      Removes a Component from the entity.
      Parameters:
      component - class of the component to remove
      Returns:
      this
    • remove

      public Entity remove(Component component)
      Removes a Component from the entity.
      Parameters:
      component - component to remove
      Returns:
      this
    • getAll

      public Component[] getAll()
      Gets all components from the entity.
      Returns:
      all components
    • clear

      public Entity clear()
      Removes all components from the entity.
      Returns:
      this
    • get

      public <C extends Component> C get(Class<C> component)
      Gets a component from the entity.
      Parameters:
      component - the component to get
      Returns:
      the component, null if not there
    • get

      public <C extends Component> Entity get(Class<C> component, Consumer<C> action)
      Executes the given function if the entity has the given component of the exact same class, passing the component onto the function.
      Parameters:
      component - class of the component to check for
      action - function to execute with the component
      Returns:
      this
    • copy

      public Entity copy()
      Clones / Copies this entity with all its components. Calls 'copy' for every component of the entity.
      Returns:
      "copy" of this entity