Remove ConfigurationService
Replaced with direct access to both EngineService and SimulationService.
This commit is contained in:
parent
99ead8691b
commit
58971016da
7 changed files with 41 additions and 108 deletions
|
|
@ -1,8 +1,14 @@
|
|||
import 'dart:html' as html;
|
||||
|
||||
import 'package:rules_of_living/src/Engine.dart';
|
||||
|
||||
class EngineService {
|
||||
Engine _uncachedEngineAccess;
|
||||
|
||||
EngineService() {
|
||||
simSpeed = 5;
|
||||
}
|
||||
|
||||
Engine get engine => _uncachedEngineAccess ?? _setCachedAndReturn(Engine());
|
||||
void set engine(Engine newEngine) {
|
||||
_uncachedEngineAccess = newEngine;
|
||||
|
|
@ -29,6 +35,22 @@ class EngineService {
|
|||
engine.step();
|
||||
}
|
||||
|
||||
/// 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 => 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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue