wyvern.kernel.player
Class GroundFrame

java.lang.Object
  extended bywyvern.kernel.player.GroundFrame
All Implemented Interfaces:
DisplayPolicy

public class GroundFrame
extends java.lang.Object
implements DisplayPolicy

This class is the DisplayPolicy for the ground-view camera. It renders the objects in its view as an inventory list.

The GroundFrame only resends object descriptions if they've changed in a way that's visible to the client. For instance, if the player is standing on an empty road, and the player moves onto a road square identical to the previous one, nothing is re-sent.

If only one object in the list changes appearance, only that object is re-sent.

The GroundFrame sends as much of the object as the player overlaps. A Giant standing next to a palm tree will see the whole tree in his ground window.

Version:
1.0, Mar 30, 1998
Author:
Steve Yegge

Field Summary
protected  GroundCamera camera_
           
protected  int height_
           
protected  GameMap map_
           
protected  Player player_
           
protected  Predicate skipPlayer_
           
protected  GroundViewer viewer_
           
protected  int viewx_
           
protected  int viewy_
           
protected  int width_
           
 
Constructor Summary
GroundFrame(Player player)
          Constructs a new GroundFrame to view the ground under the specified player.
 
Method Summary
 void addUpdateRegions(MapDirtyRegions regions)
          Adds in all the cells in the map that have become invalid since this method was last called.
 boolean canSee(int x, int y)
          Determines whether the player has a clear line of sight to the specified map location.
 boolean checkAdd(GameObject obj)
          Returns true if the player can actually see this object.
 void doRayCast()
          Not applicable for this kind of frame.
 java.util.List getLists()
          Returns a list of object descriptors that are going to the client.
 java.util.List getObjects()
          Returns a list of GroundObjDescriptors that were gathered in the last visit to the map.
 void grabAll()
          Tells the frame to grab the entire view (rather than just selected areas).
 void grabObjects()
          This is how the DisplayPolicy is told to take a snapshot of invalid camera area(s) added by calls to addUpdateRect().
 void setBounds(int x, int y, int width, int height, GameMap map)
          Sets the bounds of the frame.
 void setBounds(int x, int y, int width, int height, GameMap map, boolean raycast)
          Sets the bounds of the frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewx_

protected int viewx_

viewy_

protected int viewy_

width_

protected int width_

height_

protected int height_

player_

protected Player player_

map_

protected GameMap map_

viewer_

protected GroundViewer viewer_

camera_

protected GroundCamera camera_

skipPlayer_

protected Predicate skipPlayer_
Constructor Detail

GroundFrame

public GroundFrame(Player player)
Constructs a new GroundFrame to view the ground under the specified player.

Parameters:
player - the player to view
Method Detail

addUpdateRegions

public void addUpdateRegions(MapDirtyRegions regions)
Description copied from interface: DisplayPolicy
Adds in all the cells in the map that have become invalid since this method was last called. Called only by the Camera, as are all the other methods in this class.

Specified by:
addUpdateRegions in interface DisplayPolicy
Parameters:
regions - a matrix, the size of the map, that has all areas that have become invalid in the map since the last camera refresh.

grabObjects

public void grabObjects()
This is how the DisplayPolicy is told to take a snapshot of invalid camera area(s) added by calls to addUpdateRect().

Specified by:
grabObjects in interface DisplayPolicy

grabAll

public void grabAll()
Tells the frame to grab the entire view (rather than just selected areas). We snap up the objects underneath the camera.

Specified by:
grabAll in interface DisplayPolicy

doRayCast

public void doRayCast()
Not applicable for this kind of frame.

Specified by:
doRayCast in interface DisplayPolicy

getObjects

public java.util.List getObjects()
Returns a list of GroundObjDescriptors that were gathered in the last visit to the map.


getLists

public java.util.List getLists()
Returns a list of object descriptors that are going to the client.

Returns:
a list of three arrays: a String[] (names), a short[] (pics) and a short[] (offsets).
See Also:
GroundViewer.getLists()

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height,
                      GameMap map,
                      boolean raycast)
Sets the bounds of the frame. (Tells the frame where the camera is currently looking.)

Specified by:
setBounds in interface DisplayPolicy
Parameters:
x - the camera left side
y - the camera top side
width - the view width, in map coordinates
height - the view height, in map coordinates
map - the GameMap the camera is currently viewing
raycast - true to redo the ray-caster, false to skip

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height,
                      GameMap map)
Sets the bounds of the frame. (Tells the frame where the camera is currently looking.)

Specified by:
setBounds in interface DisplayPolicy
Parameters:
x - the camera left side
y - the camera top side
width - the view width, in map coordinates
height - the view height, in map coordinates
map - the GameMap the camera is currently viewing

canSee

public boolean canSee(int x,
                      int y)
Determines whether the player has a clear line of sight to the specified map location. Only checks with the ray-caster - doesn't check for blindness, see-invisible, etc. You can call the Frame's checkAdd() function.

Specified by:
canSee in interface DisplayPolicy
Returns:
true if it's visible, false if it's obscured/blocked by a wall or something.

checkAdd

public boolean checkAdd(GameObject obj)
Description copied from interface: DisplayPolicy
Returns true if the player can actually see this object. Does the checks for whether it's invisible, the player is blind, etc.

Specified by:
checkAdd in interface DisplayPolicy
Parameters:
obj - the object to consider for adding
Returns:
true if the object is visible to the player, false if it's invisible. Note: use canSee() to see if the player has line-of-sight to the object. You really need to call both methods (this and canSee()) to determine whether a player can see a given object.