T
- The type of CellGame that uses this SubThinker's GameStatesU
- The type of GameState that uses this SubThinkerV
- The type of SubThinker that this SubThinker is for GameState
interaction purposespublic abstract class SubThinker<T extends CellGame,U extends GameState<T,U,V>,V extends SubThinker<T,U,V>> extends Thinker<T,U,V>
A SubThinker is a type of Thinker that contributes to the mechanics of another Thinker to which it is assigned. This Thinker is called its super-Thinker. If its time factor is negative, a SubThinker will use the time factor of its super-Thinker.
The process in which a SubThinker takes its frameActions() and then performs its frame Events is itself an Event, and the SubThinker automatically ensures that this Event is in the frame Events of its current super-Thinker. The SubThinker's frame priority (0 by default) is the Event's priority in its super-Thinker's frame Events. This means that the SubThinkers assigned to a given Thinker will take their frameActions() in order from highest to lowest frame priority, and that a SubThinker will take its frameActions() after its super-Thinker, but, if its super-Thinker is itself a SubThinker, before the next Thinker assigned to its super-Thinker's super-Thinker.
The SubThinker class is intended to be extended by classes V that extend SubThinker<T,U,V> and interact with GameStates of class U. BasicThinker is an example of such a class. This allows a SubThinker's GameStates to interact with it in ways unique to its subclass of SubThinker.
It is useful to implicitly extend subclasses of SubThinker to override their methods for single instances without creating completely new class files.
Constructor and Description |
---|
SubThinker(java.lang.Class<T> gameClass,
java.lang.Class<U> stateClass,
java.lang.Class<V> subThinkerClass)
Constructs a SubThinker.
|
Modifier and Type | Method and Description |
---|---|
void |
addedActions(T game,
U state)
Actions for this SubThinker to take after being added to a new
super-Thinker, immediately after the super-Thinker takes its
addSubThinkerActions().
|
long |
getEffectiveTimeFactor()
Returns this Thinker's effective time factor; that is, the average number
of time units it experiences every frame.
|
int |
getFramePriority()
Returns this SubThinker's frame priority.
|
T |
getGame()
Returns the CellGame of the GameState to which this Thinker is assigned,
or null if it is not assigned to a GameState.
|
U |
getGameState()
Returns the GameState to which this Thinker is assigned, or null if it is
not assigned to one.
|
Thinker<T,U,V> |
getNewSuperThinker()
Returns the Thinker to which this SubThinker is about to be assigned, but
has not yet been due to one or more of the SubThinker lists involved
being iterated over.
|
Thinker<T,U,V> |
getSuperThinker()
Returns this SubThinker's super-Thinker, or null if it has none.
|
V |
getThis()
Returns this SubThinker as a V, rather than as a SubThinker<T,U,V>.
|
void |
removedActions(T game,
U state)
Actions for this SubThinker to take before being removed from its current
super-Thinker, immediately before the super-Thinker takes its
removeSubThinkerActions().
|
void |
setFramePriority(int framePriority)
Sets this SubThinker's frame priority to the specified value.
|
void |
setSuperThinker(Thinker<T,U,V> thinker)
Sets this SubThinker's super-Thinker to the specified one.
|
addSubThinker, addSubThinkerActions, clearLineages, clearSubThinkers, frameActions, getFrameEvents, getGameClass, getNumSubThinkers, getStateClass, getSubThinkerClass, getTimeFactor, getTimerValue, iteratingThroughSubThinkers, removeLineage, removeSubThinker, removeSubThinkerActions, setTimeFactor, setTimerValue, subThinkerIterator
public SubThinker(java.lang.Class<T> gameClass, java.lang.Class<U> stateClass, java.lang.Class<V> subThinkerClass)
gameClass
- The Class object representing the type of CellGame that
uses this SubThinker's GameStatesstateClass
- The Class object representing the type of GameState
that uses this SubThinkersubThinkerClass
- The Class object representing the type of
SubThinker that this SubThinker is for GameState interaction purposespublic final V getThis()
public final T getGame()
Thinker
public final U getGameState()
Thinker
public final long getEffectiveTimeFactor()
Thinker
public final Thinker<T,U,V> getSuperThinker()
public final Thinker<T,U,V> getNewSuperThinker()
public final void setSuperThinker(Thinker<T,U,V> thinker)
thinker
- This SubThinker's new super-Thinkerpublic void addedActions(T game, U state)
game
- This SubThinker's GameState's CellGame, or null if it has no
GameStatestate
- This SubThinker's GameState, or null if it has nonepublic void removedActions(T game, U state)
game
- This SubThinker's GameState's CellGame, or null if it has no
GameStatestate
- This SubThinker's GameState, or null if it has nonepublic final int getFramePriority()
public final void setFramePriority(int framePriority)
framePriority
- This SubThinker's new frame priority