Class Entity


  • public class Entity
    extends Object
    Entity class. Whilst an entity is just an Integer, and using Integer values would be more performant (no function call, primitive arrays and etc.), it is encapsulated to help distinguish between entities and Integers. Also, in this form it may be extended to also include things like names, grouping, specific ordering etc
    • Field Detail

      • engineRef

        protected static Engine engineRef
    • Constructor Detail

      • Entity

        public Entity​(int value)
    • Method Detail

      • getValue

        public int getValue()
      • asEntity

        public static Entity asEntity​(int value)
        Returns the int value wrapped as an entity. Used to provide a distinction between creating a new entity, and using an int value we assume is a valid entity.

        Functionally, this is no different to creating a new entity.

        Parameters:
        value - the integer value to read as an Entity
        Returns:
        an Entity object representing the ID value
      • hashCode

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

        @Deprecated
        public boolean addComponent​(Type componentType,
                                    Object componentData)
        Deprecated.
        This function is not ECS-like. It is provided as an auxilliary method, that will be more intuitive to those familiar with OO design
        Adds the provided component to this entity.

        This function calls Engine.addComponent(Entity, Type, Object), so that should be used instead.

        Parameters:
        componentType - the class type of the component to add
        componentData - the component data
        Returns:
        true if successful
      • removeComponent

        @Deprecated
        public boolean removeComponent​(Type componentType)
        Deprecated.
        This function is not ECS-like. It is provided as an auxilliary method, that will be more intuitive to those familiar with OO design
        Removes the provided component from this entity.

        This function calls Engine.removeComponent(Entity, Type), so that should be used instead.

        Parameters:
        componentType - the class type of the component to remove
        Returns:
        true if successful
      • getComponent

        @Deprecated
        public Object getComponent​(Type componentType)
        Deprecated.
        This function is not ECS-like. It is provided as an auxilliary method, that will be more intuitive to those familiar with OO design
        Gets the component data associated to this entity.

        This function calls Engine.getComponentData(), so that should be used instead.

        Parameters:
        componentType - the class type of the component to fetch data from
        Returns:
        the data Object, which requires casting