Interface Playfield
-
public interface Playfield
The interface for the playfield of the simulation- Author:
- Tim Neumann
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addEntity(Position pos, Entity entity)
Add a given entity to this simulation at a given position on this playfield.boolean
containsEntity(Entity entity)
Check whether the specified entity is on this playfield.List<Entity>
getAllEntities()
Get a list of all entities on this playfield.<T extends Entity>
List<T>getAllEntitiesOfType(Class<? extends T> type, boolean includeSubclasses)
Get a list of all entities matching the given type on this playfield.List<Entity>
getEntitiesAt(Position pos)
Get a list of all entities at the given position on this playfield.<T extends Entity>
List<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.Position
getEntityPosition(Entity entity)
Get the position of the specified entity on the playfield.Simulation
getSimulation()
boolean
isSolidEntityAt(Position pos)
Check whether a solid entity is at the given position.void
moveEntity(Entity entity, Position pos)
Move a entity of this simulation to a given position on this playfield.void
moveEntity(Entity entity, Position pos, EntityMoveAction action)
Move a entity of this simulation to a given position on this playfield.void
removeEntity(Entity entity)
Remove a entity of this simulation from this playfield.
-
-
-
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 Entity> List<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 nullincludeSubclasses
- 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 Entity> List<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 nulltype
- The type of entity to get; must not be nullincludeSubclasses
- 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 nullentity
- 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 beforeEntityOnAnotherFieldException
- if the entity is already on another fieldIllegalArgumentException
- 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 nullpos
- The position to move the entity to; must not be null- Throws:
EntityNotOnFieldException
- if the given entity is not in this playfieldIllegalArgumentException
- 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 nullpos
- The position to move the entity to; must not be nullaction
- An action describing this move; will be logged by this method; if null causes aEntityTeleportAction
- Throws:
EntityNotOnFieldException
- if the given entity is not in this playfieldIllegalArgumentException
- if the given pos or entity is nullIllegalArgumentException
- 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 playfieldIllegalArgumentException
- 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 playfieldIllegalArgumentException
- 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
-
-