// Compute actions
for(int index1=0; index1<influenceList.size(); index1++) {
MotionInfluence inf1 = influenceList.get(index1);
AgentBody body1 = getAgentBodyFor(inf1.getEmitter());
if (body1!=null) {
Vector2d move;
double rotation;
if (inf1.getType()==DynamicType.STEEERING) {
move = computeSteeringTranslation(body1, inf1.getLinearInfluence(), timeManager);
rotation = computeSteeringRotation(body1, inf1.getAngularInfluence(), timeManager);
}
else {
move = computeKinematicTranslation(body1, inf1.getLinearInfluence(), timeManager);
rotation = computeKinematicRotation(body1, inf1.getAngularInfluence(), timeManager);
}
double x1 = body1.getX();
double y1 = body1.getY();
// Trivial collision detection
for(int index2=index1+1; index2<influenceList.size(); index2++) {
MotionInfluence inf2 = influenceList.get(index2);
AgentBody body2 = getAgentBodyFor(inf2.getEmitter());
if (body2!=null) {
double x2 = body2.getX();
double y2 = body2.getY();
double distance = new Vector2d(x2-x1,y2-y1).length();
if (distance<(body1.getSize()+body2.getSize())) {
move.set(0,0);
break;
}
}
}
if(body1 instanceof LemmingBody)
{
LemmingBody body = (LemmingBody) body1;
if(body.getIsActing())
{
if(body.getCurrentAction() == Action.DigVertically)
{
move.set(0,0);
}
else if(body.getCurrentAction() == Action.DigHorizontally)
{
move.set(1,0);
}
}
actionApplier.doAction(body);
actions.add(physicsEngine.Gravity(body, new AnimatAction(body, move, rotation)));
}