hermes
Class Interactor<A extends HObject,B extends HObject>

java.lang.Object
  extended by hermes.Interactor<A,B>
Type Parameters:
A - The first type of HObject in the interaction.
B - The second type of HObject in the interaction.
Direct Known Subclasses:
BoundingBoxCollider, Collider, GenericMassedCollider, InsideMassedCollider, InverseSquareInteractor

public abstract class Interactor<A extends HObject,B extends HObject>
extends java.lang.Object

An Interactor defines some conditional relationship between two HObjects. It provides a method of detecting whether the objects are interacting, and a method of executing/handling the resultant interaction.

This is the primary means of writing conditional logic into the World game loop.


Constructor Summary
protected Interactor()
          Constructs a new Interactor using default settings.
protected Interactor(boolean applyImmediate, boolean multisample)
          Constructs a new Interactor, setting whether the Interactor will be handled upon detection or deferred, and whether the Interactor will be multisampled.
 
Method Summary
 boolean appliedImmediately()
          Whether the Interactor is applied upon detection, or deferred until all possible interactions have been checked for the step.
abstract  boolean detect(A object1, B object2)
          Determines whether an interaction between two objects has occurred.
abstract  void handle(A object1, B object2)
          Handles the result of an interaction that has been detected (by detect return true) for a pair of objects.
 boolean multisampled()
          Whether the Interactor is checked for each step of the objects it is registered with, or only once per update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Interactor

protected Interactor(boolean applyImmediate,
                     boolean multisample)
Constructs a new Interactor, setting whether the Interactor will be handled upon detection or deferred, and whether the Interactor will be multisampled. Note that these flags are only meaningful when the Interactor has been registered with a World.

Parameters:
applyImmediate - If true, the Interactor will be applied by World as soon as detect has returned true. If false, it will be applied only when all possible interactions have been checked for the step, for the entire World.
multisample - If true, the Interactor will be checked for and applied for each interacting object for each step, against all all objects it may interact with. If false, it will be checked for and applied only once per update of the loop, on the first step.

Interactor

protected Interactor()
Constructs a new Interactor using default settings. It will be applied as soon as detect has returned true, and will be applied on once per update (not multisampled).

Use this constructor unless you understand multisampling and delayed application and need it for a specific purpose.

Method Detail

appliedImmediately

public boolean appliedImmediately()
Whether the Interactor is applied upon detection, or deferred until all possible interactions have been checked for the step.

Returns:
If true, the World will call handle immediately upon detect returning true. If false, it will wait until the end of the loop, after all interactions have been checked.

multisampled

public boolean multisampled()
Whether the Interactor is checked for each step of the objects it is registered with, or only once per update.

Returns:
If true, for each object this Interactor is registered with, the World will apply it for all the object's steps, against all objects the object could interact with. If false, it will be checked only once per object per update, on the object's first step.

detect

public abstract boolean detect(A object1,
                               B object2)
Determines whether an interaction between two objects has occurred.

Parameters:
object1 - the first interacting object
object2 - the second interacting object
Returns:
Whether or not an interaction has occurred.

handle

public abstract void handle(A object1,
                            B object2)
Handles the result of an interaction that has been detected (by detect return true) for a pair of objects.

Parameters:
object1 - the first object
object2 - the second object