Commit 7e45d710 authored by Julian Zobel's avatar Julian Zobel
Browse files

Renamed function, removed sysout

parent 74c2e2f4
......@@ -89,8 +89,7 @@ public class RandomDynamicAttractionGenerator implements IAttractionGenerator {
this.maxDynamicIntervall = maxDynamicIntervall;
attractionPoints.clear();
createAttractionPoints();
updateAttractionPoints();
}
@Override
......@@ -113,14 +112,13 @@ public class RandomDynamicAttractionGenerator implements IAttractionGenerator {
// maybe was already removed...
if(attractionPoints.contains(attractionPoint)) {
attractionPoints.remove(attractionPoint);
createAttractionPoints();
updateAttractionPoints();
}
}
}, null, 0);
}
protected void createAttractionPoints() {
protected void updateAttractionPoints() {
int numberOfAttractionPoints = randomNumberOfAttractionPoints();
// do nothing if this is the required amount of attraction points
......@@ -129,34 +127,33 @@ public class RandomDynamicAttractionGenerator implements IAttractionGenerator {
}
// remove until this number fits
else if(numberOfAttractionPoints < attractionPoints.size()) {
else if(numberOfAttractionPoints < attractionPoints.size()) {
int deltaAP = attractionPoints.size() - numberOfAttractionPoints;
int deltaAP = attractionPoints.size() - numberOfAttractionPoints;
for(int i = 0; i < deltaAP; i++)
{
for(int i = 0; i < deltaAP; i++) {
int random = rand.nextInt(attractionPoints.size());
attractionPoints.remove(random);
}
}
return;
}
// add more attraction points until it fits
else {
int deltaAP = numberOfAttractionPoints - attractionPoints.size();
else {
int deltaAP = numberOfAttractionPoints - attractionPoints.size();
for(int i = 0; i < deltaAP; i++)
{
for(int i = 0; i < deltaAP; i++) {
AttractionPoint newAP = createAttractionPoint();
scheduleDynamicEvent(newAP);
attractionPoints.add(newAP);
}
}
}
}
/**
* Create an attraction point that is conform to all other currently saved attraction points.
*
* @return
*/
private AttractionPoint createAttractionPoint() {
// make a break counter to prevent more than 10 iterations and an infinity loop in general.
int c = 20;
......@@ -167,8 +164,7 @@ public class RandomDynamicAttractionGenerator implements IAttractionGenerator {
// set the radius of this attraction point
// minimum radius is 10 meters
double radius = Math.max(minimumRadius, rand.nextDouble() * maximumRadius);
System.out.println(radius);
if(i < c) {
// check if the attraction points would be completely within world dimensions (including radius!)
if((posVec.getX() + radius) >= worldDimension.getX() || (posVec.getY() + radius) >= worldDimension.getY()
......
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