@drincs/nqtr 0.1.6 → 0.1.7

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.
Files changed (92) hide show
  1. package/dist/classes/Activity.d.mts +4 -4
  2. package/dist/classes/Activity.d.ts +4 -4
  3. package/dist/classes/Activity.js +10 -2
  4. package/dist/classes/Activity.js.map +1 -1
  5. package/dist/classes/Activity.mjs +10 -2
  6. package/dist/classes/Activity.mjs.map +1 -1
  7. package/dist/classes/Commitment.d.mts +2 -2
  8. package/dist/classes/Commitment.d.ts +2 -2
  9. package/dist/classes/Commitment.js +5 -1
  10. package/dist/classes/Commitment.js.map +1 -1
  11. package/dist/classes/Commitment.mjs +5 -1
  12. package/dist/classes/Commitment.mjs.map +1 -1
  13. package/dist/classes/index.d.mts +2 -2
  14. package/dist/classes/index.d.ts +2 -2
  15. package/dist/classes/index.js +10 -2
  16. package/dist/classes/index.js.map +1 -1
  17. package/dist/classes/index.mjs +10 -2
  18. package/dist/classes/index.mjs.map +1 -1
  19. package/dist/classes/navigation/ActivityRoom.d.mts +2 -2
  20. package/dist/classes/navigation/ActivityRoom.d.ts +2 -2
  21. package/dist/classes/navigation/ActivityRoom.js +5 -1
  22. package/dist/classes/navigation/ActivityRoom.js.map +1 -1
  23. package/dist/classes/navigation/ActivityRoom.mjs +5 -1
  24. package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
  25. package/dist/classes/navigation/Location.d.mts +2 -2
  26. package/dist/classes/navigation/Location.d.ts +2 -2
  27. package/dist/classes/navigation/Location.js +5 -1
  28. package/dist/classes/navigation/Location.js.map +1 -1
  29. package/dist/classes/navigation/Location.mjs +5 -1
  30. package/dist/classes/navigation/Location.mjs.map +1 -1
  31. package/dist/classes/navigation/Map.d.mts +2 -2
  32. package/dist/classes/navigation/Map.d.ts +2 -2
  33. package/dist/classes/navigation/Map.js +8 -4
  34. package/dist/classes/navigation/Map.js.map +1 -1
  35. package/dist/classes/navigation/Map.mjs +8 -4
  36. package/dist/classes/navigation/Map.mjs.map +1 -1
  37. package/dist/classes/navigation/Room.d.mts +2 -2
  38. package/dist/classes/navigation/Room.d.ts +2 -2
  39. package/dist/classes/navigation/Room.js +18 -6
  40. package/dist/classes/navigation/Room.js.map +1 -1
  41. package/dist/classes/navigation/Room.mjs +18 -6
  42. package/dist/classes/navigation/Room.mjs.map +1 -1
  43. package/dist/classes/navigation/index.d.mts +2 -2
  44. package/dist/classes/navigation/index.d.ts +2 -2
  45. package/dist/classes/navigation/index.js +31 -11
  46. package/dist/classes/navigation/index.js.map +1 -1
  47. package/dist/classes/navigation/index.mjs +31 -11
  48. package/dist/classes/navigation/index.mjs.map +1 -1
  49. package/dist/decorators/ActivityDecorator.d.mts +1 -1
  50. package/dist/decorators/ActivityDecorator.d.ts +1 -1
  51. package/dist/decorators/CommitmentDecorator.d.mts +2 -2
  52. package/dist/decorators/CommitmentDecorator.d.ts +2 -2
  53. package/dist/decorators/RoomDecorator.d.mts +2 -2
  54. package/dist/decorators/RoomDecorator.d.ts +2 -2
  55. package/dist/decorators/index.d.mts +2 -2
  56. package/dist/decorators/index.d.ts +2 -2
  57. package/dist/functions/ActivityFunctions.d.mts +2 -2
  58. package/dist/functions/ActivityFunctions.d.ts +2 -2
  59. package/dist/functions/ActivityFunctions.js.map +1 -1
  60. package/dist/functions/ActivityFunctions.mjs.map +1 -1
  61. package/dist/functions/NavigationFunctions.d.mts +2 -2
  62. package/dist/functions/NavigationFunctions.d.ts +2 -2
  63. package/dist/functions/NavigationFunctions.js +5 -1
  64. package/dist/functions/NavigationFunctions.js.map +1 -1
  65. package/dist/functions/NavigationFunctions.mjs +5 -1
  66. package/dist/functions/NavigationFunctions.mjs.map +1 -1
  67. package/dist/functions/RoutineFunctions.d.mts +2 -2
  68. package/dist/functions/RoutineFunctions.d.ts +2 -2
  69. package/dist/functions/index.d.mts +2 -2
  70. package/dist/functions/index.d.ts +2 -2
  71. package/dist/functions/index.js +5 -1
  72. package/dist/functions/index.js.map +1 -1
  73. package/dist/functions/index.mjs +5 -1
  74. package/dist/functions/index.mjs.map +1 -1
  75. package/dist/{index-Lm3w4aIL.d.mts → index-CwqgrVp6.d.mts} +19 -19
  76. package/dist/{index-Cu7BBJil.d.ts → index-D_4poX-_.d.ts} +19 -19
  77. package/dist/index.d.mts +2 -2
  78. package/dist/index.d.ts +2 -2
  79. package/dist/index.js +41 -13
  80. package/dist/index.js.map +1 -1
  81. package/dist/index.mjs +41 -13
  82. package/dist/index.mjs.map +1 -1
  83. package/dist/override/{GraphicItem.js → GraphicItemType.js} +1 -1
  84. package/dist/override/GraphicItemType.mjs +3 -0
  85. package/dist/override/index.d.mts +1 -1
  86. package/dist/override/index.d.ts +1 -1
  87. package/package.json +2 -2
  88. package/dist/override/GraphicItem.mjs +0 -3
  89. /package/dist/override/{GraphicItem.d.mts → GraphicItemType.d.mts} +0 -0
  90. /package/dist/override/{GraphicItem.d.ts → GraphicItemType.d.ts} +0 -0
  91. /package/dist/override/{GraphicItem.js.map → GraphicItemType.js.map} +0 -0
  92. /package/dist/override/{GraphicItem.mjs.map → GraphicItemType.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/decorators/RoomDecorator.ts","../../src/functions/NavigationFunctions.ts","../../src/classes/navigation/Location.ts","../../src/classes/navigation/Map.ts","../../src/classes/navigation/Room.ts","../../src/decorators/CommitmentDecorator.ts","../../src/functions/RoutineFunctions.ts","../../src/classes/Activity.ts","../../src/managers/TimeManager.ts","../../src/functions/ActivityFunctions.ts"],"names":["GameStorageManager","getFlag","StoredClassModel"],"mappings":";AAEO,IAAM,kBAAmD,CAAC;AAuB1D,SAAS,YAAyD,IAA+B;AACpG,MAAI;AACA,QAAI,OAAO,gBAAgB,EAAE;AAC7B,QAAI,CAAC,MAAM;AACP,cAAQ,MAAM,eAAe,EAAE,YAAY;AAC3C;AAAA,IACJ;AACA,WAAO;AAAA,EACX,SACO,GAAG;AACN,YAAQ,MAAM,mCAAmC,EAAE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AACL;AAEO,SAAS,oBAAoC;AAChD,MAAI,cAAc,eAAe;AACjC,MAAI,CAAC,aAAa;AACd,WAAO,CAAC;AAAA,EACZ;AACA,SAAO,YAAY,WAAW,OAAO,cAAY,CAAC,SAAS,MAAM;AACrE","sourcesContent":["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","import { GameStorageManager } from \"@drincs/pixi-vn\";\nimport { LocationBaseModel, MapBaseModel, RoomBaseModel } from \"../classes/navigation\";\nimport { getRoomById } from \"../decorators/RoomDecorator\";\n\nconst CURRENT_ROOM_MEMORY_KEY = '___nqtr-current_room_memory___';\n\nexport function setCurrentRoom<TRoom extends RoomBaseModel = RoomBaseModel>(room: TRoom | LocationBaseModel) {\n if (room instanceof LocationBaseModel) {\n let entrance = room.getEntrance<TRoom>();\n if (!entrance) {\n console.error(`[NQTR] The location ${room.id} has no entrance room`);\n return;\n }\n room = entrance;\n }\n else {\n let roomRegistrated = getRoomById(room.id);\n if (!roomRegistrated) {\n console.error(`[NQTR] The room ${room.id} is not registered, so it can't be set as current room`);\n return;\n }\n }\n GameStorageManager.setVariable(CURRENT_ROOM_MEMORY_KEY, room.id);\n}\n\nexport function getCurrentRoom<TRoom extends RoomBaseModel = RoomBaseModel>(): TRoom | undefined {\n let roomId = GameStorageManager.getVariable<string>(CURRENT_ROOM_MEMORY_KEY);\n if (!roomId) {\n console.error(`[NQTR] The current room has not yet been set`);\n return\n }\n let room = getRoomById<TRoom>(roomId);\n if (!room) {\n console.error(`[NQTR] Current room ${roomId} not found`);\n return\n }\n return room\n}\n\nexport function getCurrenrLocation<TLocation extends LocationBaseModel = LocationBaseModel>(): TLocation | undefined {\n let room = getCurrentRoom<RoomBaseModel<TLocation>>();\n if (!room) {\n return\n }\n return room.location\n}\n\nexport function getCueerntMap<TMap extends MapBaseModel = MapBaseModel>(): TMap | undefined {\n let location = getCurrenrLocation<LocationBaseModel<TMap>>();\n if (!location) {\n return\n }\n return location.map\n}\n","import { getFlag, StoredClassModel } from \"@drincs/pixi-vn\";\nimport { getRoomsByLocation } from \"../../decorators/RoomDecorator\";\nimport { OnRenderGraphicItemProps } from \"../../override\";\nimport GraphicItemType from \"../../override/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 renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => 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._renderIcon = props.renderIcon\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 _renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the location.\n */\n get renderIcon(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n return this._renderIcon as ((props: OnRenderGraphicItemProps) => GraphicItemType)\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 { getFlag, StoredClassModel } from \"@drincs/pixi-vn\"\nimport { getLocationsByMap } from \"../../decorators/RoomDecorator\"\nimport { OnRenderGraphicItemProps } from \"../../override\"\nimport GraphicItemType from \"../../override/GraphicItem\"\nimport LocationBaseModel from \"./Location\"\n\nconst MAP_CATEGORY = \"__nqtr-map__\"\n\nexport interface MapBaseModelProps {\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 renderImage?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType)\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._renderImege = props.renderImage\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 _renderImege?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the image of the map.\n */\n get renderImage(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderImege !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderImege as GraphicItemType\n }\n return this._renderImege as ((props: OnRenderGraphicItemProps) => GraphicItemType)\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 { getFlag, StoredClassModel } from \"@drincs/pixi-vn\";\nimport { getActivityById } from \"../../decorators\";\nimport { getCurrentCommitments } from \"../../functions/RoutineFunctions\";\nimport { OnRenderGraphicItemProps } from \"../../override\";\nimport GraphicItemType from \"../../override/GraphicItem\";\nimport ActivityModel, { ActivityProps } from \"../Activity\";\nimport CommitmentBaseModel from \"../Commitment\";\nimport { ActivityRoom } from \"./ActivityRoom\";\nimport LocationBaseModel from \"./Location\";\n\nexport const ROOM_CATEGORY = \"__nqtr-room__\"\n\ninterface RoomActivityMemory { [key: string]: ActivityProps }\n\nexport interface RoomBaseModelProps {\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 renderImage?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The activities that are available in this room.\n * @default []\n */\n defaultActivities?: ActivityModel[],\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 renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.\n * @default false\n */\n isEntrance?: boolean\n}\n\n/**\n * The base model of a room. I suggest you extend this class to create your own room model.\n * You must use the saveRoom function to save the room in the registered rooms.\n * @example\n * ```ts\n * export const mcRoom = new RoomBaseModel('mc_room', mcHome, {\n * name: \"MC Room\",\n * icon: \"https://icon.jpg\",\n * image: \"https://image.jpg\",\n * isEntrance: false,\n * })\n * saveRoom(mcRoom)\n * ```\n */\nexport default class RoomBaseModel<TLocation extends LocationBaseModel = LocationBaseModel> extends StoredClassModel {\n /**\n * @param id The id of the room, it must be unique.\n * @param location The location where the room is.\n * @param props The properties of the room.\n */\n constructor(id: string, location: TLocation, props: RoomBaseModelProps = {}) {\n super(ROOM_CATEGORY, id)\n this._location = location\n this.defaultName = props.name || \"\"\n this._renderImege = props.renderImage\n this.defaultActivityIds = props.defaultActivities?.map(activity => activity.id) || []\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._isEntrance = props.isEntrance\n }\n\n private _location: TLocation\n /**\n * The location where the room is.\n */\n get location(): TLocation {\n return this._location\n }\n\n private _isEntrance?: boolean\n /**\n * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.\n */\n get isEntrance(): boolean {\n return this._isEntrance || false\n }\n\n private defaultName: string\n /**\n * The name.\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 _renderImege?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the image of the room.\n */\n get renderImage(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderImege !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderImege as GraphicItemType\n }\n return this._renderImege as ((props: OnRenderGraphicItemProps) => GraphicItemType)\n }\n\n private defaultActivityIds: string[]\n /**\n * The activities that are available in this room.\n */\n get defaultActivities(): ActivityRoom<this>[] {\n let roomMemories = this.getStorageProperty<RoomActivityMemory>(\"activities_memory\") || {}\n let activities = this.defaultActivityIds.map(id => {\n let activity = getActivityById(id)\n if (!activity) {\n console.warn(`[NQTR] Activity with id ${id} not found, so it will be ignored.`)\n return undefined\n }\n let memory = activity.export()\n if (roomMemories && roomMemories[id]) {\n memory = {\n ...memory,\n ...roomMemories[id]\n }\n }\n return new ActivityRoom(id, this, activity.onRun, memory)\n }).filter(activity => activity !== undefined)\n return activities as ActivityRoom<this>[]\n }\n\n private get activityIds(): string[] {\n let addedActivityIds = this.getStorageProperty<string[]>(`addedActivityIds`) || []\n return this.defaultActivityIds.concat(addedActivityIds)\n }\n /**\n * The activities that are available in this room.\n */\n get activities(): ActivityRoom<this>[] {\n let activities = this.activityIds.map(id => {\n return this.getActivity(id)\n }).filter(activity => activity !== undefined)\n return activities as ActivityRoom<this>[]\n }\n /**\n * Get the memory of an activity. This function can be used into olther libraries to get the memory of the activity.\n * @param id The id of the activity.\n * @returns The memory of the activity.\n */\n getActivityMemory(id: string): object | undefined {\n let roomMemories = this.getStorageProperty<RoomActivityMemory>(\"activities_memory\") || {}\n let roomMemory = roomMemories[id] || {}\n return roomMemory\n }\n /**\n * Get the activity by id.\n * @param id The id of the activity.\n * @returns The room activity.\n */\n getActivity(id: string): ActivityRoom<this> | undefined {\n if (!this.activityIds.includes(id)) {\n console.error(`[NQTR] Activity with id ${id} not found in room ${this.id}`)\n return undefined\n }\n let activity = getActivityById(id)\n if (!activity) {\n console.error(`[NQTR] Activity with id ${id} not found`)\n return undefined\n }\n let roomMemories = this.getStorageProperty<RoomActivityMemory>(\"activities_memory\") || {}\n let roomMemory = roomMemories[id] || {}\n roomMemory = {\n ...activity.export(),\n ...roomMemory\n }\n return new ActivityRoom(id, this, activity.onRun, roomMemory)\n }\n /**\n * Set the memory of an activity. This function can be used into olther libraries to set the memory of the activity.\n * @param id The id of the activity.\n * @param memory The memory of the activity.\n */\n setActivity(activity: ActivityRoom) {\n let roomMemories = this.getStorageProperty<RoomActivityMemory>(\"activities_memory\") || {}\n roomMemories[activity.id] = activity.export()\n this.setStorageProperty(\"activities_memory\", roomMemories)\n }\n /**\n * Add an activity to the room.\n * @param activity The activity to add.\n */\n addActivity(activity: ActivityModel) {\n if (this.activityIds.includes(activity.id)) {\n let currentActivity = this.getActivity(activity.id)\n if (currentActivity && currentActivity.isExpired()) {\n this.removeActivity(activity.id)\n return\n } else {\n console.error(`[NQTR] Activity with id ${activity.id} already exists in room ${this.id}, so it will be ignored.`)\n return\n }\n }\n let addedActivityIds = this.getStorageProperty<string[]>(`addedActivityIds`) || []\n addedActivityIds.push(activity.id)\n this.setStorageProperty(\"addedActivityIds\", addedActivityIds)\n }\n /**\n * Remove an activity from the room.\n * @param activity The activity to remove.\n */\n removeActivity(activity: ActivityModel | string) {\n let activityId = typeof activity === \"string\" ? activity : activity.id\n if (this.defaultActivityIds.includes(activityId)) {\n console.warn(`[NQTR] Activity with id ${activityId} is a default activity, so it can't be removed. It will be hidden instead.`)\n let activityToEdit = this.getActivity(activityId)\n if (!activityToEdit) {\n console.error(`[NQTR] Activity with id ${activityId} not found, so it can't be hidden.`)\n return\n }\n activityToEdit.hidden = true\n return\n }\n let addedActivityIds = this.getStorageProperty<string[]>(`addedActivityIds`) || []\n let index = addedActivityIds.indexOf(activityId)\n if (index === -1) {\n console.error(`[NQTR] Activity with id ${activityId} not found, so it can't be removed.`)\n return\n }\n addedActivityIds.splice(index, 1)\n this.setStorageProperty(\"addedActivityIds\", addedActivityIds)\n let roomMemories = this.getStorageProperty<RoomActivityMemory>(\"activities_memory\") || {}\n delete roomMemories[activityId]\n this.setStorageProperty(\"activities_memory\", roomMemories)\n }\n /**\n * Clear all expired activities.\n */\n clearExpiredActivities() {\n this.activities.forEach(activity => {\n if (activity.isExpired()) {\n this.removeActivity(activity.id)\n }\n })\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 _renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the room.\n */\n get renderIcon(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n return this._renderIcon as ((props: OnRenderGraphicItemProps) => GraphicItemType)\n }\n\n /**\n * Get the character commitments of the room.\n * @returns The character commitments of the room.\n */\n getRoutine<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[] {\n let commitments = getCurrentCommitments<TCommitment>()\n return commitments.filter(c => c.room.id === this.id)\n }\n}\n","import { GameStorageManager } from \"@drincs/pixi-vn\"\nimport CommitmentBaseModel from \"../classes/Commitment\"\n\nconst TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY = \"___nqtr-temporary_commitment___\"\nexport const registeredCommitments: { [id: string]: CommitmentBaseModel } = {}\nexport const fixedCommitments: { [id: string]: CommitmentBaseModel } = {}\n\nexport function saveCommitment<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(commitment: TCommitment | TCommitment[]) {\n if (Array.isArray(commitment)) {\n commitment.forEach(c => saveCommitment(c))\n return\n }\n if (registeredCommitments[commitment.id]) {\n console.warn(`[NQTR] Commitment id ${commitment.id} already exists, it will be overwritten`)\n }\n registeredCommitments[commitment.id] = commitment\n}\n\nexport function getCommitmentById<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(id: string): TCommitment | undefined {\n try {\n let commitment = registeredCommitments[id]\n if (!commitment) {\n console.error(`[NQTR] Commitment ${id} not found`)\n return\n }\n return commitment as TCommitment\n }\n catch (e) {\n console.error(`[NQTR] Error while getting Commitment ${id}`, e)\n return\n }\n}\n\nexport function setFixedCommitments<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(commitments: TCommitment[] | TCommitment) {\n if (Array.isArray(commitments)) {\n commitments.forEach(c => saveCommitment(c))\n return\n }\n if (registeredCommitments[commitments.id]) {\n console.warn(`[NQTR] Commitment id ${commitments.id} already exists, it will be overwritten`)\n }\n registeredCommitments[commitments.id] = commitments\n}\n\nexport function addTemporaryCommitment<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(commitment: TCommitment[] | TCommitment) {\n if (!Array.isArray(commitment)) {\n commitment = [commitment]\n }\n let commitmentsIds = commitment.map(commitment => {\n let commitmentTest = getCommitmentById(commitment.id)\n if (!commitmentTest) {\n console.warn(`[NQTR] Commitment ${commitment.id} not found, it will be ignored`)\n return undefined\n }\n return commitment.id\n }).filter(id => id !== undefined)\n\n GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, [commitmentsIds])\n}\n\nexport function getFixedCommitments<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[] {\n return Object.values(fixedCommitments) as TCommitment[]\n}\n\nexport function getTemporaryCommitments<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[] {\n let commitmentsIds = GameStorageManager.getVariable<string[]>(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY)\n if (!commitmentsIds) {\n return []\n }\n let commitments = commitmentsIds.map(id => getCommitmentById<TCommitment>(id)).filter(commitment => commitment !== undefined)\n return commitments as TCommitment[]\n}\n","import { CharacterBaseModel } from \"@drincs/pixi-vn\";\nimport CommitmentBaseModel from \"../classes/Commitment\";\nimport { getFixedCommitments, getTemporaryCommitments } from \"../decorators\";\nimport { registeredCommitments } from \"../decorators/CommitmentDecorator\";\n\nexport function clearExpiredRoutine() {\n Object.entries(registeredCommitments).forEach(([_, commitment]) => {\n if (commitment.isExpired()) {\n delete registeredCommitments[commitment.id]\n }\n })\n}\n\nexport function getCurrentCommitments<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[] {\n let character_commitments: { [character: string]: TCommitment } = {}\n let oltherCommitments: TCommitment[] = []\n getTemporaryCommitments<TCommitment>().reverse().forEach(c => {\n if (!c.hidden) {\n if (c.characters.length > 1) {\n // all the characters don't already have commitments\n let allAvailable = c.characters.every(ch => !character_commitments[ch.id])\n if (allAvailable) {\n c.characters.forEach(ch => {\n character_commitments[ch.id] = c\n })\n }\n }\n else {\n oltherCommitments.push(c)\n }\n }\n })\n getFixedCommitments<TCommitment>().reverse().forEach(c => {\n if (!c.hidden) {\n if (c.characters.length > 1) {\n c.characters.forEach(ch => {\n if (!character_commitments[ch.id]) {\n character_commitments[ch.id] = c\n }\n })\n }\n else {\n oltherCommitments.push(c)\n }\n }\n })\n return Object.values(character_commitments).concat(oltherCommitments)\n}\n\nexport function getCommitmentByCharacter<TCommitment extends CommitmentBaseModel = CommitmentBaseModel, TCharacter extends CharacterBaseModel = CharacterBaseModel>(character: TCharacter): TCommitment | undefined {\n getCurrentCommitments().forEach(c => {\n if (c.characters.map(ch => ch.id).includes(character.id)) {\n return c\n }\n })\n return undefined\n}\n","import { OnRunActivityProps } from '@drincs/nqtr/dist/override';\nimport { getFlag } from \"@drincs/pixi-vn\";\nimport TimeManager from \"../managers/TimeManager\";\nimport { OnRenderGraphicItemProps } from '../override';\nimport GraphicItemType from \"../override/GraphicItem\";\n\nexport interface ActivityProps {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into hours 1 and 2, and will be shown from hour 3.\n * @default TimeManager.minDayHours\n */\n fromHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n * If you set 3, the activity will be shown into hours 1 and 2 and will be hidden from hour 3.\n * @default TimeManager.maxDayHours + 1\n */\n toHour?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into days 1 and 2, and will be shown from day 3.\n * @default undefined\n */\n fromDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n * If you set 3, the activity will be shown into days 1 and 2 and will be deleted or hidden from day 3.\n * @default undefined\n */\n toDay?: number\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 renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType)\n}\n\n/**\n * The function that is called when the activity is runned.\n */\nexport type OnRunActivityEvent<T> = (activity: T, props?: OnRunActivityProps) => void\n\nexport abstract class ActivityStoredAbstract {\n /**\n * @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.\n * @param props The activity properties.\n */\n constructor(onRun: OnRunActivityEvent<ActivityStoredAbstract>, props: ActivityProps) {\n this.defaultName = props.name\n this.defaultFromHour = props.fromHour\n this.defaultToHour = props.toHour\n this.defaultFromDay = props.fromDay\n this.defaultToDay = props.toDay\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n abstract setStorageProperty<T>(propertyName: string, value: T | undefined): void;\n abstract getStorageProperty<T>(propertyName: string): T | undefined;\n abstract get id(): string\n\n private defaultName?: string\n /**\n * The 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 defaultFromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number {\n return this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour || TimeManager.minDayHours\n }\n set fromHour(value: number | undefined) {\n this.setStorageProperty(\"fromHour\", value)\n }\n\n private defaultToHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number {\n return this.getStorageProperty<number>(\"toHour\") || this.defaultToHour || (TimeManager.maxDayHours + 1)\n }\n set toHour(value: number | undefined) {\n this.setStorageProperty(\"toHour\", value)\n }\n\n private defaultFromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay\n }\n set fromDay(value: number | undefined) {\n this.setStorageProperty(\"fromDay\", value)\n }\n\n private defaultToDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this.getStorageProperty<number>(\"toDay\") || this.defaultToDay\n }\n set toDay(value: number | undefined) {\n this.setStorageProperty(\"toDay\", value)\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled.\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 the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {\n return true\n }\n if (!this.isExpired) {\n return true\n }\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 _renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n return this._renderIcon as ((props: OnRenderGraphicItemProps) => GraphicItemType)\n }\n\n private _onRun: (activity: ActivityStoredAbstract, props?: OnRunActivityProps) => void\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isExpired(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this.getStorageProperty<string>(\"name\") || this.defaultName,\n fromHour: this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour,\n toHour: this.getStorageProperty<number>(\"toHour\") || this.defaultToHour,\n fromDay: this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay,\n toDay: this.getStorageProperty<number>(\"toDay\") || this.defaultToDay,\n disabled: this.getStorageProperty<boolean>(\"disabled\") || this.defaultDisabled,\n hidden: this.getStorageProperty<boolean>(\"hidden\") || this.defaultHidden,\n renderIcon: this._renderIcon\n }\n }\n}\n\n/**\n * The activity model.\n */\nexport default class ActivityModel {\n /**\n * @param id The activity id, that must be unique.\n * @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.\n * @param props The activity properties.\n */\n constructor(id: string, onRun: OnRunActivityEvent<ActivityModel>, props: ActivityProps) {\n this._id = id\n this._name = props.name\n this._fromHour = props.fromHour\n this._toHour = props.toHour\n this._fromDay = props.fromDay\n this._toDay = props.toDay\n this._disabled = props.disabled || false\n this._hidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n private _id: string\n /**\n * The activity id, that is unique.\n */\n get id(): string {\n return this._id\n }\n\n private _name?: string\n /**\n * The name\n */\n get name(): string | undefined {\n return this._name\n }\n\n private _fromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number | undefined {\n return this._fromHour\n }\n\n private _toHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number | undefined {\n return this._toHour\n }\n\n private _fromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this._fromDay\n }\n\n private _toDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this._toDay\n }\n\n private _disabled?: boolean | string\n /**\n * Whether is disabled.\n */\n get disabled(): boolean | undefined {\n if (typeof this._disabled === \"string\") {\n return getFlag(this._disabled)\n }\n return this._disabled\n }\n\n private _hidden: boolean | string\n /**\n * Whether is hidden. If the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!this.isDeadline) {\n return true\n }\n if (typeof this._hidden === \"string\") {\n return getFlag(this._hidden)\n }\n return this._hidden\n }\n\n private _renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n return this._renderIcon as ((props: OnRenderGraphicItemProps) => GraphicItemType)\n }\n\n private _onRun: OnRunActivityEvent<ActivityModel>\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isDeadline(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this._name,\n fromHour: this._fromHour,\n toHour: this._toHour,\n fromDay: this._fromDay,\n toDay: this._toDay,\n disabled: this._disabled,\n hidden: this._hidden,\n renderIcon: this._renderIcon,\n }\n }\n}\n","import { GameStorageManager } from \"@drincs/pixi-vn\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nconst TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nconst TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\ntype ITimeData = {\n currentHour?: number\n currentDay?: number\n}\n\nexport default class TimeManager {\n private constructor() { }\n private static editSettings(settings: TimeSettings) {\n let data: any = {}\n if (typeof settings.minDayHours === 'number') {\n data['minDayHours'] = settings.minDayHours\n }\n if (typeof settings.maxDayHours === 'number') {\n data['maxDayHours'] = settings.maxDayHours\n }\n if (typeof settings.minDayHours === 'number') {\n data['defaultTimeSpent'] = settings.defaultTimeSpent\n }\n if (Array.isArray(settings.timeSlots)) {\n data['timeSlots'] = settings.timeSlots\n }\n if (typeof settings.weekLength === 'number') {\n data['weekLength'] = settings.weekLength\n }\n if (typeof settings.weekendStartDay === 'number') {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekendStartDay >= weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`)\n }\n data['weekendStartDay'] = settings.weekendStartDay\n }\n if (Array.isArray(settings.weekDaysNames)) {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`)\n }\n data['weekDaysNames'] = settings.weekDaysNames\n }\n GameStorageManager.setVariable(TIME_SETTINGS_KEY, data)\n }\n /**\n * Get time settings\n * @default {}\n */\n static get settings(): TimeSettings {\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY) || {}\n return settings\n }\n /**\n * Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.\n */\n static set settings(value: TimeSettings) {\n TimeManager.editSettings(value)\n }\n static get minDayHours(): number {\n let result = 0\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('minDayHours')) {\n result = settings.minDayHours || 0\n }\n return result\n }\n static get maxDayHours(): number {\n let result = 24\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('maxDayHours')) {\n result = settings.maxDayHours || 24\n }\n return result\n }\n static get defaultTimeSpent(): number {\n let result = 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('defaultTimeSpent')) {\n result = settings.defaultTimeSpent || 1\n }\n return result\n }\n static get timeSlots(): ITimeStlot[] {\n let result: ITimeStlot[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('timeSlots')) {\n result = settings.timeSlots || []\n }\n return result\n }\n static get weekLength(): number {\n let result = 7\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekLength')) {\n result = settings.weekLength || 7\n }\n return result\n }\n static get weekendStartDay(): number {\n let result = TimeManager.weekLength - 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekendStartDay')) {\n result = settings.weekendStartDay || TimeManager.weekLength - 1\n }\n return result\n }\n static get weekDaysNames(): string[] {\n let result: string[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekDaysNames')) {\n result = settings.weekDaysNames || result\n }\n return result\n }\n\n /**\n * Get the current hour\n */\n static get currentHour(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return TimeManager.minDayHours\n }\n static set currentHour(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n GameStorageManager.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n static get currentDay(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n static set currentDay(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n GameStorageManager.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * If the current day is greater than or equal to the weekend start day, then it will return true.\n */\n static get isWeekend(): boolean {\n return TimeManager.currentWeekDayNumber >= TimeManager.weekendStartDay\n }\n /**\n * Get the current week day number (1-TimeManager.weekLength).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n static get currentWeekDayNumber(): number {\n let result = TimeManager.currentDay % TimeManager.weekLength\n return result + 1\n }\n /**\n * Get the current week day name. If the week days names are not defined, then it will return undefined.\n * For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.\n * @default \"\"\n */\n static get currentDayName(): string {\n let weekDayNumber = TimeManager.currentWeekDayNumber - 1\n if (weekDayNumber >= TimeManager.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, TimeManager.weekDaysNames)\n return \"\"\n }\n return TimeManager.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current TimeManager.timeSlots index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```ts\n * import { TimeManager } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-${TimeManager.currentTimeSlot}.png`} />\n * )\n * }\n */\n static get currentTimeSlot(): number {\n if (TimeManager.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < TimeManager.timeSlots.length; index++) {\n let slot = TimeManager.timeSlots[index]\n if (TimeManager.timeSlots.length > index + 1) {\n if (TimeManager.nowIsBetween(slot.startHour, TimeManager.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return TimeManager.timeSlots.length - 1\n }\n\n /**\n * This function will increase the current hour by the given time spent.\n * If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.\n * @param timeSpent is the time spent in hours (default: TimeManager.defaultTimeSpent)\n * @returns TimeManager.currentHour\n */\n static increaseHour(timeSpent: number = TimeManager.defaultTimeSpent): number {\n let newHour = TimeManager.currentHour + timeSpent\n if (newHour >= TimeManager.maxDayHours) {\n TimeManager.increaseDay()\n newHour = TimeManager.minDayHours + (newHour - TimeManager.maxDayHours)\n }\n TimeManager.currentHour = newHour\n return TimeManager.currentHour\n }\n\n /**\n * This function will increase the current day by the given days.\n * @param newDayHour is the hour of the new day (default: TimeManager.minDayHours)\n * @param days is the number of days to increase (default: 1)\n * @returns TimeManager.currentDay\n */\n static increaseDay(newDayHour: number = TimeManager.minDayHours, days: number = 1): number {\n let newDay = TimeManager.currentDay + days\n TimeManager.currentDay = newDay\n TimeManager.currentHour = newDayHour\n return TimeManager.currentDay\n }\n\n /**\n * This function will check if the current hour is between the given hours.\n * @param fromHour the starting hour. If the TimeManager.currentHour is equal to this hour, the function will return true.\n * @param toHour the ending hour.\n * @returns true if the current hour is between the given hours, otherwise false.\n */\n static nowIsBetween(fromHour: number, toHour: number): boolean {\n let currentHour = TimeManager.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n","import { ActivityRoom } from \"../classes/navigation/ActivityRoom\"\nimport { registeredRooms } from \"../decorators/RoomDecorator\"\nimport { getCurrentRoom } from \"./NavigationFunctions\"\n\nexport function clearExpiredActivities() {\n Object.entries(registeredRooms).forEach(([_, room]) => {\n room.clearExpiredActivities()\n })\n}\n\nexport function currentActivities(): ActivityRoom[] {\n let currentRoom = getCurrentRoom()\n if (!currentRoom) {\n return []\n }\n return currentRoom.activities.filter(activity => !activity.hidden)\n}\n"]}
1
+ {"version":3,"sources":["../../src/decorators/RoomDecorator.ts","../../src/functions/NavigationFunctions.ts","../../src/classes/navigation/Location.ts","../../src/classes/navigation/Map.ts","../../src/classes/navigation/Room.ts","../../src/decorators/CommitmentDecorator.ts","../../src/functions/RoutineFunctions.ts","../../src/classes/Activity.ts","../../src/managers/TimeManager.ts","../../src/functions/ActivityFunctions.ts"],"names":["GameStorageManager","getFlag","StoredClassModel"],"mappings":";AAEO,IAAM,kBAAmD,CAAC;AAuB1D,SAAS,YAAyD,IAA+B;AACpG,MAAI;AACA,QAAI,OAAO,gBAAgB,EAAE;AAC7B,QAAI,CAAC,MAAM;AACP,cAAQ,MAAM,eAAe,EAAE,YAAY;AAC3C;AAAA,IACJ;AACA,WAAO;AAAA,EACX,SACO,GAAG;AACN,YAAQ,MAAM,mCAAmC,EAAE,IAAI,CAAC;AACxD;AAAA,EACJ;AACJ;AAOO,SAAS,mBAAgE,UAAsC;AAClH,SAAO,OAAO,OAAO,eAAe,EAAE,OAAO,UAAQ,KAAK,SAAS,OAAO,SAAS,EAAE;AACzF;;;AC/CA,SAAS,sBAAAA,2BAA0B;;;ACAnC,SAAS,SAAS,wBAAwB;AAO1C,IAAM,oBAAoB;AAmC1B,IAAqB,oBAArB,cAAyF,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtG,YAAY,IAAY,KAAW,QAAsC,CAAC,GAAG;AACzE,UAAM,mBAAmB,EAAE;AAC3B,SAAK,cAAc,MAAM,QAAQ;AACjC,SAAK,kBAAkB,MAAM,YAAY;AACzC,SAAK,gBAAgB,MAAM,UAAU;AACrC,SAAK,cAAc,MAAM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A,WAAO;AAAA,EACX,OACK;AACD,QAAI,kBAAkB,YAAY,KAAK,EAAE;AACzC,QAAI,CAAC,iBAAiB;AAClB,cAAQ,MAAM,mBAAmB,KAAK,EAAE,wDAAwD;AAChG;AAAA,IACJ;AAAA,EACJ;AACA,EAAAA,oBAAmB,YAAY,yBAAyB,KAAK,EAAE;AACnE;AAEO,SAAS,iBAAiF;AAC7F,MAAI,SAASA,oBAAmB,YAAoB,uBAAuB;AAC3E,MAAI,CAAC,QAAQ;AACT,YAAQ,MAAM,8CAA8C;AAC5D;AAAA,EACJ;AACA,MAAI,OAAO,YAAmB,MAAM;AACpC,MAAI,CAAC,MAAM;AACP,YAAQ,MAAM,uBAAuB,MAAM,YAAY;AACvD;AAAA,EACJ;AACA,SAAO;AACX;AAEO,SAAS,qBAAqG;AACjH,MAAI,OAAO,eAAyC;AACpD,MAAI,CAAC,MAAM;AACP;AAAA,EACJ;AACA,SAAO,KAAK;AAChB;AAEO,SAAS,gBAA4E;AACxF,MAAI,WAAW,mBAA4C;AAC3D,MAAI,CAAC,UAAU;AACX;AAAA,EACJ;AACA,SAAO,SAAS;AACpB;;;AQjDO,SAAS,yBAAyB;AACrC,SAAO,QAAQ,eAAe,EAAE,QAAQ,CAAC,CAAC,GAAG,IAAI,MAAM;AACnD,SAAK,uBAAuB;AAAA,EAChC,CAAC;AACL;AAEO,SAAS,oBAAoC;AAChD,MAAI,cAAc,eAAe;AACjC,MAAI,CAAC,aAAa;AACd,WAAO,CAAC;AAAA,EACZ;AACA,SAAO,YAAY,WAAW,OAAO,cAAY,CAAC,SAAS,MAAM;AACrE","sourcesContent":["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","import { GameStorageManager } from \"@drincs/pixi-vn\";\nimport { LocationBaseModel, MapBaseModel, RoomBaseModel } from \"../classes/navigation\";\nimport { getRoomById } from \"../decorators/RoomDecorator\";\n\nconst CURRENT_ROOM_MEMORY_KEY = '___nqtr-current_room_memory___';\n\nexport function setCurrentRoom<TRoom extends RoomBaseModel = RoomBaseModel>(room: TRoom | LocationBaseModel) {\n if (room instanceof LocationBaseModel) {\n let entrance = room.getEntrance<TRoom>();\n if (!entrance) {\n console.error(`[NQTR] The location ${room.id} has no entrance room`);\n return;\n }\n room = entrance;\n }\n else {\n let roomRegistrated = getRoomById(room.id);\n if (!roomRegistrated) {\n console.error(`[NQTR] The room ${room.id} is not registered, so it can't be set as current room`);\n return;\n }\n }\n GameStorageManager.setVariable(CURRENT_ROOM_MEMORY_KEY, room.id);\n}\n\nexport function getCurrentRoom<TRoom extends RoomBaseModel = RoomBaseModel>(): TRoom | undefined {\n let roomId = GameStorageManager.getVariable<string>(CURRENT_ROOM_MEMORY_KEY);\n if (!roomId) {\n console.error(`[NQTR] The current room has not yet been set`);\n return\n }\n let room = getRoomById<TRoom>(roomId);\n if (!room) {\n console.error(`[NQTR] Current room ${roomId} not found`);\n return\n }\n return room\n}\n\nexport function getCurrenrLocation<TLocation extends LocationBaseModel = LocationBaseModel>(): TLocation | undefined {\n let room = getCurrentRoom<RoomBaseModel<TLocation>>();\n if (!room) {\n return\n }\n return room.location\n}\n\nexport function getCueerntMap<TMap extends MapBaseModel = MapBaseModel>(): TMap | undefined {\n let location = getCurrenrLocation<LocationBaseModel<TMap>>();\n if (!location) {\n return\n }\n return location.map\n}\n","import { getFlag, StoredClassModel } from \"@drincs/pixi-vn\";\nimport { getRoomsByLocation } from \"../../decorators/RoomDecorator\";\nimport { OnRenderGraphicItemProps } from \"../../override\";\nimport GraphicItemType from \"../../override/GraphicItemType\";\nimport MapBaseModel from \"./Map\";\nimport RoomBaseModel from \"./Room\";\n\nconst LOCATION_CATEGORY = \"__nqtr-location__\"\n\nexport interface LocationBaseModelProps<TMap extends MapBaseModel = MapBaseModel> {\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 renderIcon?: GraphicItemType | ((location: LocationBaseModel<TMap>, props?: OnRenderGraphicItemProps) => 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<TMap> = {}) {\n super(LOCATION_CATEGORY, id)\n this.defaultName = props.name || \"\"\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._renderIcon = props.renderIcon\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 _renderIcon?: GraphicItemType | ((location: LocationBaseModel<TMap>, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the location.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n if (this._renderIcon !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this._renderIcon as any)(this, props)\n }\n }\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 { getFlag, StoredClassModel } from \"@drincs/pixi-vn\"\nimport { getLocationsByMap } from \"../../decorators/RoomDecorator\"\nimport { OnRenderGraphicItemProps } from \"../../override\"\nimport GraphicItemType from \"../../override/GraphicItemType\"\nimport LocationBaseModel from \"./Location\"\n\nconst MAP_CATEGORY = \"__nqtr-map__\"\n\nexport interface MapBaseModelProps {\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 renderImage?: GraphicItemType | ((map: MapBaseModel, props?: OnRenderGraphicItemProps) => GraphicItemType)\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._renderImage = props.renderImage\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 _renderImage?: GraphicItemType | ((map: MapBaseModel, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the image of the map.\n */\n get renderImage(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderImage !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderImage as GraphicItemType\n }\n if (this.renderImage !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this.renderImage as any)(this, props)\n }\n }\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 { getFlag, StoredClassModel } from \"@drincs/pixi-vn\";\nimport { getActivityById } from \"../../decorators\";\nimport { getCurrentCommitments } from \"../../functions/RoutineFunctions\";\nimport { OnRenderGraphicItemProps } from \"../../override\";\nimport GraphicItemType from \"../../override/GraphicItemType\";\nimport ActivityModel, { ActivityProps } from \"../Activity\";\nimport CommitmentBaseModel from \"../Commitment\";\nimport { ActivityRoom } from \"./ActivityRoom\";\nimport LocationBaseModel from \"./Location\";\n\nexport const ROOM_CATEGORY = \"__nqtr-room__\"\n\ninterface RoomActivityMemory { [key: string]: ActivityProps }\n\nexport interface RoomBaseModelProps<TLocation extends LocationBaseModel = LocationBaseModel> {\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 renderImage?: GraphicItemType | ((room: RoomBaseModel<TLocation>, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The activities that are available in this room.\n * @default []\n */\n defaultActivities?: ActivityModel[],\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 renderIcon?: GraphicItemType | ((room: RoomBaseModel<TLocation>, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.\n * @default false\n */\n isEntrance?: boolean\n}\n\n/**\n * The base model of a room. I suggest you extend this class to create your own room model.\n * You must use the saveRoom function to save the room in the registered rooms.\n * @example\n * ```ts\n * export const mcRoom = new RoomBaseModel('mc_room', mcHome, {\n * name: \"MC Room\",\n * icon: \"https://icon.jpg\",\n * image: \"https://image.jpg\",\n * isEntrance: false,\n * })\n * saveRoom(mcRoom)\n * ```\n */\nexport default class RoomBaseModel<TLocation extends LocationBaseModel = LocationBaseModel> extends StoredClassModel {\n /**\n * @param id The id of the room, it must be unique.\n * @param location The location where the room is.\n * @param props The properties of the room.\n */\n constructor(id: string, location: TLocation, props: RoomBaseModelProps<TLocation> = {}) {\n super(ROOM_CATEGORY, id)\n this._location = location\n this.defaultName = props.name || \"\"\n this._renderImage = props.renderImage\n this.defaultActivityIds = props.defaultActivities?.map(activity => activity.id) || []\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._isEntrance = props.isEntrance\n }\n\n private _location: TLocation\n /**\n * The location where the room is.\n */\n get location(): TLocation {\n return this._location\n }\n\n private _isEntrance?: boolean\n /**\n * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.\n */\n get isEntrance(): boolean {\n return this._isEntrance || false\n }\n\n private defaultName: string\n /**\n * The name.\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 _renderImage?: GraphicItemType | ((room: RoomBaseModel<TLocation>, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the image of the room.\n */\n get renderImage(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderImage !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderImage as GraphicItemType\n }\n if (this.renderImage !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this.renderImage as any)(this, props)\n }\n }\n }\n\n private defaultActivityIds: string[]\n /**\n * The activities that are available in this room.\n */\n get defaultActivities(): ActivityRoom<this>[] {\n let roomMemories = this.getStorageProperty<RoomActivityMemory>(\"activities_memory\") || {}\n let activities = this.defaultActivityIds.map(id => {\n let activity = getActivityById(id)\n if (!activity) {\n console.warn(`[NQTR] Activity with id ${id} not found, so it will be ignored.`)\n return undefined\n }\n let memory = activity.export()\n if (roomMemories && roomMemories[id]) {\n memory = {\n ...memory,\n ...roomMemories[id]\n }\n }\n return new ActivityRoom(id, this, activity.onRun, memory)\n }).filter(activity => activity !== undefined)\n return activities as ActivityRoom<this>[]\n }\n\n private get activityIds(): string[] {\n let addedActivityIds = this.getStorageProperty<string[]>(`addedActivityIds`) || []\n return this.defaultActivityIds.concat(addedActivityIds)\n }\n /**\n * The activities that are available in this room.\n */\n get activities(): ActivityRoom<this>[] {\n let activities = this.activityIds.map(id => {\n return this.getActivity(id)\n }).filter(activity => activity !== undefined)\n return activities as ActivityRoom<this>[]\n }\n /**\n * Get the memory of an activity. This function can be used into olther libraries to get the memory of the activity.\n * @param id The id of the activity.\n * @returns The memory of the activity.\n */\n getActivityMemory(id: string): object | undefined {\n let roomMemories = this.getStorageProperty<RoomActivityMemory>(\"activities_memory\") || {}\n let roomMemory = roomMemories[id] || {}\n return roomMemory\n }\n /**\n * Get the activity by id.\n * @param id The id of the activity.\n * @returns The room activity.\n */\n getActivity(id: string): ActivityRoom<this> | undefined {\n if (!this.activityIds.includes(id)) {\n console.error(`[NQTR] Activity with id ${id} not found in room ${this.id}`)\n return undefined\n }\n let activity = getActivityById(id)\n if (!activity) {\n console.error(`[NQTR] Activity with id ${id} not found`)\n return undefined\n }\n let roomMemories = this.getStorageProperty<RoomActivityMemory>(\"activities_memory\") || {}\n let roomMemory = roomMemories[id] || {}\n roomMemory = {\n ...activity.export(),\n ...roomMemory\n }\n return new ActivityRoom(id, this, activity.onRun, roomMemory)\n }\n /**\n * Set the memory of an activity. This function can be used into olther libraries to set the memory of the activity.\n * @param id The id of the activity.\n * @param memory The memory of the activity.\n */\n setActivity(activity: ActivityRoom) {\n let roomMemories = this.getStorageProperty<RoomActivityMemory>(\"activities_memory\") || {}\n roomMemories[activity.id] = activity.export()\n this.setStorageProperty(\"activities_memory\", roomMemories)\n }\n /**\n * Add an activity to the room.\n * @param activity The activity to add.\n */\n addActivity(activity: ActivityModel) {\n if (this.activityIds.includes(activity.id)) {\n let currentActivity = this.getActivity(activity.id)\n if (currentActivity && currentActivity.isExpired()) {\n this.removeActivity(activity.id)\n return\n } else {\n console.error(`[NQTR] Activity with id ${activity.id} already exists in room ${this.id}, so it will be ignored.`)\n return\n }\n }\n let addedActivityIds = this.getStorageProperty<string[]>(`addedActivityIds`) || []\n addedActivityIds.push(activity.id)\n this.setStorageProperty(\"addedActivityIds\", addedActivityIds)\n }\n /**\n * Remove an activity from the room.\n * @param activity The activity to remove.\n */\n removeActivity(activity: ActivityModel | string) {\n let activityId = typeof activity === \"string\" ? activity : activity.id\n if (this.defaultActivityIds.includes(activityId)) {\n console.warn(`[NQTR] Activity with id ${activityId} is a default activity, so it can't be removed. It will be hidden instead.`)\n let activityToEdit = this.getActivity(activityId)\n if (!activityToEdit) {\n console.error(`[NQTR] Activity with id ${activityId} not found, so it can't be hidden.`)\n return\n }\n activityToEdit.hidden = true\n return\n }\n let addedActivityIds = this.getStorageProperty<string[]>(`addedActivityIds`) || []\n let index = addedActivityIds.indexOf(activityId)\n if (index === -1) {\n console.error(`[NQTR] Activity with id ${activityId} not found, so it can't be removed.`)\n return\n }\n addedActivityIds.splice(index, 1)\n this.setStorageProperty(\"addedActivityIds\", addedActivityIds)\n let roomMemories = this.getStorageProperty<RoomActivityMemory>(\"activities_memory\") || {}\n delete roomMemories[activityId]\n this.setStorageProperty(\"activities_memory\", roomMemories)\n }\n /**\n * Clear all expired activities.\n */\n clearExpiredActivities() {\n this.activities.forEach(activity => {\n if (activity.isExpired()) {\n this.removeActivity(activity.id)\n }\n })\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 _renderIcon?: GraphicItemType | ((room: RoomBaseModel<TLocation>, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the room.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n if (this._renderIcon !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this._renderIcon as any)(this, props)\n }\n }\n }\n\n /**\n * Get the character commitments of the room.\n * @returns The character commitments of the room.\n */\n getRoutine<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[] {\n let commitments = getCurrentCommitments<TCommitment>()\n return commitments.filter(c => c.room.id === this.id)\n }\n}\n","import { GameStorageManager } from \"@drincs/pixi-vn\"\nimport CommitmentBaseModel from \"../classes/Commitment\"\n\nconst TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY = \"___nqtr-temporary_commitment___\"\nexport const registeredCommitments: { [id: string]: CommitmentBaseModel } = {}\nexport const fixedCommitments: { [id: string]: CommitmentBaseModel } = {}\n\nexport function saveCommitment<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(commitment: TCommitment | TCommitment[]) {\n if (Array.isArray(commitment)) {\n commitment.forEach(c => saveCommitment(c))\n return\n }\n if (registeredCommitments[commitment.id]) {\n console.warn(`[NQTR] Commitment id ${commitment.id} already exists, it will be overwritten`)\n }\n registeredCommitments[commitment.id] = commitment\n}\n\nexport function getCommitmentById<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(id: string): TCommitment | undefined {\n try {\n let commitment = registeredCommitments[id]\n if (!commitment) {\n console.error(`[NQTR] Commitment ${id} not found`)\n return\n }\n return commitment as TCommitment\n }\n catch (e) {\n console.error(`[NQTR] Error while getting Commitment ${id}`, e)\n return\n }\n}\n\nexport function setFixedCommitments<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(commitments: TCommitment[] | TCommitment) {\n if (Array.isArray(commitments)) {\n commitments.forEach(c => saveCommitment(c))\n return\n }\n if (registeredCommitments[commitments.id]) {\n console.warn(`[NQTR] Commitment id ${commitments.id} already exists, it will be overwritten`)\n }\n registeredCommitments[commitments.id] = commitments\n}\n\nexport function addTemporaryCommitment<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(commitment: TCommitment[] | TCommitment) {\n if (!Array.isArray(commitment)) {\n commitment = [commitment]\n }\n let commitmentsIds = commitment.map(commitment => {\n let commitmentTest = getCommitmentById(commitment.id)\n if (!commitmentTest) {\n console.warn(`[NQTR] Commitment ${commitment.id} not found, it will be ignored`)\n return undefined\n }\n return commitment.id\n }).filter(id => id !== undefined)\n\n GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, [commitmentsIds])\n}\n\nexport function getFixedCommitments<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[] {\n return Object.values(fixedCommitments) as TCommitment[]\n}\n\nexport function getTemporaryCommitments<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[] {\n let commitmentsIds = GameStorageManager.getVariable<string[]>(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY)\n if (!commitmentsIds) {\n return []\n }\n let commitments = commitmentsIds.map(id => getCommitmentById<TCommitment>(id)).filter(commitment => commitment !== undefined)\n return commitments as TCommitment[]\n}\n","import { CharacterBaseModel } from \"@drincs/pixi-vn\";\nimport CommitmentBaseModel from \"../classes/Commitment\";\nimport { getFixedCommitments, getTemporaryCommitments } from \"../decorators\";\nimport { registeredCommitments } from \"../decorators/CommitmentDecorator\";\n\nexport function clearExpiredRoutine() {\n Object.entries(registeredCommitments).forEach(([_, commitment]) => {\n if (commitment.isExpired()) {\n delete registeredCommitments[commitment.id]\n }\n })\n}\n\nexport function getCurrentCommitments<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[] {\n let character_commitments: { [character: string]: TCommitment } = {}\n let oltherCommitments: TCommitment[] = []\n getTemporaryCommitments<TCommitment>().reverse().forEach(c => {\n if (!c.hidden) {\n if (c.characters.length > 1) {\n // all the characters don't already have commitments\n let allAvailable = c.characters.every(ch => !character_commitments[ch.id])\n if (allAvailable) {\n c.characters.forEach(ch => {\n character_commitments[ch.id] = c\n })\n }\n }\n else {\n oltherCommitments.push(c)\n }\n }\n })\n getFixedCommitments<TCommitment>().reverse().forEach(c => {\n if (!c.hidden) {\n if (c.characters.length > 1) {\n c.characters.forEach(ch => {\n if (!character_commitments[ch.id]) {\n character_commitments[ch.id] = c\n }\n })\n }\n else {\n oltherCommitments.push(c)\n }\n }\n })\n return Object.values(character_commitments).concat(oltherCommitments)\n}\n\nexport function getCommitmentByCharacter<TCommitment extends CommitmentBaseModel = CommitmentBaseModel, TCharacter extends CharacterBaseModel = CharacterBaseModel>(character: TCharacter): TCommitment | undefined {\n getCurrentCommitments().forEach(c => {\n if (c.characters.map(ch => ch.id).includes(character.id)) {\n return c\n }\n })\n return undefined\n}\n","import { OnRunActivityProps } from '@drincs/nqtr/dist/override';\nimport { getFlag } from \"@drincs/pixi-vn\";\nimport TimeManager from \"../managers/TimeManager\";\nimport { OnRenderGraphicItemProps } from '../override';\nimport GraphicItemType from \"../override/GraphicItemType\";\n\nexport interface ActivityProps {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into hours 1 and 2, and will be shown from hour 3.\n * @default TimeManager.minDayHours\n */\n fromHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n * If you set 3, the activity will be shown into hours 1 and 2 and will be hidden from hour 3.\n * @default TimeManager.maxDayHours + 1\n */\n toHour?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into days 1 and 2, and will be shown from day 3.\n * @default undefined\n */\n fromDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n * If you set 3, the activity will be shown into days 1 and 2 and will be deleted or hidden from day 3.\n * @default undefined\n */\n toDay?: number\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 renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n}\n\n/**\n * The function that is called when the activity is runned.\n */\nexport type OnRunActivityEvent<T> = (activity: T, props?: OnRunActivityProps) => void\n\nexport abstract class ActivityStoredAbstract {\n /**\n * @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.\n * @param props The activity properties.\n */\n constructor(onRun: OnRunActivityEvent<ActivityStoredAbstract>, props: ActivityProps) {\n this.defaultName = props.name\n this.defaultFromHour = props.fromHour\n this.defaultToHour = props.toHour\n this.defaultFromDay = props.fromDay\n this.defaultToDay = props.toDay\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n abstract setStorageProperty<T>(propertyName: string, value: T | undefined): void;\n abstract getStorageProperty<T>(propertyName: string): T | undefined;\n abstract get id(): string\n\n private defaultName?: string\n /**\n * The 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 defaultFromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number {\n return this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour || TimeManager.minDayHours\n }\n set fromHour(value: number | undefined) {\n this.setStorageProperty(\"fromHour\", value)\n }\n\n private defaultToHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number {\n return this.getStorageProperty<number>(\"toHour\") || this.defaultToHour || (TimeManager.maxDayHours + 1)\n }\n set toHour(value: number | undefined) {\n this.setStorageProperty(\"toHour\", value)\n }\n\n private defaultFromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay\n }\n set fromDay(value: number | undefined) {\n this.setStorageProperty(\"fromDay\", value)\n }\n\n private defaultToDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this.getStorageProperty<number>(\"toDay\") || this.defaultToDay\n }\n set toDay(value: number | undefined) {\n this.setStorageProperty(\"toDay\", value)\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled.\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 the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {\n return true\n }\n if (!this.isExpired) {\n return true\n }\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 _renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n if (this._renderIcon !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this._renderIcon as any)(this, props)\n }\n }\n }\n\n private _onRun: (activity: ActivityStoredAbstract, props?: OnRunActivityProps) => void\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isExpired(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this.getStorageProperty<string>(\"name\") || this.defaultName,\n fromHour: this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour,\n toHour: this.getStorageProperty<number>(\"toHour\") || this.defaultToHour,\n fromDay: this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay,\n toDay: this.getStorageProperty<number>(\"toDay\") || this.defaultToDay,\n disabled: this.getStorageProperty<boolean>(\"disabled\") || this.defaultDisabled,\n hidden: this.getStorageProperty<boolean>(\"hidden\") || this.defaultHidden,\n renderIcon: this._renderIcon\n }\n }\n}\n\n/**\n * The activity model.\n */\nexport default class ActivityModel {\n /**\n * @param id The activity id, that must be unique.\n * @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.\n * @param props The activity properties.\n */\n constructor(id: string, onRun: OnRunActivityEvent<ActivityModel>, props: ActivityProps) {\n this._id = id\n this._name = props.name\n this._fromHour = props.fromHour\n this._toHour = props.toHour\n this._fromDay = props.fromDay\n this._toDay = props.toDay\n this._disabled = props.disabled || false\n this._hidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n private _id: string\n /**\n * The activity id, that is unique.\n */\n get id(): string {\n return this._id\n }\n\n private _name?: string\n /**\n * The name\n */\n get name(): string | undefined {\n return this._name\n }\n\n private _fromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number | undefined {\n return this._fromHour\n }\n\n private _toHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number | undefined {\n return this._toHour\n }\n\n private _fromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this._fromDay\n }\n\n private _toDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this._toDay\n }\n\n private _disabled?: boolean | string\n /**\n * Whether is disabled.\n */\n get disabled(): boolean | undefined {\n if (typeof this._disabled === \"string\") {\n return getFlag(this._disabled)\n }\n return this._disabled\n }\n\n private _hidden: boolean | string\n /**\n * Whether is hidden. If the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!this.isDeadline) {\n return true\n }\n if (typeof this._hidden === \"string\") {\n return getFlag(this._hidden)\n }\n return this._hidden\n }\n\n private _renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n if (this._renderIcon !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this._renderIcon as any)(this, props)\n }\n }\n }\n\n private _onRun: OnRunActivityEvent<ActivityModel>\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isDeadline(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this._name,\n fromHour: this._fromHour,\n toHour: this._toHour,\n fromDay: this._fromDay,\n toDay: this._toDay,\n disabled: this._disabled,\n hidden: this._hidden,\n renderIcon: this._renderIcon,\n }\n }\n}\n","import { GameStorageManager } from \"@drincs/pixi-vn\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nconst TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nconst TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\ntype ITimeData = {\n currentHour?: number\n currentDay?: number\n}\n\nexport default class TimeManager {\n private constructor() { }\n private static editSettings(settings: TimeSettings) {\n let data: any = {}\n if (typeof settings.minDayHours === 'number') {\n data['minDayHours'] = settings.minDayHours\n }\n if (typeof settings.maxDayHours === 'number') {\n data['maxDayHours'] = settings.maxDayHours\n }\n if (typeof settings.minDayHours === 'number') {\n data['defaultTimeSpent'] = settings.defaultTimeSpent\n }\n if (Array.isArray(settings.timeSlots)) {\n data['timeSlots'] = settings.timeSlots\n }\n if (typeof settings.weekLength === 'number') {\n data['weekLength'] = settings.weekLength\n }\n if (typeof settings.weekendStartDay === 'number') {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekendStartDay >= weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`)\n }\n data['weekendStartDay'] = settings.weekendStartDay\n }\n if (Array.isArray(settings.weekDaysNames)) {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`)\n }\n data['weekDaysNames'] = settings.weekDaysNames\n }\n GameStorageManager.setVariable(TIME_SETTINGS_KEY, data)\n }\n /**\n * Get time settings\n * @default {}\n */\n static get settings(): TimeSettings {\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY) || {}\n return settings\n }\n /**\n * Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.\n */\n static set settings(value: TimeSettings) {\n TimeManager.editSettings(value)\n }\n static get minDayHours(): number {\n let result = 0\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('minDayHours')) {\n result = settings.minDayHours || 0\n }\n return result\n }\n static get maxDayHours(): number {\n let result = 24\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('maxDayHours')) {\n result = settings.maxDayHours || 24\n }\n return result\n }\n static get defaultTimeSpent(): number {\n let result = 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('defaultTimeSpent')) {\n result = settings.defaultTimeSpent || 1\n }\n return result\n }\n static get timeSlots(): ITimeStlot[] {\n let result: ITimeStlot[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('timeSlots')) {\n result = settings.timeSlots || []\n }\n return result\n }\n static get weekLength(): number {\n let result = 7\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekLength')) {\n result = settings.weekLength || 7\n }\n return result\n }\n static get weekendStartDay(): number {\n let result = TimeManager.weekLength - 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekendStartDay')) {\n result = settings.weekendStartDay || TimeManager.weekLength - 1\n }\n return result\n }\n static get weekDaysNames(): string[] {\n let result: string[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekDaysNames')) {\n result = settings.weekDaysNames || result\n }\n return result\n }\n\n /**\n * Get the current hour\n */\n static get currentHour(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return TimeManager.minDayHours\n }\n static set currentHour(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n GameStorageManager.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n static get currentDay(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n static set currentDay(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n GameStorageManager.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * If the current day is greater than or equal to the weekend start day, then it will return true.\n */\n static get isWeekend(): boolean {\n return TimeManager.currentWeekDayNumber >= TimeManager.weekendStartDay\n }\n /**\n * Get the current week day number (1-TimeManager.weekLength).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n static get currentWeekDayNumber(): number {\n let result = TimeManager.currentDay % TimeManager.weekLength\n return result + 1\n }\n /**\n * Get the current week day name. If the week days names are not defined, then it will return undefined.\n * For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.\n * @default \"\"\n */\n static get currentDayName(): string {\n let weekDayNumber = TimeManager.currentWeekDayNumber - 1\n if (weekDayNumber >= TimeManager.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, TimeManager.weekDaysNames)\n return \"\"\n }\n return TimeManager.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current TimeManager.timeSlots index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```ts\n * import { TimeManager } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-${TimeManager.currentTimeSlot}.png`} />\n * )\n * }\n */\n static get currentTimeSlot(): number {\n if (TimeManager.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < TimeManager.timeSlots.length; index++) {\n let slot = TimeManager.timeSlots[index]\n if (TimeManager.timeSlots.length > index + 1) {\n if (TimeManager.nowIsBetween(slot.startHour, TimeManager.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return TimeManager.timeSlots.length - 1\n }\n\n /**\n * This function will increase the current hour by the given time spent.\n * If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.\n * @param timeSpent is the time spent in hours (default: TimeManager.defaultTimeSpent)\n * @returns TimeManager.currentHour\n */\n static increaseHour(timeSpent: number = TimeManager.defaultTimeSpent): number {\n let newHour = TimeManager.currentHour + timeSpent\n if (newHour >= TimeManager.maxDayHours) {\n TimeManager.increaseDay()\n newHour = TimeManager.minDayHours + (newHour - TimeManager.maxDayHours)\n }\n TimeManager.currentHour = newHour\n return TimeManager.currentHour\n }\n\n /**\n * This function will increase the current day by the given days.\n * @param newDayHour is the hour of the new day (default: TimeManager.minDayHours)\n * @param days is the number of days to increase (default: 1)\n * @returns TimeManager.currentDay\n */\n static increaseDay(newDayHour: number = TimeManager.minDayHours, days: number = 1): number {\n let newDay = TimeManager.currentDay + days\n TimeManager.currentDay = newDay\n TimeManager.currentHour = newDayHour\n return TimeManager.currentDay\n }\n\n /**\n * This function will check if the current hour is between the given hours.\n * @param fromHour the starting hour. If the TimeManager.currentHour is equal to this hour, the function will return true.\n * @param toHour the ending hour.\n * @returns true if the current hour is between the given hours, otherwise false.\n */\n static nowIsBetween(fromHour: number, toHour: number): boolean {\n let currentHour = TimeManager.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n","import { ActivityRoom } from \"../classes/navigation/ActivityRoom\"\nimport { registeredRooms } from \"../decorators/RoomDecorator\"\nimport { getCurrentRoom } from \"./NavigationFunctions\"\n\nexport function clearExpiredActivities() {\n Object.entries(registeredRooms).forEach(([_, room]) => {\n room.clearExpiredActivities()\n })\n}\n\nexport function currentActivities(): ActivityRoom[] {\n let currentRoom = getCurrentRoom()\n if (!currentRoom) {\n return []\n }\n return currentRoom.activities.filter(activity => !activity.hidden)\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import ActivityModel, { ActivityStoredAbstract, OnRunActivityEvent, ActivityProps } from './classes/Activity.mjs';
2
2
  import { StoredClassModel, CharacterBaseModel } from '@drincs/pixi-vn';
3
3
  import { ExecutionTypeEnum } from './enums/ExecutionTypeEnum.mjs';
4
- import GraphicItemType from './override/GraphicItem.mjs';
4
+ import GraphicItemType from './override/GraphicItemType.mjs';
5
5
  import OnRenderGraphicItemProps from './override/OnRenderGraphicItemProps.mjs';
6
6
 
7
7
  interface MapBaseModelProps {
@@ -24,7 +24,7 @@ interface MapBaseModelProps {
24
24
  * ```
25
25
  * @default undefined
26
26
  */
27
- renderImage?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType);
27
+ renderImage?: GraphicItemType | ((map: MapBaseModel, props?: OnRenderGraphicItemProps) => GraphicItemType);
28
28
  /**
29
29
  * The neighboring maps that are available in this map.
30
30
  * @example
@@ -81,11 +81,11 @@ declare class MapBaseModel extends StoredClassModel {
81
81
  */
82
82
  get name(): string;
83
83
  set name(value: string | undefined);
84
- private _renderImege?;
84
+ private _renderImage?;
85
85
  /**
86
86
  * The function for rendering the image of the map.
87
87
  */
88
- get renderImage(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
88
+ get renderImage(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
89
89
  private defaultDisabled;
90
90
  /**
91
91
  * Whether is disabled. If it is a string, it is a Pixi'VN flag name.
@@ -142,7 +142,7 @@ declare class ActivityRoom<TRoom extends RoomBaseModel = RoomBaseModel> extends
142
142
  }
143
143
 
144
144
  declare const ROOM_CATEGORY = "__nqtr-room__";
145
- interface RoomBaseModelProps {
145
+ interface RoomBaseModelProps<TLocation extends LocationBaseModel = LocationBaseModel> {
146
146
  /**
147
147
  * The name
148
148
  * @default ""
@@ -162,7 +162,7 @@ interface RoomBaseModelProps {
162
162
  * ```
163
163
  * @default undefined
164
164
  */
165
- renderImage?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType);
165
+ renderImage?: GraphicItemType | ((room: RoomBaseModel<TLocation>, props?: OnRenderGraphicItemProps) => GraphicItemType);
166
166
  /**
167
167
  * The activities that are available in this room.
168
168
  * @default []
@@ -182,7 +182,7 @@ interface RoomBaseModelProps {
182
182
  * The icon element. Can be a string or an Element or a Pixi'VN CanvasItem
183
183
  * @default undefined
184
184
  */
185
- renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType);
185
+ renderIcon?: GraphicItemType | ((room: RoomBaseModel<TLocation>, props?: OnRenderGraphicItemProps) => GraphicItemType);
186
186
  /**
187
187
  * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
188
188
  * @default false
@@ -209,7 +209,7 @@ declare class RoomBaseModel<TLocation extends LocationBaseModel = LocationBaseMo
209
209
  * @param location The location where the room is.
210
210
  * @param props The properties of the room.
211
211
  */
212
- constructor(id: string, location: TLocation, props?: RoomBaseModelProps);
212
+ constructor(id: string, location: TLocation, props?: RoomBaseModelProps<TLocation>);
213
213
  private _location;
214
214
  /**
215
215
  * The location where the room is.
@@ -227,11 +227,11 @@ declare class RoomBaseModel<TLocation extends LocationBaseModel = LocationBaseMo
227
227
  */
228
228
  get name(): string;
229
229
  set name(value: string | undefined);
230
- private _renderImege?;
230
+ private _renderImage?;
231
231
  /**
232
232
  * The function for rendering the image of the room.
233
233
  */
234
- get renderImage(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
234
+ get renderImage(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
235
235
  private defaultActivityIds;
236
236
  /**
237
237
  * The activities that are available in this room.
@@ -290,7 +290,7 @@ declare class RoomBaseModel<TLocation extends LocationBaseModel = LocationBaseMo
290
290
  /**
291
291
  * The function for rendering the icon of the room.
292
292
  */
293
- get renderIcon(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
293
+ get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
294
294
  /**
295
295
  * Get the character commitments of the room.
296
296
  * @returns The character commitments of the room.
@@ -298,7 +298,7 @@ declare class RoomBaseModel<TLocation extends LocationBaseModel = LocationBaseMo
298
298
  getRoutine<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[];
299
299
  }
300
300
 
301
- interface LocationBaseModelProps {
301
+ interface LocationBaseModelProps<TMap extends MapBaseModel = MapBaseModel> {
302
302
  /**
303
303
  * The name
304
304
  * @default ""
@@ -318,7 +318,7 @@ interface LocationBaseModelProps {
318
318
  * The icon element. Can be a string or an Element or a Pixi'VN CanvasItem
319
319
  * @default undefined
320
320
  */
321
- renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType);
321
+ renderIcon?: GraphicItemType | ((location: LocationBaseModel<TMap>, props?: OnRenderGraphicItemProps) => GraphicItemType);
322
322
  }
323
323
  /**
324
324
  * The base model of a location. I suggest you extend this class to create your own location model.
@@ -336,7 +336,7 @@ declare class LocationBaseModel<TMap extends MapBaseModel = MapBaseModel> extend
336
336
  * @param map The map where the location is.
337
337
  * @param props The properties of the location.
338
338
  */
339
- constructor(id: string, map: TMap, props?: LocationBaseModelProps);
339
+ constructor(id: string, map: TMap, props?: LocationBaseModelProps<TMap>);
340
340
  private defaultName;
341
341
  /**
342
342
  * The name of the location.
@@ -360,7 +360,7 @@ declare class LocationBaseModel<TMap extends MapBaseModel = MapBaseModel> extend
360
360
  /**
361
361
  * The function for rendering the icon of the location.
362
362
  */
363
- get renderIcon(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
363
+ get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
364
364
  private _map;
365
365
  /**
366
366
  * The map where the location is.
@@ -388,7 +388,7 @@ declare class LocationBaseModel<TMap extends MapBaseModel = MapBaseModel> extend
388
388
  getRooms<TRoom extends RoomBaseModel = RoomBaseModel>(): TRoom[];
389
389
  }
390
390
 
391
- interface CommitmentBaseModelProps {
391
+ interface CommitmentBaseModelProps<TCharacter extends CharacterBaseModel = CharacterBaseModel, TRoom extends RoomBaseModel = RoomBaseModel> {
392
392
  /**
393
393
  * The name
394
394
  * @default ""
@@ -432,7 +432,7 @@ interface CommitmentBaseModelProps {
432
432
  * ```
433
433
  * @default undefined
434
434
  */
435
- renderImage?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType);
435
+ renderImage?: GraphicItemType | ((commitment: CommitmentBaseModel<TCharacter, TRoom>, props?: OnRenderGraphicItemProps) => GraphicItemType);
436
436
  /**
437
437
  * Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
438
438
  * @default ExecutionTypeEnum.INTERACTION
@@ -480,7 +480,7 @@ declare class CommitmentBaseModel<TCharacter extends CharacterBaseModel = Charac
480
480
  * @param room The room where the commitment is.
481
481
  * @param props The properties of the commitment.
482
482
  */
483
- constructor(id: string, character: TCharacter | TCharacter[] | undefined, room: TRoom, props: CommitmentBaseModelProps);
483
+ constructor(id: string, character: TCharacter | TCharacter[] | undefined, room: TRoom, props: CommitmentBaseModelProps<TCharacter, TRoom>);
484
484
  private _characters;
485
485
  /**
486
486
  * The character or characters that are in the commitment and so in the room.
@@ -528,7 +528,7 @@ declare class CommitmentBaseModel<TCharacter extends CharacterBaseModel = Charac
528
528
  /**
529
529
  * The function for rendering the image of the room.
530
530
  */
531
- get renderImage(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
531
+ get renderImage(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
532
532
  private _executionType;
533
533
  /**
534
534
  * Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
@@ -1,7 +1,7 @@
1
1
  import ActivityModel, { ActivityStoredAbstract, OnRunActivityEvent, ActivityProps } from './classes/Activity.js';
2
2
  import { StoredClassModel, CharacterBaseModel } from '@drincs/pixi-vn';
3
3
  import { ExecutionTypeEnum } from './enums/ExecutionTypeEnum.js';
4
- import GraphicItemType from './override/GraphicItem.js';
4
+ import GraphicItemType from './override/GraphicItemType.js';
5
5
  import OnRenderGraphicItemProps from './override/OnRenderGraphicItemProps.js';
6
6
 
7
7
  interface MapBaseModelProps {
@@ -24,7 +24,7 @@ interface MapBaseModelProps {
24
24
  * ```
25
25
  * @default undefined
26
26
  */
27
- renderImage?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType);
27
+ renderImage?: GraphicItemType | ((map: MapBaseModel, props?: OnRenderGraphicItemProps) => GraphicItemType);
28
28
  /**
29
29
  * The neighboring maps that are available in this map.
30
30
  * @example
@@ -81,11 +81,11 @@ declare class MapBaseModel extends StoredClassModel {
81
81
  */
82
82
  get name(): string;
83
83
  set name(value: string | undefined);
84
- private _renderImege?;
84
+ private _renderImage?;
85
85
  /**
86
86
  * The function for rendering the image of the map.
87
87
  */
88
- get renderImage(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
88
+ get renderImage(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
89
89
  private defaultDisabled;
90
90
  /**
91
91
  * Whether is disabled. If it is a string, it is a Pixi'VN flag name.
@@ -142,7 +142,7 @@ declare class ActivityRoom<TRoom extends RoomBaseModel = RoomBaseModel> extends
142
142
  }
143
143
 
144
144
  declare const ROOM_CATEGORY = "__nqtr-room__";
145
- interface RoomBaseModelProps {
145
+ interface RoomBaseModelProps<TLocation extends LocationBaseModel = LocationBaseModel> {
146
146
  /**
147
147
  * The name
148
148
  * @default ""
@@ -162,7 +162,7 @@ interface RoomBaseModelProps {
162
162
  * ```
163
163
  * @default undefined
164
164
  */
165
- renderImage?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType);
165
+ renderImage?: GraphicItemType | ((room: RoomBaseModel<TLocation>, props?: OnRenderGraphicItemProps) => GraphicItemType);
166
166
  /**
167
167
  * The activities that are available in this room.
168
168
  * @default []
@@ -182,7 +182,7 @@ interface RoomBaseModelProps {
182
182
  * The icon element. Can be a string or an Element or a Pixi'VN CanvasItem
183
183
  * @default undefined
184
184
  */
185
- renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType);
185
+ renderIcon?: GraphicItemType | ((room: RoomBaseModel<TLocation>, props?: OnRenderGraphicItemProps) => GraphicItemType);
186
186
  /**
187
187
  * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
188
188
  * @default false
@@ -209,7 +209,7 @@ declare class RoomBaseModel<TLocation extends LocationBaseModel = LocationBaseMo
209
209
  * @param location The location where the room is.
210
210
  * @param props The properties of the room.
211
211
  */
212
- constructor(id: string, location: TLocation, props?: RoomBaseModelProps);
212
+ constructor(id: string, location: TLocation, props?: RoomBaseModelProps<TLocation>);
213
213
  private _location;
214
214
  /**
215
215
  * The location where the room is.
@@ -227,11 +227,11 @@ declare class RoomBaseModel<TLocation extends LocationBaseModel = LocationBaseMo
227
227
  */
228
228
  get name(): string;
229
229
  set name(value: string | undefined);
230
- private _renderImege?;
230
+ private _renderImage?;
231
231
  /**
232
232
  * The function for rendering the image of the room.
233
233
  */
234
- get renderImage(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
234
+ get renderImage(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
235
235
  private defaultActivityIds;
236
236
  /**
237
237
  * The activities that are available in this room.
@@ -290,7 +290,7 @@ declare class RoomBaseModel<TLocation extends LocationBaseModel = LocationBaseMo
290
290
  /**
291
291
  * The function for rendering the icon of the room.
292
292
  */
293
- get renderIcon(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
293
+ get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
294
294
  /**
295
295
  * Get the character commitments of the room.
296
296
  * @returns The character commitments of the room.
@@ -298,7 +298,7 @@ declare class RoomBaseModel<TLocation extends LocationBaseModel = LocationBaseMo
298
298
  getRoutine<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[];
299
299
  }
300
300
 
301
- interface LocationBaseModelProps {
301
+ interface LocationBaseModelProps<TMap extends MapBaseModel = MapBaseModel> {
302
302
  /**
303
303
  * The name
304
304
  * @default ""
@@ -318,7 +318,7 @@ interface LocationBaseModelProps {
318
318
  * The icon element. Can be a string or an Element or a Pixi'VN CanvasItem
319
319
  * @default undefined
320
320
  */
321
- renderIcon?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType);
321
+ renderIcon?: GraphicItemType | ((location: LocationBaseModel<TMap>, props?: OnRenderGraphicItemProps) => GraphicItemType);
322
322
  }
323
323
  /**
324
324
  * The base model of a location. I suggest you extend this class to create your own location model.
@@ -336,7 +336,7 @@ declare class LocationBaseModel<TMap extends MapBaseModel = MapBaseModel> extend
336
336
  * @param map The map where the location is.
337
337
  * @param props The properties of the location.
338
338
  */
339
- constructor(id: string, map: TMap, props?: LocationBaseModelProps);
339
+ constructor(id: string, map: TMap, props?: LocationBaseModelProps<TMap>);
340
340
  private defaultName;
341
341
  /**
342
342
  * The name of the location.
@@ -360,7 +360,7 @@ declare class LocationBaseModel<TMap extends MapBaseModel = MapBaseModel> extend
360
360
  /**
361
361
  * The function for rendering the icon of the location.
362
362
  */
363
- get renderIcon(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
363
+ get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
364
364
  private _map;
365
365
  /**
366
366
  * The map where the location is.
@@ -388,7 +388,7 @@ declare class LocationBaseModel<TMap extends MapBaseModel = MapBaseModel> extend
388
388
  getRooms<TRoom extends RoomBaseModel = RoomBaseModel>(): TRoom[];
389
389
  }
390
390
 
391
- interface CommitmentBaseModelProps {
391
+ interface CommitmentBaseModelProps<TCharacter extends CharacterBaseModel = CharacterBaseModel, TRoom extends RoomBaseModel = RoomBaseModel> {
392
392
  /**
393
393
  * The name
394
394
  * @default ""
@@ -432,7 +432,7 @@ interface CommitmentBaseModelProps {
432
432
  * ```
433
433
  * @default undefined
434
434
  */
435
- renderImage?: GraphicItemType | ((props: OnRenderGraphicItemProps) => GraphicItemType);
435
+ renderImage?: GraphicItemType | ((commitment: CommitmentBaseModel<TCharacter, TRoom>, props?: OnRenderGraphicItemProps) => GraphicItemType);
436
436
  /**
437
437
  * Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
438
438
  * @default ExecutionTypeEnum.INTERACTION
@@ -480,7 +480,7 @@ declare class CommitmentBaseModel<TCharacter extends CharacterBaseModel = Charac
480
480
  * @param room The room where the commitment is.
481
481
  * @param props The properties of the commitment.
482
482
  */
483
- constructor(id: string, character: TCharacter | TCharacter[] | undefined, room: TRoom, props: CommitmentBaseModelProps);
483
+ constructor(id: string, character: TCharacter | TCharacter[] | undefined, room: TRoom, props: CommitmentBaseModelProps<TCharacter, TRoom>);
484
484
  private _characters;
485
485
  /**
486
486
  * The character or characters that are in the commitment and so in the room.
@@ -528,7 +528,7 @@ declare class CommitmentBaseModel<TCharacter extends CharacterBaseModel = Charac
528
528
  /**
529
529
  * The function for rendering the image of the room.
530
530
  */
531
- get renderImage(): ((props: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
531
+ get renderImage(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined;
532
532
  private _executionType;
533
533
  /**
534
534
  * Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.