import 'dart:html' as html;
import 'dart:math';
import 'package:rules_of_living/service/engine_service.dart';
import 'package:rules_of_living/service/simulation_service.dart';
class ConfigurationService {
final EngineService _engine;
final SimulationService _sim;
bool showGrid;
int _simSpeed;
ConfigurationService(this._engine, this._sim) {
showGrid = false;
simSpeed = 5;
}
/// Simulation Speed
///
/// Sets the number of updates the simulation takes per second. Can range from
/// 1 to arbitrarily high numbers (though setting it too high can potentially
/// make the app brittle).
int get simSpeed => _simSpeed;
void set simSpeed(int val) {
_simSpeed = val;
//TODO make method in EngineService to respect Demeter
_engine.engine.stepsPerSecond = simSpeed;
}
void set canvas(html.CanvasElement canvas) => _engine.engine.canvas = canvas;
html.CanvasElement get canvas => _engine.engine.canvas;
void toggleGrid() {
showGrid = !showGrid;
}
void setGridSize({int x, int y}) {
_sim.gridSize = Point(x ?? gridSize.x, y ?? gridSize.y);
}
Point get gridSize => _sim.gridSize;
}