|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.motion.Mover
This class contains all the contorted logic for deciding whether a monster can move into a particular square, and how fast it can do so.
Field Summary | |
static int |
FASTEST_MOVE_SPEED
It puts a HUGE load on the server if your move speed is too fast, since player movement is the largest consumer of CPU and network bandwidth. |
Constructor Summary | |
Mover()
|
Method Summary | |
boolean |
canMove(GameObject agent,
Terrain t)
Returns true if the agent can move onto the specified terrain at all. |
boolean |
canWalk(GameObject obj,
int x,
int y)
Checks to see if the object is walkable at the specified map location. |
void |
checkAllLocations(MoveEvent event)
Checks every destination location to make sure it's a valid move. |
boolean |
checkPreconditions(MoveEvent event,
GameMap map,
java.util.List dest_objs,
int x,
int y)
Examines the destination of the move to see if we should do anything "special". |
static Mover |
getInstance()
|
int |
getSpeed(Commandable agent,
Terrain t)
Gets the speed across this Terrain. |
boolean |
isWater(Terrain t)
Checks if it's water. |
void |
setNoPassDelay(MoveEvent event)
Sets the delay for a blocked move. |
boolean |
terrainCheck(GameObject agent,
Terrain t,
java.util.List objects,
int x,
int y)
Returns true if the monster can move into the specified square. |
GameObject |
terrainCheckBlockedBy(GameObject agent,
Terrain terrain,
java.util.List objects,
int x,
int y)
Returns whatever's in our way, null if nothing |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int FASTEST_MOVE_SPEED
move-speed | moves per second |
---|---|
50 | 20 |
30 | 33 |
20 | 50 |
10 | 100 |
5 | 200 |
1 | 1000 |
It's important that players aren't able to move faster than this cap. Back when players could get move speeds of zero, we were adding thousands of events per second to the game scheduler, which effectively cut the total number of simultaneous players by half (or more).
So tuning this parameter has a big impact on the server performance. I've put it as low (fast) as I think I can justify. It's twice the speed of an unencumbered human.
Constructor Detail |
public Mover()
Method Detail |
public static Mover getInstance()
public void checkAllLocations(MoveEvent event)
event
- the MoveEvent we're buildingpublic boolean checkPreconditions(MoveEvent event, GameMap map, java.util.List dest_objs, int x, int y)
event
- the MoveEventmap
- the map the agent is indest_objs
- the objects at the destination locationx
- the destination x coordinatey
- the destination y coordinate
public boolean terrainCheck(GameObject agent, Terrain t, java.util.List objects, int x, int y)
t
- the Terrain in questionobjects
- the other objects at that locationx
- the x map location we're checkingy
- the y map location we're checking
public GameObject terrainCheckBlockedBy(GameObject agent, Terrain terrain, java.util.List objects, int x, int y)
agent
- the agent that's movingterrain
- the terrain at this squareobjects
- the objects in this squarex
- the x map location we're checkingy
- the y map location we're checking
public boolean canMove(GameObject agent, Terrain t)
Commandables may make a subclass of Mover that overrides this method if they want to constrain their movement in some way; e.g. a Shark might have a WaterMover subclass that only lets it move in water-type terrain.
I had really high hopes for this method, by the way. I wanted to have a general extension mechanism by which you could see who was preventing (or allowing) a move, and veto them. The team couldn't think of a satisfactory mechanism, though.
agent
- the Commandable trying to move theret
- the Terrain to examinepublic int getSpeed(Commandable agent, Terrain t)
agent
- the agent that's trying to movet
- the terrain into which the agent is moving
public boolean isWater(Terrain t)
t
- the the Terrain to check
public boolean canWalk(GameObject obj, int x, int y)
x
- the map x locationy
- the map y locationobj
- the object to check
public void setNoPassDelay(MoveEvent event)
event
- the event in which to set the delay. Sets the
delay in the event.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |