GameSceneObjTableMgr.ts
1.42 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
import { tMgr } from "../../Global";
import { GameSceneObjTable, TableName } from "./TableDefine";
export class GameSceneObjTableMgr {
private _map: Map<number, GameSceneObjTable[]> = new Map<number, GameSceneObjTable[]>();
private static _ins: GameSceneObjTableMgr = null;
static get ins(): GameSceneObjTableMgr {
if (this._ins == null) {
this._ins = new GameSceneObjTableMgr();
let all = tMgr.map[TableName.GAME_SCENE_OBJ];
for (let i = 0; i < 3; ++i) {
this._ins._map.set(i + 1, []);
}
for (const key in all) {
if (Object.prototype.hasOwnProperty.call(all, key)) {
if (!Number(key)) {
continue;
}
const element = all[key] as GameSceneObjTable;
this._ins._map.get(element.SceneId).push(element);
}
}
}
return this._ins;
}
// getBy
getByScene(scendId: number): GameSceneObjTable[] {
return this._map.get(scendId);
}
getParentObj(obj: GameSceneObjTable): GameSceneObjTable {
let sceneObj = this.getByScene(obj.SceneId);
for (let i = 0; i < sceneObj.length; i++) {
const element = sceneObj[i];
if (element.Unlock.includes(obj.ID)) {
return element;
}
}
return null;
}
}