Interface Playfield


  • public interface Playfield
    The interface for the playfield of the simulation
    Author:
    Tim Neumann
    • Method Detail

      • getSimulation

        Simulation getSimulation()
        Returns:
        the simulation this playfield is part of
      • getAllEntities

        List<Entity> getAllEntities()
        Get a list of all entities on this playfield.
        Returns:
        A list of all entities
      • getAllEntitiesOfType

        <T extends EntityList<T> getAllEntitiesOfType​(Class<? extends T> type,
                                                        boolean includeSubclasses)
        Get a list of all entities matching the given type on this playfield.
        Type Parameters:
        T - The generic type to return the entities as
        Parameters:
        type - The type of entity to get; must not be null
        includeSubclasses - Whether to include the subclasses of the given type
        Returns:
        A list of all matching entities
        Throws:
        IllegalArgumentException - if the given type is null
      • getEntitiesAt

        List<Entity> getEntitiesAt​(Position pos)
        Get a list of all entities at the given position on this playfield.
        Parameters:
        pos - The position at which to get the entities; must not be null
        Returns:
        A list of all entities at that position
        Throws:
        IllegalArgumentException - if the given pos is null
      • getEntitiesOfTypeAt

        <T extends EntityList<T> getEntitiesOfTypeAt​(Position pos,
                                                       Class<? extends T> type,
                                                       boolean includeSubclasses)
        Get a list of all entities matching the given type at the given position on this playfield.
        Type Parameters:
        T - The generic type to return the entities as
        Parameters:
        pos - The position at which to get the entities; must not be null
        type - The type of entity to get; must not be null
        includeSubclasses - Whether to include the subclasses of the given type
        Returns:
        A list of all matching entities
        Throws:
        IllegalArgumentException - if the given pos or type is null
      • addEntity

        void addEntity​(Position pos,
                       Entity entity)
        Add a given entity to this simulation at a given position on this playfield.
        Parameters:
        pos - The position to add the entity; must not be null
        entity - The entity to add; must not be on the field; must not be null
        Throws:
        EntityAlreadyOnFieldExcpetion - if the given entity has been added to this playfield before
        IllegalArgumentException - if the given pos or entity is null
      • moveEntity

        void moveEntity​(Entity entity,
                        Position pos)
        Move a entity of this simulation to a given position on this playfield.

        This causes a EntityTeleportAction.

        Parameters:
        entity - The entity to move; must be on the field; must not be null
        pos - The position to move the entity to; must not be null
        Throws:
        EntityNotOnFieldException - if the given entity is not in this playfield
        IllegalArgumentException - if the given pos or entity is null
      • moveEntity

        void moveEntity​(Entity entity,
                        Position pos,
                        EntityMoveAction action)
        Move a entity of this simulation to a given position on this playfield.
        Parameters:
        entity - The entity to move; must be on the field; must not be null
        pos - The position to move the entity to; must not be null
        action - An action describing this move; will be logged by this method; if null causes a EntityTeleportAction
        Throws:
        EntityNotOnFieldException - if the given entity is not in this playfield
        IllegalArgumentException - if the given pos or entity is null
        IllegalArgumentException - if the given action match with the other arguments
      • removeEntity

        void removeEntity​(Entity entity)
        Remove a entity of this simulation from this playfield.
        Parameters:
        entity - The entity to add; must be on the field; must not be null
        Throws:
        EntityNotOnFieldException - if the given entity is not in this playfield
        IllegalArgumentException - if the given entity is null
      • getEntityPosition

        Position getEntityPosition​(Entity entity)
        Get the position of the specified entity on the playfield.
        Parameters:
        entity - The entity to get the position of; must be on the field; must not be null
        Returns:
        The position of the given entity
        Throws:
        EntityNotOnFieldException - if the given entity is not in this playfield
        IllegalArgumentException - if the given entity is null
      • containsEntity

        boolean containsEntity​(Entity entity)
        Check whether the specified entity is on this playfield.
        Parameters:
        entity - The entity to check; must not be null
        Returns:
        whether the given entity is on this playfield
        Throws:
        IllegalArgumentException - if the given entity is null
      • isSolidEntityAt

        boolean isSolidEntityAt​(Position pos)
        Check whether a solid entity is at the given position.
        Parameters:
        pos - The position to check
        Returns:
        true if and only if a solid entity is at that position