public abstract class ComplexBehavior extends Behavior
decideNextBasicBehaviors()
method.Constructor and Description |
---|
ComplexBehavior(java.lang.String name,
IThoughtModel thoughtModel,
java.util.Map<java.lang.String,IBehavior> behaviors)
Default constructor for complex behaviors
|
ComplexBehavior(java.lang.String name,
IThoughtModel thoughtModel,
java.util.Map<java.lang.String,IBehavior> behaviors,
IBehavior defaultBehavior)
Default constructor for complex behaviors
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Called when to stop this behavior without caring for stopping it softly
|
IBehavior |
getCurrentBehavior() |
static java.util.List<IBehavior> |
getCurrentBehaviorchain(IBehavior referenceBehavior)
Retrieve the chain of behavior that are currently performed, starting with
the given referenceBehavior.
|
IBehavior |
getRootBehavior()
A call does not have side effects.
|
void |
init()
Reinitializes the Behavior-StateMachine (if present)
|
static boolean |
isBehaviorInExecution(IBehavior testee,
IBehavior referenceBehavior)
Checks if the testee behavior is in execution by the referenceBehavior.
|
boolean |
isFinished()
Check if this behavior is finished performing
|
void |
onLeavingBehavior(IBehavior newBehavior)
Called to notify this behavior that is no longer performed and replaced by
the new behavior.
|
void |
perform()
Called to perform the behavior
|
IBehavior |
switchFrom(IBehavior actualBehavior)
Decide if it is possible to switch to this behavior from the current
behavior.
|
java.lang.String |
toString() |
getConsecutivePerforms, getIntensity, getName, getPerforms, getSuccessfulPerforms, getUnsuccessfulPerforms, reload, setIntensity, setName, stayIn
public ComplexBehavior(java.lang.String name, IThoughtModel thoughtModel, java.util.Map<java.lang.String,IBehavior> behaviors, IBehavior defaultBehavior)
name
- name of behaviorthoughtModel
- Reference to the thought model objectbehaviors
- map of all available behaviorsdefaultBehavior
- the default behavior to start withpublic ComplexBehavior(java.lang.String name, IThoughtModel thoughtModel, java.util.Map<java.lang.String,IBehavior> behaviors)
name
- name of behaviorthoughtModel
- Reference to the thought model objectbehaviors
- map of all available behaviorspublic void perform()
IBehavior
public IBehavior switchFrom(IBehavior actualBehavior)
IBehavior
switchFrom
in interface IBehavior
switchFrom
in class Behavior
actualBehavior
- the currently/actually performed behaviorpublic void onLeavingBehavior(IBehavior newBehavior)
IBehavior
onLeavingBehavior
in interface IBehavior
onLeavingBehavior
in class Behavior
newBehavior
- the new behavior which will be performed after this
behaviorpublic void abort()
IBehavior
public IBehavior getCurrentBehavior()
public boolean isFinished()
IBehavior
isFinished
in interface IBehavior
isFinished
in class Behavior
public void init()
IBehavior
public IBehavior getRootBehavior()
IBehavior
getRootBehavior
in interface IBehavior
getRootBehavior
in class Behavior
public static boolean isBehaviorInExecution(IBehavior testee, IBehavior referenceBehavior)
testee
- the behavior we are looking forreferenceBehavior
- the reference behavior in which we search for the
testeepublic static java.util.List<IBehavior> getCurrentBehaviorchain(IBehavior referenceBehavior)
referenceBehavior
- the top level behavior to expand