@drincs/nqtr 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/Activity.d.mts +199 -0
- package/dist/classes/Activity.d.ts +199 -0
- package/dist/classes/Activity.js +508 -0
- package/dist/classes/Activity.js.map +1 -0
- package/dist/classes/Activity.mjs +503 -0
- package/dist/classes/Activity.mjs.map +1 -0
- package/dist/classes/Commitment.d.mts +6 -0
- package/dist/classes/Commitment.d.ts +6 -0
- package/dist/classes/Commitment.js +402 -0
- package/dist/classes/Commitment.js.map +1 -0
- package/dist/classes/Commitment.mjs +400 -0
- package/dist/classes/Commitment.mjs.map +1 -0
- package/dist/classes/index.d.mts +6 -0
- package/dist/classes/index.d.ts +6 -0
- package/dist/classes/index.js +520 -0
- package/dist/classes/index.js.map +1 -0
- package/dist/classes/index.mjs +517 -0
- package/dist/classes/index.mjs.map +1 -0
- package/dist/classes/navigation/ActivityRoom.d.mts +6 -0
- package/dist/classes/navigation/ActivityRoom.d.ts +6 -0
- package/dist/classes/navigation/ActivityRoom.js +435 -0
- package/dist/classes/navigation/ActivityRoom.js.map +1 -0
- package/dist/classes/navigation/ActivityRoom.mjs +433 -0
- package/dist/classes/navigation/ActivityRoom.mjs.map +1 -0
- package/dist/classes/navigation/Location.d.mts +6 -0
- package/dist/classes/navigation/Location.d.ts +6 -0
- package/dist/classes/navigation/Location.js +110 -0
- package/dist/classes/navigation/Location.js.map +1 -0
- package/dist/classes/navigation/Location.mjs +108 -0
- package/dist/classes/navigation/Location.mjs.map +1 -0
- package/dist/classes/navigation/Map.d.mts +6 -0
- package/dist/classes/navigation/Map.d.ts +6 -0
- package/dist/classes/navigation/Map.js +109 -0
- package/dist/classes/navigation/Map.js.map +1 -0
- package/dist/classes/navigation/Map.mjs +107 -0
- package/dist/classes/navigation/Map.mjs.map +1 -0
- package/dist/classes/navigation/Room.d.mts +6 -0
- package/dist/classes/navigation/Room.d.ts +6 -0
- package/dist/classes/navigation/Room.js +750 -0
- package/dist/classes/navigation/Room.js.map +1 -0
- package/dist/classes/navigation/Room.mjs +745 -0
- package/dist/classes/navigation/Room.mjs.map +1 -0
- package/dist/classes/navigation/index.d.mts +6 -0
- package/dist/classes/navigation/index.d.ts +6 -0
- package/dist/classes/navigation/index.js +945 -0
- package/dist/classes/navigation/index.js.map +1 -0
- package/dist/classes/navigation/index.mjs +941 -0
- package/dist/classes/navigation/index.mjs.map +1 -0
- package/dist/classes/quest/Goal.d.mts +23 -0
- package/dist/classes/quest/Goal.d.ts +23 -0
- package/dist/classes/quest/Goal.js +33 -0
- package/dist/classes/quest/Goal.js.map +1 -0
- package/dist/classes/quest/Goal.mjs +31 -0
- package/dist/classes/quest/Goal.mjs.map +1 -0
- package/dist/classes/quest/Quest.d.mts +3 -0
- package/dist/classes/quest/Quest.d.ts +3 -0
- package/dist/classes/quest/Quest.js +39 -0
- package/dist/classes/quest/Quest.js.map +1 -0
- package/dist/classes/quest/Quest.mjs +37 -0
- package/dist/classes/quest/Quest.mjs.map +1 -0
- package/dist/classes/quest/Stage.d.mts +3 -0
- package/dist/classes/quest/Stage.d.ts +3 -0
- package/dist/classes/quest/Stage.js +105 -0
- package/dist/classes/quest/Stage.js.map +1 -0
- package/dist/classes/quest/Stage.mjs +103 -0
- package/dist/classes/quest/Stage.mjs.map +1 -0
- package/dist/classes/quest/index.d.mts +3 -0
- package/dist/classes/quest/index.d.ts +3 -0
- package/dist/classes/quest/index.js +133 -0
- package/dist/classes/quest/index.js.map +1 -0
- package/dist/classes/quest/index.mjs +129 -0
- package/dist/classes/quest/index.mjs.map +1 -0
- package/dist/decorators/ActivityDecorator.d.mts +12 -0
- package/dist/decorators/ActivityDecorator.d.ts +12 -0
- package/dist/decorators/ActivityDecorator.js +33 -0
- package/dist/decorators/ActivityDecorator.js.map +1 -0
- package/dist/decorators/ActivityDecorator.mjs +29 -0
- package/dist/decorators/ActivityDecorator.mjs.map +1 -0
- package/dist/decorators/CommitmentDecorator.d.mts +21 -0
- package/dist/decorators/CommitmentDecorator.d.ts +21 -0
- package/dist/decorators/CommitmentDecorator.js +77 -0
- package/dist/decorators/CommitmentDecorator.js.map +1 -0
- package/dist/decorators/CommitmentDecorator.mjs +68 -0
- package/dist/decorators/CommitmentDecorator.mjs.map +1 -0
- package/dist/decorators/RoomDecorator.d.mts +46 -0
- package/dist/decorators/RoomDecorator.d.ts +46 -0
- package/dist/decorators/RoomDecorator.js +57 -0
- package/dist/decorators/RoomDecorator.js.map +1 -0
- package/dist/decorators/RoomDecorator.mjs +49 -0
- package/dist/decorators/RoomDecorator.mjs.map +1 -0
- package/dist/decorators/index.d.mts +9 -0
- package/dist/decorators/index.d.ts +9 -0
- package/dist/decorators/index.js +145 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/index.mjs +132 -0
- package/dist/decorators/index.mjs.map +1 -0
- package/dist/enums/ExecutionTypeEnum.d.mts +6 -0
- package/dist/enums/ExecutionTypeEnum.d.ts +6 -0
- package/dist/enums/ExecutionTypeEnum.js +12 -0
- package/dist/enums/ExecutionTypeEnum.js.map +1 -0
- package/dist/enums/ExecutionTypeEnum.mjs +10 -0
- package/dist/enums/ExecutionTypeEnum.mjs.map +1 -0
- package/dist/enums/index.d.mts +1 -0
- package/dist/enums/index.d.ts +1 -0
- package/dist/enums/index.js +12 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/enums/index.mjs +10 -0
- package/dist/enums/index.mjs.map +1 -0
- package/dist/functions/ActivityFunctions.d.mts +11 -0
- package/dist/functions/ActivityFunctions.d.ts +11 -0
- package/dist/functions/ActivityFunctions.js +54 -0
- package/dist/functions/ActivityFunctions.js.map +1 -0
- package/dist/functions/ActivityFunctions.mjs +51 -0
- package/dist/functions/ActivityFunctions.mjs.map +1 -0
- package/dist/functions/NavigationFunctions.d.mts +13 -0
- package/dist/functions/NavigationFunctions.d.ts +13 -0
- package/dist/functions/NavigationFunctions.js +173 -0
- package/dist/functions/NavigationFunctions.js.map +1 -0
- package/dist/functions/NavigationFunctions.mjs +168 -0
- package/dist/functions/NavigationFunctions.mjs.map +1 -0
- package/dist/functions/RoutineFunctions.d.mts +12 -0
- package/dist/functions/RoutineFunctions.d.ts +12 -0
- package/dist/functions/RoutineFunctions.js +87 -0
- package/dist/functions/RoutineFunctions.js.map +1 -0
- package/dist/functions/RoutineFunctions.mjs +83 -0
- package/dist/functions/RoutineFunctions.mjs.map +1 -0
- package/dist/functions/index.d.mts +9 -0
- package/dist/functions/index.d.ts +9 -0
- package/dist/functions/index.js +264 -0
- package/dist/functions/index.js.map +1 -0
- package/dist/functions/index.mjs +254 -0
- package/dist/functions/index.mjs.map +1 -0
- package/dist/index-BjOzVDyw.d.ts +76 -0
- package/dist/index-BvCfRbJB.d.mts +564 -0
- package/dist/index-Ci6Aw7YE.d.ts +564 -0
- package/dist/index-gJ26gdgL.d.mts +76 -0
- package/dist/index.d.mts +16 -1031
- package/dist/index.d.ts +16 -1031
- package/dist/index.js +83 -154
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -80
- package/dist/index.mjs.map +1 -1
- package/dist/managers/TimeManager.d.mts +84 -0
- package/dist/managers/TimeManager.d.ts +84 -0
- package/dist/managers/TimeManager.js +251 -0
- package/dist/managers/TimeManager.js.map +1 -0
- package/dist/managers/TimeManager.mjs +249 -0
- package/dist/managers/TimeManager.mjs.map +1 -0
- package/dist/managers/index.d.mts +2 -0
- package/dist/managers/index.d.ts +2 -0
- package/dist/managers/index.js +251 -0
- package/dist/managers/index.js.map +1 -0
- package/dist/managers/index.mjs +249 -0
- package/dist/managers/index.mjs.map +1 -0
- package/dist/override/OnRunActivityProps.d.mts +19 -0
- package/dist/override/OnRunActivityProps.d.ts +19 -0
- package/dist/override/OnRunActivityProps.js +4 -0
- package/dist/override/OnRunActivityProps.js.map +1 -0
- package/dist/override/OnRunActivityProps.mjs +3 -0
- package/dist/override/OnRunActivityProps.mjs.map +1 -0
- package/dist/override/index.d.mts +1 -0
- package/dist/override/index.d.ts +1 -0
- package/dist/override/index.js +4 -0
- package/dist/override/index.js.map +1 -0
- package/dist/override/index.mjs +3 -0
- package/dist/override/index.mjs.map +1 -0
- package/dist/types/GraphicItem.d.mts +5 -0
- package/dist/types/GraphicItem.d.ts +5 -0
- package/dist/types/GraphicItem.js +4 -0
- package/dist/types/GraphicItem.js.map +1 -0
- package/dist/types/GraphicItem.mjs +3 -0
- package/dist/types/GraphicItem.mjs.map +1 -0
- package/dist/types/QuestsRequired.d.mts +3 -0
- package/dist/types/QuestsRequired.d.ts +3 -0
- package/dist/types/QuestsRequired.js +4 -0
- package/dist/types/QuestsRequired.js.map +1 -0
- package/dist/types/QuestsRequired.mjs +3 -0
- package/dist/types/QuestsRequired.mjs.map +1 -0
- package/dist/types/TimeSettings.d.mts +58 -0
- package/dist/types/TimeSettings.d.ts +58 -0
- package/dist/types/TimeSettings.js +4 -0
- package/dist/types/TimeSettings.js.map +1 -0
- package/dist/types/TimeSettings.mjs +3 -0
- package/dist/types/TimeSettings.mjs.map +1 -0
- package/dist/types/index.d.mts +4 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +3 -0
- package/dist/types/index.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { StoredClassModel, getFlag } from '@drincs/pixi-vn';
|
|
2
|
+
|
|
3
|
+
// src/classes/navigation/Location.ts
|
|
4
|
+
|
|
5
|
+
// src/decorators/RoomDecorator.ts
|
|
6
|
+
var registeredRooms = {};
|
|
7
|
+
function getRoomsByLocation(location) {
|
|
8
|
+
return Object.values(registeredRooms).filter((room) => room.location.id === location.id);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/classes/navigation/Location.ts
|
|
12
|
+
var LOCATION_CATEGORY = "__nqtr-location__";
|
|
13
|
+
var LocationBaseModel = class extends StoredClassModel {
|
|
14
|
+
/**
|
|
15
|
+
* @param id The id of the location, it must be unique.
|
|
16
|
+
* @param map The map where the location is.
|
|
17
|
+
* @param props The properties of the location.
|
|
18
|
+
*/
|
|
19
|
+
constructor(id, map, props = {}) {
|
|
20
|
+
super(LOCATION_CATEGORY, id);
|
|
21
|
+
this.defaultName = props.name || "";
|
|
22
|
+
this.defaultDisabled = props.disabled || false;
|
|
23
|
+
this.defaultHidden = props.hidden || false;
|
|
24
|
+
this._icon = props.icon;
|
|
25
|
+
this._map = map;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The name of the location.
|
|
29
|
+
* If you set undefined, it will return the initial value of name.
|
|
30
|
+
*/
|
|
31
|
+
get name() {
|
|
32
|
+
return this.getStorageProperty("name") || this.defaultName;
|
|
33
|
+
}
|
|
34
|
+
set name(value) {
|
|
35
|
+
this.setStorageProperty("name", value);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
39
|
+
*/
|
|
40
|
+
get disabled() {
|
|
41
|
+
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
42
|
+
if (typeof value === "string") {
|
|
43
|
+
return getFlag(value);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
set disabled(value) {
|
|
48
|
+
this.setStorageProperty("disabled", value);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
52
|
+
*/
|
|
53
|
+
get hidden() {
|
|
54
|
+
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
55
|
+
if (typeof value === "string") {
|
|
56
|
+
return getFlag(value);
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
set hidden(value) {
|
|
61
|
+
this.setStorageProperty("hidden", value);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The icon element. Can be a string or an Element or a Pixi'VN CanvasItem
|
|
65
|
+
*/
|
|
66
|
+
get icon() {
|
|
67
|
+
return this._icon;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The map where the location is.
|
|
71
|
+
*/
|
|
72
|
+
get map() {
|
|
73
|
+
return this._map;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get the entrance room of the location.
|
|
77
|
+
* You can cast the room to a specific type that extends RoomBaseModel.
|
|
78
|
+
* @returns The entrance room or the first room if there is no entrance.
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const entranceHome = new RoomBaseModel("entrance-home", home, { isEntrance: true })
|
|
82
|
+
* saveRoom(entranceHome)
|
|
83
|
+
* const home = new LocationBaseModel("home", map, { name: "Home" })
|
|
84
|
+
*
|
|
85
|
+
* const entrance = home.getEntrance() // entrance === entranceHome
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
getEntrance() {
|
|
89
|
+
let rooms = this.getRooms();
|
|
90
|
+
if (rooms.length === 0) {
|
|
91
|
+
console.error(`[NQTR] The location ${this.id} has no rooms`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
return rooms.find((room) => room.isEntrance) || rooms[0];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get all rooms in the location.
|
|
98
|
+
* You can cast the rooms to a specific type that extends RoomBaseModel.
|
|
99
|
+
* @returns The rooms in the location.
|
|
100
|
+
*/
|
|
101
|
+
getRooms() {
|
|
102
|
+
return getRoomsByLocation(this);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export { LocationBaseModel as default };
|
|
107
|
+
//# sourceMappingURL=out.js.map
|
|
108
|
+
//# sourceMappingURL=Location.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/classes/navigation/Location.ts","../../../src/decorators/RoomDecorator.ts"],"names":[],"mappings":";AAAA,SAAS,SAAS,wBAAwB;;;ACEnC,IAAM,kBAAmD,CA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AAAA;AAAA,EAMA,IAAI,MAAY;AACZ,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,cAA8E;AAC1E,QAAI,QAAQ,KAAK,SAAgB;AACjC,QAAI,MAAM,WAAW,GAAG;AACpB,cAAQ,MAAM,uBAAuB,KAAK,EAAE,eAAe;AAC3D;AAAA,IACJ;AACA,WAAO,MAAM,KAAK,UAAQ,KAAK,UAAU,KAAK,MAAM,CAAC;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAiE;AAC7D,WAAO,mBAA0B,IAAI;AAAA,EACzC;AACJ","sourcesContent":["import { getFlag, StoredClassModel } from \"@drincs/pixi-vn\";\nimport { getRoomsByLocation } from \"../../decorators/RoomDecorator\";\nimport { GraphicItemType } from \"../../types/GraphicItem\";\nimport MapBaseModel from \"./Map\";\nimport RoomBaseModel from \"./Room\";\n\nconst LOCATION_CATEGORY = \"__nqtr-location__\"\n\nexport interface LocationBaseModelProps {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * Whether is disabled. You can also pass a Pixi'VN flag name.\n * @default false\n */\n disabled?: boolean | string\n /**\n * Whether is hidden. You can also pass a Pixi'VN flag name.\n * @default false\n */\n hidden?: boolean | string\n /**\n * The icon element. Can be a string or an Element or a Pixi'VN CanvasItem\n * @default undefined\n */\n icon?: GraphicItemType\n}\n\n/**\n * The base model of a location. I suggest you extend this class to create your own location model.\n * @example\n * ```typescript\n * export const mcHome = new LocationBaseModel('mc_home', mainMap, {\n * name: 'MC Home',\n * icon: \"https://icon.jpg\",\n * });\n * ```\n */\nexport default class LocationBaseModel<TMap extends MapBaseModel = MapBaseModel> extends StoredClassModel {\n /**\n * @param id The id of the location, it must be unique.\n * @param map The map where the location is.\n * @param props The properties of the location.\n */\n constructor(id: string, map: TMap, props: LocationBaseModelProps = {}) {\n super(LOCATION_CATEGORY, id)\n this.defaultName = props.name || \"\"\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._icon = props.icon\n this._map = map\n }\n\n private defaultName: string\n /**\n * The name of the location.\n * If you set undefined, it will return the initial value of name.\n */\n get name(): string {\n return this.getStorageProperty<string>(\"name\") || this.defaultName\n }\n set name(value: string | undefined) {\n this.setStorageProperty(\"name\", value)\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled. If it is a string, it is a Pixi'VN flag name.\n */\n get disabled(): boolean {\n let value = this.getStorageProperty<boolean>(\"disabled\") || this.defaultDisabled\n if (typeof value === \"string\") {\n return getFlag(value)\n }\n return value\n }\n set disabled(value: boolean | string) {\n this.setStorageProperty(\"disabled\", value)\n }\n\n private defaultHidden: boolean | string\n /**\n * Whether is hidden. If it is a string, it is a Pixi'VN flag name.\n */\n get hidden(): boolean {\n let value = this.getStorageProperty<boolean>(\"hidden\") || this.defaultHidden\n if (typeof value === \"string\") {\n return getFlag(value)\n }\n return value\n }\n set hidden(value: boolean | string) {\n this.setStorageProperty(\"hidden\", value)\n }\n\n private _icon?: GraphicItemType\n /**\n * The icon element. Can be a string or an Element or a Pixi'VN CanvasItem\n */\n get icon(): GraphicItemType | undefined {\n return this._icon\n }\n\n private _map: TMap\n /**\n * The map where the location is.\n */\n get map(): TMap {\n return this._map\n }\n\n /**\n * Get the entrance room of the location.\n * You can cast the room to a specific type that extends RoomBaseModel.\n * @returns The entrance room or the first room if there is no entrance.\n * @example\n * ```typescript\n * const entranceHome = new RoomBaseModel(\"entrance-home\", home, { isEntrance: true })\n * saveRoom(entranceHome)\n * const home = new LocationBaseModel(\"home\", map, { name: \"Home\" })\n * \n * const entrance = home.getEntrance() // entrance === entranceHome\n * ```\n */\n getEntrance<TRoom extends RoomBaseModel = RoomBaseModel>(): TRoom | undefined {\n let rooms = this.getRooms<TRoom>()\n if (rooms.length === 0) {\n console.error(`[NQTR] The location ${this.id} has no rooms`)\n return\n }\n return rooms.find(room => room.isEntrance) || rooms[0]\n }\n\n /**\n * Get all rooms in the location.\n * You can cast the rooms to a specific type that extends RoomBaseModel.\n * @returns The rooms in the location.\n */\n getRooms<TRoom extends RoomBaseModel = RoomBaseModel>(): TRoom[] {\n return getRoomsByLocation<TRoom>(this)\n }\n}\n","import { LocationBaseModel, MapBaseModel, RoomBaseModel } from \"../classes/navigation\"\n\nexport const registeredRooms: { [id: string]: RoomBaseModel } = {}\n\n/**\n * Save a room in the registered rooms.\n * @param room The room to save.\n * @returns \n */\nexport function saveRoom<TRoom extends RoomBaseModel = RoomBaseModel>(room: TRoom | TRoom[]) {\n if (Array.isArray(room)) {\n room.forEach(c => saveRoom(c))\n return\n }\n if (registeredRooms[room.id]) {\n console.warn(`[NQTR] Room id ${room.id} already exists, it will be overwritten`)\n }\n registeredRooms[room.id] = room\n}\n\n/**\n * Get a room by its id.\n * @param id The id of the room.\n * @returns The room or undefined if not found.\n */\nexport function getRoomById<TRoom extends RoomBaseModel = RoomBaseModel>(id: string): TRoom | undefined {\n try {\n let room = registeredRooms[id]\n if (!room) {\n console.error(`[NQTR] Room ${id} not found`)\n return\n }\n return room as TRoom\n }\n catch (e) {\n console.error(`[NQTR] Error while getting Room ${id}`, e)\n return\n }\n}\n\n/**\n * Get all rooms in a location.\n * @param location The location where the rooms are.\n * @returns The rooms in the location.\n */\nexport function getRoomsByLocation<TRoom extends RoomBaseModel = RoomBaseModel>(location: LocationBaseModel): TRoom[] {\n return Object.values(registeredRooms).filter(room => room.location.id === location.id) as TRoom[]\n}\n\n/**\n * Get all locations in the registered rooms.\n * @returns All locations in the registered rooms.\n */\nexport function getAllLocations<TLocation extends LocationBaseModel = LocationBaseModel>(): TLocation[] {\n let result: { [id: string]: TLocation } = {}\n Object.values(registeredRooms).forEach(room => {\n result[room.location.id] = room.location as TLocation\n })\n return Object.values(result)\n}\n\n/**\n * Get all locations in a map.\n * @param map The map where the locations are.\n * @returns The locations in the map.\n */\nexport function getLocationsByMap<TLocation extends LocationBaseModel = LocationBaseModel>(map: MapBaseModel): TLocation[] {\n return getAllLocations<TLocation>().filter(location => location.map.id === map.id) as TLocation[]\n}\n\n/**\n * Get all maps in the registered rooms.\n * @returns All maps in the registered rooms.\n */\nexport function getAllMaps<TMap extends MapBaseModel = MapBaseModel>(): TMap[] {\n let result: { [id: string]: TMap } = {}\n Object.values(registeredRooms).forEach(room => {\n result[room.location.map.id] = room.location.map as TMap\n })\n return Object.values(result)\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '@drincs/pixi-vn';
|
|
2
|
+
import '../../types/GraphicItem.mjs';
|
|
3
|
+
export { c as MapBaseModelProps, M as default } from '../../index-BvCfRbJB.mjs';
|
|
4
|
+
import '../Activity.mjs';
|
|
5
|
+
import '../../override/OnRunActivityProps.mjs';
|
|
6
|
+
import '../../enums/ExecutionTypeEnum.mjs';
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pixiVn = require('@drincs/pixi-vn');
|
|
4
|
+
|
|
5
|
+
// src/classes/navigation/Map.ts
|
|
6
|
+
|
|
7
|
+
// src/decorators/RoomDecorator.ts
|
|
8
|
+
var registeredRooms = {};
|
|
9
|
+
function getAllLocations() {
|
|
10
|
+
let result = {};
|
|
11
|
+
Object.values(registeredRooms).forEach((room) => {
|
|
12
|
+
result[room.location.id] = room.location;
|
|
13
|
+
});
|
|
14
|
+
return Object.values(result);
|
|
15
|
+
}
|
|
16
|
+
function getLocationsByMap(map) {
|
|
17
|
+
return getAllLocations().filter((location) => location.map.id === map.id);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// src/classes/navigation/Map.ts
|
|
21
|
+
var MAP_CATEGORY = "__nqtr-map__";
|
|
22
|
+
var MapBaseModel = class extends pixiVn.StoredClassModel {
|
|
23
|
+
/**
|
|
24
|
+
* @param id The id of the map, it must be unique.
|
|
25
|
+
* @param props The properties of the map.
|
|
26
|
+
*/
|
|
27
|
+
constructor(id, props = {}) {
|
|
28
|
+
super(MAP_CATEGORY, id);
|
|
29
|
+
this.defaultName = props.name || "";
|
|
30
|
+
this.defaultImage = props.image;
|
|
31
|
+
this.defaultDisabled = props.disabled || false;
|
|
32
|
+
this.defaultHidden = props.hidden || false;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The name of the map.
|
|
36
|
+
* If you set undefined, it will return the initial value of name.
|
|
37
|
+
*/
|
|
38
|
+
get name() {
|
|
39
|
+
return this.getStorageProperty("name") || this.defaultName;
|
|
40
|
+
}
|
|
41
|
+
set name(value) {
|
|
42
|
+
this.setStorageProperty("name", value);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The image of the map. It can be a string, an Element or a Pixi'VN Canvas Item.
|
|
46
|
+
* If you set undefined, it will return the initial value of image.
|
|
47
|
+
*/
|
|
48
|
+
get image() {
|
|
49
|
+
return this.getStorageProperty("image") || this.defaultImage;
|
|
50
|
+
}
|
|
51
|
+
set image(value) {
|
|
52
|
+
this.setStorageProperty("image", value);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
56
|
+
*/
|
|
57
|
+
get disabled() {
|
|
58
|
+
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
59
|
+
if (typeof value === "string") {
|
|
60
|
+
return pixiVn.getFlag(value);
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
set disabled(value) {
|
|
65
|
+
this.setStorageProperty("disabled", value);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
69
|
+
*/
|
|
70
|
+
get hidden() {
|
|
71
|
+
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
72
|
+
if (typeof value === "string") {
|
|
73
|
+
return pixiVn.getFlag(value);
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
set hidden(value) {
|
|
78
|
+
this.setStorageProperty("hidden", value);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The neighboring maps that are available in this map.
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* {
|
|
85
|
+
* "north": "atlanta_map_id",
|
|
86
|
+
* "south": "miami_map_id",
|
|
87
|
+
* "east": "new_york_map_id",
|
|
88
|
+
* "west": "los_angeles_map_id"
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
get neighboringMaps() {
|
|
93
|
+
return this._neighboringMaps || {};
|
|
94
|
+
}
|
|
95
|
+
set neighboringMaps(value) {
|
|
96
|
+
this._neighboringMaps = value;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get all locations in the map.
|
|
100
|
+
* @returns The locations in the map.
|
|
101
|
+
*/
|
|
102
|
+
getLocations() {
|
|
103
|
+
return getLocationsByMap(this);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
module.exports = MapBaseModel;
|
|
108
|
+
//# sourceMappingURL=out.js.map
|
|
109
|
+
//# sourceMappingURL=Map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/classes/navigation/Map.ts","../../../src/decorators/RoomDecorator.ts"],"names":[],"mappings":";AAAA,SAAS,SAAS,wBAAwB;;;ACEnC,IAAM,kBAAmD,CAAC;AAmD1D,SAAS,kBAAwF;AACpG,MAAI,SAAsC,CAAC;AAC3C,SAAO,OAAO,eAAe,EAAE,QAAQ,UAAQ;AAC3C,WAAO,KAAK,SAAS,EAAE,IAAI,KAAK;AAAA,EACpC,CAAC;AACD,SAAO,OAAO,OAAO,MAAM;AAC/B;AAOO,SAAS,kBAA2E,KAAgC;AACvH,SAAO,gBAA2B,EAAE,OAAO,cAAY,SAAS,IAAI,OAAO,IAAI,EAAE;AACrF;;;AD/DA,IAAM,eAAe;AAiErB,IAAqB,eAArB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C7C,WAAO,KAAK,oBAAoB,CAAC;AAAA,EACrC;AAAA,EACA,IAAI,gBAAgB,OAA8C;AAC9D,SAAK,mBAAmB;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,eAAqF;AACjF,WAAO,kBAA6B,IAAI;AAAA,EAC5C;AACJ","sourcesContent":["import { getFlag, StoredClassModel } from \"@drincs/pixi-vn\"\nimport { getLocationsByMap } from \"../../decorators/RoomDecorator\"\nimport { GraphicItemType } from \"../../types/GraphicItem\"\nimport LocationBaseModel from \"./Location\"\n\nconst MAP_CATEGORY = \"__nqtr-map__\"\n\nexport interface MapBaseModelProps<TMap extends MapBaseModel = MapBaseModel> {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * The image. It can be a string, an Element or a Pixi'VN Canvas Item.\n * Or an object to manage multiple image types. For example to have a image based on time.\n * @example\n * ```ts\n * {\n * \"morning\": \"morning-background.jpg\",\n * \"afternoon\": \"afternoon-background.jpg\",\n * \"evening\": \"evening-background.jpg\",\n * \"night\": \"night-background.jpg\"\n * }\n * ```\n * @default undefined\n */\n image?: GraphicItemType | Record<any, GraphicItemType> | object\n /**\n * The neighboring maps that are available in this map.\n * @example\n * ```ts\n * {\n * \"north\": \"atlanta_map_id\",\n * \"south\": \"miami_map_id\",\n * \"east\": \"new_york_map_id\",\n * \"west\": \"los_angeles_map_id\"\n * }\n * ```\n * @default {}\n */\n neighboringMaps?: { [key: string]: string }\n /**\n * Whether is disabled. You can also pass a Pixi'VN flag name.\n * @default false\n */\n disabled?: boolean | string\n /**\n * Whether is hidden. You can also pass a Pixi'VN flag name.\n * @default false\n */\n hidden?: boolean | string\n}\n\n/**\n * The base model of a map. I suggest you extend this class to create your own map model.\n * @example\n * ```typescript\n * export const mainMap = new MapBaseModel('main_map', {\n * name: 'Main Map',\n * image: \"https://image.jpg\",\n * neighboringMaps: {\n * \"north\": \"atlanta_map_id\",\n * \"south\": \"miami_map_id\",\n * \"east\": \"new_york_map_id\",\n * \"west\": \"los_angeles_map_id\"\n * }\n * });\n * ```\n */\nexport default class MapBaseModel extends StoredClassModel {\n /**\n * @param id The id of the map, it must be unique.\n * @param props The properties of the map. \n */\n constructor(id: string, props: MapBaseModelProps = {}) {\n super(MAP_CATEGORY, id)\n this.defaultName = props.name || \"\"\n this.defaultImage = props.image\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n }\n\n private defaultName: string\n /**\n * The name of the map.\n * If you set undefined, it will return the initial value of name.\n */\n get name(): string {\n return this.getStorageProperty<string>(\"name\") || this.defaultName\n }\n set name(value: string | undefined) {\n this.setStorageProperty(\"name\", value)\n }\n\n private defaultImage?: GraphicItemType | Record<any, GraphicItemType> | object\n /**\n * The image of the map. It can be a string, an Element or a Pixi'VN Canvas Item.\n * If you set undefined, it will return the initial value of image.\n */\n get image(): GraphicItemType | Record<any, GraphicItemType> | object | undefined {\n return this.getStorageProperty<GraphicItemType>(\"image\") || this.defaultImage\n }\n set image(value: GraphicItemType | Record<any, GraphicItemType> | object | undefined) {\n this.setStorageProperty(\"image\", value)\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled. If it is a string, it is a Pixi'VN flag name.\n */\n get disabled(): boolean {\n let value = this.getStorageProperty<boolean>(\"disabled\") || this.defaultDisabled\n if (typeof value === \"string\") {\n return getFlag(value)\n }\n return value\n }\n set disabled(value: boolean | string) {\n this.setStorageProperty(\"disabled\", value)\n }\n\n private defaultHidden: boolean | string\n /**\n * Whether is hidden. If it is a string, it is a Pixi'VN flag name.\n */\n get hidden(): boolean {\n let value = this.getStorageProperty<boolean>(\"hidden\") || this.defaultHidden\n if (typeof value === \"string\") {\n return getFlag(value)\n }\n return value\n }\n set hidden(value: boolean | string) {\n this.setStorageProperty(\"hidden\", value)\n }\n\n private _neighboringMaps?: { [key: string]: string }\n /**\n * The neighboring maps that are available in this map.\n * @example\n * ```ts\n * {\n * \"north\": \"atlanta_map_id\",\n * \"south\": \"miami_map_id\",\n * \"east\": \"new_york_map_id\",\n * \"west\": \"los_angeles_map_id\"\n * }\n * ```\n */\n get neighboringMaps(): { [key: string]: string } {\n return this._neighboringMaps || {}\n }\n set neighboringMaps(value: { [key: string]: string } | undefined) {\n this._neighboringMaps = value\n }\n\n /**\n * Get all locations in the map.\n * @returns The locations in the map.\n */\n getLocations<TLocation extends LocationBaseModel = LocationBaseModel>(): TLocation[] {\n return getLocationsByMap<TLocation>(this)\n }\n}\n","import { LocationBaseModel, MapBaseModel, RoomBaseModel } from \"../classes/navigation\"\n\nexport const registeredRooms: { [id: string]: RoomBaseModel } = {}\n\n/**\n * Save a room in the registered rooms.\n * @param room The room to save.\n * @returns \n */\nexport function saveRoom<TRoom extends RoomBaseModel = RoomBaseModel>(room: TRoom | TRoom[]) {\n if (Array.isArray(room)) {\n room.forEach(c => saveRoom(c))\n return\n }\n if (registeredRooms[room.id]) {\n console.warn(`[NQTR] Room id ${room.id} already exists, it will be overwritten`)\n }\n registeredRooms[room.id] = room\n}\n\n/**\n * Get a room by its id.\n * @param id The id of the room.\n * @returns The room or undefined if not found.\n */\nexport function getRoomById<TRoom extends RoomBaseModel = RoomBaseModel>(id: string): TRoom | undefined {\n try {\n let room = registeredRooms[id]\n if (!room) {\n console.error(`[NQTR] Room ${id} not found`)\n return\n }\n return room as TRoom\n }\n catch (e) {\n console.error(`[NQTR] Error while getting Room ${id}`, e)\n return\n }\n}\n\n/**\n * Get all rooms in a location.\n * @param location The location where the rooms are.\n * @returns The rooms in the location.\n */\nexport function getRoomsByLocation<TRoom extends RoomBaseModel = RoomBaseModel>(location: LocationBaseModel): TRoom[] {\n return Object.values(registeredRooms).filter(room => room.location.id === location.id) as TRoom[]\n}\n\n/**\n * Get all locations in the registered rooms.\n * @returns All locations in the registered rooms.\n */\nexport function getAllLocations<TLocation extends LocationBaseModel = LocationBaseModel>(): TLocation[] {\n let result: { [id: string]: TLocation } = {}\n Object.values(registeredRooms).forEach(room => {\n result[room.location.id] = room.location as TLocation\n })\n return Object.values(result)\n}\n\n/**\n * Get all locations in a map.\n * @param map The map where the locations are.\n * @returns The locations in the map.\n */\nexport function getLocationsByMap<TLocation extends LocationBaseModel = LocationBaseModel>(map: MapBaseModel): TLocation[] {\n return getAllLocations<TLocation>().filter(location => location.map.id === map.id) as TLocation[]\n}\n\n/**\n * Get all maps in the registered rooms.\n * @returns All maps in the registered rooms.\n */\nexport function getAllMaps<TMap extends MapBaseModel = MapBaseModel>(): TMap[] {\n let result: { [id: string]: TMap } = {}\n Object.values(registeredRooms).forEach(room => {\n result[room.location.map.id] = room.location.map as TMap\n })\n return Object.values(result)\n}\n"]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { StoredClassModel, getFlag } from '@drincs/pixi-vn';
|
|
2
|
+
|
|
3
|
+
// src/classes/navigation/Map.ts
|
|
4
|
+
|
|
5
|
+
// src/decorators/RoomDecorator.ts
|
|
6
|
+
var registeredRooms = {};
|
|
7
|
+
function getAllLocations() {
|
|
8
|
+
let result = {};
|
|
9
|
+
Object.values(registeredRooms).forEach((room) => {
|
|
10
|
+
result[room.location.id] = room.location;
|
|
11
|
+
});
|
|
12
|
+
return Object.values(result);
|
|
13
|
+
}
|
|
14
|
+
function getLocationsByMap(map) {
|
|
15
|
+
return getAllLocations().filter((location) => location.map.id === map.id);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/classes/navigation/Map.ts
|
|
19
|
+
var MAP_CATEGORY = "__nqtr-map__";
|
|
20
|
+
var MapBaseModel = class extends StoredClassModel {
|
|
21
|
+
/**
|
|
22
|
+
* @param id The id of the map, it must be unique.
|
|
23
|
+
* @param props The properties of the map.
|
|
24
|
+
*/
|
|
25
|
+
constructor(id, props = {}) {
|
|
26
|
+
super(MAP_CATEGORY, id);
|
|
27
|
+
this.defaultName = props.name || "";
|
|
28
|
+
this.defaultImage = props.image;
|
|
29
|
+
this.defaultDisabled = props.disabled || false;
|
|
30
|
+
this.defaultHidden = props.hidden || false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The name of the map.
|
|
34
|
+
* If you set undefined, it will return the initial value of name.
|
|
35
|
+
*/
|
|
36
|
+
get name() {
|
|
37
|
+
return this.getStorageProperty("name") || this.defaultName;
|
|
38
|
+
}
|
|
39
|
+
set name(value) {
|
|
40
|
+
this.setStorageProperty("name", value);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The image of the map. It can be a string, an Element or a Pixi'VN Canvas Item.
|
|
44
|
+
* If you set undefined, it will return the initial value of image.
|
|
45
|
+
*/
|
|
46
|
+
get image() {
|
|
47
|
+
return this.getStorageProperty("image") || this.defaultImage;
|
|
48
|
+
}
|
|
49
|
+
set image(value) {
|
|
50
|
+
this.setStorageProperty("image", value);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
54
|
+
*/
|
|
55
|
+
get disabled() {
|
|
56
|
+
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
57
|
+
if (typeof value === "string") {
|
|
58
|
+
return getFlag(value);
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
set disabled(value) {
|
|
63
|
+
this.setStorageProperty("disabled", value);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
67
|
+
*/
|
|
68
|
+
get hidden() {
|
|
69
|
+
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
70
|
+
if (typeof value === "string") {
|
|
71
|
+
return getFlag(value);
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
set hidden(value) {
|
|
76
|
+
this.setStorageProperty("hidden", value);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The neighboring maps that are available in this map.
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* {
|
|
83
|
+
* "north": "atlanta_map_id",
|
|
84
|
+
* "south": "miami_map_id",
|
|
85
|
+
* "east": "new_york_map_id",
|
|
86
|
+
* "west": "los_angeles_map_id"
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
get neighboringMaps() {
|
|
91
|
+
return this._neighboringMaps || {};
|
|
92
|
+
}
|
|
93
|
+
set neighboringMaps(value) {
|
|
94
|
+
this._neighboringMaps = value;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get all locations in the map.
|
|
98
|
+
* @returns The locations in the map.
|
|
99
|
+
*/
|
|
100
|
+
getLocations() {
|
|
101
|
+
return getLocationsByMap(this);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export { MapBaseModel as default };
|
|
106
|
+
//# sourceMappingURL=out.js.map
|
|
107
|
+
//# sourceMappingURL=Map.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/classes/navigation/Map.ts","../../../src/decorators/RoomDecorator.ts"],"names":[],"mappings":";AAAA,SAAS,SAAS,wBAAwB;;;ACEnC,IAAM,kBAAmD,CAAC;AAmD1D,SAAS,kBAAwF;AACpG,MAAI,SAAsC,CAAC;AAC3C,SAAO,OAAO,eAAe,EAAE,QAAQ,UAAQ;AAC3C,WAAO,KAAK,SAAS,EAAE,IAAI,KAAK;AAAA,EACpC,CAAC;AACD,SAAO,OAAO,OAAO,MAAM;AAC/B;AAOO,SAAS,kBAA2E,KAAgC;AACvH,SAAO,gBAA2B,EAAE,OAAO,cAAY,SAAS,IAAI,OAAO,IAAI,EAAE;AACrF;;;AD/DA,IAAM,eAAe;AAiErB,IAAqB,eAArB,cAA0C,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKvD,YAAY,IAAY,QAA2B,CAAC,GAAG;AACnD,UAAM,cAAc,EAAE;AACtB,SAAK,cAAc,MAAM,QAAQ;AACjC,SAAK,eAAe,MAAM;AAC1B,SAAK,kBAAkB,MAAM,YAAY;A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sourcesContent":["import { getFlag, StoredClassModel } from \"@drincs/pixi-vn\"\nimport { getLocationsByMap } from \"../../decorators/RoomDecorator\"\nimport { GraphicItemType } from \"../../types/GraphicItem\"\nimport LocationBaseModel from \"./Location\"\n\nconst MAP_CATEGORY = \"__nqtr-map__\"\n\nexport interface MapBaseModelProps<TMap extends MapBaseModel = MapBaseModel> {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * The image. It can be a string, an Element or a Pixi'VN Canvas Item.\n * Or an object to manage multiple image types. For example to have a image based on time.\n * @example\n * ```ts\n * {\n * \"morning\": \"morning-background.jpg\",\n * \"afternoon\": \"afternoon-background.jpg\",\n * \"evening\": \"evening-background.jpg\",\n * \"night\": \"night-background.jpg\"\n * }\n * ```\n * @default undefined\n */\n image?: GraphicItemType | Record<any, GraphicItemType> | object\n /**\n * The neighboring maps that are available in this map.\n * @example\n * ```ts\n * {\n * \"north\": \"atlanta_map_id\",\n * \"south\": \"miami_map_id\",\n * \"east\": \"new_york_map_id\",\n * \"west\": \"los_angeles_map_id\"\n * }\n * ```\n * @default {}\n */\n neighboringMaps?: { [key: string]: string }\n /**\n * Whether is disabled. You can also pass a Pixi'VN flag name.\n * @default false\n */\n disabled?: boolean | string\n /**\n * Whether is hidden. You can also pass a Pixi'VN flag name.\n * @default false\n */\n hidden?: boolean | string\n}\n\n/**\n * The base model of a map. I suggest you extend this class to create your own map model.\n * @example\n * ```typescript\n * export const mainMap = new MapBaseModel('main_map', {\n * name: 'Main Map',\n * image: \"https://image.jpg\",\n * neighboringMaps: {\n * \"north\": \"atlanta_map_id\",\n * \"south\": \"miami_map_id\",\n * \"east\": \"new_york_map_id\",\n * \"west\": \"los_angeles_map_id\"\n * }\n * });\n * ```\n */\nexport default class MapBaseModel extends StoredClassModel {\n /**\n * @param id The id of the map, it must be unique.\n * @param props The properties of the map. \n */\n constructor(id: string, props: MapBaseModelProps = {}) {\n super(MAP_CATEGORY, id)\n this.defaultName = props.name || \"\"\n this.defaultImage = props.image\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n }\n\n private defaultName: string\n /**\n * The name of the map.\n * If you set undefined, it will return the initial value of name.\n */\n get name(): string {\n return this.getStorageProperty<string>(\"name\") || this.defaultName\n }\n set name(value: string | undefined) {\n this.setStorageProperty(\"name\", value)\n }\n\n private defaultImage?: GraphicItemType | Record<any, GraphicItemType> | object\n /**\n * The image of the map. It can be a string, an Element or a Pixi'VN Canvas Item.\n * If you set undefined, it will return the initial value of image.\n */\n get image(): GraphicItemType | Record<any, GraphicItemType> | object | undefined {\n return this.getStorageProperty<GraphicItemType>(\"image\") || this.defaultImage\n }\n set image(value: GraphicItemType | Record<any, GraphicItemType> | object | undefined) {\n this.setStorageProperty(\"image\", value)\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled. If it is a string, it is a Pixi'VN flag name.\n */\n get disabled(): boolean {\n let value = this.getStorageProperty<boolean>(\"disabled\") || this.defaultDisabled\n if (typeof value === \"string\") {\n return getFlag(value)\n }\n return value\n }\n set disabled(value: boolean | string) {\n this.setStorageProperty(\"disabled\", value)\n }\n\n private defaultHidden: boolean | string\n /**\n * Whether is hidden. If it is a string, it is a Pixi'VN flag name.\n */\n get hidden(): boolean {\n let value = this.getStorageProperty<boolean>(\"hidden\") || this.defaultHidden\n if (typeof value === \"string\") {\n return getFlag(value)\n }\n return value\n }\n set hidden(value: boolean | string) {\n this.setStorageProperty(\"hidden\", value)\n }\n\n private _neighboringMaps?: { [key: string]: string }\n /**\n * The neighboring maps that are available in this map.\n * @example\n * ```ts\n * {\n * \"north\": \"atlanta_map_id\",\n * \"south\": \"miami_map_id\",\n * \"east\": \"new_york_map_id\",\n * \"west\": \"los_angeles_map_id\"\n * }\n * ```\n */\n get neighboringMaps(): { [key: string]: string } {\n return this._neighboringMaps || {}\n }\n set neighboringMaps(value: { [key: string]: string } | undefined) {\n this._neighboringMaps = value\n }\n\n /**\n * Get all locations in the map.\n * @returns The locations in the map.\n */\n getLocations<TLocation extends LocationBaseModel = LocationBaseModel>(): TLocation[] {\n return getLocationsByMap<TLocation>(this)\n }\n}\n","import { LocationBaseModel, MapBaseModel, RoomBaseModel } from \"../classes/navigation\"\n\nexport const registeredRooms: { [id: string]: RoomBaseModel } = {}\n\n/**\n * Save a room in the registered rooms.\n * @param room The room to save.\n * @returns \n */\nexport function saveRoom<TRoom extends RoomBaseModel = RoomBaseModel>(room: TRoom | TRoom[]) {\n if (Array.isArray(room)) {\n room.forEach(c => saveRoom(c))\n return\n }\n if (registeredRooms[room.id]) {\n console.warn(`[NQTR] Room id ${room.id} already exists, it will be overwritten`)\n }\n registeredRooms[room.id] = room\n}\n\n/**\n * Get a room by its id.\n * @param id The id of the room.\n * @returns The room or undefined if not found.\n */\nexport function getRoomById<TRoom extends RoomBaseModel = RoomBaseModel>(id: string): TRoom | undefined {\n try {\n let room = registeredRooms[id]\n if (!room) {\n console.error(`[NQTR] Room ${id} not found`)\n return\n }\n return room as TRoom\n }\n catch (e) {\n console.error(`[NQTR] Error while getting Room ${id}`, e)\n return\n }\n}\n\n/**\n * Get all rooms in a location.\n * @param location The location where the rooms are.\n * @returns The rooms in the location.\n */\nexport function getRoomsByLocation<TRoom extends RoomBaseModel = RoomBaseModel>(location: LocationBaseModel): TRoom[] {\n return Object.values(registeredRooms).filter(room => room.location.id === location.id) as TRoom[]\n}\n\n/**\n * Get all locations in the registered rooms.\n * @returns All locations in the registered rooms.\n */\nexport function getAllLocations<TLocation extends LocationBaseModel = LocationBaseModel>(): TLocation[] {\n let result: { [id: string]: TLocation } = {}\n Object.values(registeredRooms).forEach(room => {\n result[room.location.id] = room.location as TLocation\n })\n return Object.values(result)\n}\n\n/**\n * Get all locations in a map.\n * @param map The map where the locations are.\n * @returns The locations in the map.\n */\nexport function getLocationsByMap<TLocation extends LocationBaseModel = LocationBaseModel>(map: MapBaseModel): TLocation[] {\n return getAllLocations<TLocation>().filter(location => location.map.id === map.id) as TLocation[]\n}\n\n/**\n * Get all maps in the registered rooms.\n * @returns All maps in the registered rooms.\n */\nexport function getAllMaps<TMap extends MapBaseModel = MapBaseModel>(): TMap[] {\n let result: { [id: string]: TMap } = {}\n Object.values(registeredRooms).forEach(room => {\n result[room.location.map.id] = room.location.map as TMap\n })\n return Object.values(result)\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '@drincs/pixi-vn';
|
|
2
|
+
import '../../types/GraphicItem.mjs';
|
|
3
|
+
import '../Activity.mjs';
|
|
4
|
+
export { e as ROOM_CATEGORY, d as RoomBaseModelProps, R as default } from '../../index-BvCfRbJB.mjs';
|
|
5
|
+
import '../../override/OnRunActivityProps.mjs';
|
|
6
|
+
import '../../enums/ExecutionTypeEnum.mjs';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '@drincs/pixi-vn';
|
|
2
|
+
import '../../types/GraphicItem.js';
|
|
3
|
+
import '../Activity.js';
|
|
4
|
+
export { e as ROOM_CATEGORY, d as RoomBaseModelProps, R as default } from '../../index-Ci6Aw7YE.js';
|
|
5
|
+
import '../../override/OnRunActivityProps.js';
|
|
6
|
+
import '../../enums/ExecutionTypeEnum.js';
|