Class OccupantArea
java.lang.Object
marauroa.common.game.Attributes
marauroa.common.game.SlotOwner
marauroa.common.game.RPObject
games.stendhal.server.entity.Entity
games.stendhal.server.entity.mapstuff.area.AreaEntity
games.stendhal.server.entity.mapstuff.area.OccupantArea
- All Implemented Interfaces:
MovementListener
,TurnListener
,Killer
,Cloneable
,Iterable<String>
,Serializable
- Direct Known Subclasses:
DamagingArea
,LifeDrainArea
An base area that performs actions on RPEntity's that are entering, leaving,
moving in, or standing in it's space.
-
Nested Class Summary
Nested classes/interfaces inherited from class marauroa.common.game.RPObject
RPObject.ID
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
How often an action is done while stationary (in turns).protected boolean
Applies only to players.protected List<RPObject.ID>
A list of entities [potentially] occupying this area.Fields inherited from class games.stendhal.server.entity.mapstuff.area.AreaEntity
ATTR_NAME
Fields inherited from class marauroa.common.game.RPObject
INVALID_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Add an entity to the target list.void
beforeMove(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY)
Invoked before an entity moves while over the object area.protected boolean
handleAdded(RPEntity entity)
An entity has entered the area.protected boolean
handleInterval(RPEntity entity)
Apply actions done at regular intervals.protected boolean
handleMovement(RPEntity entity)
Apply actions done while moving.protected void
handleRemoved(RPEntity entity)
An entity has left the area.boolean
isOccupant(RPEntity entity)
Check if an entity is an [acknowledged] occupant of this area.void
onAdded(StendhalRPZone zone)
Called when this object is added to a zone.void
onEntered(ActiveEntity entity, StendhalRPZone zone, int newX, int newY)
Invoked when an entity enters the object area.void
onExited(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY)
Invoked when an entity leaves the object area.void
onMoved(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY)
Invoked when an entity moves while over the object area.void
onRemoved(StendhalRPZone zone)
Called when this object is being removed from a zone.void
onTurnReached(int currentTurn)
This method is called when the turn number is reached.protected void
removeTarget(RPEntity entity)
Remove an entity from the target list.void
setPlayersOnly(boolean playersOnly)
Set whether only players get affected.void
update()
Handle object attribute change(s).Methods inherited from class games.stendhal.server.entity.mapstuff.area.AreaEntity
addBehaviour, generateRPClass, getDescriptionName, getName, getTitle, setName
Methods inherited from class games.stendhal.server.entity.Entity
describe, getAdjacentNodes, getArea, getArea, getCursor, getDescription, getEntitySlot, getHeight, getOrigin, getResistance, getResistance, getWidth, getX, getY, getZone, hasDescription, isInSight, isObstacle, nextTo, nextTo, notifyWorldAboutChanges, onMoved, setCursor, setDescription, setEntityClass, setEntitySubclass, setMenu, setPosition, setResistance, setSize, setVisibility, slotIterator, slots, squaredDistance, squaredDistance, stopped
Methods inherited from class marauroa.common.game.RPObject
addEvent, addLink, addLink, addMap, addSlot, addSlot, applyDifferences, clearEvents, clearVisible, clone, containsKey, equals, events, eventsIterator, fill, get, getBaseContainer, getBoolean, getContainer, getContainerBaseOwner, getContainerOwner, getContainerSlot, getDifferences, getDouble, getFromSlots, getID, getInt, getLink, getLinkedObject, getMap, getSlot, has, hashCode, hasLink, hasMap, hasSlot, hide, isContained, isEmpty, isHidden, isStorable, maps, put, put, put, put, readObject, remove, removeLink, removeMap, removeSlot, resetAddedAndDeleted, resetAddedAndDeletedMaps, resetAddedAndDeletedRPLink, resetAddedAndDeletedRPSlot, setAddedMaps, setAddedRPSlot, setContainer, setDeletedMaps, setDeletedRPSlot, setID, size, slots, slotsIterator, store, toString, unhide, unstore, writeObject, writeObject, writeToJson
Methods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlots
Methods inherited from class marauroa.common.game.Attributes
add, applyDifferences, get, getBool, getDouble, getInt, getList, getLong, getRPClass, has, instanceOf, iterator, put, put, put, put, put, readFromMap, remove, resetAddedAndDeletedAttributes, setAddedAttributes, setDeletedAttributes, setRPClass, setRPClass, toAttributeString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface games.stendhal.server.core.events.MovementListener
getArea
-
Field Details
-
interval
protected int intervalHow often an action is done while stationary (in turns). -
playersOnly
protected boolean playersOnlyApplies only to players. -
targets
A list of entities [potentially] occupying this area.
-
-
Constructor Details
-
OccupantArea
public OccupantArea(int width, int height, int interval)Create an occupant area.- Parameters:
width
- Width of this areaheight
- Height of this areainterval
- Standing action interval.
-
-
Method Details
-
addTarget
Add an entity to the target list.- Parameters:
entity
- The RPEntity to add.
-
isOccupant
Check if an entity is an [acknowledged] occupant of this area.- Parameters:
entity
- to be tested- Returns:
- true if is occupant
-
handleAdded
An entity has entered the area. This should not apply any actions thathandleMovement()
does.- Parameters:
entity
- The RPEntity that was added.- Returns:
false
if this entity should not be processed,true
otherwise.
-
handleInterval
Apply actions done at regular intervals.- Parameters:
entity
- The RPEntity occupant.- Returns:
false
if this entity should be removed from further processing,true
otherwise.
-
handleMovement
Apply actions done while moving.- Parameters:
entity
- The RPEntity that moved.- Returns:
false
if this entity should be removed from further processing,true
otherwise.
-
handleRemoved
An entity has left the area. This should not apply any actions thathandleMovement()
does.- Parameters:
entity
- The RPEntity that was added.
-
removeTarget
Remove an entity from the target list.- Parameters:
entity
- The RPEntity to remove.
-
setPlayersOnly
public void setPlayersOnly(boolean playersOnly)Set whether only players get affected.- Parameters:
playersOnly
- Whether to only affect players.
-
onAdded
Called when this object is added to a zone.- Overrides:
onAdded
in classAreaEntity
- Parameters:
zone
- The zone this was added to.
-
onRemoved
Called when this object is being removed from a zone.- Overrides:
onRemoved
in classAreaEntity
- Parameters:
zone
- The zone this will be removed from.
-
update
public void update()Handle object attribute change(s). -
onEntered
Invoked when an entity enters the object area.- Specified by:
onEntered
in interfaceMovementListener
- Parameters:
entity
- The entity that moved.zone
- The new zone.newX
- The new X coordinate.newY
- The new Y coordinate.
-
onExited
Invoked when an entity leaves the object area.- Specified by:
onExited
in interfaceMovementListener
- Parameters:
entity
- The entity that entered.zone
- The old zone.oldX
- The old X coordinate.oldY
- The old Y coordinate.
-
onMoved
public void onMoved(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY)Invoked when an entity moves while over the object area.- Specified by:
onMoved
in interfaceMovementListener
- Parameters:
entity
- The entity that left.zone
- The zone.oldX
- The old X coordinate.oldY
- The old Y coordinate.newX
- The new X coordinate.newY
- The new Y coordinate.
-
onTurnReached
public void onTurnReached(int currentTurn)This method is called when the turn number is reached.- Specified by:
onTurnReached
in interfaceTurnListener
- Parameters:
currentTurn
- Current turn number.
-
beforeMove
public void beforeMove(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY)Description copied from interface:MovementListener
Invoked before an entity moves while over the object area.- Specified by:
beforeMove
in interfaceMovementListener
- Parameters:
entity
- The entity that left.zone
- The zone.oldX
- The old X coordinate.oldY
- The old Y coordinate.newX
- The new X coordinate.newY
- The new Y coordinate.
-