com.threerings.tudey.client.sprite
Class ActorSprite

java.lang.Object
  extended by com.threerings.expr.SimpleScope
      extended by com.threerings.tudey.client.sprite.Sprite
          extended by com.threerings.tudey.client.sprite.ActorSprite
All Implemented Interfaces:
ConfigUpdateListener<ActorConfig>, Scope, ScopeUpdateListener, TudeySceneView.TickParticipant, HasActor

public class ActorSprite
extends Sprite
implements TudeySceneView.TickParticipant, ConfigUpdateListener<ActorConfig>, HasActor

Represents an active element of the scene.


Nested Class Summary
static class ActorSprite.Acting
          Depicts an active actor with activity animations.
static class ActorSprite.Implementation
          The actual sprite implementation.
static class ActorSprite.Moving
          Depicts a mobile actor with optional movement animations.
static class ActorSprite.Original
          Superclass of the original implementations.
static class ActorSprite.StatefulEntry
          Executes animations on the corresponding entry sprite.
static class ActorSprite.StatefulModelEntry
          Changes model configurations on the corresponding entry sprite.
 
Field Summary
protected  Actor _actor
          The "play head" actor with interpolated or advanced state.
protected  ActorAdvancer _advancer
          The advancer, if this is a controlled actor.
protected  List<Model> _attachedModels
          Models attached to this sprite (including the primary model).
protected  boolean _attachedVisible
          If attached models are visible.
protected  ActorConfig _config
          The actor configuration.
protected  boolean _disposed
          Set when the sprite has been disposed.
protected  ActorHistory _history
          The history that we use to find interpolated actor state.
protected  ActorSprite.Implementation _impl
          The actor implementation (null until actually created).
protected  Model _model
          The actor model.
protected  int _removed
          The timestamp at which the actor was removed, if any.
protected  ShapeElement _shape
          The actor's shape element.
protected static ActorSprite.Implementation NULL_IMPLEMENTATION
          An implementation that does nothing.
 
Fields inherited from class com.threerings.tudey.client.sprite.Sprite
_ctx, _view
 
Fields inherited from class com.threerings.expr.SimpleScope
_parentScope
 
Fields inherited from interface com.threerings.expr.Scope
EPOCH, NOW
 
Constructor Summary
ActorSprite(TudeyContext ctx, TudeySceneView view, int timestamp, Actor actor)
          Creates a new actor sprite.
 
Method Summary
 void attachModel(Model model)
          Attaches a model to this sprite.
 void attachScaledModel(Model model)
          Attaches a model to this sprite, setting its scale to the product of its current scale and an attachment scale specified by the implementation.
 void attachScaledModel(Model model, float baseScale)
          Attaches a model to this sprite, setting its scale to the product of the provided base scale and an attachment scale specified by the implementation.
 void clearMessages()
          Requests that the sprite clear any chat messages being displayed.
 void configUpdated(ConfigEvent<ActorConfig> event)
          Called when a configuration has been updated.
 Component createTooltipComponent(String tiptext)
          Creates a tooltip component for the sprite (will only be called if Sprite.getTooltipText() returns true).
 void detachModel(Model model)
          Detaches a model from this sprite.
 boolean dispatchEvent(Event event)
          Dispatches an event on the sprite.
 boolean displayMessage(UserMessage msg, boolean alreadyDisplayed)
          Gives the sprite a chance to display a message sent by the occupant controlling the actor.
 void dispose()
          Releases the resources associated with this scope.
 Actor getActor()
          Returns a reference to the actor object.
protected  int getActorTime()
          Returns the time value for the actor.
 ActorAdvancer getAdvancer()
          Returns a reference to the advancer used to advance the state, if this is actor is controlled by the client.
protected  float getAttachedScale()
          Returns the scale to use for attachments.
 int getFloorFlags()
          Returns the sprite's floor flags.
 int getFloorMask()
          Returns the sprite's floor mask.
 ActorSprite.Implementation getImplementation()
          Returns a reference to the sprite implementation.
 Model getModel()
          Returns the model associated with the sprite (if any).
 List<Model> getModels()
          Returns a reference to all the sprites models.
 String getTooltipText()
          Returns the sprite's tooltip text, or null for none.
 float getTooltipTimeout()
          Returns the sprite's tooltip timeout, or -1 to use the default.
 String getTooltipWindowStyle()
          Returns the sprite's tooltip window style.
 boolean isClickable()
          Determines whether the sprite is clickable.
protected  boolean isCreated()
          Determines whether the actor has been created.
protected  boolean isDestroyed()
          Determines whether the actor has been destroyed.
 boolean isHoverable()
          Determines whether the sprite is hoverable (for purposes of in-game user interaction).
protected  boolean isRemoved()
          Determines whether the actor has been removed.
 void occupantEntered(TudeyOccupantInfo info)
          Notes that the occupant controlling this actor has entered.
 void occupantLeft(TudeyOccupantInfo info)
          Notes that the occupant controlling this actor has left.
 void occupantUpdated(TudeyOccupantInfo oinfo, TudeyOccupantInfo ninfo)
          Notes that the occupant controlling this actor has been updated.
 void reinit(int timestamp, Actor actor)
          Reinitializes the sprite.
 void remove(int timestamp)
          Notes that the actor has been removed.
 void setAttachedVisibility(boolean visible)
          Updates the visibility of attached models.
protected  void setConfig(ActorConfig config)
          Sets the configuration of this sprite.
protected  void setConfig(ConfigReference<ActorConfig> ref)
          Sets the configuration of this sprite.
 void spawnAttachedTransientModel(ConfigReference<ModelConfig> ref)
          Gets and attaches a transient model to this sprite.
 Model spawnOffsetTransientModel(ConfigReference<ModelConfig> ref, boolean rotate)
          Spawns a transient model at a z-offset of the location of this sprite.
 Model spawnOffsetTransientModel(ConfigReference<ModelConfig> ref, boolean rotate, float offset)
          Spawns a transient model at a z-offset of the location of this sprite.
 Model spawnTransientModel(ConfigReference<ModelConfig> ref)
          Spawns a transient model at the location (translation and rotation) of this sprite.
 Model spawnTransientModel(ConfigReference<ModelConfig> ref, boolean rotate)
          Spawns a transient model at the location of this sprite.
 boolean tick(int delayedTime)
          Ticks the participant.
protected  void update()
          Updates the configuration and implementation of the sprite.
 void update(int timestamp, Actor actor)
          Updates this sprite with new state.
protected  void updateActor()
          Brings the state of the actor up-to-date with the current time.
protected static void updateAttachedTransform(Model attached, Transform3D mtrans)
          Updates the transform of an attached model based on that of the primary.
protected  void updateFromConfig()
          Updates the sprite to match its new or modified configuration.
protected  void updateShape()
          Updates the shape according to the state of the actor.
 
Methods inherited from class com.threerings.tudey.client.sprite.Sprite
getScopeName, setVisible
 
Methods inherited from class com.threerings.expr.SimpleScope
addListener, get, getParentScope, removeListener, scopeUpdated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_history

protected ActorHistory _history
The history that we use to find interpolated actor state.


_advancer

protected ActorAdvancer _advancer
The advancer, if this is a controlled actor.


_actor

@Scoped
protected Actor _actor
The "play head" actor with interpolated or advanced state.


_config

protected ActorConfig _config
The actor configuration.


_removed

protected int _removed
The timestamp at which the actor was removed, if any.


_model

@Scoped
protected Model _model
The actor model.


_attachedModels

@Scoped
protected List<Model> _attachedModels
Models attached to this sprite (including the primary model).


_attachedVisible

protected boolean _attachedVisible
If attached models are visible.


_shape

protected ShapeElement _shape
The actor's shape element.


_impl

protected ActorSprite.Implementation _impl
The actor implementation (null until actually created).


_disposed

protected boolean _disposed
Set when the sprite has been disposed.


NULL_IMPLEMENTATION

protected static final ActorSprite.Implementation NULL_IMPLEMENTATION
An implementation that does nothing.

Constructor Detail

ActorSprite

public ActorSprite(TudeyContext ctx,
                   TudeySceneView view,
                   int timestamp,
                   Actor actor)
Creates a new actor sprite.

Method Detail

reinit

public void reinit(int timestamp,
                   Actor actor)
Reinitializes the sprite.


getAdvancer

public ActorAdvancer getAdvancer()
Returns a reference to the advancer used to advance the state, if this is actor is controlled by the client.


getModels

public List<Model> getModels()
Returns a reference to all the sprites models.


getImplementation

public ActorSprite.Implementation getImplementation()
Returns a reference to the sprite implementation.


attachScaledModel

public void attachScaledModel(Model model)
Attaches a model to this sprite, setting its scale to the product of its current scale and an attachment scale specified by the implementation.


attachScaledModel

public void attachScaledModel(Model model,
                              float baseScale)
Attaches a model to this sprite, setting its scale to the product of the provided base scale and an attachment scale specified by the implementation.


attachModel

public void attachModel(Model model)
Attaches a model to this sprite.


detachModel

public void detachModel(Model model)
Detaches a model from this sprite.


setAttachedVisibility

public void setAttachedVisibility(boolean visible)
Updates the visibility of attached models.


spawnAttachedTransientModel

public void spawnAttachedTransientModel(ConfigReference<ModelConfig> ref)
Gets and attaches a transient model to this sprite.


spawnTransientModel

public Model spawnTransientModel(ConfigReference<ModelConfig> ref)
Spawns a transient model at the location (translation and rotation) of this sprite.


spawnTransientModel

public Model spawnTransientModel(ConfigReference<ModelConfig> ref,
                                 boolean rotate)
Spawns a transient model at the location of this sprite.

Parameters:
rotate - if true, match the rotation as well as the translation of the sprite.

spawnOffsetTransientModel

public Model spawnOffsetTransientModel(ConfigReference<ModelConfig> ref,
                                       boolean rotate)
Spawns a transient model at a z-offset of the location of this sprite.

Parameters:
rotate - if true, match the rotation as well as the translation of the sprite.

update

public void update(int timestamp,
                   Actor actor)
Updates this sprite with new state.


remove

public void remove(int timestamp)
Notes that the actor has been removed.


occupantEntered

public void occupantEntered(TudeyOccupantInfo info)
Notes that the occupant controlling this actor has entered.


occupantLeft

public void occupantLeft(TudeyOccupantInfo info)
Notes that the occupant controlling this actor has left.


occupantUpdated

public void occupantUpdated(TudeyOccupantInfo oinfo,
                            TudeyOccupantInfo ninfo)
Notes that the occupant controlling this actor has been updated.


displayMessage

public boolean displayMessage(UserMessage msg,
                              boolean alreadyDisplayed)
Gives the sprite a chance to display a message sent by the occupant controlling the actor.

Returns:
true if the sprite displayed the message.

clearMessages

public void clearMessages()
Requests that the sprite clear any chat messages being displayed.


tick

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

Specified by:
tick in interface TudeySceneView.TickParticipant
Parameters:
delayedTime - the current delayed client time.
Returns:
true to continue ticking the participant, false to remove it from the list.

configUpdated

public void configUpdated(ConfigEvent<ActorConfig> event)
Description copied from interface: ConfigUpdateListener
Called when a configuration has been updated.

Specified by:
configUpdated in interface ConfigUpdateListener<ActorConfig>

getActor

public Actor getActor()
Description copied from interface: HasActor
Returns a reference to the actor object.

Specified by:
getActor in interface HasActor

getModel

public Model getModel()
Description copied from class: Sprite
Returns the model associated with the sprite (if any).

Overrides:
getModel in class Sprite

getFloorFlags

public int getFloorFlags()
Description copied from class: Sprite
Returns the sprite's floor flags.

Overrides:
getFloorFlags in class Sprite

getFloorMask

public int getFloorMask()
Description copied from class: Sprite
Returns the sprite's floor mask.

Overrides:
getFloorMask in class Sprite

isHoverable

public boolean isHoverable()
Description copied from class: Sprite
Determines whether the sprite is hoverable (for purposes of in-game user interaction).

Overrides:
isHoverable in class Sprite

isClickable

public boolean isClickable()
Description copied from class: Sprite
Determines whether the sprite is clickable.

Overrides:
isClickable in class Sprite

getTooltipText

public String getTooltipText()
Description copied from class: Sprite
Returns the sprite's tooltip text, or null for none.

Overrides:
getTooltipText in class Sprite

getTooltipTimeout

public float getTooltipTimeout()
Description copied from class: Sprite
Returns the sprite's tooltip timeout, or -1 to use the default.

Overrides:
getTooltipTimeout in class Sprite

getTooltipWindowStyle

public String getTooltipWindowStyle()
Description copied from class: Sprite
Returns the sprite's tooltip window style.

Overrides:
getTooltipWindowStyle in class Sprite

createTooltipComponent

public Component createTooltipComponent(String tiptext)
Description copied from class: Sprite
Creates a tooltip component for the sprite (will only be called if Sprite.getTooltipText() returns true).

Overrides:
createTooltipComponent in class Sprite

dispatchEvent

public boolean dispatchEvent(Event event)
Description copied from class: Sprite
Dispatches an event on the sprite.

Overrides:
dispatchEvent in class Sprite
Returns:
true if the sprite handled the event, false if it should be handled elsewhere.

dispose

public void dispose()
Description copied from class: SimpleScope
Releases the resources associated with this scope.

Overrides:
dispose in class SimpleScope

updateActor

protected void updateActor()
Brings the state of the actor up-to-date with the current time.


isCreated

protected boolean isCreated()
Determines whether the actor has been created.


isDestroyed

protected boolean isDestroyed()
Determines whether the actor has been destroyed.


isRemoved

protected boolean isRemoved()
Determines whether the actor has been removed.


getActorTime

protected int getActorTime()
Returns the time value for the actor.


update

protected void update()
Updates the configuration and implementation of the sprite.


setConfig

protected void setConfig(ConfigReference<ActorConfig> ref)
Sets the configuration of this sprite.


setConfig

protected void setConfig(ActorConfig config)
Sets the configuration of this sprite.


updateFromConfig

protected void updateFromConfig()
Updates the sprite to match its new or modified configuration.


updateShape

protected void updateShape()
Updates the shape according to the state of the actor.


getAttachedScale

protected float getAttachedScale()
Returns the scale to use for attachments.


spawnOffsetTransientModel

public Model spawnOffsetTransientModel(ConfigReference<ModelConfig> ref,
                                       boolean rotate,
                                       float offset)
Spawns a transient model at a z-offset of the location of this sprite.

Parameters:
rotate - if true, match the rotation as well as the translation of the sprite.

updateAttachedTransform

protected static void updateAttachedTransform(Model attached,
                                              Transform3D mtrans)
Updates the transform of an attached model based on that of the primary.