com.threerings.tudey.server.logic
Class AgentLogic

java.lang.Object
  extended by com.threerings.util.ShallowObject
      extended by com.threerings.tudey.server.logic.Logic
          extended by com.threerings.tudey.server.logic.ActorLogic
              extended by com.threerings.tudey.server.logic.MobileLogic
                  extended by com.threerings.tudey.server.logic.ActiveLogic
                      extended by com.threerings.tudey.server.logic.AgentLogic
All Implemented Interfaces:
HasActor, TudeySceneManager.TickParticipant, ActorAdvancer.Environment

public class AgentLogic
extends ActiveLogic

Controls an autonomous agent.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.tudey.server.logic.ActorLogic
ActorLogic.CollisionFlagObserver
 
Nested classes/interfaces inherited from class com.threerings.tudey.server.logic.Logic
Logic.ShapeObserver
 
Field Summary
protected  BehaviorLogic _behavior
          The agent's behavior logic.
protected  float _targetRotation
          The agent's target rotation.
protected  int _timestamp
          The timestamp of the last tick.
protected  float _turnRate
          The agent's turn rate.
 
Fields inherited from class com.threerings.tudey.server.logic.ActiveLogic
_activities, _lastActivityStarted
 
Fields inherited from class com.threerings.tudey.server.logic.MobileLogic
_advancer, _inStasis, _penetrationCount, _penetrationSum
 
Fields inherited from class com.threerings.tudey.server.logic.ActorLogic
_activator, _actor, _collisionFlagObservers, _collisionFlags, _config, _destroyed, _entityKey, _handlers, _previousSnapshot, _shape, _shapeDidChangeOp, _shapeObservers, _shapeWillChangeOp, _snapshot, _snapshotDelta, _snaptime, _source, MAX_ADJUSTMENT_DISTANCE, MAX_ADJUSTMENT_PATH_LENGTH
 
Fields inherited from class com.threerings.tudey.server.logic.Logic
_scenemgr, _variables
 
Constructor Summary
AgentLogic()
           
 
Method Summary
 boolean canMove()
          Checks whether we can move.
 boolean canRotate()
          Checks whether we can rotate.
 boolean canThink()
          Checks whether we can evaluate our behavior.
 void clearSpeed()
          Clears a modified speed.
 void clearTargetRotation()
          Clears the agent's target rotation.
 void clearTurnRate()
          Clears the turn rate.
 BehaviorLogic createBehavior(ConfigReference<BehaviorConfig> ref)
          Creates a behavior for this agent.
protected  void didInit()
          Override to perform custom initialization.
 void face(Logic logic)
          Sets the target rotation to face another entity.
 void face(Logic logic, boolean force)
          Sets the target rotation to face another entity.
 Logic getBehaviorTarget()
          Returns the logic currently being targeted by our behavior, if any.
 float getTargetRotation()
          Returns the target rotation.
protected  void penetratedEnvironment(Vector2f penetration)
          Notes that the actor collided with one or more things during its advancement.
protected  void reachedTargetRotation()
          Called when we reach our target rotation.
 void setSpeed(float speed)
          Sets the speed.
 void setTargetRotation(float rotation)
          Sets the target rotation for the agent to turn towards.
 void setTurnRate(float rate)
          Sets the turn rate.
 void startMoving()
          Sets the agent in motion.
 void stopMoving()
          Stops the agent.
 boolean tick(int timestamp)
          Ticks the participant.
 void transfer(Logic source, Map<Object,Object> refs)
          Transfers state from the specified source logic.
protected  void wasDestroyed()
          Override to perform custom cleanup.
 
Methods inherited from class com.threerings.tudey.server.logic.ActiveLogic
getActivityAdvance, updateActivities
 
Methods inherited from class com.threerings.tudey.server.logic.MobileLogic
collides, createAdvancer, enteredStasis, getDirection, getPenetration, getSceneModel, getSnapshot, leftStasis, stepLimit, updateShape
 
Methods inherited from class com.threerings.tudey.server.logic.ActorLogic
addCollisionFlagObserver, addShapeObserver, adjustSpawnPoint, adjustSpawnPoint, bodyWillEnter, bodyWillLeave, createActor, destroy, getActivator, getActor, getCollisionFlags, getEntityKey, getModel, getPreviousSnapshot, getRotation, getShape, getShapeElement, getSnapshotDelta, getSource, getTags, getTranslation, init, isActive, isDefaultEntrance, isDestroyed, isRemoved, isStatic, move, remove, removeCollisionFlagObserver, removeOnNextTick, removeShapeObserver, request, set, setActivator, setSource, setVariable, signal, testSpawnPoint, updateCollisionFlags, updateSnapshot, warp, warp, warp, wasRemoved, wasUpdated
 
Methods inherited from class com.threerings.tudey.server.logic.Logic
createAction, createCondition, createExpression, createHandler, createRegion, createTarget, getPatrolPath, getSceneManager, getTransform, getTransform, getVariable, init, isVisible, resolveTarget
 
Methods inherited from class com.threerings.util.ShallowObject
equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_behavior

protected BehaviorLogic _behavior
The agent's behavior logic.


_targetRotation

protected float _targetRotation
The agent's target rotation.


_turnRate

protected float _turnRate
The agent's turn rate.


_timestamp

protected int _timestamp
The timestamp of the last tick.

Constructor Detail

AgentLogic

public AgentLogic()
Method Detail

canMove

public boolean canMove()
Checks whether we can move.


canRotate

public boolean canRotate()
Checks whether we can rotate.


canThink

public boolean canThink()
Checks whether we can evaluate our behavior.


getBehaviorTarget

public Logic getBehaviorTarget()
Returns the logic currently being targeted by our behavior, if any.


face

public void face(Logic logic)
Sets the target rotation to face another entity.


face

public void face(Logic logic,
                 boolean force)
Sets the target rotation to face another entity.


setTargetRotation

public void setTargetRotation(float rotation)
Sets the target rotation for the agent to turn towards.


getTargetRotation

public float getTargetRotation()
Returns the target rotation.


clearTargetRotation

public void clearTargetRotation()
Clears the agent's target rotation.


setTurnRate

public void setTurnRate(float rate)
Sets the turn rate.


clearTurnRate

public void clearTurnRate()
Clears the turn rate.


setSpeed

public void setSpeed(float speed)
Sets the speed.


clearSpeed

public void clearSpeed()
Clears a modified speed.


startMoving

public void startMoving()
Sets the agent in motion.


stopMoving

public void stopMoving()
Stops the agent.


createBehavior

public BehaviorLogic createBehavior(ConfigReference<BehaviorConfig> ref)
Creates a behavior for this agent.


transfer

public void transfer(Logic source,
                     Map<Object,Object> refs)
Description copied from class: Logic
Transfers state from the specified source logic. Where relevant, this also takes the place of addition/startup notification.

Overrides:
transfer in class ActiveLogic

tick

public boolean tick(int timestamp)
Description copied from interface: TudeySceneManager.TickParticipant
Ticks the participant.

Specified by:
tick in interface TudeySceneManager.TickParticipant
Overrides:
tick in class ActiveLogic
Parameters:
timestamp - the timestamp of the current tick.
Returns:
true to continue ticking the participant, false to remove it from the list.

wasDestroyed

protected void wasDestroyed()
Description copied from class: ActorLogic
Override to perform custom cleanup.

Overrides:
wasDestroyed in class MobileLogic

didInit

protected void didInit()
Description copied from class: ActorLogic
Override to perform custom initialization.

Overrides:
didInit in class MobileLogic

penetratedEnvironment

protected void penetratedEnvironment(Vector2f penetration)
Description copied from class: MobileLogic
Notes that the actor collided with one or more things during its advancement.

Overrides:
penetratedEnvironment in class MobileLogic
Parameters:
penetration - the sum of the penetration vectors.

reachedTargetRotation

protected void reachedTargetRotation()
Called when we reach our target rotation.