Point2d position = new Point2d(getX(), getY());
Vector2d orientation = getDirection();
double linearSpeed = getCurrentLinearSpeed();
double angularSpeed = getCurrentAngularSpeed();
BehaviourOutput output = null;
List<Perception> perceptions = getPerceivedObjects();
if (this.seekBehaviour!=null && !perceptions.isEmpty()) {
Perception percept = perceptions.get(0);
if (percept.getPerceivedObject() instanceof MouseTarget) {
Point2d target = new Point2d(percept.getPerceivedObject().getPosition());
// run the seek behaviour
output = this.seekBehaviour.runSeek(position, linearSpeed, getMaxLinear(), target);
}
else {
// run the wander behaviour
output = this.wanderBehaviour.runWander(position, orientation, linearSpeed, getMaxLinear(), angularSpeed, getMaxAngular());
}
}
else {
// run the wander behaviour
output = this.wanderBehaviour.runWander(position, orientation, linearSpeed, getMaxLinear(), angularSpeed, getMaxAngular());
}
// Send the behaviour output to the environment
if (output!=null) {
if (this.isSteering)
influenceSteering(output.getLinear(),output.getAngular());
else
influenceKinematic(output.getLinear(),output.getAngular());
}
return StatusFactory.ok(this);
}