|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwyvern.kernel.properties.PList
wyvern.kernel.maps.MapObject
wyvern.lib.classes.Teleporter
The Teleporter is a fundamental game object responsible for moving objects between maps. It can also put things in a different location in the same map. Teleporters are used for entrances and exits, and also to create "fake walls" or let you walk on terrain you couldn't normally walk on.
| Field Summary | |
static boolean |
FORCE_PLAYERS
This behavior might bother some people, so I've set a compile-time flag for it, for now. |
static int |
MAX_DISTANCE
The maximum distance we'll try to randomly teleport someone in a sparse map (applies to both x & y coordinates). |
static java.lang.String |
PLEASE_WAIT_MSG
Default message to print while destination map is loading. |
| Fields inherited from class wyvern.kernel.maps.MapObject |
IN_MAP_EDITOR, listenerList_ |
| Fields inherited from class wyvern.kernel.properties.PList |
readOnly_ |
| Fields inherited from interface wyvern.lib.PropertyList |
PROPERTY_PACKAGE |
| Constructor Summary | |
Teleporter()
|
|
| Method Summary | |
void |
apply(Commandable agent)
User applies the teleporter. |
protected void |
checkBounds(GameMap map,
Point dest,
Commandable agent)
Checks that the specified destination location is in the bounds of the map. |
protected void |
checkPerPlayer(java.lang.String mapname)
Check if this teleporter's map is the same as the map being loaded. |
protected java.lang.String |
checkRelativePath(Commandable agent,
java.lang.String name)
Checks whether the specified relative map path exists under this teleporter's absolute path. |
static Point |
chooseRandomLocation(GameMap map,
Point ref)
Chooses a random place to teleport an object. |
Location |
getDestination()
Gets the destination for this teleporter. |
Point |
getDestLoc(GameMap map)
Figures out where to put the agent. |
GameMap |
getDestMap(Commandable agent)
Returns the destination map for the teleporter. |
java.lang.String |
getWaitMessage()
Returns the value of "please-wait-msg", if present, or Teleporter.PLEASE_WAIT_MSG. |
void |
initialize()
Initializes the object's default properties. |
GameMap |
loadMap(java.lang.String path,
Commandable agent)
Locates & returns the GameMap specified by the destination. |
Location |
parseDestination(java.lang.String dest)
Turns a destination string into a Location object. |
static boolean |
passedClaim(GameMap map,
Commandable agent)
Checks whether a player is allowed to enter the map. |
static boolean |
pathOutIsBlocked(Commandable agent,
GameMap map)
Returns true if the specified map is part of the "way out" for the agent. |
protected void |
printLoadMessage(Commandable agent)
If the map isn't loaded, prints an appropriate message - either the unavailable-map, if there's no destination, or a "please wait" message if it's going to load in the background. |
void |
setDestination(int x,
int y,
java.lang.String map)
Sets the destination for this teleporter. |
void |
setDestination(Location loc)
Sets the destination for this teleporter. |
void |
setMap(GameMap map,
int x,
int y)
Autoloads our destination, if we have the "autoload" property. |
void |
startTeleport(Commandable agent)
Initiates a command that will teleport the agent. |
void |
steppedOn(Monster m)
WalkNotify: someone moved over us. |
boolean |
teleport(Commandable agent,
GameMap map,
Point dest)
Teleports a Commandable to destination point in a map. |
boolean |
teleport(Commandable agent,
java.lang.String mapname,
Point dest)
Teleports the agent to the specified map, loading the map if necessary. |
protected boolean |
teleport(Location loc,
Commandable agent)
Teleports agent to the passed location. |
boolean |
teleport(java.lang.String mapname,
Commandable agent)
Teleports the agent to the specified map by asking the map for a destination location. |
java.lang.String |
toString()
Returns a String representation of this object. |
protected void |
tryForcing(Commandable agent)
Adds a "force-map" property on the player with this teleporter's destination, so that when the map is loaded, the player will teleport there automatically. |
protected boolean |
validateLevel(Commandable agent)
Ensures the agent is in the specified experience level the teleporter (or destination map) will allow. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int MAX_DISTANCE
public static final java.lang.String PLEASE_WAIT_MSG
public static final boolean FORCE_PLAYERS
| Constructor Detail |
public Teleporter()
| Method Detail |
public void initialize()
GameObject
initialize in interface GameObjectinitialize in class MapObject
public void setMap(GameMap map,
int x,
int y)
setMap in interface GameObjectsetMap in class MapObject
public void setDestination(int x,
int y,
java.lang.String map)
public void setDestination(Location loc)
public Location getDestination()
public void steppedOn(Monster m)
steppedOn in interface WalkNotifym - the monster who walked on uspublic void apply(Commandable agent)
apply in interface Applyableagent - the monster or player trying to pass throughpublic void startTeleport(Commandable agent)
Any Player (or subclass) or Commandable with the "teleportable" property may go through a teleporter.
agent - the Commandable to teleport to our destinationprotected void printLoadMessage(Commandable agent)
public GameMap getDestMap(Commandable agent)
agent - the agent to put in the map (for printing errors; null
if no error messages should be sent).
public Point getDestLoc(GameMap map)
map - the map to put them in
protected void checkBounds(GameMap map,
Point dest,
Commandable agent)
java.lang.IllegalArgumentException - if the dest loc is OOBprotected boolean validateLevel(Commandable agent)
agent - the Commandable to teleport to our destination
public static Point chooseRandomLocation(GameMap map,
Point ref)
ref - the starting point for the object - in sparse maps,
the object is never teleported more than MAX_DISTANCE from
this point. This parameter will be ignored (and can be null)
if the map is dense or it has a "bounds" property defining
the valid bounds for the map.map - the map to teleport the object to
public Location parseDestination(java.lang.String dest)
dest - a destination string, such as "cities/blarg 20 30"
public java.lang.String toString()
toString in class MapObject
public boolean teleport(java.lang.String mapname,
Commandable agent)
mapname - the map to go to. ".map" extension is optional.agent - the agent to send there.
protected boolean teleport(Location loc,
Commandable agent)
loc - the Location to go toagent - the agent to send
public boolean teleport(Commandable agent,
java.lang.String mapname,
Point dest)
agent - the agent to sendmapname - the relative path the map to go to.
".map" extension optional. Example: "village/village"dest - the destination in the map. Can be null, in
which case the map is asked for the starting location.
public boolean teleport(Commandable agent,
GameMap map,
Point dest)
This is the final method in the teleporting sequence that takes you to another location within a map, or within the same map. It starts with the "teleport" command, which creates a TeleportEvent, figures out the destination, runs the hooks, loads the map in the background, issues map-entry messages and background music changes, and so on. This is the final method that actually performs the transfer of the agent into the destination map.
map - the map to teleport todest - the destination point to go to (can't be null)agent - the agent to send there
public GameMap loadMap(java.lang.String path,
Commandable agent)
path - the relative path to the map file. ".map"
extension is optional (but we prefer that you don't include it).agent - the agent wanting to go to the map
protected void checkPerPlayer(java.lang.String mapname)
protected java.lang.String checkRelativePath(Commandable agent,
java.lang.String name)
agent - the agent being teleportedname - the name (or relative path plus name) of a map
public static boolean passedClaim(GameMap map,
Commandable agent)
map - the map to checkagent - the player who wants to enter
public static boolean pathOutIsBlocked(Commandable agent,
GameMap map)
agent - the player that's teleportingmap - the map they're trying to teleport to
public java.lang.String getWaitMessage()
protected void tryForcing(Commandable agent)
This method is called from startTeleport(), after printing the "please wait" message. If the teleporter has no destination, this method returns without doing anything.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||