Unknown
17697070ee
All ControlService was used for was a redirection to the engine service. This will be further split up in the future into more logical units of responsibility.
46 lines
783 B
Dart
46 lines
783 B
Dart
import 'package:rules_of_living/src/Engine.dart';
|
|
|
|
class EngineService {
|
|
Engine _uncachedEngineAccess;
|
|
|
|
Engine get engine => _uncachedEngineAccess ?? _setCachedAndReturn(Engine());
|
|
void set engine(Engine newEngine) {
|
|
_uncachedEngineAccess = newEngine;
|
|
}
|
|
|
|
Engine _setCachedAndReturn(Engine newEngine) {
|
|
engine = newEngine;
|
|
return newEngine;
|
|
}
|
|
|
|
void run() {
|
|
engine.running = true;
|
|
}
|
|
|
|
void stop() {
|
|
engine.running = false;
|
|
}
|
|
|
|
void toggleRunning() {
|
|
engine.running = !engine.running;
|
|
}
|
|
|
|
void step() {
|
|
engine.step();
|
|
}
|
|
|
|
void reset() {
|
|
engine.reset();
|
|
}
|
|
|
|
void addRandomPattern() {
|
|
engine.running = false;
|
|
engine.addPattern();
|
|
}
|
|
|
|
void clear() {
|
|
engine.clear();
|
|
}
|
|
|
|
bool get isRunning => engine.running;
|
|
}
|