com.threerings.tudey.client.sprite
Class ActorSprite.Moving

java.lang.Object
  extended by com.threerings.expr.SimpleScope
      extended by com.threerings.tudey.client.sprite.ActorSprite.Implementation
          extended by com.threerings.tudey.client.sprite.ActorSprite.Original
              extended by com.threerings.tudey.client.sprite.ActorSprite.Moving
All Implemented Interfaces:
Scope, ScopeUpdateListener
Direct Known Subclasses:
ActorSprite.Acting
Enclosing class:
ActorSprite

public static class ActorSprite.Moving
extends ActorSprite.Original

Depicts a mobile actor with optional movement animations.


Field Summary
protected  Animation _currentIdle
          The current idle animation.
protected  Animation[] _idles
          The resolved idle animations.
protected  float[] _idleWeights
          The weights of the idle animations.
protected  Animation[][] _movements
          The movement animations.
protected  Animation[][] _rotations
          The rotation animations.
 
Fields inherited from class com.threerings.tudey.client.sprite.ActorSprite.Original
_attachedModels, _config, _ctx, _initZ, _model, _view
 
Fields inherited from class com.threerings.expr.SimpleScope
_parentScope
 
Fields inherited from interface com.threerings.expr.Scope
EPOCH, NOW
 
Constructor Summary
protected ActorSprite.Moving(TudeyContext ctx, Scope parentScope)
          Creates a new implementation without configuring it.
  ActorSprite.Moving(TudeyContext ctx, Scope parentScope, ActorSpriteConfig.Moving config)
          Creates a new implementation.
 
Method Summary
 float getAttachedScale()
          Returns a scale factor for attached models.
protected  Animation getBase(Mobile actor)
          Returns the base animation for the actor.
protected  Animation getIdle()
          Returns a reference to the idle animation that the sprite should be playing.
protected  Animation getMovement(Mobile actor)
          Returns the movement animation appropriate to the actor's speed and direction, or null for none.
protected static Animation getMovement(Mobile actor, float scale, ActorSpriteConfig.MovementSet[] sets, Animation[][] movements)
          Configures and returns the appropriate movement animation for the actor.
protected  Animation getRotation(Mobile actor)
          Returns the rotation animation appropriate to the actor's turn rate and direction, or null for none.
protected static Animation getRotation(Mobile actor, ActorSpriteConfig.RotationSet[] sets, Animation[][] rotations)
          Configures and returns the appropriate rotation animation for the actor.
protected static Animation getWeightedAnimation(Animation[] anims, float[] weights)
          Returns a weighted random animation (unless one of the animations is already playing, in which case the method will return that animation).
protected  Animation[][] resolve(ActorSpriteConfig.MovementSet[] sets)
          Resolves the animations from an array of movement sets.
protected  Animation[][] resolve(ActorSpriteConfig.RotationSet[] sets)
          Resolves the animations from an array of rotation sets.
protected  Animation[] resolve(ActorSpriteConfig.WeightedAnimation[] weighted)
          Resolves an array of weighted animations.
 void setConfig(ActorSpriteConfig config)
          (Re)configures the implementation.
 void update(Actor actor)
          Updates the implementation with new interpolated state.
 
Methods inherited from class com.threerings.tudey.client.sprite.ActorSprite.Original
createTooltipComponent, getFloorFlags, getFloorMask, getModelConfig, isControlled, wasCreated, willBeDestroyed
 
Methods inherited from class com.threerings.tudey.client.sprite.ActorSprite.Implementation
clearMessages, dispatchEvent, displayMessage, getScopeName, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, isClickable, isHoverable, occupantEntered, occupantLeft, occupantUpdated
 
Methods inherited from class com.threerings.expr.SimpleScope
addListener, dispose, get, getParentScope, removeListener, scopeUpdated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_idles

protected Animation[] _idles
The resolved idle animations.


_idleWeights

protected float[] _idleWeights
The weights of the idle animations.


_movements

protected Animation[][] _movements
The movement animations.


_rotations

protected Animation[][] _rotations
The rotation animations.


_currentIdle

protected Animation _currentIdle
The current idle animation.

Constructor Detail

ActorSprite.Moving

public ActorSprite.Moving(TudeyContext ctx,
                          Scope parentScope,
                          ActorSpriteConfig.Moving config)
Creates a new implementation.


ActorSprite.Moving

protected ActorSprite.Moving(TudeyContext ctx,
                             Scope parentScope)
Creates a new implementation without configuring it.

Method Detail

setConfig

public void setConfig(ActorSpriteConfig config)
Description copied from class: ActorSprite.Original
(Re)configures the implementation.

Overrides:
setConfig in class ActorSprite.Original

update

public void update(Actor actor)
Description copied from class: ActorSprite.Implementation
Updates the implementation with new interpolated state.

Overrides:
update in class ActorSprite.Original

getAttachedScale

public float getAttachedScale()
Description copied from class: ActorSprite.Implementation
Returns a scale factor for attached models.

Overrides:
getAttachedScale in class ActorSprite.Implementation

resolve

protected Animation[] resolve(ActorSpriteConfig.WeightedAnimation[] weighted)
Resolves an array of weighted animations.


resolve

protected Animation[][] resolve(ActorSpriteConfig.MovementSet[] sets)
Resolves the animations from an array of movement sets.


resolve

protected Animation[][] resolve(ActorSpriteConfig.RotationSet[] sets)
Resolves the animations from an array of rotation sets.


getBase

protected Animation getBase(Mobile actor)
Returns the base animation for the actor.


getIdle

protected Animation getIdle()
Returns a reference to the idle animation that the sprite should be playing.


getMovement

protected Animation getMovement(Mobile actor)
Returns the movement animation appropriate to the actor's speed and direction, or null for none.


getRotation

protected Animation getRotation(Mobile actor)
Returns the rotation animation appropriate to the actor's turn rate and direction, or null for none.


getWeightedAnimation

protected static Animation getWeightedAnimation(Animation[] anims,
                                                float[] weights)
Returns a weighted random animation (unless one of the animations is already playing, in which case the method will return that animation).


getMovement

protected static Animation getMovement(Mobile actor,
                                       float scale,
                                       ActorSpriteConfig.MovementSet[] sets,
                                       Animation[][] movements)
Configures and returns the appropriate movement animation for the actor.

Parameters:
scale - the actor scale.
sets - the movement set configs.
movements - the resolved movement animations.

getRotation

protected static Animation getRotation(Mobile actor,
                                       ActorSpriteConfig.RotationSet[] sets,
                                       Animation[][] rotations)
Configures and returns the appropriate rotation animation for the actor.

Parameters:
sets - the rotation set configs.
rotations - the resolved rotation animations.