Class StendhalRPZone

java.lang.Object
marauroa.server.game.rp.MarauroaRPZone
games.stendhal.server.core.engine.StendhalRPZone
All Implemented Interfaces:
Iterable<RPObject>, IRPZone
Direct Known Subclasses:
AdventureIsland, Northpole, Vault

public class StendhalRPZone extends MarauroaRPZone
  • Field Details

    • collisionMap

      public CollisionDetection collisionMap
      contains data to if a certain area is walkable.
    • protectionMap

      public CollisionDetection protectionMap
      Contains data to verify is someone is in a PK-free area.
  • Constructor Details

    • StendhalRPZone

      public StendhalRPZone(String name)
    • StendhalRPZone

      public StendhalRPZone(String name, int width, int height)
    • StendhalRPZone

      public StendhalRPZone(String name, StendhalRPZone zone)
  • Method Details

    • getBlood

      public Blood getBlood(int x, int y)
      Get blood (if any) at a specified zone position.
      Parameters:
      x - The X coordinate.
      y - The Y coordinate.
      Returns:
      The blood, or null.
    • getNPCList

      public List<NPC> getNPCList()
    • getPortals

      public List<Portal> getPortals()
    • getPortal

      public Portal getPortal(Object reference)
    • getPortal

      public Portal getPortal(int x, int y)
      Get the portal (if any) at a specified zone position.
      Parameters:
      x - The X coordinate.
      y - The Y coordinate.
      Returns:
      The portal, or null.
    • getSheepFoodList

      public List<SheepFood> getSheepFoodList()
      Get the list of sheep foods in the zone.
      Returns:
      The list of sheep foods.
    • getRespawnPointList

      public List<CreatureRespawnPoint> getRespawnPointList()
    • add

      public void add(CreatureRespawnPoint point)
      Add a creature respawn point to the zone.
      Parameters:
      point - The respawn point.
    • remove

      public void remove(CreatureRespawnPoint point)
      Remove a creature respawn point from the zone.
      Parameters:
      point - The respawn point.
    • getPlantGrowers

      public List<PassiveEntityRespawnPoint> getPlantGrowers()
    • assignPortalID

      public Object assignPortalID(Portal portal)
    • setEntryPoint

      public void setEntryPoint(int x, int y)
    • placeObjectAtEntryPoint

      public boolean placeObjectAtEntryPoint(Entity entity)
    • addLayer

      public void addLayer(String name, LayerDefinition layer) throws IOException
      Throws:
      IOException
    • addTilesets

      public void addTilesets(String name, List<TileSetDefinition> tilesets) throws IOException
      Throws:
      IOException
    • notifyOnlinePlayers

      public void notifyOnlinePlayers()
      Resend the zone data to players on the zone. This is meant for situations where the map data changes. (Weather and lighting changes, and so on).
    • setAttributes

      public void setAttributes(ZoneAttributes attr)
      Set zone attributes that should be passed to the client.
      Parameters:
      attr - attributes
    • addCollisionLayer

      public void addCollisionLayer(String name, LayerDefinition collisionLayer) throws IOException
      Throws:
      IOException
    • addProtectionLayer

      public void addProtectionLayer(String name, LayerDefinition protectionLayer) throws IOException
      Throws:
      IOException
    • setPosition

      public void setPosition(int level, int x, int y)
    • setPosition

      public void setPosition()
    • getX

      public int getX()
    • getY

      public int getY()
    • getLevel

      public int getLevel()
    • isInterior

      public boolean isInterior()
    • intersects

      public boolean intersects(Rectangle2D area)
      Determine if this zone overlaps an area in global coordinates.
      Parameters:
      area - The area (in global coordinate space).
      Returns:
      true if the area overlaps.
    • populate

      public void populate(LayerDefinition objectsLayer)
      Populate a zone based on it's map content. TODO: This should be moved to the zone loader or something.
      Parameters:
      objectsLayer -
    • calculateDangerLevel

      public void calculateDangerLevel()
      Calculate danger level for the zone, and store it in the data layer.
    • createEntityAt

      protected void createEntityAt(String clazz, int type, int x, int y)
      Create a map entity as a given coordinate.
      Parameters:
      clazz - the clazz of entity we are loading.
      It is related to the way entities are stored in tilesets now.
      type - integer to represent the type of entity to be created.

      if the class contains portal type is evaluated as follows:

      • 0 , 1 entry point
      • 1 zone change
      • 5 ,2 , 3 LevelPortal
      x -
      y -
    • createLevelPortalAt

      protected void createLevelPortalAt(int type, int x, int y)
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • getContents

      public List<TransferContent> getContents()
    • isInProtectionArea

      public boolean isInProtectionArea(Entity entity)
    • leavesZone

      public boolean leavesZone(Entity entity, double x, double y)
    • simpleCollides

      public boolean simpleCollides(Entity entity, double x, double y, double w, double h)
    • add

      public void add(RPObject object)
      Description copied from class: MarauroaRPZone
      This method adds an object to this zone.
      Specified by:
      add in interface IRPZone
      Overrides:
      add in class MarauroaRPZone
      Parameters:
      object - object to add.
    • add

      public void add(RPObject object, Player player)
      Adds an object to the ground. The player parameter can be used to create special items that react when they are dropped on the ground by a player.
      Parameters:
      object - The object that should be added to the zone
      player - The player that dropped the item
    • add

      public void add(RPObject object, boolean expire)
      Adds an object to the ground.
      Parameters:
      object - The object that should be added to the zone
      expire - True if the item should expire according to its normal behaviour, false otherwise
    • addToPlayersAndFriends

      public void addToPlayersAndFriends(RPEntity object)
      adds an RPEntity to the playersAndFriends list.
      Parameters:
      object - RPEntity
    • remove

      public RPObject remove(RPObject.ID id)
      Description copied from class: MarauroaRPZone
      Removes the object from zone.
      Specified by:
      remove in interface IRPZone
      Overrides:
      remove in class MarauroaRPZone
      Parameters:
      id - identified of the removed object
      Returns:
      the removed object
    • remove

      public RPObject remove(RPObject object)
      removes object from zone.
      Parameters:
      object -
      Returns:
      the removed object
    • modify

      public void modify(RPObject object)
      Description copied from class: MarauroaRPZone
      This method notify zone that the object has been modified. You should call it only once per turn, even if inside the turn you modify it several times.
      Specified by:
      modify in interface IRPZone
      Overrides:
      modify in class MarauroaRPZone
      Parameters:
      object - object to modify.
    • collidesOnLine

      public boolean collidesOnLine(int x1, int y1, int x2, int y2)
      Checks if there is a collision on the airline between 2 positions. Only the collision map will be used.
      Parameters:
      x1 - x value of position 1
      y1 - y value of position 1
      x2 - x value of position 2
      y2 - y value of position 2
      Returns:
      true if there is a collision
    • collides

      public boolean collides(int x, int y)
      Checks a single pair of coordinates for collision.
      Parameters:
      x - X-coordinate
      y - Y-coordinate
      Returns:
      true if collision tile located at coordinates.
    • collides

      public boolean collides(Rectangle2D shape)
      Checks an area for collision.
      Parameters:
      shape - Rectangle area.
      Returns:
      true if any collision tiles are found in the area.
    • collides

      public boolean collides(Entity entity, double x, double y)
      Checks whether the given entity would be able to stand at the given position, or if it would collide with the collision map or with another entity.
      Parameters:
      entity - The entity that would stand on the given position
      x - The x coordinate of the position where the entity would stand
      y - The y coordinate of the position where the entity would stand
      Returns:
      true iff the entity could stand on the given position
    • collides

      public boolean collides(Entity entity, double x, double y, boolean checkObjects)
      Checks whether the given entity would be able to stand at the given position, or if it would collide with the collision map or (if checkObjects is enabled) with another entity.
      Parameters:
      entity - The entity that would stand on the given position
      x - The x coordinate of the position where the entity would stand
      y - The y coordinate of the position where the entity would stand
      checkObjects - If false, only the collision map will be used.
      Returns:
      true iff the entity could stand on the given position
    • collidesObjects

      public boolean collidesObjects(Entity entity, Rectangle2D area)
    • getEntityAt

      public Entity getEntityAt(double x, double y)
      Finds an Entity at the given coordinates.
      Parameters:
      x - coordinate
      y - coordinate
      Returns:
      the first entity found if there are more than one or null if there are none
    • getEntitiesAt

      public List<Entity> getEntitiesAt(double x, double y)
      Finds all entities at the given coordinates.
      Parameters:
      x - coordinate
      y - coordinate
      Returns:
      list of entities at (x, y)
    • getEntitiesAt

      public <T extends Entity> List<T> getEntitiesAt(double x, double y, Class<T> clazz)
      Finds all entities at the given coordinates.
      Parameters:
      x - coordinate
      y - coordinate
      Returns:
      list of entities at (x, y)
    • getName

      public String getName()
      Get the zone name. This is the same as getID().getID(), only cleaner to use.
      Returns:
      The zone name.
    • getHumanReadableName

      public String getHumanReadableName()
    • notifyEntered

      public void notifyEntered(ActiveEntity entity, int newX, int newY)
      Notify anything interested in when an entity entered.
      Parameters:
      entity - The entity that entered.
      newX - The new X coordinate.
      newY - The new Y coordinate.
    • notifyExited

      public void notifyExited(ActiveEntity entity, int oldX, int oldY)
      Notify anything interested in when an entity exited.
      Parameters:
      entity - The entity that moved.
      oldX - The old X coordinate.
      oldY - The old Y coordinate.
    • notifyMovement

      public void notifyMovement(ActiveEntity entity, int oldX, int oldY, int newX, int newY)
      Notify anything interested that an entity moved.
      Parameters:
      entity - The entity that moved.
      oldX - The old X coordinate.
      oldY - The old Y coordinate.
      newX - The new X coordinate.
      newY - The new Y coordinate.
    • notifyBeforeMovement

      public void notifyBeforeMovement(ActiveEntity entity, int oldX, int oldY, int newX, int newY)
    • addZoneEnterExitListener

      public void addZoneEnterExitListener(ZoneEnterExitListener listener)
    • removeZoneEnterExitListener

      public void removeZoneEnterExitListener(ZoneEnterExitListener listener)
    • addMovementListener

      public void addMovementListener(MovementListener listener)
      Register a movement listener for notification. Eventually create a macro-block hash to cut down on listeners to check.
      Parameters:
      listener - A movement listener to register.
    • removeMovementListener

      public void removeMovementListener(MovementListener listener)
      Unregister a movement listener from notification.
      Parameters:
      listener - A movement listener to unregister.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getItemsOnGround

      public Set<Item> getItemsOnGround()
      Returns:
      a set of all items that are lying on the ground in this zone.
    • getPlayers

      public List<Player> getPlayers()
      Gets all players in this zone.
      Returns:
      A list of all players.
    • getPlayerAndFriends

      public List<RPEntity> getPlayerAndFriends()
      Gets all players in this zone, as well as friendly entities such as sheep. These are the targets (enemies) for wild creatures such as orcs.
      Returns:
      a list of all players and friendly entities
    • isMoveToAllowed

      public boolean isMoveToAllowed()
      Can moveto (mouse movement using pathfinding) be done on this map?
      Returns:
      true, if moveto is possible, false otherwise
    • setMoveToAllowed

      public void setMoveToAllowed(boolean moveToAllowed)
      Sets the flag whether moveto (mouse movement using pathfinding) is possible in this zone.
      Parameters:
      moveToAllowed - true, if it is possible, false otherwise
    • nextTurn

      public void nextTurn()
      Description copied from class: MarauroaRPZone
      This method moves zone from this turn to the next turn. It is called by RPWorld.
      Specified by:
      nextTurn in interface IRPZone
      Overrides:
      nextTurn in class MarauroaRPZone
    • logic

      public void logic()
    • isEmpty

      public boolean isEmpty()
      Return whether the zone is completely empty.
      Returns:
      true if there are no objects in zone
    • containsPlayer

      public boolean containsPlayer()
      Return whether the zone contains one or more players.
      Returns:
      if there are players in zone
    • containsAnimal

      public boolean containsAnimal()
      Return whether the zone contains one or more animals.
      Returns:
      true if there are domesticalanimals in zone
    • containsCreature

      public boolean containsCreature()
      Return whether the zone contains any creature including players and animals.
      Returns:
      true if there are creatures in zone
    • getFilteredEntities

      public List<Entity> getFilteredEntities(FilterCriteria<Entity> criteria)
    • disAllowTeleport

      public void disAllowTeleport()
      Sets the flag whether magic scrolls for teleportation may be uses in this zone.
    • disAllowTeleport

      public void disAllowTeleport(int x, int y, int width, int height)
      Disallow teleporting to and from a specified area.
      Parameters:
      x - left x coordinate
      y - top y coordinate
      width - width of the area
      height - height of the area
    • isTeleportInAllowed

      public boolean isTeleportInAllowed(int x, int y)
      Check if teleporting with a scroll to a location is allowed.
      Parameters:
      x - x coordinate
      y - y coordinate
      Returns:
      true iff teleporting is allowed
    • isTeleportOutAllowed

      public boolean isTeleportOutAllowed(int x, int y)
      Check if teleporting with a scroll from a location is allowed.
      Parameters:
      x - x coordinate
      y - y coordinate
      Returns:
      true iff teleporting is allowed
    • disallowIn

      public void disallowIn()
      Forbid teleporting to the entire zone using a scroll.
    • disallowIn

      public void disallowIn(int x, int y, int width, int height)
      Disallow teleporting to specified area.
      Parameters:
      x - left x coordinate
      y - top y coordinate
      width - width of the area
      height - height of the area
    • disallowOut

      public void disallowOut()
      Forbid teleporting from the entire zone using a scroll.
    • disallowOut

      public void disallowOut(int x, int y, int width, int height)
      Disallow teleporting from specified area.
      Parameters:
      x - left x coordinate
      y - top y coordinate
      width - width of the area
      height - height of the area
    • onRemoved

      public void onRemoved()
    • isPublicAccessible

      public boolean isPublicAccessible()
      Returns:
      is this zone accessible by the public
    • setPublicAccessible

      public void setPublicAccessible(boolean accessible)
      Sets the public accessibility of this zone
      Parameters:
      accessible -
    • describe

      public static String describe(String zoneName)
    • describe

      public String describe()
    • setNoItemMoveMessage

      public void setNoItemMoveMessage(String message)
      Disabled movement of items in this zone.
      Parameters:
      message - in game error message
    • getNoItemMoveMessage

      public String getNoItemMoveMessage()
      Gets the in game error message if movement of items is disabled in this zone.
      Returns:
      message in game error message or null
    • getAttributes

      public ZoneAttributes getAttributes()
      gets the zone attributes
      Returns:
      zone attributes
    • setAssociatedZones

      public void setAssociatedZones(String zones)
      Sets other zones that should receive certain events such as knocking on door.
      Parameters:
      zones - Comma-separated string of zone names.
    • getAssociatedZones

      public String getAssociatedZones()
      Gets other zones that should receive certain events such as knocking on door.
    • getAssociatedZonesList

      public List<String> getAssociatedZonesList()
      Gets other zones that should receive certain events such as knocking on door.