main #48
@ -34,6 +34,7 @@ import {ItemOverviewComponent} from "./side-overviews/item-overview/item-overvie
|
|||||||
import {Overview} from "./side-overviews/Overview";
|
import {Overview} from "./side-overviews/Overview";
|
||||||
import {ItemCreator} from "./project/game-model/utils/creator/ItemCreator";
|
import {ItemCreator} from "./project/game-model/utils/creator/ItemCreator";
|
||||||
import {ScriptAccountCreator} from "./project/game-model/utils/creator/ScriptAccountCreator";
|
import {ScriptAccountCreator} from "./project/game-model/utils/creator/ScriptAccountCreator";
|
||||||
|
import {CharacterCreator} from "./project/game-model/utils/creator/CharacterCreator";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@ -104,6 +105,9 @@ export class AppComponent implements OnInit{
|
|||||||
case ModelComponentType.SCRIPTACCOUNT: {
|
case ModelComponentType.SCRIPTACCOUNT: {
|
||||||
componentCreator = new ScriptAccountCreator(creationContext, this.gameModel!, this.selectedModelComponent);
|
componentCreator = new ScriptAccountCreator(creationContext, this.gameModel!, this.selectedModelComponent);
|
||||||
} break
|
} break
|
||||||
|
case ModelComponentType.CHARACTER: {
|
||||||
|
componentCreator = new CharacterCreator(creationContext, this.gameModel!, this.selectedModelComponent);
|
||||||
|
} break
|
||||||
}
|
}
|
||||||
|
|
||||||
if(componentCreator) {
|
if(componentCreator) {
|
||||||
@ -188,15 +192,6 @@ export class AppComponent implements OnInit{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private onCreateNewCharacter() {
|
|
||||||
const createdCharacter = this.gameModel!.createCharacter("New Character")
|
|
||||||
if(createdCharacter != undefined) {
|
|
||||||
this.editor?.openGameModelComponent(createdCharacter);
|
|
||||||
} else {
|
|
||||||
console.log("[DEBUG] [App-Component] ScriptAccount could not be created (Name not unique)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private getSelectedModelComponent(): ModelComponent | undefined {
|
private getSelectedModelComponent(): ModelComponent | undefined {
|
||||||
if(this.openContent == ModelComponentType.SCRIPTACCOUNT) {
|
if(this.openContent == ModelComponentType.SCRIPTACCOUNT) {
|
||||||
if(this.scriptAccountOverview != undefined) {
|
if(this.scriptAccountOverview != undefined) {
|
||||||
|
@ -232,4 +232,12 @@ export class GameModel {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addCharacter(character: Character) {
|
||||||
|
if(this.characters.find(c => c.componentName === character.componentName) === undefined) {
|
||||||
|
this.characters.push(character)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
22
src/app/project/game-model/utils/creator/CharacterCreator.ts
Normal file
22
src/app/project/game-model/utils/creator/CharacterCreator.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import {ModelComponentCreator} from "./ModelComponentCreator";
|
||||||
|
import {GameModel} from "../../GameModel";
|
||||||
|
import {ModelComponent} from "../../ModelComponent";
|
||||||
|
import {Character} from "../../characters/Character";
|
||||||
|
|
||||||
|
export class CharacterCreator extends ModelComponentCreator{
|
||||||
|
|
||||||
|
|
||||||
|
constructor(context: string, gameModel: GameModel, selectedComponent: ModelComponent | undefined) {
|
||||||
|
super(context, gameModel, selectedComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
createModelComponent(): ModelComponent | undefined {
|
||||||
|
const character = new Character("New Character", "");
|
||||||
|
if(this.gameModel.addCharacter(character)) {
|
||||||
|
return character;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user