|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Cameras provide different views of game maps to the client.
Different implementations will display the information differently: the client map-display and ground-display are both Camera implementations.
All existing game cameras inherit from wyvern.kernel.maps.AbstractCamera, which provides a framework that makes it easier to create new camera types.
Method Summary | |
void |
forceInvalidate()
Forces the camera contents to refresh, even if it's already been marked as completely invalid. |
Point |
getCenter()
Returns the center point of the camera view, in map coords. |
DisplayPolicy |
getFrame()
Returns the object used for collecting and filtering the objects sent to the camera by the map. |
GameMap |
getMap()
Returns the map this camera is viewing. |
Player |
getOwner()
Returns the player associated with this camera. |
Point |
getPosition()
Returns the upper-left corner of the camera, in map coords. |
Rectangle |
getViewRect()
Gets the rectangle that this camera is viewing in the map. |
Dimension |
getViewSize()
Returns the width and height of the camera. |
boolean |
hasBeenMoved()
Returns whether the camera has been moved since the last client refresh. |
void |
invalidate()
Markes the camera as dirty (i.e. needing a refresh). |
void |
invalidateNoRayCast()
Forces the camera contents to refresh, but without redoing the visibility model raycasting. |
boolean |
isHandheld()
Returns true if this camera is for a player using a handheld device. |
boolean |
isInvalid()
Returns whether the entire camera is invalid. |
boolean |
isShutDown()
Returns true if this camera has been shut down. |
DisplayPolicy |
makeFrame()
A factory method that instantiates a DisplayPolicy subclass appropriate for this camera. |
void |
markReady()
Called by the networking layer when the camera's last request has finished sending over the wire. |
void |
markValid()
Sets the "completely-invalid" flag for the camera. |
void |
move(int xoffset,
int yoffset)
Moves the camera by a relative (x, y) amount without resizing it. |
void |
setMap(GameMap map,
int x,
int y)
Sets a new map and position for the camera simultaneously. |
void |
setMap(GameMap map,
Point p)
Sets a new map and position for the camera simultaneously. |
void |
setMoved(int xoffset,
int yoffset)
Remembers that the camera has been moved by a small amount, so the client can blit the old contents over. |
void |
setPosition(int x,
int y)
Tells the camera where in the map to view. |
void |
setViewRect(Rectangle r)
Sets the view rectangle to a new position and size. |
void |
setViewSize(int width,
int height)
Resizes the camera view without moving the upper-left corner. |
void |
shutDown()
Turns the camera off (permanently). |
void |
validate(MapDirtyRegions updates)
Tells the camera to check if it should update itself. |
Method Detail |
public void setViewRect(Rectangle r)
r
- the map rectangle to viewpublic void setViewSize(int width, int height)
width
- the new view widthheight
- the new view heightpublic void setPosition(int x, int y)
x
- the new map X position for the camera upper-left cornery
- the new map Y position for the camera upper-left cornerpublic void move(int xoffset, int yoffset)
xoffset
- the relative X offset to move the camerayoffset
- the relative Y offset to move the camerapublic Rectangle getViewRect()
public Point getPosition()
public Point getCenter()
public Dimension getViewSize()
public void setMap(GameMap map, int x, int y)
map
- the GameMap to viewx
- the x position to viewy
- the y position to viewpublic void setMap(GameMap map, Point p)
map
- the GameMap to viewp
- the map coordinatespublic Player getOwner()
public GameMap getMap()
public DisplayPolicy getFrame()
public DisplayPolicy makeFrame()
public void validate(MapDirtyRegions updates)
This method is called by the game scheduler thread, via the CameraManager. When this method is called, the CameraManager has determined that some changes have occurred in the map that we're viewing (or that we've marked ourselves dirty). This method is called even if none of those changes are visible (the 'updates' parameter will be null or empty). It's up to this method, or a subclass, to determine whether to do a client update.
The camera doesn't actually pull any data from the map unless it has been marked "ready" by the network output thread. If it's not ready, it just remembers the invalid regions and waits until it's ready again.
updates
- a MapDirtyRegions that contains a BitMatrix the
size of the map we're viewing, with bits set everywhere there
was a map cell invalidated. Can be null if camera is
completely invalid, in which case it won't be used. Called by
the CameraManager when refreshing the camera.public void invalidate()
public void forceInvalidate()
public void invalidateNoRayCast()
public boolean isInvalid()
public void setMoved(int xoffset, int yoffset)
public boolean hasBeenMoved()
public void shutDown()
public boolean isShutDown()
public void markReady()
markReady
in interface RPCDataSource
public boolean isHandheld()
public void markValid()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |