wyvern.kernel.maps
Interface DisplayPolicy

All Known Implementing Classes:
Frame, GroundFrame

public interface DisplayPolicy

This interface provides a way to change the drawing policy without changing any of the GameMap code. Each Camera in the game has a DrawingPolicy object that's responsible for collecting the objects in the view and rendering them somehow.

Version:
1.0, Aug 30, 1997
Author:
Steve Yegge

Method Summary
 void addUpdateRegions(MapDirtyRegions changes)
          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()
          Called when the frame needs to recompute its visibility (using the raycaster).
 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 the invalid camera area(s).
 void setBounds(int x, int y, int width, int height, GameMap map)
          Tells the DisplayPolicy what area the camera is viewing.
 void setBounds(int x, int y, int width, int height, GameMap map, boolean raycast)
          Tells the DisplayPolicy what area the camera is viewing.
 

Method Detail

addUpdateRegions

public void addUpdateRegions(MapDirtyRegions changes)
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.

Parameters:
changes - 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 the invalid camera area(s). AbstractCamera.addUpdates() calls this method, after notifying the frame of all the update regions that need to be processed, so the frame can visit the objects in those regions.


grabAll

public void grabAll()
Tells the frame to grab the entire view (rather than just selected areas).


setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height,
                      GameMap map,
                      boolean raycast)
Tells the DisplayPolicy what area the camera is viewing. Called when the frame is first created and whenver the camera moves.

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)
Tells the DisplayPolicy what area the camera is viewing. Called when the frame is first created and whenver the camera moves. Redoes the raycast after setting the bounds, to get the new visibility info.

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

doRayCast

public void doRayCast()
Called when the frame needs to recompute its visibility (using the raycaster). If the frame doesn't have this concept, it can be safely ignored.


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.

Returns:
true if it's visible, false if it's obscured/blocked by a wall or something.

checkAdd

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

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.