From c1ed3799bd1326354cfacc0c2ee9d745ca76a9d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Thu, 11 Apr 2024 09:52:31 +0200 Subject: [PATCH] Update States of template when reference gets new state --- .../project/game-model/gamesystems/SimpleGamesystem.ts | 8 +++++++- .../game-model/gamesystems/SimpleTemplateGamesystem.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/project/game-model/gamesystems/SimpleGamesystem.ts b/src/app/project/game-model/gamesystems/SimpleGamesystem.ts index c602bfc..c28e78e 100644 --- a/src/app/project/game-model/gamesystems/SimpleGamesystem.ts +++ b/src/app/project/game-model/gamesystems/SimpleGamesystem.ts @@ -4,7 +4,7 @@ import {SimpleState} from "./states/SimpleState"; import {SimpleTransition} from "./transitions/SimpleTransition"; export class SimpleGamesystem extends Gamesystem { - + templateSystems: SimpleTemplateGamesystem[] = [] createState(label: string, description: string): SimpleState | undefined { if(label == null) { @@ -18,6 +18,8 @@ export class SimpleGamesystem extends Gamesystem const state = new SimpleState(label, description); if(this.states.find(s => s.stateLabel == label) == undefined) { this.states.push(state); + + this.templateSystems.forEach(templatesystem => templatesystem.createState(label, description)) return state; } else { return undefined @@ -55,4 +57,8 @@ export class SimpleGamesystem extends Gamesystem protected findStateByStateLabel(stateLabel: string) { return this.states.find(state => stateLabel === stateLabel); } + + addTemplateSystem(templateSystem: SimpleTemplateGamesystem) { + this.templateSystems.push(templateSystem) + } } diff --git a/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts b/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts index 4e08528..61184e4 100644 --- a/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts +++ b/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts @@ -35,7 +35,7 @@ export class SimpleTemplateGamesystem extends SimpleGamesystem { this.transitions.push(templateTransition); }) - + this.referenceSystem.addTemplateSystem(this) }