Update States of template when reference gets new state
All checks were successful
E2E Testing / test (push) Successful in 1m37s

This commit is contained in:
Sebastian Böckelmann 2024-04-11 09:52:31 +02:00
parent d643f6bb1c
commit c1ed3799bd
2 changed files with 8 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import {SimpleState} from "./states/SimpleState";
import {SimpleTransition} from "./transitions/SimpleTransition"; import {SimpleTransition} from "./transitions/SimpleTransition";
export class SimpleGamesystem extends Gamesystem<SimpleState, SimpleTransition> { export class SimpleGamesystem extends Gamesystem<SimpleState, SimpleTransition> {
templateSystems: SimpleTemplateGamesystem[] = []
createState(label: string, description: string): SimpleState | undefined { createState(label: string, description: string): SimpleState | undefined {
if(label == null) { if(label == null) {
@ -18,6 +18,8 @@ export class SimpleGamesystem extends Gamesystem<SimpleState, SimpleTransition>
const state = new SimpleState(label, description); const state = new SimpleState(label, description);
if(this.states.find(s => s.stateLabel == label) == undefined) { if(this.states.find(s => s.stateLabel == label) == undefined) {
this.states.push(state); this.states.push(state);
this.templateSystems.forEach(templatesystem => templatesystem.createState(label, description))
return state; return state;
} else { } else {
return undefined return undefined
@ -55,4 +57,8 @@ export class SimpleGamesystem extends Gamesystem<SimpleState, SimpleTransition>
protected findStateByStateLabel(stateLabel: string) { protected findStateByStateLabel(stateLabel: string) {
return this.states.find(state => stateLabel === stateLabel); return this.states.find(state => stateLabel === stateLabel);
} }
addTemplateSystem(templateSystem: SimpleTemplateGamesystem) {
this.templateSystems.push(templateSystem)
}
} }

View File

@ -35,7 +35,7 @@ export class SimpleTemplateGamesystem extends SimpleGamesystem {
this.transitions.push(templateTransition); this.transitions.push(templateTransition);
}) })
this.referenceSystem.addTemplateSystem(this)
} }