issue-12 #14
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user