|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.properties.PList wyvern.kernel.maps.MapObject wyvern.kernel.commands.AbstractCommandable wyvern.lib.classes.Vehicle
This class implements a generic vehicle that can be boarded and piloted around.
Field Summary |
Fields inherited from class wyvern.kernel.commands.AbstractCommandable |
hookList_, queue_, started_ |
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 |
Fields inherited from interface wyvern.common.net.RemoteAudio |
DEFAULT_ALERT_GAIN, DEFAULT_ALERT_REPEAT_DELAY, DEFAULT_ALERT_REPEATS, DEFAULT_GAIN, DEFAULT_REPEAT_DELAY, DEFAULT_REPEATS |
Constructor Summary | |
Vehicle()
|
Method Summary | |
void |
addCamera(Camera cam)
Adds a camera to our control-list. |
void |
addHooks(Player p)
Adds hooks to be notified before & after moves. |
void |
addPilot(Commandable agent)
Adds the passed Commandable as a pilot of the vehicle. |
protected boolean |
adjacentTo(java.util.List alocs,
Point p,
java.util.List locs)
Checks whether the proposed destination would put the agent within one square of the vehicle. |
void |
apply(Commandable agent)
The vehicle is being applied/boarded. |
boolean |
boardPassenger(Commandable agent)
Puts a passenger in the vehicle, if there's room. |
void |
createCommandList()
Creates a CommandList holding the built-in game commands that we respond to. |
CommandEvent |
createEvent(CommandEvent initialInfo)
Creates a CommandEvent that encapsulates the command. |
protected GameMap |
createInteriorMap()
This method is called from initialize() to create the interior of the vehicle. |
boolean |
disembark(Commandable agent)
Removes a passenger from the vehicle. |
protected void |
ensureAI()
We have no AI. |
boolean |
execute(CommandEvent event)
Executes the specified CommandEvent. |
Point |
findDisembarkLocation(Commandable agent)
Looks for a place to dump the player upon disembarking. |
Point |
getCameraPos()
Returns the position at which to place cameras viewing the vehicle from the outside. |
Command |
getCommand(CommandEvent event)
Returns the Command to handle our commands. |
GameMap |
getInteriorMap()
Returns the vehicle-interior map. |
void |
grabCamera(Player p)
Puts a player's camera outside the vehicle so they can see where it's going. |
protected boolean |
handleExit(CommandEvent event)
Player wants out. |
void |
handleFailedPostMove(CommandEvent event)
Handles notifying the player, after we moved, if something went wrong. |
void |
handleLookXY(CommandEvent event)
Handles mouse-click for looking at an object. |
void |
handleMouse(CommandEvent ev)
Handles mouse clicks while player is in the vehicle. |
protected boolean |
handlePilot(CommandEvent event)
Turns vehicle piloting (i.e. overriding moves to move the vehicle) on or off. |
void |
handlePreMove(CommandEvent event)
Figures out whether to move the vehicle instead of the agent. |
void |
handleTeleport(CommandEvent event)
See if we can intercept teleporting out of the vehicle. |
protected boolean |
handleView(CommandEvent event)
Handles the "view" command, by way of which the user can put their camera inside or outside the vehicle. |
void |
hookEvent(java.lang.String hookName,
CommandEvent event)
Hooks motion events. |
void |
initialize()
Initializes the object's default properties. |
boolean |
isPilot(Commandable agent)
Returns true if the agent is listed among the vehicles's pilots. |
boolean |
isValidDir(int dir)
Returns whether the passed direction (interpreted as a wyvern.lib.Direction constant) is a valid direction for this vehicle. |
boolean |
knowsCommand(java.lang.String command)
Returns true if we want to handle the command. |
void |
methodCalled(java.lang.String hookName,
MethodHookable target,
java.lang.Object data)
Shuts down the ship if the map is unloading. |
void |
printWelcome(Commandable agent)
Prints the welcome message when the agent boards the vessel. |
void |
relinquishCamera(Player p)
Puts the camera back under the control of the player. |
void |
remove()
Removes from the map. |
void |
removeCamera(Camera cam)
Removes a camera from our control-list. |
void |
removeHooks(Player p)
Removes ourself from any hooks we got on. |
void |
removePilot(Commandable agent)
Removes the specified agent from the pilot-list. |
void |
setMap(GameMap map,
int x,
int y)
Puts the vehicle in a new map. |
void |
teleport(int x,
int y)
Teleports the object to a completely new map location. |
void |
toggleView(Player p)
Toggles the player's camera from inside to out & vice-versa. |
Point |
translateToThisMap(Point p,
Player player)
Translates the point from the agent's coordinate space into our coordinate space. |
void |
unhookPlayer(Commandable agent)
Removes any hooks, commands and camera-manipulation stuff that were added when the player boarded. |
void |
updateMapLocation(java.util.List oldpos,
java.util.List newpos)
Translates the object to a new relative location. |
boolean |
viewingInside(Player p)
Returns true if the player is looking inside the vehicle. |
Methods inherited from class wyvern.kernel.commands.AbstractCommandable |
addAttack, addHook, addMessageListener, addMethodHook, checkAnimated, command, command, commandNow, destroy, ensureEventQueue, fireMessageReceived, getAI, getCapName, getCombatQueue, getEncumbrance, getFiringPoint, getHookList, getHooks, getInventory, getName, getQueue, isCommandable, isStarted, isTelnet, message, message, message, pauseSound, playAlert, playAlert, playDefaultMusic, playPriorityMusic, playPriorityMusic, playSound, playSound, registerCommand, removeAttack, removeHook, removeMessageListener, removeMethodHook, resumeSound, runFailedPostHook, runMethodHook, runPostHook, runPreHook, sendPicture, sendPicture, setAI, setEncumbrance, setMusicGain, setName, setSoundGain, start, stop, stopAllSounds, stopMusic, stopSound, unregisterCommand |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface wyvern.lib.Broadcaster |
broadcast, broadcast, broadcast, broadcast, broadcast |
Constructor Detail |
public Vehicle()
Method Detail |
public void initialize()
GameObject
initialize
in interface GameObject
initialize
in class MapObject
protected void ensureAI()
ensureAI
in class AbstractCommandable
protected GameMap createInteriorMap()
It's possible for a vehicle to specify a predefined map for its interior. The map is specified in a property called "interior", the map referenced by the property is loaded by the MapLoader and used by the vehicle for depositing players. The dimensions of the map determine how many people will fit in the vehicle.
Vehicle subclasses are also free to create their interior maps during construction, by overriding this method, ignoring any "interior" or "template" property, and instantiating a GameMap implementation directly.
public void apply(Commandable agent)
apply
in interface Applyable
agent
- the boarderpublic boolean boardPassenger(Commandable agent)
agent
- the passenger to board
public boolean disembark(Commandable agent)
agent
- the agent to remove
public Point findDisembarkLocation(Commandable agent)
agent
- the person disembarking
protected boolean adjacentTo(java.util.List alocs, Point p, java.util.List locs)
alocs
- the agent relative location listp
- the proposed reference locationlocs
- our location list
public void unhookPlayer(Commandable agent)
agent
- the person leaving the vehiclepublic void printWelcome(Commandable agent)
public void addCamera(Camera cam)
public void removeCamera(Camera cam)
cam
- the camera to remove. Does nothing if the camera
wasn't in the list.public void updateMapLocation(java.util.List oldpos, java.util.List newpos)
The preferred way to move an object is to command() it with command ( "move <direction>" ). This will ensure that the object only moves as fast as it can, and will run the pre- and post-move hooks so that others can participate in the event, possibly vetoing it if it's not allowed.
updateMapLocation
in class MapObject
oldpos
- previous positionnewpos
- new positionpublic void setMap(GameMap map, int x, int y)
setMap
in interface GameObject
setMap
in class MapObject
map
- the GameMap we're going to.public void remove()
remove
in interface GameObject
remove
in class MapObject
public void methodCalled(java.lang.String hookName, MethodHookable target, java.lang.Object data)
methodCalled
in interface MethodHookCallback
hookName
- the name of the hook being runtarget
- the object on which the method was invoked:
a GameMap or GameObject.data
- a method-specific data object; can be null.
Check the documentation for the method hook to see if
any data is passed to the callbacks.public void teleport(int x, int y)
teleport
in interface GameObject
teleport
in class MapObject
x
- the new x location for the object.y
- the new y location for the object.public void relinquishCamera(Player p)
p
- the player whose camera to movepublic void grabCamera(Player p)
p
- the player whose camera to movepublic Point getCameraPos()
public GameMap getInteriorMap()
public void addHooks(Player p)
public void removeHooks(Player p)
public Command getCommand(CommandEvent event)
getCommand
in interface Commandable
getCommand
in class AbstractCommandable
event
- the event with the command to execute
public void createCommandList()
public boolean knowsCommand(java.lang.String command)
Subclasses often need to override this method. It's always a good idea to check the command arguments and make sure the command was really intended for us.
knowsCommand
in interface Command
command
- the entire command string, including arguments
public CommandEvent createEvent(CommandEvent initialInfo)
createEvent
in interface Command
initialInfo
- a "blank" CommandEvent containing only the
command text and the agent who's performing the command.
public boolean execute(CommandEvent event)
execute
in interface Command
event
- the CommandEvent to execute
protected boolean handlePilot(CommandEvent event)
event
- the "pilot" command event
protected boolean handleExit(CommandEvent event)
event
- the "exit" command event
protected boolean handleView(CommandEvent event)
event
- the "view" command event
public void toggleView(Player p)
p
- the player whose camera we should togglepublic boolean viewingInside(Player p)
p
- the player
public void hookEvent(java.lang.String hookName, CommandEvent event)
hookEvent
in interface HookCallback
hookName
- the name of the hook, such as "movePreHook".event
- the CommandEvent encapsulating the event parameterspublic void handleTeleport(CommandEvent event)
public void handlePreMove(CommandEvent event)
event
- the MoveEvent about to take placepublic void handleFailedPostMove(CommandEvent event)
public void handleLookXY(CommandEvent event)
public Point translateToThisMap(Point p, Player player)
public boolean isPilot(Commandable agent)
agent
- the agent to check
public void addPilot(Commandable agent)
agent
- the new pilotpublic void removePilot(Commandable agent)
public boolean isValidDir(int dir)
public void handleMouse(CommandEvent ev)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |