wyvern.lib.event
Class MapPlayerEvent

java.lang.Object
  extended bywyvern.lib.event.MapPlayerEvent

public final class MapPlayerEvent
extends java.lang.Object

A notification sent to wyvern.lib.properties.MapPlayerListener objects when any player enters the map, leaves the map, or moves in the map.

Version:
1.0, Aug 05, 2003
Author:
Steve Yegge

Field Summary
static int ENTERED_MAP
           
static int LEFT_MAP
           
static int MOVED_IN_MAP
           
 
Constructor Summary
MapPlayerEvent(GameMap map, Player player, int type, Point source)
          Constructs a new MapPlayerEvent.
 
Method Summary
 GameMap getMap()
          Returns GameMap where the event occurred.
 Player getPlayer()
          Returns player who entered/left/moved
 Point getSource()
          Returns an extra piece of information, depending on the event type.
 int getType()
          Returns event type
 java.lang.String toString()
          Returns debugging string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ENTERED_MAP

public static final int ENTERED_MAP
See Also:
Constant Field Values

LEFT_MAP

public static final int LEFT_MAP
See Also:
Constant Field Values

MOVED_IN_MAP

public static final int MOVED_IN_MAP
See Also:
Constant Field Values
Constructor Detail

MapPlayerEvent

public MapPlayerEvent(GameMap map,
                      Player player,
                      int type,
                      Point source)
Constructs a new MapPlayerEvent. You probably shouldn't be creating these yourself, but if you do, make sure the source parameter is correct for the event type you pass in. See getSourcePoint() for details.

Method Detail

getType

public int getType()
Returns event type

Returns:
event type

getPlayer

public Player getPlayer()
Returns player who entered/left/moved

Returns:
player who entered/left/moved

getSource

public Point getSource()
Returns an extra piece of information, depending on the event type.

Returns:
a wyvern.lib.Point:
  • For ENTERED_MAP events, returns the point they entered at. This is equivalent to calling player.getReferenceLoc().

  • For LEFT_MAP events, returns the point they departed from. They've already left the map, so player.getReferenceLoc() will return their position in their new map, unless they left by quitting the game.

  • For MOVED_IN_MAP events, returns the point they moved or teleported from. player.getReferenceLoc() will return their new location in the map, post-move. Having the source and destination points available is useful for determining whether the player has moved in or out of range of a given object.
In all three cases, **DO NOT** modify the returned Point's x or y values.

getMap

public GameMap getMap()
Returns GameMap where the event occurred.

Returns:
GameMap where the event occurred.

toString

public java.lang.String toString()
Returns debugging string.