com.threerings.tudey.data.actor
Class Actor

java.lang.Object
  extended by com.threerings.util.DeepObject
      extended by com.threerings.tudey.data.actor.Actor
All Implemented Interfaces:
Deltable, com.threerings.io.Streamable, Copyable, Cloneable
Direct Known Subclasses:
EntryState, Mobile

public class Actor
extends DeepObject
implements com.threerings.io.Streamable, Deltable

Represents an active, stateful element of the scene.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
com.threerings.io.Streamable.Closure
 
Field Summary
static int LAST_FLAG
          The value of the last flag defined in this class.
static int WARP
          A flag indicating that the actor has changed its position in a discontinuous fashion.
 
Constructor Summary
Actor()
          No-arg constructor for deserialization.
Actor(ConfigReference<ActorConfig> config, int id, int created, Vector2f translation, float rotation)
          Creates a new actor.
 
Method Summary
 boolean canCollide(Actor oactor)
          Determines whether this actor should be checked for collisions with the specified other actor.
 boolean canCollide(int flags)
          Determines whether this actor should be checked for collisions with scene elements with the specified flags.
 void clear(int flag)
          Clears a flag.
 Object copy(Object dest)
          Creates a copy of this object, (re)populating the supplied destination object if possible.
 ActorAdvancer createAdvancer(ActorAdvancer.Environment environment, int timestamp)
          Creates an advancer for the actor.
 boolean equals(Object other)
           
 Actor extrapolate(float elapsed, int timestamp, Actor result)
          Extrapolates the state of this actor after the specified time interval, in seconds (which may be negative).
 int getCollisionFlags()
          Returns the actor's collision flags.
 int getCollisionMask()
          Returns the actor's collision mask.
 ConfigReference<ActorConfig> getConfig()
          Returns the actor's config reference.
 int getCreated()
          Returns the timestamp at which the actor was created.
 int getDestroyed()
          Returns the timestamp at which the actor was destroyed, or Integer.MAX_VALUE if not yet destroyed.
 int getFlags()
          Returns the actor's flags.
 int getId()
          Returns the actor's unique identifier.
 ActorConfig.Original getOriginal()
          Returns a reference to the cached config implementation.
 void getPreloads(ConfigManager cfgmgr, PreloadableSet preloads)
          Adds the resources to preload for this actor into the provided set.
 float getRotation()
          Returns the actor's rotation angle.
 Vector2f getTranslation()
          Returns a reference to the actor's translation vector.
 int hashCode()
           
 void init(ConfigManager cfgmgr)
          Gives the actor a chance to resolve and cache configuration data after being created or deserialized.
 Actor interpolate(Actor other, int start, int end, int timestamp, Actor result)
          Interpolates between the state of this actor and that of the specified other, placing the result in the provided object.
 boolean isClientControlled(TudeyContext ctx, TudeySceneView view)
          Checks whether this actor is client controlled.
 boolean isDirty()
          Returns the state of the actor's dirty flag.
 boolean isSet(int flag)
          Determines whether a flag is set.
 ActorAdvancer maybeCreateAdvancer(TudeyContext ctx, TudeySceneView view, int timestamp)
          Determines whether this actor is controlled by the client and, if so, creates and returns an ActorAdvancer instance to perform client-side prediction.
 void set(int flag)
          Sets a flag.
 void set(int flag, boolean value)
          Sets or clears a flag.
 void setConfig(ConfigReference<ActorConfig> config)
          Sets the actor's config reference.
 void setDestroyed(int destroyed)
          Sets the timestamp at which the actor was destroyed.
 void setDirty(boolean dirty)
          Sets the state of the actor's dirty flag.
 void setFlags(int flags)
          Sets the actor's flags.
 void setRotation(float rotation)
          Sets the actor's rotation angle.
 void setTranslation(float x, float y)
          Sets the actor's translation and its dirty flag.
 String toString()
           
 
Methods inherited from class com.threerings.util.DeepObject
clone, copy
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

WARP

public static final int WARP
A flag indicating that the actor has changed its position in a discontinuous fashion.

See Also:
Constant Field Values

LAST_FLAG

public static final int LAST_FLAG
The value of the last flag defined in this class.

See Also:
Constant Field Values
Constructor Detail

Actor

public Actor(ConfigReference<ActorConfig> config,
             int id,
             int created,
             Vector2f translation,
             float rotation)
Creates a new actor.


Actor

public Actor()
No-arg constructor for deserialization.

Method Detail

init

public void init(ConfigManager cfgmgr)
Gives the actor a chance to resolve and cache configuration data after being created or deserialized.


getPreloads

public void getPreloads(ConfigManager cfgmgr,
                        PreloadableSet preloads)
Adds the resources to preload for this actor into the provided set.


setConfig

public void setConfig(ConfigReference<ActorConfig> config)
Sets the actor's config reference.


getConfig

public ConfigReference<ActorConfig> getConfig()
Returns the actor's config reference.


getOriginal

public ActorConfig.Original getOriginal()
Returns a reference to the cached config implementation.


getId

public int getId()
Returns the actor's unique identifier.


getCreated

public int getCreated()
Returns the timestamp at which the actor was created.


setDestroyed

public void setDestroyed(int destroyed)
Sets the timestamp at which the actor was destroyed.


getDestroyed

public int getDestroyed()
Returns the timestamp at which the actor was destroyed, or Integer.MAX_VALUE if not yet destroyed.


setTranslation

public void setTranslation(float x,
                           float y)
Sets the actor's translation and its dirty flag.


getTranslation

public Vector2f getTranslation()
Returns a reference to the actor's translation vector.


setRotation

public void setRotation(float rotation)
Sets the actor's rotation angle.


getRotation

public float getRotation()
Returns the actor's rotation angle.


setFlags

public void setFlags(int flags)
Sets the actor's flags.


getFlags

public int getFlags()
Returns the actor's flags.


set

public void set(int flag,
                boolean value)
Sets or clears a flag.


set

public void set(int flag)
Sets a flag.


clear

public void clear(int flag)
Clears a flag.


isSet

public boolean isSet(int flag)
Determines whether a flag is set.


interpolate

public Actor interpolate(Actor other,
                         int start,
                         int end,
                         int timestamp,
                         Actor result)
Interpolates between the state of this actor and that of the specified other, placing the result in the provided object.

Parameters:
start - the start time (the timestamp of this actor).
end - the end time (the timestamp of the other actor).
timestamp - the desired time (the timestamp of the result).

extrapolate

public Actor extrapolate(float elapsed,
                         int timestamp,
                         Actor result)
Extrapolates the state of this actor after the specified time interval, in seconds (which may be negative).


maybeCreateAdvancer

public ActorAdvancer maybeCreateAdvancer(TudeyContext ctx,
                                         TudeySceneView view,
                                         int timestamp)
Determines whether this actor is controlled by the client and, if so, creates and returns an ActorAdvancer instance to perform client-side prediction. Returns null if not controlled by the client.


isClientControlled

public boolean isClientControlled(TudeyContext ctx,
                                  TudeySceneView view)
Checks whether this actor is client controlled.


createAdvancer

public ActorAdvancer createAdvancer(ActorAdvancer.Environment environment,
                                    int timestamp)
Creates an advancer for the actor.


canCollide

public boolean canCollide(Actor oactor)
Determines whether this actor should be checked for collisions with the specified other actor.


canCollide

public boolean canCollide(int flags)
Determines whether this actor should be checked for collisions with scene elements with the specified flags.


getCollisionFlags

public int getCollisionFlags()
Returns the actor's collision flags.


getCollisionMask

public int getCollisionMask()
Returns the actor's collision mask.


setDirty

public void setDirty(boolean dirty)
Sets the state of the actor's dirty flag.


isDirty

public boolean isDirty()
Returns the state of the actor's dirty flag.


copy

public Object copy(Object dest)
Description copied from interface: Copyable
Creates a copy of this object, (re)populating the supplied destination object if possible.

Specified by:
copy in interface Copyable
Overrides:
copy in class DeepObject
Returns:
either a reference to the destination object, if it could be repopulated, or a new object containing the copied state.

equals

public boolean equals(Object other)
Overrides:
equals in class DeepObject

hashCode

public int hashCode()
Overrides:
hashCode in class DeepObject

toString

public String toString()
Overrides:
toString in class DeepObject


Copyright © 2011. All Rights Reserved.