issue-12 #14

Merged
sebastian merged 6 commits from issue-12 into main 2024-02-17 15:14:34 +01:00
2 changed files with 26 additions and 0 deletions
Showing only changes of commit a93a7411a3 - Show all commits

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);
}