DatingEventSceneModel.ts
1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { ConfigManager } from "../../common/gameplay/managers/ConfigManager";
import { dateSceneConfig } from "../../config/DateSceneConfig";
import { GameRecord } from "../../avg/game-data/GameRecord";
import { ReadonlyPlot } from "../../avg/model/PlotModel";
import { getPlot } from "../../avg/game-data/PlotsData";
import { DateType } from "../../avg/EditorEnums";
export enum DatingEventStatus {
Locked = 1,
New,
InProgress,
Completed
}
export class DatingEventSceneModel {
private _id: number;
get id() { return this._id }
get config() { return ConfigManager.getConfig(dateSceneConfig, this._id); }
private _status: DatingEventStatus;
get status() { return this._status; }
set status(v: DatingEventStatus) {
if (this._status !== v) {
this._status = v;
GameRecord.recordVariables[this._recordKey + ".s"] = v;
}
}
private _firstPlot: ReadonlyPlot;
get firstPlot() { return this._firstPlot; }
set firstPlot(plot: ReadonlyPlot) {
this._firstPlot = plot;
GameRecord.recordVariables[this._recordKey + ".f"] = plot.id;
}
private _bg: string;
get background() { return this._bg; }
set background(bg: string) {
this._bg = bg;
GameRecord.recordVariables[this._recordKey + ".bg"] = bg;
}
private _recordKey: string;
constructor(id: number) {
this._id = id;
this._recordKey = "de" + this._id;
this._bg = "";
}
async initFromRecords() {
this._status = GameRecord.recordVariables[this._recordKey + ".s"] as number || DatingEventStatus.Locked;
let firstPlotId = this.config.DateType === DateType.Date_Normal ? GameRecord.recordVariables[this._recordKey + ".f"] as number : this.config.start_plot_id;
this._firstPlot = (await getPlot(firstPlotId))!;
this._bg = GameRecord.recordVariables[this._recordKey + ".bg"] as string || "";
}
}