net.jinx.action.input
Class Participant

java.lang.Object
  extended by net.jinx.action.Actor
      extended by net.jinx.action.input.Participant
All Implemented Interfaces:
ClockSensitive
Direct Known Subclasses:
Robot

public abstract class Participant
extends Actor
implements ClockSensitive

Participant is the base superclass of any kind of Actor that is actively self guiding. This includes both computer and human controlled Actors.

API Stability: Beta.


Constructor Summary
protected Participant(java.lang.String name)
          Constructors a new Participant.
protected Participant(java.lang.String name, Behavior b)
          Utility constructor that allows setting the Behavior.
 
Method Summary
 Behavior getBehavior()
          Provides the current Behavior for this Participant.
abstract  Condition getCondition()
          Provides the Condition object for this Participant.
abstract  void processAction(Action action)
          Should be called by Behavior to process the actions it produces.
protected  void processEvent(ActorEvent event)
          Ignores all events except ClockEvent instances.
 void setBehavior(Behavior b)
          Sets the Behavior for this Participant.
protected  void step(float dt)
          Calls the Behavior's act(Participant, float) method.
 
Methods inherited from class net.jinx.action.Actor
checkAllowAdd, getName, getOwner, hashCode, ownerChanged, sendEvent, sendEvent, sendEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Participant

protected Participant(java.lang.String name)
Constructors a new Participant.

Parameters:
name - the name for this Participant.

Participant

protected Participant(java.lang.String name,
                      Behavior b)
Utility constructor that allows setting the Behavior.

Parameters:
name - the name for this Participant.
b - the Behavior to use.
Method Detail

setBehavior

public void setBehavior(Behavior b)
Sets the Behavior for this Participant.

Parameters:
b - the Behavior to use. Setting this to null will disable the Participant and cause it to stop acting on it's own. This can be good for dead participants, but may not fit quite correctly.

getBehavior

public Behavior getBehavior()
Provides the current Behavior for this Participant.

Returns:
the Behavior.

processEvent

protected void processEvent(ActorEvent event)
Ignores all events except ClockEvent instances. If a ClockEvent is received, it will call it's Behavior's getActions(Participant, float) method. Then it will call processActions(Action[]) on the results.

If the Behavior is currently null, then this will do nothing.

Specified by:
processEvent in class Actor
Parameters:
event - the ActorEvent to process.

step

protected void step(float dt)
Calls the Behavior's act(Participant, float) method. Subclasses can override this to do more if needed.

Parameters:
dt - the change in time value.

getCondition

public abstract Condition getCondition()
Provides the Condition object for this Participant.

Returns:
the Condition object.

processAction

public abstract void processAction(Action action)
Should be called by Behavior to process the actions it produces.

Parameters:
action - the Action object.