Move Render Methods into SimulationService
This commit is contained in:
parent
58971016da
commit
45e8f01acb
4 changed files with 13 additions and 12 deletions
|
@ -49,6 +49,6 @@ class ConfigurationComponent {
|
|||
ConfigurationComponent(this.engine, this.sim);
|
||||
|
||||
void onEdgesClicked() {
|
||||
engine.toggleGrid();
|
||||
sim.toggleGrid();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:html' as html;
|
|||
|
||||
import 'package:angular/angular.dart';
|
||||
import 'package:rules_of_living/service/engine_service.dart';
|
||||
import 'package:rules_of_living/service/simulation_service.dart';
|
||||
|
||||
@Component(
|
||||
selector: 'gol-simulation',
|
||||
|
@ -11,6 +12,7 @@ import 'package:rules_of_living/service/engine_service.dart';
|
|||
)
|
||||
class SimulationComponent implements OnInit {
|
||||
final EngineService engine;
|
||||
final SimulationService sim;
|
||||
|
||||
SimulationComponent(this.engine);
|
||||
|
||||
|
@ -29,6 +31,6 @@ class SimulationComponent implements OnInit {
|
|||
|
||||
the canvas did not load correctly :(
|
||||
''', canvas.width / 2 - 50, canvas.height / 2);
|
||||
engine.canvas = canvas;
|
||||
sim.canvas = canvas;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import 'dart:html' as html;
|
||||
|
||||
import 'package:rules_of_living/src/Engine.dart';
|
||||
|
||||
class EngineService {
|
||||
|
@ -43,14 +41,6 @@ class EngineService {
|
|||
int get simSpeed => engine.stepsPerSecond;
|
||||
void set simSpeed(int val) => engine.stepsPerSecond = val;
|
||||
|
||||
//TODO split into RenderService when rendering is decoupled from engine.
|
||||
html.CanvasElement get canvas => engine.canvas;
|
||||
void set canvas(html.CanvasElement canvas) => engine.canvas = canvas;
|
||||
|
||||
void toggleGrid() {
|
||||
engine.toggleEdgeRendering();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
engine.reset();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:html' as html;
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:rules_of_living/service/engine_service.dart';
|
||||
|
@ -24,4 +25,12 @@ class SimulationService {
|
|||
}
|
||||
|
||||
Point<int> get gridSize => _engine.engine.gridSize;
|
||||
|
||||
//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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue