Class Villager

All Implemented Interfaces:
Drawable2DObject, PathUser,, SimObject

public class Villager
extends MyUnit

Charles-Philip Bentley
See Also:
Serialized Form

Field Summary
Fields inherited from class cad.simcad.worldsimulator.objects.units.MyUnit
_baseTurnIncrement, _boundingRadius, _pp, _previousOne, _recomputing, _savedMovPoints, _state, _uc, _um, _velocity, IncrementWaypoint, ReachedGoal, WaitingForPath
Fields inherited from class cad.simcad.worldsimulator.objects.SimulatedObject
_am, _className, _height, _id, _name, _om, _owner, _serial, _sime, _stateId, _width
Constructor Summary
Villager(SimEnvironment sime, PathPlace mp, UnitMediator um, Owner owner)
          Creates new Villager
Method Summary
 double getDeformFactor()
          Returns the deform factor of the Path user.
 double getMaxSteepNessRatio()
          Return the maximum slope ratio the PathUser can walk on.
 void move()
          Top of movement state loop: { If we're in IncrementWaypoint state: Increment our waypoint.
Methods inherited from class cad.simcad.worldsimulator.objects.units.MyUnit
debug, firePathComputed, getBoundingCircleRadius, getCurrentPathPlace, getHeight, getMiniMapColor, getObjectType, getOwner, getUnitControler, getVelocity, getWidth, getX, getY, isCollision, resolveNewMove, setState, setVelocity, stopObject, stopUnit, takeTurn, updateStateId
Methods inherited from class cad.simcad.worldsimulator.objects.SimulatedObject
getClassName, getId, getName, getSerialNumber, getStateId, setStateId
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface cad.simcad.objectserver.spec.pathfinding.PathUser
getId, getName

Constructor Detail


public Villager(SimEnvironment sime,
                PathPlace mp,
                UnitMediator um,
                Owner owner)
Creates new Villager

Method Detail


public double getMaxSteepNessRatio()
Description copied from interface: PathUser
Return the maximum slope ratio the PathUser can walk on.

double value


public double getDeformFactor()
Description copied from interface: PathUser
Returns the deform factor of the Path user. The Deform factor is a ratio. 0 means the PathUser shrink completely to pass through holes infinitely small 1 means the PathUser is unabled to shrink 0.5 means the PathUser can shrink to half its size. Usually, most mechanical objects will have a deform factor of 1. While human can usually shrink a little to go through narrow pathways

double value


public void move()
Description copied from class: MyUnit
Top of movement state loop: { If we're in IncrementWaypoint state: Increment our waypoint. If we're on a patrol Grab the next waypoint as defined by the patrol direction. Set state to WaitingForPath. Else If we're out of waypoints Set state to ReachedGoal. Else Set state to WaitingForPath. If we're in ReachedGoal state: Make the appropriate notifications (if any). We're done. Stop the walking animation. Exit function. If we're in WaitingForPath state: Find a path and save it. If we could not find one We've failed. Exit function. Calculate the direction we need to head in to get to our desired waypoint. Modify that direction by any limitations such as turn radius. Using that new direction, calculate where we'll end up after this move. If that new position causes a collision Set state to WaitingForPath. Jump back to the top of the loop. Using the current and future position: If we're closer to the waypoint before moving Set state to IncrementWaypoint Go back to top of loop. If we're going to jump over the waypoint during this move Set state to IncrementWaypoint. Break out of loop. } Set the accelerations accordingly. Do the actual move. Set or update any animation hooks that we might have. Update our predicted positions

move in class MyUnit


With the help of and