Move ControlService tasks into EngineService
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.
This commit is contained in:
parent
b37487a222
commit
17697070ee
4 changed files with 33 additions and 42 deletions
|
@ -5,7 +5,6 @@ import 'package:rules_of_living/components/controls_component.dart';
|
||||||
import 'package:rules_of_living/components/header_component.dart';
|
import 'package:rules_of_living/components/header_component.dart';
|
||||||
import 'package:rules_of_living/components/simulation_component.dart';
|
import 'package:rules_of_living/components/simulation_component.dart';
|
||||||
import 'package:rules_of_living/service/configuration_service.dart';
|
import 'package:rules_of_living/service/configuration_service.dart';
|
||||||
import 'package:rules_of_living/service/control_service.dart';
|
|
||||||
import 'package:rules_of_living/service/engine_service.dart';
|
import 'package:rules_of_living/service/engine_service.dart';
|
||||||
|
|
||||||
@Component(
|
@Component(
|
||||||
|
@ -25,7 +24,6 @@ import 'package:rules_of_living/service/engine_service.dart';
|
||||||
materialProviders,
|
materialProviders,
|
||||||
ClassProvider(EngineService),
|
ClassProvider(EngineService),
|
||||||
ClassProvider(ConfigurationService),
|
ClassProvider(ConfigurationService),
|
||||||
ClassProvider(ControlService)
|
|
||||||
],
|
],
|
||||||
styleUrls: const [
|
styleUrls: const [
|
||||||
'package:angular_components/app_layout/layout.scss.css',
|
'package:angular_components/app_layout/layout.scss.css',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import 'package:angular/angular.dart';
|
import 'package:angular/angular.dart';
|
||||||
import 'package:angular_components/angular_components.dart';
|
import 'package:angular_components/angular_components.dart';
|
||||||
import 'package:rules_of_living/service/control_service.dart';
|
import 'package:rules_of_living/service/engine_service.dart';
|
||||||
|
|
||||||
@Component(
|
@Component(
|
||||||
selector: 'sim-controls',
|
selector: 'sim-controls',
|
||||||
|
@ -15,7 +15,7 @@ import 'package:rules_of_living/service/control_service.dart';
|
||||||
styleUrls: const ["controls_component.css"],
|
styleUrls: const ["controls_component.css"],
|
||||||
)
|
)
|
||||||
class ControlsComponent {
|
class ControlsComponent {
|
||||||
final ControlService ctrl;
|
final EngineService ctrl;
|
||||||
|
|
||||||
ControlsComponent(this.ctrl);
|
ControlsComponent(this.ctrl);
|
||||||
|
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
import 'package:rules_of_living/service/engine_service.dart';
|
|
||||||
|
|
||||||
class ControlService {
|
|
||||||
EngineService _es;
|
|
||||||
|
|
||||||
ControlService(this._es);
|
|
||||||
|
|
||||||
void run() {
|
|
||||||
_es.engine.running = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void stop() {
|
|
||||||
_es.engine.running = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void toggleRunning() {
|
|
||||||
_es.engine.running = !_es.engine.running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void step() {
|
|
||||||
_es.engine.step();
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset() {
|
|
||||||
_es.engine.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void addRandomPattern() {
|
|
||||||
_es.engine.running = false;
|
|
||||||
_es.engine.addPattern();
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear() {
|
|
||||||
_es.engine.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get isRunning => _es.engine.running;
|
|
||||||
}
|
|
|
@ -12,4 +12,35 @@ class EngineService {
|
||||||
engine = newEngine;
|
engine = newEngine;
|
||||||
return 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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue