phantasmal-world/src/quest_editor/actions/CreateEventAction.ts
Daan Vanden Bosch d824984889 - Events are now serialized in the order that they were deserialized
- When adding a new event while an existing event is selected, the new event will now have the selected event as parent
- Generated event IDs now follow the SEGA convention more closely
2019-12-31 20:00:43 +01:00

26 lines
808 B
TypeScript

import { Action } from "../../core/undo/Action";
import { QuestModel } from "../model/QuestModel";
import { QuestEventDagModel } from "../model/QuestEventDagModel";
import { QuestEventModel } from "../model/QuestEventModel";
export class CreateEventAction implements Action {
readonly description: string;
constructor(
private readonly quest: QuestModel,
private readonly event_dag: QuestEventDagModel,
private readonly event: QuestEventModel,
private readonly parent_event?: QuestEventModel,
) {
this.description = `Add event ${event.id}`;
}
undo(): void {
this.quest.remove_event(this.event_dag, this.event);
}
redo(): void {
this.quest.add_event(this.event, this.parent_event ? [this.parent_event] : [], []);
}
}