Interface IEntity

  • All Known Implementing Classes:
    Entity

    public interface IEntity
    An entity is something that exists in your game world. Again, an entity is little more than a list of components. Because they are so simple, most implementations won't define an entity as a concrete piece of data. Instead, an entity is a unique ID, and all components that make up an entity will be tagged with that ID.
    Author:
    kong
    • Method Detail

      • setId

        void setId​(java.lang.String id)
        Set new id
        Parameters:
        id - the desired id
      • getId

        java.lang.String getId()
        Retrieves the entity's id
        Returns:
        entity's id
      • setContextInfo

        void setContextInfo​(ContextInfo contextInfo)
        Set context information
        Parameters:
        contextInfo - see ContextInfo
      • setComponentPools

        void setComponentPools​(IElementPool<IComponent>[] __componentPools)
        Set list of component pools, each component pool manages specific component type
        Parameters:
        __componentPools - an array of ComponentPool
      • setComponent

        void setComponent​(int index,
                          IComponent component)
        Set new component
        Parameters:
        index - the component index
        component - the component object
      • removeComponent

        void removeComponent​(int index)
        Remove component by index
        Parameters:
        index - the component index
      • replaceComponent

        void replaceComponent​(int index,
                              IComponent component)
        Replace old component by new component by index
        Parameters:
        index - the component index
        component - the component object
      • getComponent

        IComponent getComponent​(int index)
        Retrieves the component by index
        Parameters:
        index - the component index
        Returns:
        the corresponding component
      • getComponents

        IComponent[] getComponents()
        Retrieves a list of the current entity
        Returns:
        list of components
      • hasComponent

        boolean hasComponent​(int index)
        Check if the component is existed or not
        Parameters:
        index - component index
        Returns:
        true if the component is existed, false otherwise
      • hasComponents

        boolean hasComponents​(int... indices)
        Check if all the components in list are existed or not
        Parameters:
        indices - list of component indices
        Returns:
        true if the all components are existed, false otherwise
      • hasAnyComponent

        boolean hasAnyComponent​(int... indices)
        Check if one of components in list are existed or not
        Parameters:
        indices - list of component indices
        Returns:
        true if the one of components in list is existed, false otherwise
      • removeAllComponents

        void removeAllComponents()
        Remove all components
      • reset

        void reset()
        Reset entity