com.threerings.tudey.server.logic
Class MobileLogic

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
All Implemented Interfaces:
HasActor, TudeySceneManager.TickParticipant, ActorAdvancer.Environment
Direct Known Subclasses:
ActiveLogic

public class MobileLogic
extends ActorLogic
implements TudeySceneManager.TickParticipant, ActorAdvancer.Environment

Controls the state of a mobile actor.


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  ActorAdvancer _advancer
          Used to advance the state of the actor.
protected  boolean _inStasis
          Whether or not the actor is in stasis.
protected  int _penetrationCount
          The number of penetrations.
protected  Vector2f _penetrationSum
          The penetration vector sum.
 
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
MobileLogic()
           
 
Method Summary
 boolean collides(Actor actor, Shape shape)
          Checks whether the actor is colliding with anything.
protected  ActorAdvancer createAdvancer()
          Creates the advancer to use to update the actor.
protected  void didInit()
          Override to perform custom initialization.
protected  void enteredStasis()
          Called when the actor enters stasis.
 float getDirection()
          Returns the direction of the mobile.
 boolean getPenetration(Actor actor, Shape shape, Vector2f result)
          Checks whether the actor is colliding with anything and, if it is, populates the provided object with the penetration vector (the minimum translation required to cancel the penetration).
 TudeySceneModel getSceneModel()
          Returns a reference to the scene model.
 Actor getSnapshot()
          Returns the current tick's snapshot of the actor.
protected  void leftStasis()
          Called when the actor leaves stasis.
protected  void penetratedEnvironment(Vector2f penetration)
          Notes that the actor collided with one or more things during its advancement.
 void stepLimit(float minDirection, float maxDirection, boolean remove)
          Adds or removes a step limiter.
 boolean tick(int timestamp)
          Ticks the participant.
 void transfer(Logic source, Map<Object,Object> refs)
          Transfers state from the specified source logic.
protected  void updateShape()
          Updates the shape transform based on the actor's position.
protected  void wasDestroyed()
          Override to perform custom cleanup.
 
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

_advancer

protected ActorAdvancer _advancer
Used to advance the state of the actor.


_inStasis

protected boolean _inStasis
Whether or not the actor is in stasis.


_penetrationCount

protected int _penetrationCount
The number of penetrations.


_penetrationSum

protected Vector2f _penetrationSum
The penetration vector sum.

Constructor Detail

MobileLogic

public MobileLogic()
Method Detail

stepLimit

public void stepLimit(float minDirection,
                      float maxDirection,
                      boolean remove)
Adds or removes a step limiter.


getDirection

public float getDirection()
Returns the direction of the mobile.


tick

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

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

getSceneModel

public TudeySceneModel getSceneModel()
Description copied from interface: ActorAdvancer.Environment
Returns a reference to the scene model.

Specified by:
getSceneModel in interface ActorAdvancer.Environment

getPenetration

public boolean getPenetration(Actor actor,
                              Shape shape,
                              Vector2f result)
Description copied from interface: ActorAdvancer.Environment
Checks whether the actor is colliding with anything and, if it is, populates the provided object with the penetration vector (the minimum translation required to cancel the penetration).

Specified by:
getPenetration in interface ActorAdvancer.Environment
Returns:
true if a collision was detected (in which case the result vector will be populated), false otherwise.

collides

public boolean collides(Actor actor,
                        Shape shape)
Description copied from interface: ActorAdvancer.Environment
Checks whether the actor is colliding with anything.

Specified by:
collides in interface ActorAdvancer.Environment

getSnapshot

public Actor getSnapshot()
Description copied from class: ActorLogic
Returns the current tick's snapshot of the actor.

Overrides:
getSnapshot in class ActorLogic

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 ActorLogic

didInit

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

Overrides:
didInit in class ActorLogic

wasDestroyed

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

Overrides:
wasDestroyed in class ActorLogic

createAdvancer

protected ActorAdvancer createAdvancer()
Creates the advancer to use to update the actor.


leftStasis

protected void leftStasis()
Called when the actor leaves stasis.


enteredStasis

protected void enteredStasis()
Called when the actor enters stasis.


penetratedEnvironment

protected void penetratedEnvironment(Vector2f penetration)
Notes that the actor collided with one or more things during its advancement.

Parameters:
penetration - the sum of the penetration vectors.

updateShape

protected void updateShape()
Description copied from class: ActorLogic
Updates the shape transform based on the actor's position.

Overrides:
updateShape in class ActorLogic