2018-08-22 18:16:31 +00:00
|
|
|
import 'package:rules_of_living/src/Engine.dart';
|
|
|
|
|
|
|
|
class EngineService {
|
2018-08-27 18:50:12 +00:00
|
|
|
Engine _uncachedEngineAccess;
|
2018-08-25 07:33:15 +00:00
|
|
|
|
2018-08-27 18:50:12 +00:00
|
|
|
Engine get engine => _uncachedEngineAccess ?? _setCachedAndReturn(Engine());
|
|
|
|
void set engine(Engine newEngine) {
|
|
|
|
_uncachedEngineAccess = newEngine;
|
2018-08-25 07:33:15 +00:00
|
|
|
}
|
|
|
|
|
2018-08-27 18:50:12 +00:00
|
|
|
Engine _setCachedAndReturn(Engine newEngine) {
|
|
|
|
engine = newEngine;
|
|
|
|
return newEngine;
|
2018-08-25 07:33:15 +00:00
|
|
|
}
|
2018-10-18 09:58:38 +00:00
|
|
|
|
|
|
|
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;
|
2018-08-22 18:16:31 +00:00
|
|
|
}
|