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);
}
void addPattern(
{CellPattern pattern,
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 addPattern({int amount, int dispersal}) {
_grid.addPattern(amount: amount, dispersal: dispersal);
}
void toggleEdgeRendering() {

View file

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