com.threerings.tudey.server.logic
Class ActorLogic

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
All Implemented Interfaces:
HasActor
Direct Known Subclasses:
EntryStateLogic, MobileLogic

public class ActorLogic
extends Logic
implements HasActor

Controls the state of an actor on the server.


Nested Class Summary
static interface ActorLogic.CollisionFlagObserver
          An interface for objects interested in updates to the actor's collision flags.
 
Nested classes/interfaces inherited from class com.threerings.tudey.server.logic.Logic
Logic.ShapeObserver
 
Constructor Summary
ActorLogic()
           
 
Method Summary
 void addCollisionFlagObserver(ActorLogic.CollisionFlagObserver observer)
          Adds a listener for changes to the actor's collision flags.
 void addShapeObserver(Logic.ShapeObserver observer)
          Adds an observer for changes to the logic's shape.
 void bodyWillEnter(com.threerings.crowd.data.BodyObject body)
          For player-controlled actors, this notifies the logic that the controlling player is about to enter.
 void bodyWillLeave(com.threerings.crowd.data.BodyObject body)
          For player-controlled actors, this notifies the logic that the controlling player is about to leave.
 void destroy(int timestamp, Logic activator)
          Destroys the actor.
 Logic getActivator()
          Returns a reference to the entity that caused the actor to be spawned, if known/any.
 Actor getActor()
          Returns a reference to the actor object.
 int getCollisionFlags()
          Returns the cached collision flags.
 EntityKey getEntityKey()
          Returns the entity key for this logic, if any.
 ConfigReference<ModelConfig> getModel()
          Returns a reference to the model associated with this logic, if any.
 Actor getPreviousSnapshot()
          Returns the previous tick's snapshot of the actor.
 float getRotation()
          Returns the rotation of this logic for the purpose of spawning actors, etc.
 Shape getShape()
          Returns a reference to this logic's shape, or returns null for none.
 ShapeElement getShapeElement()
          Returns a reference to the actor's shape element.
 Actor getSnapshot()
          Returns the current tick's snapshot of the actor.
 ActorDelta getSnapshotDelta()
          Returns the delta between the last snapshot of the actor and the current state, or null if the actor has not changed.
 Logic getSource()
          Returns a reference to the entity that spawned the actor, if known/any.
 String[] getTags()
          Returns the tags for this logic, if any.
 Vector2f getTranslation()
          Returns the translation of this logic for the purpose of spawning actors, etc.
 void init(TudeySceneManager scenemgr, ConfigReference<ActorConfig> ref, ActorConfig.Original config, int id, int timestamp, Vector2f translation, float rotation, Actor actor)
          Initializes the actor.
 boolean isActive()
          Determines whether this logic object is still active in the scene.
 boolean isDefaultEntrance()
          Checks whether this logic object corresponds to a default entrance.
 boolean isDestroyed()
          Determines whether the actor is destroyed as of the current server tick.
 boolean isRemoved()
          Determines whether the actor has been removed from the manager.
 boolean isStatic()
          Checks whether this is a "static" actor.
 void move(float x, float y, float rotation)
          Moves the actor and updates its shape.
 void remove()
          Removes this actor after it has been destroyed.
 void removeCollisionFlagObserver(ActorLogic.CollisionFlagObserver observer)
          Removes a collision flag observer.
 void removeShapeObserver(Logic.ShapeObserver observer)
          Removes a shape observer.
 void request(int timestamp, PawnLogic source, String name)
          Notifies the logic of a client request.
 void setActivator(Logic activator)
          Sets the reference to the entity that caused the actor to be spawned.
 void setSource(Logic source)
          Sets the reference to the entity that spawned the actor.
 void setVariable(int timestamp, Logic source, String name, Object value)
          Sets the value of a variable.
 void signal(int timestamp, Logic source, String name)
          Sends a generic "signal" to the logic.
 void transfer(Logic source, Map<Object,Object> refs)
          Transfers state from the specified source logic.
 void warp(float x, float y, float rotation)
          Warps the actor.
 void warp(float x, float y, float rotation, float tx, float ty)
          Warps the actor.
 void warp(float x, float y, float rotation, float tx, float ty, boolean adjust)
          Warps the actor.
 
Methods inherited from class com.threerings.tudey.server.logic.Logic
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
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActorLogic

public ActorLogic()
Method Detail

init

public void init(TudeySceneManager scenemgr,
                 ConfigReference<ActorConfig> ref,
                 ActorConfig.Original config,
                 int id,
                 int timestamp,
                 Vector2f translation,
                 float rotation,
                 Actor actor)
Initializes the actor.


isStatic

public boolean isStatic()
Checks whether this is a "static" actor. Static actors are always in clients' areas of interest and must notify the scene manager when their state changes.


setSource

public void setSource(Logic source)
Sets the reference to the entity that spawned the actor.


getSource

public Logic getSource()
Returns a reference to the entity that spawned the actor, if known/any.


setActivator

public void setActivator(Logic activator)
Sets the reference to the entity that caused the actor to be spawned.


getActivator

public Logic getActivator()
Returns a reference to the entity that caused the actor to be spawned, if known/any.


getCollisionFlags

public int getCollisionFlags()
Returns the cached collision flags.


addCollisionFlagObserver

public void addCollisionFlagObserver(ActorLogic.CollisionFlagObserver observer)
Adds a listener for changes to the actor's collision flags.


removeCollisionFlagObserver

public void removeCollisionFlagObserver(ActorLogic.CollisionFlagObserver observer)
Removes a collision flag observer.


bodyWillEnter

public void bodyWillEnter(com.threerings.crowd.data.BodyObject body)
For player-controlled actors, this notifies the logic that the controlling player is about to enter.


bodyWillLeave

public void bodyWillLeave(com.threerings.crowd.data.BodyObject body)
For player-controlled actors, this notifies the logic that the controlling player is about to leave.


getSnapshot

public Actor getSnapshot()
Returns the current tick's snapshot of the actor.


getPreviousSnapshot

public Actor getPreviousSnapshot()
Returns the previous tick's snapshot of the actor.


getSnapshotDelta

public ActorDelta getSnapshotDelta()
Returns the delta between the last snapshot of the actor and the current state, or null if the actor has not changed.


getShapeElement

public ShapeElement getShapeElement()
Returns a reference to the actor's shape element.


isDestroyed

public boolean isDestroyed()
Determines whether the actor is destroyed as of the current server tick.


isRemoved

public boolean isRemoved()
Determines whether the actor has been removed from the manager.


warp

public void warp(float x,
                 float y,
                 float rotation)
Warps the actor.


warp

public void warp(float x,
                 float y,
                 float rotation,
                 float tx,
                 float ty)
Warps the actor.


warp

public void warp(float x,
                 float y,
                 float rotation,
                 float tx,
                 float ty,
                 boolean adjust)
Warps the actor.

Parameters:
adjust - if true, adjusts the location as when spawning to avoid intersecting other actors.

move

public void move(float x,
                 float y,
                 float rotation)
Moves the actor and updates its shape.


destroy

public void destroy(int timestamp,
                    Logic activator)
Destroys the actor.


remove

public void remove()
Removes this actor after it has been destroyed.


getActor

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

Specified by:
getActor in interface HasActor

getTags

public String[] getTags()
Description copied from class: Logic
Returns the tags for this logic, if any.

Overrides:
getTags in class Logic

isDefaultEntrance

public boolean isDefaultEntrance()
Description copied from class: Logic
Checks whether this logic object corresponds to a default entrance.

Overrides:
isDefaultEntrance in class Logic

isActive

public boolean isActive()
Description copied from class: Logic
Determines whether this logic object is still active in the scene.

Overrides:
isActive in class Logic

getEntityKey

public EntityKey getEntityKey()
Description copied from class: Logic
Returns the entity key for this logic, if any.

Overrides:
getEntityKey in class Logic

getTranslation

public Vector2f getTranslation()
Description copied from class: Logic
Returns the translation of this logic for the purpose of spawning actors, etc.

Overrides:
getTranslation in class Logic

getRotation

public float getRotation()
Description copied from class: Logic
Returns the rotation of this logic for the purpose of spawning actors, etc.

Overrides:
getRotation in class Logic

getShape

public Shape getShape()
Description copied from class: Logic
Returns a reference to this logic's shape, or returns null for none.

Overrides:
getShape in class Logic

addShapeObserver

public void addShapeObserver(Logic.ShapeObserver observer)
Description copied from class: Logic
Adds an observer for changes to the logic's shape.

Overrides:
addShapeObserver in class Logic

removeShapeObserver

public void removeShapeObserver(Logic.ShapeObserver observer)
Description copied from class: Logic
Removes a shape observer.

Overrides:
removeShapeObserver in class Logic

getModel

public ConfigReference<ModelConfig> getModel()
Description copied from class: Logic
Returns a reference to the model associated with this logic, if any.

Overrides:
getModel in class Logic

signal

public void signal(int timestamp,
                   Logic source,
                   String name)
Description copied from class: Logic
Sends a generic "signal" to the logic.

Overrides:
signal in class Logic
Parameters:
timestamp - the signal timestamp.
source - the source of the signal.

setVariable

public void setVariable(int timestamp,
                        Logic source,
                        String name,
                        Object value)
Description copied from class: Logic
Sets the value of a variable.

Overrides:
setVariable in class Logic
Parameters:
timestamp - the set timestamp.
source - the source of the request.

request

public void request(int timestamp,
                    PawnLogic source,
                    String name)
Description copied from class: Logic
Notifies the logic of a client request.

Overrides:
request in class Logic
Parameters:
timestamp - the request timestamp.
source - the source of the request.

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 Logic


Copyright © 2011. All Rights Reserved.