[update] Allowed ElementScheduledController not to require Initialize() method.

This commit is contained in:
falsycat 2019-10-08 00:00:00 +00:00
parent 32a80bf865
commit 0a864950cd
3 changed files with 8 additions and 4 deletions

View File

@ -9,13 +9,11 @@ class Background {
///
this(BackgroundProgram program) {
program_ = program;
}
///
void Initialize() {
inner_color = vec4(0, 0, 0, 0);
outer_color = vec4(0, 0, 0, 0);
}
///
void Draw() {
program_.Draw(inner_color, outer_color);

View File

@ -22,6 +22,7 @@ alias CircleElementScheduledController = ElementScheduledController!(
);
static assert(CircleElementScheduledController.AliveManagementAvailable);
static assert(CircleElementScheduledController.MatrixModificationAvailable);
static assert(CircleElementScheduledController.AutoInitializationAvailable);
///
alias CircleElementScheduledControllerFactory =

View File

@ -35,6 +35,9 @@ class ElementScheduledController(
enum MatrixModificationAvailable =
is(typeof((Element e) => e.matrix)) &&
is(ReturnType!((Element e) => e.matrix) == mat3);
///
enum AutoInitializationAvailable =
is(typeof((Element e) => e.Initialize()));
///
this(
@ -47,7 +50,9 @@ class ElementScheduledController(
protected:
override void PrepareOperation(ref in ParametersBlock params) {
element_.Initialize();
static if (AutoInitializationAvailable) {
element_.Initialize();
}
static if (AliveManagementAvailable) {
element_.alive = true;
}