Class MapLevel

java.lang.Object
fr.r1r0r0.deltaengine.model.maplevel.MapLevel

public final class MapLevel
extends java.lang.Object
MapLevel that represent the area where entities move It is compose of cells, entities and events
See Also:
MapLevelBuilder
  • Field Details

    • name

      private final java.lang.String name
    • width

      private final int width
    • height

      private final int height
    • cells

      private final BufferedHashMap<Coordinates<java.lang.Integer>,​Cell> cells
    • entities

      private final BufferedHashMap<java.lang.String,​Entity> entities
    • events

      private final java.util.Collection<Event> events
  • Constructor Details

    • MapLevel

      MapLevel​(java.lang.String name, Cell[][] cells)
      Constructor
      Parameters:
      name - name of the map
      cells - cells that compose the map, can not contain null
  • Method Details

    • getName

      public java.lang.String getName()
      Return the name
      Returns:
      the name
    • getWidth

      public int getWidth()
      Return the width
      Returns:
      the width
    • getHeight

      public int getHeight()
      Return the height
      Returns:
      the height
    • replaceCell

      public void replaceCell​(Cell cell) throws MapLevelCoordinatesOutOfBoundException
      Add a case in the map
      Parameters:
      cell - a cell
      Throws:
      MapLevelCoordinatesOutOfBoundException - throw if a cell with coordinate out of the area define by the map is added
    • isValidCoordinate

      private boolean isValidCoordinate​(Coordinates<java.lang.Integer> coordinates)
      Return if the coordinates given are include in the area of the map
      Parameters:
      coordinates - a coordinate
      Returns:
      if the coordinates are valid (include in the area of the map)
    • getCell

      public Cell getCell​(int x, int y)
      Return the cell in the map with coordinate (x,y)
      Parameters:
      x - the x value
      y - the y value
      Returns:
      the cell in the map with coordinate (x,y), returns OutOfBoundsCell if wanted cell is out of bounds
    • addEntity

      public void addEntity​(Entity entity) throws MapLevelEntityNameStackingException
      Add an entity in the map
      Parameters:
      entity - an entity
      Throws:
      MapLevelEntityNameStackingException - throw if the name of the entity is already present in the map
    • getEntity

      public Entity getEntity​(java.lang.String name)
      Return the entity in map with the same given
      Parameters:
      name - a name
      Returns:
      an entity in map with the same given, or null if there is no entity with this name
    • removeEntity

      public void removeEntity​(Entity entity)
      Remove an entity in map with the same given
      Parameters:
      entity - an entity
    • clearEntities

      public void clearEntities()
      Remove all the entities present in map
    • addEvent

      public void addEvent​(Event event)
      add an event
      Parameters:
      event -
    • removeEvent

      public void removeEvent​(Event event)
      Remove an event
      Parameters:
      event - an event
    • clearEvents

      public void clearEvents()
      Remove all events in map
    • getCells

      public java.util.Collection<Cell> getCells()
      Return all the cells in map
      Returns:
      a collection of case
    • getEntities

      public java.util.Collection<Entity> getEntities()
      Return all the entities in map
      Returns:
      a collection of entity
    • getEvents

      public java.util.Collection<Event> getEvents()
      Return all the events in map
      Returns:
      a map of event
    • getBufferedCells

      public BufferedHashMap<Coordinates<java.lang.Integer>,​Cell> getBufferedCells()
      Getter of attribute cells
      Returns:
      attribute cells
    • getBufferedEntities

      public BufferedHashMap<java.lang.String,​Entity> getBufferedEntities()
      Getter of attribute entities
      Returns:
      attributes entities