wyvern.kernel.maps
Class MapCommandList

java.lang.Object
  extended bywyvern.kernel.maps.MapCommandList

public final class MapCommandList
extends java.lang.Object

This class keeps track of Commands registered with the map for various commands. It implements the same API for registering commands as the map, and serves as a delegate for those API calls.

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

Constructor Summary
MapCommandList(GameMap map)
           
 
Method Summary
 Command getCommand(CommandEvent event, Commandable agent)
          Checks the list of Commands who have registered this command with the map, and returns the first one whose rectangle of interest intersects the agent issuing the command.
 void registerCommand(java.lang.String command, Command handler, Rectangle room)
          Registers a command handler in a map.
 void unregisterCommand(java.lang.String command, Command handler, Rectangle room)
          Removes the specified Command from the map's command-list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapCommandList

public MapCommandList(GameMap map)
Method Detail

registerCommand

public void registerCommand(java.lang.String command,
                            Command handler,
                            Rectangle room)
Registers a command handler in a map.

Parameters:
command - the command to handle
handler - the callback object to handle the command
room - the map sub-rectangle in which to register interest. It can be the entire map bounds if the handler wants to handle the command no matter where the agent is. The rectangle is clipped against the map bounds, so it's not an error if it specifies an area outside the map bounds.

unregisterCommand

public void unregisterCommand(java.lang.String command,
                              Command handler,
                              Rectangle room)
Removes the specified Command from the map's command-list. The Command may be registered for the command in multiple rectangles in the same map, so you need to pass in the rectangle that was passed to registerCommand().

Parameters:
command - the command to unregister
handler - the handler to unregister
room - the rect to unregister

getCommand

public Command getCommand(CommandEvent event,
                          Commandable agent)
Checks the list of Commands who have registered this command with the map, and returns the first one whose rectangle of interest intersects the agent issuing the command.

Parameters:
event - the command event to look for a handler for
agent - the agent doing the command
Returns:
a Command to handle the command, or null if no Command was registered for that command where the agent is at.