Remove unnecessary Switch Case in Simulation
This commit is contained in:
parent
9b2b5f3e55
commit
e6e82f78f2
1 changed files with 10 additions and 12 deletions
|
@ -43,19 +43,17 @@ class Simulation {
|
||||||
_dispersal = dispersal ?? 10;
|
_dispersal = dispersal ?? 10;
|
||||||
int cx = x ?? rng.nextInt(map.width ~/ 3) + (map.width ~/ 3);
|
int cx = x ?? rng.nextInt(map.width ~/ 3) + (map.width ~/ 3);
|
||||||
int cy = y ?? rng.nextInt(map.height ~/ 3) + (map.height ~/ 3);
|
int cy = y ?? rng.nextInt(map.height ~/ 3) + (map.height ~/ 3);
|
||||||
switch (pattern) {
|
|
||||||
default:
|
|
||||||
int sanityCheck = 0;
|
int sanityCheck = 0;
|
||||||
for (var i = 0; i < (_amount); i++) {
|
for (var i = 0; i < (_amount); i++) {
|
||||||
sanityCheck++;
|
sanityCheck++;
|
||||||
getCellState(cx, cy)
|
getCellState(cx, cy)
|
||||||
? i--
|
? i--
|
||||||
: setCellState(cx + rng.nextInt(_dispersal),
|
: setCellState(
|
||||||
cy + rng.nextInt(_dispersal), true);
|
cx + rng.nextInt(_dispersal), cy + rng.nextInt(_dispersal), true);
|
||||||
if (sanityCheck > 100 && sanityCheck > i * 3) break;
|
if (sanityCheck > 100 && sanityCheck > i * 3) break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue