2018-10-18 12:41:57 +00:00
|
|
|
import 'dart:html' as html;
|
2018-10-18 10:16:47 +00:00
|
|
|
import 'dart:math';
|
|
|
|
|
2018-10-18 10:05:02 +00:00
|
|
|
import 'package:rules_of_living/service/engine_service.dart';
|
|
|
|
|
|
|
|
class SimulationService {
|
2018-10-18 10:16:47 +00:00
|
|
|
final EngineService _engine;
|
2018-10-18 10:05:02 +00:00
|
|
|
|
2018-10-18 10:16:47 +00:00
|
|
|
SimulationService(this._engine);
|
2018-10-18 10:05:02 +00:00
|
|
|
|
|
|
|
void reset() {
|
2018-10-18 10:16:47 +00:00
|
|
|
_engine.reset();
|
2018-10-18 10:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void addRandomPattern() {
|
2018-10-18 10:16:47 +00:00
|
|
|
_engine.addRandomPattern();
|
2018-10-18 10:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void clear() {
|
2018-10-18 10:16:47 +00:00
|
|
|
_engine.clear();
|
|
|
|
}
|
|
|
|
|
2018-10-18 10:29:46 +00:00
|
|
|
void set gridSize(Point<int> size) {
|
2018-10-18 10:16:47 +00:00
|
|
|
_engine.engine.gridSize = size;
|
2018-10-18 10:05:02 +00:00
|
|
|
}
|
2018-10-18 10:16:47 +00:00
|
|
|
|
|
|
|
Point<int> get gridSize => _engine.engine.gridSize;
|
2018-10-18 12:41:57 +00:00
|
|
|
|
|
|
|
//TODO split into RenderService when rendering is decoupled from engine.
|
|
|
|
html.CanvasElement get canvas => _engine.engine.canvas;
|
|
|
|
void set canvas(html.CanvasElement canvas) => _engine.engine.canvas = canvas;
|
|
|
|
|
|
|
|
void toggleGrid() {
|
|
|
|
_engine.engine.toggleEdgeRendering();
|
|
|
|
}
|
2018-10-18 10:05:02 +00:00
|
|
|
}
|