wyvern.kernel.motion
Class TeleportCommand

java.lang.Object
  extended bywyvern.kernel.motion.TeleportCommand
All Implemented Interfaces:
BuiltInCommand, Command, NoOverride

public class TeleportCommand
extends java.lang.Object
implements BuiltInCommand, NoOverride

This Command handles hookable teleport events.

NOTE: If you register with a map (via a map, room or proximity hook) for "teleportPostHook", to tell when someone has left the map by teleporting, you won't ever get called. This is because the game kernel runs the map hook using the agent's map after the command is processed, which for teleporting is a different map. There are two (somewhat cumbersome) possible workarounds:

(A possible engine-level workaround is to have the TeleportCommand be on its own teleportPostHook somehow, and run the post-hook on both the starting and ending maps.)

Version:
1.0, Nov 5, 1998
Author:
Steve Yegge

Method Summary
 void addCommands(java.util.Map commands, CommandList list)
          Adds commands.
 CommandEvent createEvent(CommandEvent event)
          Creates an event to encapsulate the wizard typing "teleport map|player [ ]".
 boolean execute(CommandEvent event)
          Teleports the agent.
static TeleportCommand getImpl()
           
static boolean goingToOtherWorkroom(java.lang.String name, java.lang.String path)
          Returns true if the destination is a workroom *other* than the agent's workroom.
 boolean handleBack(CommandEvent event)
          Executes the "back" command, taking the wizard back to whichever map they were in before they last typed "goto <map>".
 boolean knowsCommand(java.lang.String command)
          Built-in commands return true for this method.
static void main(java.lang.String[] args)
          Tests the pattern-matching stuff.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImpl

public static TeleportCommand getImpl()

addCommands

public void addCommands(java.util.Map commands,
                        CommandList list)
Adds commands.

Specified by:
addCommands in interface BuiltInCommand
Parameters:
list - the CommandList we're being added to
commands - the map to add our commands to

knowsCommand

public boolean knowsCommand(java.lang.String command)
Built-in commands return true for this method.

Specified by:
knowsCommand in interface Command
Parameters:
command - the command to check
Returns:
true if we want to handle the command

createEvent

public CommandEvent createEvent(CommandEvent event)
Creates an event to encapsulate the wizard typing "teleport map|player [ ]".

Specified by:
createEvent in interface Command
Parameters:
event - the event containing the initial arguments
Returns:
a CommandEvent containing properties relevant to this event:

  • "src-map" - agent's original map
  • "dest-map" - destination map virtual path
  • "dest-loc" - Point in destination map to try to go to
  • "src-loc" - Point in source map they came from

execute

public boolean execute(CommandEvent event)
Teleports the agent.

Specified by:
execute in interface Command
Parameters:
event - the CommandEvent with the args & properties relevant to a teleport command.
Returns:
true if the event completed successfully, else false.

goingToOtherWorkroom

public static boolean goingToOtherWorkroom(java.lang.String name,
                                           java.lang.String path)
Returns true if the destination is a workroom *other* than the agent's workroom.

Parameters:
name - the agent's name
path - the path to the destination map
Returns:
true if it's a wizard workroom other than the agent's.

handleBack

public boolean handleBack(CommandEvent event)
Executes the "back" command, taking the wizard back to whichever map they were in before they last typed "goto <map>".


main

public static void main(java.lang.String[] args)
Tests the pattern-matching stuff.