Class StendhalRPZone
java.lang.Object
marauroa.server.game.rp.MarauroaRPZone
games.stendhal.server.core.engine.StendhalRPZone
- Direct Known Subclasses:
AdventureIsland,Northpole,Vault
-
Nested Class Summary
Nested classes/interfaces inherited from interface marauroa.common.game.IRPZone
IRPZone.ID -
Field Summary
FieldsModifier and TypeFieldDescriptioncontains data to if a certain area is walkable.Contains data to verify is someone is in a PK-free area.Fields inherited from class marauroa.server.game.rp.MarauroaRPZone
objects, zoneid -
Constructor Summary
ConstructorsConstructorDescriptionStendhalRPZone(String name) StendhalRPZone(String name, int width, int height) StendhalRPZone(String name, StendhalRPZone zone) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(CreatureRespawnPoint point) Add a creature respawn point to the zone.voidThis method adds an object to this zone.voidAdds an object to the ground.voidAdds an object to the ground.voidaddCollisionLayer(String name, LayerDefinition collisionLayer) voidaddLayer(String name, LayerDefinition layer) voidaddMovementListener(MovementListener listener) Register a movement listener for notification.voidRegisters a grower in this zone.voidaddProtectionLayer(String name, LayerDefinition protectionLayer) voidaddTilesets(String name, List<TileSetDefinition> tilesets) voidaddToPlayersAndFriends(RPEntity object) adds an RPEntity to the playersAndFriends list.voidassignPortalID(Portal portal) voidCalculate danger level for the zone, and store it in the data layer.booleancollides(int x, int y) Checks a single pair of coordinates for collision.booleanChecks 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.booleanChecks 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.booleancollides(Rectangle2D shape) Checks an area for collision.booleancollidesObjects(Entity entity, Rectangle2D area) booleancollidesOnLine(int x1, int y1, int x2, int y2) Checks if there is a collision on the airline between 2 positions.booleanReturn whether the zone contains one or more animals.booleanReturn whether the zone contains any creature including players and animals.booleanReturn whether the zone contains one or more players.protected voidcreateEntityAt(String clazz, int type, int x, int y) Create a map entity as a given coordinate.protected voidcreateLevelPortalAt(int type, int x, int y) describe()static StringvoidForbid teleporting to the entire zone using a scroll.voiddisallowIn(int x, int y, int width, int height) Disallow teleporting to specified area.voidForbid teleporting from the entire zone using a scroll.voiddisallowOut(int x, int y, int width, int height) Disallow teleporting from specified area.voidSets the flag whether magic scrolls for teleportation may be uses in this zone.voiddisAllowTeleport(int x, int y, int width, int height) Disallow teleporting to and from a specified area.Gets other zones that should receive certain events such as knocking on door.Gets other zones that should receive certain events such as knocking on door.gets the zone attributesgetBlood(int x, int y) Get blood (if any) at a specified zone position.getEntitiesAt(double x, double y) Finds all entities at the given coordinates.getEntitiesAt(double x, double y, Class<T> clazz) Finds all entities at the given coordinates.getEntityAt(double x, double y) Finds an Entity at the given coordinates.getFilteredEntities(FilterCriteria<Entity> criteria) intintgetLevel()getName()Get the zone name.Gets the in game error message if movement of items is disabled in this zone.Retrieves growers in this zone.Gets all players in this zone, as well as friendly entities such as sheep.Gets all players in this zone.getPortal(int x, int y) Get the portal (if any) at a specified zone position.Get the list of sheep foods in the zone.Retrieves the zone's weather management entity.intgetWidth()intgetX()intgetY()booleanintersects(Rectangle2D area) Determine if this zone overlaps an area in global coordinates.booleanisEmpty()Return whether the zone is completely empty.booleanisInProtectionArea(Entity entity) booleanbooleanCan moveto (mouse movement using pathfinding) be done on this map?booleanbooleanisTeleportInAllowed(int x, int y) Check if teleporting with a scroll to a location is allowed.booleanisTeleportOutAllowed(int x, int y) Check if teleporting with a scroll from a location is allowed.booleanleavesZone(Entity entity, double x, double y) voidlogic()voidThis method notify zone that the object has been modified.voidnextTurn()This method moves zone from this turn to the next turn.voidnotifyBeforeMovement(ActiveEntity entity, int oldX, int oldY, int newX, int newY) voidnotifyEntered(ActiveEntity entity, int newX, int newY) Notify anything interested in when an entity entered.voidnotifyExited(ActiveEntity entity, int oldX, int oldY) Notify anything interested in when an entity exited.voidnotifyMovement(ActiveEntity entity, int oldX, int oldY, int newX, int newY) Notify anything interested that an entity moved.voidResend the zone data to players on the zone.voidbooleanplaceObjectAtEntryPoint(Entity entity) voidpopulate(LayerDefinition objectsLayer) Populate a zone based on it's map content.voidremove(CreatureRespawnPoint point) Remove a creature respawn point from the zone.removes object from zone.remove(RPObject.ID id) Removes the object from zone.voidremoveMovementListener(MovementListener listener) Unregister a movement listener from notification.voidUnregisters a grower in this zone.voidvoidsetAssociatedZones(String zones) Sets other zones that should receive certain events such as knocking on door.voidsetAttributes(ZoneAttributes attr) Set zone attributes that should be passed to the client.voidsetEntryPoint(int x, int y) voidsetMoveToAllowed(boolean moveToAllowed) Sets the flag whether moveto (mouse movement using pathfinding) is possible in this zone.voidsetNoItemMoveMessage(String message) Disabled movement of items in this zone.voidvoidsetPosition(int level, int x, int y) voidsetPublicAccessible(boolean accessible) Sets the public accessibility of this zonebooleansimpleCollides(Entity entity, double x, double y, double w, double h) toString()Methods inherited from class marauroa.server.game.rp.MarauroaRPZone
assignRPObjectID, get, getID, getPerception, has, hide, iterator, onFinish, onInit, print, reset, size, storeToDatabase, unhideMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
collisionMap
contains data to if a certain area is walkable. -
protectionMap
Contains data to verify is someone is in a PK-free area.
-
-
Constructor Details
-
StendhalRPZone
-
StendhalRPZone
-
StendhalRPZone
-
-
Method Details
-
getBlood
Get blood (if any) at a specified zone position.- Parameters:
x- The X coordinate.y- The Y coordinate.- Returns:
- The blood, or
null.
-
getNPCList
-
getPortals
-
getPortal
-
getPortal
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
Get the list of sheep foods in the zone.- Returns:
- The list of sheep foods.
-
getRespawnPointList
-
add
Add a creature respawn point to the zone.- Parameters:
point- The respawn point.
-
remove
Remove a creature respawn point from the zone.- Parameters:
point- The respawn point.
-
getPlantGrowers
Retrieves growers in this zone. -
addPlantGrower
Registers a grower in this zone.- Parameters:
grower- Grower being added.
-
removePlantGrower
Unregisters a grower in this zone.- Parameters:
grower- Grower being removed.
-
assignPortalID
-
setEntryPoint
public void setEntryPoint(int x, int y) -
placeObjectAtEntryPoint
-
addLayer
- Throws:
IOException
-
addTilesets
- 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
Set zone attributes that should be passed to the client.- Parameters:
attr- attributes
-
addCollisionLayer
- Throws:
IOException
-
addProtectionLayer
- 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
Determine if this zone overlaps an area in global coordinates.- Parameters:
area- The area (in global coordinate space).- Returns:
trueif the area overlaps.
-
populate
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
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
-
isInProtectionArea
-
leavesZone
-
simpleCollides
-
add
Description copied from class:MarauroaRPZoneThis method adds an object to this zone.- Specified by:
addin interfaceIRPZone- Overrides:
addin classMarauroaRPZone- Parameters:
object- object to add.
-
add
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 zoneplayer- The player that dropped the item
-
add
Adds an object to the ground.- Parameters:
object- The object that should be added to the zoneexpire- True if the item should expire according to its normal behaviour, false otherwise
-
addToPlayersAndFriends
adds an RPEntity to the playersAndFriends list.- Parameters:
object- RPEntity
-
remove
Description copied from class:MarauroaRPZoneRemoves the object from zone.- Specified by:
removein interfaceIRPZone- Overrides:
removein classMarauroaRPZone- Parameters:
id- identified of the removed object- Returns:
- the removed object
-
remove
removes object from zone.- Parameters:
object-- Returns:
- the removed object
-
modify
Description copied from class:MarauroaRPZoneThis 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:
modifyin interfaceIRPZone- Overrides:
modifyin classMarauroaRPZone- 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 1y1- y value of position 1x2- x value of position 2y2- 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-coordinatey- Y-coordinate- Returns:
trueif collision tile located at coordinates.
-
collides
Checks an area for collision.- Parameters:
shape- Rectangle area.- Returns:
trueif any collision tiles are found in the area.
-
collides
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 positionx- The x coordinate of the position where the entity would standy- The y coordinate of the position where the entity would stand- Returns:
- true iff the entity could stand on the given position
-
collides
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 positionx- The x coordinate of the position where the entity would standy- The y coordinate of the position where the entity would standcheckObjects- If false, only the collision map will be used.- Returns:
- true iff the entity could stand on the given position
-
collidesObjects
-
getEntityAt
Finds an Entity at the given coordinates.- Parameters:
x- coordinatey- coordinate- Returns:
- the first entity found if there are more than one or null if there are none
-
getEntitiesAt
Finds all entities at the given coordinates.- Parameters:
x- coordinatey- coordinate- Returns:
- list of entities at (x, y)
-
getEntitiesAt
Finds all entities at the given coordinates.- Parameters:
x- coordinatey- coordinate- Returns:
- list of entities at (x, y)
-
getName
Get the zone name. This is the same asgetID().getID(), only cleaner to use.- Returns:
- The zone name.
-
getHumanReadableName
-
notifyEntered
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
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
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
-
addZoneEnterExitListener
-
removeZoneEnterExitListener
-
addMovementListener
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
Unregister a movement listener from notification.- Parameters:
listener- A movement listener to unregister.
-
toString
-
getItemsOnGround
- Returns:
- a set of all items that are lying on the ground in this zone.
-
getPlayers
Gets all players in this zone.- Returns:
- A list of all players.
-
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:MarauroaRPZoneThis method moves zone from this turn to the next turn. It is called by RPWorld.- Specified by:
nextTurnin interfaceIRPZone- Overrides:
nextTurnin classMarauroaRPZone
-
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
-
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 coordinatey- top y coordinatewidth- width of the areaheight- 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 coordinatey- y coordinate- Returns:
trueiff 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 coordinatey- y coordinate- Returns:
trueiff 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 coordinatey- top y coordinatewidth- width of the areaheight- 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 coordinatey- top y coordinatewidth- width of the areaheight- 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
-
describe
-
setNoItemMoveMessage
Disabled movement of items in this zone.- Parameters:
message- in game error message
-
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
gets the zone attributes- Returns:
- zone attributes
-
setAssociatedZones
Sets other zones that should receive certain events such as knocking on door.- Parameters:
zones- Comma-separated string of zone names.
-
getAssociatedZones
Gets other zones that should receive certain events such as knocking on door. -
getAssociatedZonesList
Gets other zones that should receive certain events such as knocking on door. -
getWeatherEntity
Retrieves the zone's weather management entity.- Returns:
- Weather entity instance.
-