Remove unnecessary pattern parameters

This commit is contained in:
Unknown 2018-10-18 09:57:08 +02:00
parent 6d7120650f
commit bac65ef116
2 changed files with 6 additions and 25 deletions

View file

@ -124,20 +124,8 @@ class Engine {
if (canvas != null) _grid.render(canvas, interp); if (canvas != null) _grid.render(canvas, interp);
} }
void addPattern( void addPattern({int amount, int dispersal}) {
{CellPattern pattern, _grid.addPattern(amount: amount, dispersal: dispersal);
int x,
int y,
int amount,
int dispersal,
int seed}) {
_grid.addPattern(
pattern: pattern,
x: x,
y: y,
amount: amount,
dispersal: dispersal,
seed: seed);
} }
void toggleEdgeRendering() { void toggleEdgeRendering() {

View file

@ -13,7 +13,6 @@ class Simulation {
bool _dirty = true; bool _dirty = true;
bool _renderEdges = true; bool _renderEdges = true;
int _startingSeed;
int _amount; int _amount;
int _dispersal; int _dispersal;
@ -30,19 +29,13 @@ class Simulation {
_dirty = true; _dirty = true;
} }
void addPattern( void addPattern({int amount, int dispersal}) {
{CellPattern pattern, int _startingSeed = DateTime.now().millisecondsSinceEpoch;
int x,
int y,
int amount,
int dispersal,
int seed}) {
_startingSeed = seed ?? DateTime.now().millisecondsSinceEpoch;
math.Random rng = new math.Random(_startingSeed); math.Random rng = new math.Random(_startingSeed);
_amount = amount ?? rng.nextInt(20); _amount = amount ?? rng.nextInt(20);
_dispersal = dispersal ?? 10; _dispersal = dispersal ?? 10;
int cx = x ?? rng.nextInt(map.width ~/ 3) + (map.width ~/ 3); int cx = rng.nextInt(map.width ~/ 3) + (map.width ~/ 3);
int cy = y ?? rng.nextInt(map.height ~/ 3) + (map.height ~/ 3); int cy = rng.nextInt(map.height ~/ 3) + (map.height ~/ 3);
int sanityCheck = 0; int sanityCheck = 0;
for (var i = 0; i < (_amount); i++) { for (var i = 0; i < (_amount); i++) {