Generate Productgamesystem States + Transition after loading them
All checks were successful
E2E Testing / test (push) Successful in 1m28s

This commit is contained in:
Sebastian Böckelmann 2024-02-17 14:40:07 +01:00
parent 3b0d4e0194
commit a93a7411a3
2 changed files with 26 additions and 0 deletions

View File

@ -8,15 +8,26 @@ import {SimpleGamesystemParser} from "./parser/SimpleGamesystemParser";
import {SimpleGamesystem} from "../gamesystems/SimpleGamesystem";
import {ProductGamesystem} from "../gamesystems/ProductGamesystem";
import {ProductGamesystemParser} from "./parser/ProductGamesystemParser";
import {Gamesystem} from "../gamesystems/Gamesystem";
export class ProcessLoadedProject {
static processLoadedProject(loadedProject: LoadedProject): GameModel {
const gameModel = new GameModel(loadedProject.projectName);
loadedProject.loadedModels.forEach(loadedModel => this.processLoadedModel(gameModel, loadedModel))
//Generate product Gamesystems
this.generateProductGamesystems(gameModel.gamesystems)
return gameModel;
}
static generateProductGamesystems(gamesystems: Gamesystem<any, any>[]) {
gamesystems.forEach(gamesystem => {
if(gamesystem instanceof ProductGamesystem) {
gamesystem.generateFromChildsystems();
}
})
}
static processLoadedModel(gameModel: GameModel, loadedModel: LoadModel) {
switch (loadedModel.modelType) {
case ModelComponentType.SCRIPTACCOUNT: this.processLoadedScriptAccount(gameModel, loadedModel); break;

View File

@ -65,10 +65,25 @@ export class ProductGamesystem extends Gamesystem<ProductState, ProductTransitio
generateFromChildsystems() {
//Assume that childsystems that are productsystems are already generated
if(this.innerGamesystems.length < 2) {
//currently only safe-guard
return;
}
const integratedSystems: Gamesystem<any, any>[] = [this.innerGamesystems[0], this.innerGamesystems[1]];
if(this.innerGamesystems[0] instanceof ProductGamesystem) {
this.innerGamesystems[0].generateFromChildsystems();
}
if(this.innerGamesystems[1] instanceof ProductGamesystem) {
this.innerGamesystems[1].generateFromChildsystems();
}
let gamesystem: ProductGamesystem = ProductGamesystem.generateFromChildsystems(this.innerGamesystems[0], this.innerGamesystems[1], false, integratedSystems);
for(let i=2; i<this.innerGamesystems.length; i++) {
if(this.innerGamesystems[i] instanceof ProductGamesystem) {
(this.innerGamesystems[i] as ProductGamesystem).generateFromChildsystems();
}
integratedSystems.push(this.innerGamesystems[i]);
gamesystem = ProductGamesystem.generateFromChildsystems(gamesystem, this.innerGamesystems[i], true, integratedSystems);
}