Commit de66d70e authored by Christina's avatar Christina
Browse files

refactored

parent ef3d810b
Pipeline #237232 failed with stages
in 2 minutes and 3 seconds
......@@ -81,7 +81,26 @@ public class TargetChangerController {
if (hasAgentReachedTargetChangerArea(agent) && processedAgents.containsKey(agent.getId()) == false) {
logEnteringTimeOfAgent(agent, simTimeInSec);
boolean changeTarget = false;
LinkedList<Integer> keepTargets = getFilteredTargetList();
if (keepTargets.size() > 0) {
if (targetChanger.getAttributes().isNextTargetIsPedestrian()) {
useDynamicTargetForAgentOrUseStaticAsFallback(agent);
} else {
useStaticTargetForAgent(agent,keepTargets);
}
}
notifyListenersTargetChangerAreaReached(agent);
processedAgents.put(agent.getId(), agent);
}
}
}
private LinkedList<Integer> getFilteredTargetList(){
boolean keepTarget;
int targetId;
int binomialDistributionSample;
......@@ -101,7 +120,6 @@ public class TargetChangerController {
if (keepTarget){
changeTarget = true;
if (targetChanger.getAttributes().getProbabilityToChangeTarget().size() == 1){
keepTargets = targetChanger.getAttributes().getNextTarget();
break;
......@@ -115,21 +133,8 @@ public class TargetChangerController {
index += 1;
}
return keepTargets;
if (changeTarget) {
if (targetChanger.getAttributes().isNextTargetIsPedestrian()) {
useDynamicTargetForAgentOrUseStaticAsFallback(agent);
} else {
useStaticTargetForAgent(agent,keepTargets);
}
}
notifyListenersTargetChangerAreaReached(agent);
processedAgents.put(agent.getId(), agent);
}
}
}
private Collection<DynamicElement> getDynamicElementsNearTargetChangerArea() {
......@@ -185,8 +190,8 @@ public class TargetChangerController {
Pedestrian pedToFollow = (pedsWithFollowers.isEmpty()) ? pedsWithCorrectTargetId.get(0) : pedsWithFollowers.get(0);
agentFollowsOtherPedestrian(agent, pedToFollow);
} else {
LinkedList<Integer> usedTargets = targetChanger.getAttributes().getNextTarget();
useStaticTargetForAgent(agent, usedTargets);
LinkedList<Integer> keepTargets = getFilteredTargetList();
useStaticTargetForAgent(agent, keepTargets);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment