@drincs/nqtr 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +422 -125
- package/dist/index.d.ts +422 -125
- package/dist/index.js +382 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +374 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
35
35
|
var src_exports = {};
|
|
36
36
|
__export(src_exports, {
|
|
37
37
|
ActivityModel: () => ActivityModel,
|
|
38
|
+
CommitmentBaseModel: () => CommitmentBaseModel,
|
|
38
39
|
ExecutionTypeEnum: () => ExecutionTypeEnum,
|
|
39
40
|
Goal: () => Goal,
|
|
40
41
|
LocationBaseModel: () => LocationBaseModel,
|
|
@@ -48,6 +49,8 @@ __export(src_exports, {
|
|
|
48
49
|
clearExpiredRoutine: () => clearExpiredRoutine,
|
|
49
50
|
currentActivities: () => currentActivities,
|
|
50
51
|
getActivityById: () => getActivityById,
|
|
52
|
+
getAllLocations: () => getAllLocations,
|
|
53
|
+
getAllMaps: () => getAllMaps,
|
|
51
54
|
getCommitmentByCharacter: () => getCommitmentByCharacter,
|
|
52
55
|
getCommitmentById: () => getCommitmentById,
|
|
53
56
|
getCueerntMap: () => getCueerntMap,
|
|
@@ -320,7 +323,7 @@ var ActivityStoredAbstract = class {
|
|
|
320
323
|
this.defaultToDay = props.toDay;
|
|
321
324
|
this.defaultDisabled = props.disabled || false;
|
|
322
325
|
this.defaultHidden = props.hidden || false;
|
|
323
|
-
this.
|
|
326
|
+
this._icon = props.icon;
|
|
324
327
|
this._onRun = onRun;
|
|
325
328
|
}
|
|
326
329
|
get name() {
|
|
@@ -382,8 +385,8 @@ var ActivityStoredAbstract = class {
|
|
|
382
385
|
set hidden(value) {
|
|
383
386
|
this.setStorageProperty("hidden", value);
|
|
384
387
|
}
|
|
385
|
-
get
|
|
386
|
-
return this.
|
|
388
|
+
get icon() {
|
|
389
|
+
return this._icon;
|
|
387
390
|
}
|
|
388
391
|
get onRun() {
|
|
389
392
|
return this._onRun;
|
|
@@ -403,7 +406,7 @@ var ActivityStoredAbstract = class {
|
|
|
403
406
|
toDay: this.getStorageProperty("toDay") || this.defaultToDay,
|
|
404
407
|
disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
|
|
405
408
|
hidden: this.getStorageProperty("hidden") || this.defaultHidden,
|
|
406
|
-
|
|
409
|
+
icon: this._icon
|
|
407
410
|
};
|
|
408
411
|
}
|
|
409
412
|
};
|
|
@@ -417,7 +420,7 @@ var ActivityModel = class {
|
|
|
417
420
|
this._toDay = props.toDay;
|
|
418
421
|
this._disabled = props.disabled || false;
|
|
419
422
|
this._hidden = props.hidden || false;
|
|
420
|
-
this.
|
|
423
|
+
this._icon = props.icon;
|
|
421
424
|
this._onRun = onRun;
|
|
422
425
|
}
|
|
423
426
|
get id() {
|
|
@@ -456,8 +459,8 @@ var ActivityModel = class {
|
|
|
456
459
|
}
|
|
457
460
|
return this._hidden;
|
|
458
461
|
}
|
|
459
|
-
get
|
|
460
|
-
return this.
|
|
462
|
+
get icon() {
|
|
463
|
+
return this._icon;
|
|
461
464
|
}
|
|
462
465
|
get onRun() {
|
|
463
466
|
return this._onRun;
|
|
@@ -477,14 +480,175 @@ var ActivityModel = class {
|
|
|
477
480
|
toDay: this._toDay,
|
|
478
481
|
disabled: this._disabled,
|
|
479
482
|
hidden: this._hidden,
|
|
480
|
-
|
|
483
|
+
icon: this._icon
|
|
481
484
|
};
|
|
482
485
|
}
|
|
483
486
|
};
|
|
484
487
|
|
|
485
|
-
// src/classes/
|
|
488
|
+
// src/classes/Commitment.ts
|
|
486
489
|
var import_pixi_vn3 = require("@drincs/pixi-vn");
|
|
487
490
|
|
|
491
|
+
// src/enums/ExecutionTypeEnum.ts
|
|
492
|
+
var ExecutionTypeEnum = /* @__PURE__ */ ((ExecutionTypeEnum2) => {
|
|
493
|
+
ExecutionTypeEnum2["AUTOMATIC"] = "automatic";
|
|
494
|
+
ExecutionTypeEnum2["INTERACTION"] = "interaction";
|
|
495
|
+
return ExecutionTypeEnum2;
|
|
496
|
+
})(ExecutionTypeEnum || {});
|
|
497
|
+
|
|
498
|
+
// src/classes/Commitment.ts
|
|
499
|
+
var COMMITMENT_CATEGORY = "__nqtr-commitment__";
|
|
500
|
+
var CommitmentBaseModel = class extends import_pixi_vn3.StoredClassModel {
|
|
501
|
+
/**
|
|
502
|
+
* @param id The id of the commitment, it must be unique.
|
|
503
|
+
* @param character The character or characters that are in the commitment and so in the room.
|
|
504
|
+
* @param room The room where the commitment is.
|
|
505
|
+
* @param props The properties of the commitment.
|
|
506
|
+
*/
|
|
507
|
+
constructor(id, character, room, props) {
|
|
508
|
+
super(COMMITMENT_CATEGORY, id);
|
|
509
|
+
this._characters = character ? Array.isArray(character) ? character : [character] : [];
|
|
510
|
+
this._room = room;
|
|
511
|
+
this._name = props.name || "";
|
|
512
|
+
this.defaultFromHour = props.fromHour;
|
|
513
|
+
this.defaultToHour = props.toHour;
|
|
514
|
+
this.defaultFromDay = props.fromDay;
|
|
515
|
+
this.defaultToDay = props.toDay;
|
|
516
|
+
this._image = props.image;
|
|
517
|
+
this._executionType = props.executionType || "interaction" /* INTERACTION */;
|
|
518
|
+
this._onRun = props.onRun;
|
|
519
|
+
this.defaultDisabled = props.disabled || false;
|
|
520
|
+
this.defaultHidden = props.hidden || false;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* The character or characters that are in the commitment and so in the room.
|
|
524
|
+
*/
|
|
525
|
+
get characters() {
|
|
526
|
+
return this._characters;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* The room where the commitment is.
|
|
530
|
+
*/
|
|
531
|
+
get room() {
|
|
532
|
+
return this._room;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* The name
|
|
536
|
+
*/
|
|
537
|
+
get name() {
|
|
538
|
+
return this._name;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* The hour when the commitment starts. If the commitment is not started yet, it will be hidden.
|
|
542
|
+
* If you set undefined, it will return the initial value of fromHour.
|
|
543
|
+
*/
|
|
544
|
+
get fromHour() {
|
|
545
|
+
return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
|
|
546
|
+
}
|
|
547
|
+
set fromHour(value) {
|
|
548
|
+
this.setStorageProperty("fromHour", value);
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* The hour when the commitment ends. If the commitment is ended yet, it will be hidden.
|
|
552
|
+
* If you set undefined, it will return the initial value of toHour.
|
|
553
|
+
*/
|
|
554
|
+
get toHour() {
|
|
555
|
+
return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
|
|
556
|
+
}
|
|
557
|
+
set toHour(value) {
|
|
558
|
+
this.setStorageProperty("toHour", value);
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* The day when the commitment starts. If the commitment is not started yet, it will be hidden.
|
|
562
|
+
* If you set undefined, it will return the initial value of fromDay.
|
|
563
|
+
*/
|
|
564
|
+
get fromDay() {
|
|
565
|
+
return this.getStorageProperty("fromDay") || this.defaultFromDay;
|
|
566
|
+
}
|
|
567
|
+
set fromDay(value) {
|
|
568
|
+
this.setStorageProperty("fromDay", value);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* The day when the commitment ends. If the commitment is ended yet, it will be deleted or hidden.
|
|
572
|
+
* If you set undefined, it will return the initial value of toDay.
|
|
573
|
+
*/
|
|
574
|
+
get toDay() {
|
|
575
|
+
return this.getStorageProperty("toDay") || this.defaultToDay;
|
|
576
|
+
}
|
|
577
|
+
set toDay(value) {
|
|
578
|
+
this.setStorageProperty("toDay", value);
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* The image. It can be a string, an Element or a Pixi'VN Canvas Item.
|
|
582
|
+
*/
|
|
583
|
+
get image() {
|
|
584
|
+
return this._image;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* 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.
|
|
588
|
+
*/
|
|
589
|
+
get executionType() {
|
|
590
|
+
return this._executionType;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Is a function that is called when the player interacts with the character.
|
|
594
|
+
*/
|
|
595
|
+
onRun() {
|
|
596
|
+
if (!this._onRun) {
|
|
597
|
+
console.warn("[NQTR] onRun() is not defined for commitmen, so it will not run.", this);
|
|
598
|
+
} else {
|
|
599
|
+
this._onRun(this);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Whether is disabled. You can also pass a Pixi'VN flag name.
|
|
604
|
+
*/
|
|
605
|
+
get disabled() {
|
|
606
|
+
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
607
|
+
if (typeof value === "string") {
|
|
608
|
+
return (0, import_pixi_vn3.getFlag)(value);
|
|
609
|
+
}
|
|
610
|
+
return value;
|
|
611
|
+
}
|
|
612
|
+
set disabled(value) {
|
|
613
|
+
this.setStorageProperty("disabled", value);
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Whether is hidden. You can also pass a Pixi'VN flag name.
|
|
617
|
+
*/
|
|
618
|
+
get hidden() {
|
|
619
|
+
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
620
|
+
return true;
|
|
621
|
+
}
|
|
622
|
+
if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
if (!this.isExpired) {
|
|
626
|
+
return true;
|
|
627
|
+
}
|
|
628
|
+
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
629
|
+
if (typeof value === "string") {
|
|
630
|
+
return (0, import_pixi_vn3.getFlag)(value);
|
|
631
|
+
}
|
|
632
|
+
return value;
|
|
633
|
+
}
|
|
634
|
+
set hidden(value) {
|
|
635
|
+
this.setStorageProperty("hidden", value);
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Whether the commitment is expired.
|
|
639
|
+
* @returns Whether the commitment is expired.
|
|
640
|
+
*/
|
|
641
|
+
isExpired() {
|
|
642
|
+
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
643
|
+
return true;
|
|
644
|
+
}
|
|
645
|
+
return false;
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
// src/classes/navigation/Location.ts
|
|
650
|
+
var import_pixi_vn4 = require("@drincs/pixi-vn");
|
|
651
|
+
|
|
488
652
|
// src/decorators/RoomDecorator.ts
|
|
489
653
|
var registeredRooms = {};
|
|
490
654
|
function saveRoom(room) {
|
|
@@ -510,109 +674,203 @@ function getRoomById(id) {
|
|
|
510
674
|
return;
|
|
511
675
|
}
|
|
512
676
|
}
|
|
513
|
-
function
|
|
514
|
-
return Object.values(registeredRooms).filter((room) => room.location === location);
|
|
677
|
+
function getRoomsByLocation(location) {
|
|
678
|
+
return Object.values(registeredRooms).filter((room) => room.location.id === location.id);
|
|
679
|
+
}
|
|
680
|
+
function getAllLocations() {
|
|
681
|
+
let result = {};
|
|
682
|
+
Object.values(registeredRooms).forEach((room) => {
|
|
683
|
+
result[room.location.id] = room.location;
|
|
684
|
+
});
|
|
685
|
+
return Object.values(result);
|
|
686
|
+
}
|
|
687
|
+
function getLocationsByMap(map) {
|
|
688
|
+
return getAllLocations().filter((location) => location.map.id === map.id);
|
|
689
|
+
}
|
|
690
|
+
function getAllMaps() {
|
|
691
|
+
let result = {};
|
|
692
|
+
Object.values(registeredRooms).forEach((room) => {
|
|
693
|
+
result[room.location.map.id] = room.location.map;
|
|
694
|
+
});
|
|
695
|
+
return Object.values(result);
|
|
515
696
|
}
|
|
516
697
|
|
|
517
698
|
// src/classes/navigation/Location.ts
|
|
518
699
|
var LOCATION_CATEGORY = "__nqtr-location__";
|
|
519
|
-
var LocationBaseModel = class extends
|
|
520
|
-
|
|
700
|
+
var LocationBaseModel = class extends import_pixi_vn4.StoredClassModel {
|
|
701
|
+
/**
|
|
702
|
+
* @param id The id of the location, it must be unique.
|
|
703
|
+
* @param map The map where the location is.
|
|
704
|
+
* @param props The properties of the location.
|
|
705
|
+
*/
|
|
706
|
+
constructor(id, map, props = {}) {
|
|
521
707
|
super(LOCATION_CATEGORY, id);
|
|
522
708
|
this.defaultName = props.name || "";
|
|
523
709
|
this.defaultDisabled = props.disabled || false;
|
|
524
710
|
this.defaultHidden = props.hidden || false;
|
|
525
|
-
this.
|
|
711
|
+
this._icon = props.icon;
|
|
526
712
|
this._map = map;
|
|
527
713
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
}
|
|
533
|
-
return rooms.find((room) => room.isEntrance) || rooms[0];
|
|
534
|
-
}
|
|
714
|
+
/**
|
|
715
|
+
* The name of the location.
|
|
716
|
+
* If you set undefined, it will return the initial value of name.
|
|
717
|
+
*/
|
|
535
718
|
get name() {
|
|
536
719
|
return this.getStorageProperty("name") || this.defaultName;
|
|
537
720
|
}
|
|
538
721
|
set name(value) {
|
|
539
722
|
this.setStorageProperty("name", value);
|
|
540
723
|
}
|
|
724
|
+
/**
|
|
725
|
+
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
726
|
+
*/
|
|
541
727
|
get disabled() {
|
|
542
728
|
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
543
729
|
if (typeof value === "string") {
|
|
544
|
-
return (0,
|
|
730
|
+
return (0, import_pixi_vn4.getFlag)(value);
|
|
545
731
|
}
|
|
546
732
|
return value;
|
|
547
733
|
}
|
|
548
734
|
set disabled(value) {
|
|
549
735
|
this.setStorageProperty("disabled", value);
|
|
550
736
|
}
|
|
737
|
+
/**
|
|
738
|
+
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
739
|
+
*/
|
|
551
740
|
get hidden() {
|
|
552
741
|
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
553
742
|
if (typeof value === "string") {
|
|
554
|
-
return (0,
|
|
743
|
+
return (0, import_pixi_vn4.getFlag)(value);
|
|
555
744
|
}
|
|
556
745
|
return value;
|
|
557
746
|
}
|
|
558
747
|
set hidden(value) {
|
|
559
748
|
this.setStorageProperty("hidden", value);
|
|
560
749
|
}
|
|
561
|
-
|
|
562
|
-
|
|
750
|
+
/**
|
|
751
|
+
* The icon element. Can be a string or an Element or a Pixi'VN CanvasItem
|
|
752
|
+
*/
|
|
753
|
+
get icon() {
|
|
754
|
+
return this._icon;
|
|
563
755
|
}
|
|
756
|
+
/**
|
|
757
|
+
* The map where the location is.
|
|
758
|
+
*/
|
|
564
759
|
get map() {
|
|
565
760
|
return this._map;
|
|
566
761
|
}
|
|
762
|
+
/**
|
|
763
|
+
* Get the entrance room of the location.
|
|
764
|
+
* You can cast the room to a specific type that extends RoomBaseModel.
|
|
765
|
+
* @returns The entrance room or the first room if there is no entrance.
|
|
766
|
+
* @example
|
|
767
|
+
* ```typescript
|
|
768
|
+
* const entranceHome = new RoomBaseModel("entrance-home", home, { isEntrance: true })
|
|
769
|
+
* saveRoom(entranceHome)
|
|
770
|
+
* const home = new LocationBaseModel("home", map, { name: "Home" })
|
|
771
|
+
*
|
|
772
|
+
* const entrance = home.getEntrance() // entrance === entranceHome
|
|
773
|
+
* ```
|
|
774
|
+
*/
|
|
775
|
+
getEntrance() {
|
|
776
|
+
let rooms = this.getRooms();
|
|
777
|
+
if (rooms.length === 0) {
|
|
778
|
+
console.error(`[NQTR] The location ${this.id} has no rooms`);
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
return rooms.find((room) => room.isEntrance) || rooms[0];
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Get all rooms in the location.
|
|
785
|
+
* You can cast the rooms to a specific type that extends RoomBaseModel.
|
|
786
|
+
* @returns The rooms in the location.
|
|
787
|
+
*/
|
|
788
|
+
getRooms() {
|
|
789
|
+
return getRoomsByLocation(this);
|
|
790
|
+
}
|
|
567
791
|
};
|
|
568
792
|
|
|
569
793
|
// src/classes/navigation/Map.ts
|
|
570
|
-
var
|
|
794
|
+
var import_pixi_vn5 = require("@drincs/pixi-vn");
|
|
571
795
|
var MAP_CATEGORY = "__nqtr-map__";
|
|
572
|
-
var MapBaseModel = class extends
|
|
573
|
-
|
|
796
|
+
var MapBaseModel = class extends import_pixi_vn5.StoredClassModel {
|
|
797
|
+
/**
|
|
798
|
+
* @param id The id of the map, it must be unique.
|
|
799
|
+
* @param props The properties of the map.
|
|
800
|
+
*/
|
|
801
|
+
constructor(id, props = {}) {
|
|
574
802
|
super(MAP_CATEGORY, id);
|
|
575
803
|
this.defaultName = props.name || "";
|
|
576
804
|
this.defaultImage = props.image;
|
|
577
805
|
this.defaultDisabled = props.disabled || false;
|
|
578
806
|
this.defaultHidden = props.hidden || false;
|
|
579
807
|
}
|
|
808
|
+
/**
|
|
809
|
+
* The name of the map.
|
|
810
|
+
* If you set undefined, it will return the initial value of name.
|
|
811
|
+
*/
|
|
580
812
|
get name() {
|
|
581
813
|
return this.getStorageProperty("name") || this.defaultName;
|
|
582
814
|
}
|
|
583
815
|
set name(value) {
|
|
584
816
|
this.setStorageProperty("name", value);
|
|
585
817
|
}
|
|
818
|
+
/**
|
|
819
|
+
* The image of the map. It can be a string, an Element or a Pixi'VN Canvas Item.
|
|
820
|
+
* If you set undefined, it will return the initial value of image.
|
|
821
|
+
*/
|
|
586
822
|
get image() {
|
|
587
823
|
return this.getStorageProperty("image") || this.defaultImage;
|
|
588
824
|
}
|
|
589
825
|
set image(value) {
|
|
590
826
|
this.setStorageProperty("image", value);
|
|
591
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
830
|
+
*/
|
|
592
831
|
get disabled() {
|
|
593
832
|
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
594
833
|
if (typeof value === "string") {
|
|
595
|
-
return (0,
|
|
834
|
+
return (0, import_pixi_vn5.getFlag)(value);
|
|
596
835
|
}
|
|
597
836
|
return value;
|
|
598
837
|
}
|
|
599
838
|
set disabled(value) {
|
|
600
839
|
this.setStorageProperty("disabled", value);
|
|
601
840
|
}
|
|
841
|
+
/**
|
|
842
|
+
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
843
|
+
*/
|
|
602
844
|
get hidden() {
|
|
603
845
|
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
604
846
|
if (typeof value === "string") {
|
|
605
|
-
return (0,
|
|
847
|
+
return (0, import_pixi_vn5.getFlag)(value);
|
|
606
848
|
}
|
|
607
849
|
return value;
|
|
608
850
|
}
|
|
609
851
|
set hidden(value) {
|
|
610
852
|
this.setStorageProperty("hidden", value);
|
|
611
853
|
}
|
|
854
|
+
/**
|
|
855
|
+
* The neighboring maps that are available in this map.
|
|
856
|
+
*/
|
|
857
|
+
get neighboringMaps() {
|
|
858
|
+
return this._neighboringMaps || {};
|
|
859
|
+
}
|
|
860
|
+
set neighboringMaps(value) {
|
|
861
|
+
this._neighboringMaps = value;
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Get all locations in the map.
|
|
865
|
+
* @returns The locations in the map.
|
|
866
|
+
*/
|
|
867
|
+
getLocations() {
|
|
868
|
+
return getLocationsByMap(this);
|
|
869
|
+
}
|
|
612
870
|
};
|
|
613
871
|
|
|
614
872
|
// src/classes/navigation/Room.ts
|
|
615
|
-
var
|
|
873
|
+
var import_pixi_vn7 = require("@drincs/pixi-vn");
|
|
616
874
|
|
|
617
875
|
// src/decorators/ActivityDecorator.ts
|
|
618
876
|
var registeredActivities = {};
|
|
@@ -641,7 +899,7 @@ function getActivityById(id) {
|
|
|
641
899
|
}
|
|
642
900
|
|
|
643
901
|
// src/decorators/CommitmentDecorator.ts
|
|
644
|
-
var
|
|
902
|
+
var import_pixi_vn6 = require("@drincs/pixi-vn");
|
|
645
903
|
var TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY = "___nqtr-temporary_commitment___";
|
|
646
904
|
var registeredCommitments = {};
|
|
647
905
|
var fixedCommitments = {};
|
|
@@ -690,13 +948,13 @@ function addTemporaryCommitment(commitment) {
|
|
|
690
948
|
}
|
|
691
949
|
return commitment2.id;
|
|
692
950
|
}).filter((id) => id !== void 0);
|
|
693
|
-
|
|
951
|
+
import_pixi_vn6.GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, [commitmentsIds]);
|
|
694
952
|
}
|
|
695
953
|
function getFixedCommitments() {
|
|
696
954
|
return Object.values(fixedCommitments);
|
|
697
955
|
}
|
|
698
956
|
function getTemporaryCommitments() {
|
|
699
|
-
let commitmentsIds =
|
|
957
|
+
let commitmentsIds = import_pixi_vn6.GameStorageManager.getVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY);
|
|
700
958
|
if (!commitmentsIds) {
|
|
701
959
|
return [];
|
|
702
960
|
}
|
|
@@ -802,8 +1060,13 @@ var ActivityRoom = class extends ActivityStoredAbstract {
|
|
|
802
1060
|
|
|
803
1061
|
// src/classes/navigation/Room.ts
|
|
804
1062
|
var ROOM_CATEGORY = "__nqtr-room__";
|
|
805
|
-
var RoomBaseModel = class extends
|
|
806
|
-
|
|
1063
|
+
var RoomBaseModel = class extends import_pixi_vn7.StoredClassModel {
|
|
1064
|
+
/**
|
|
1065
|
+
* @param id The id of the room, it must be unique.
|
|
1066
|
+
* @param location The location where the room is.
|
|
1067
|
+
* @param props The properties of the room.
|
|
1068
|
+
*/
|
|
1069
|
+
constructor(id, location, props = {}) {
|
|
807
1070
|
var _a;
|
|
808
1071
|
super(ROOM_CATEGORY, id);
|
|
809
1072
|
this._location = location;
|
|
@@ -812,27 +1075,44 @@ var RoomBaseModel = class extends import_pixi_vn6.StoredClassModel {
|
|
|
812
1075
|
this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
|
|
813
1076
|
this.defaultDisabled = props.disabled || false;
|
|
814
1077
|
this.defaultHidden = props.hidden || false;
|
|
815
|
-
this.
|
|
1078
|
+
this._icon = props.icon;
|
|
816
1079
|
this._isEntrance = props.isEntrance;
|
|
817
1080
|
}
|
|
1081
|
+
/**
|
|
1082
|
+
* The location where the room is.
|
|
1083
|
+
*/
|
|
818
1084
|
get location() {
|
|
819
1085
|
return this._location;
|
|
820
1086
|
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
|
|
1089
|
+
*/
|
|
821
1090
|
get isEntrance() {
|
|
822
1091
|
return this._isEntrance || false;
|
|
823
1092
|
}
|
|
1093
|
+
/**
|
|
1094
|
+
* The name.
|
|
1095
|
+
* If you set undefined, it will return the initial value of name.
|
|
1096
|
+
*/
|
|
824
1097
|
get name() {
|
|
825
1098
|
return this.getStorageProperty("name") || this.defaultName;
|
|
826
1099
|
}
|
|
827
1100
|
set name(value) {
|
|
828
1101
|
this.setStorageProperty("name", value);
|
|
829
1102
|
}
|
|
1103
|
+
/**
|
|
1104
|
+
* The image. It can be a string, an Element or a Pixi'VN Canvas Item.
|
|
1105
|
+
* If you set undefined, it will return the initial value of image.
|
|
1106
|
+
*/
|
|
830
1107
|
get image() {
|
|
831
1108
|
return this.getStorageProperty("image") || this.defaultImage;
|
|
832
1109
|
}
|
|
833
1110
|
set image(value) {
|
|
834
1111
|
this.setStorageProperty("image", value);
|
|
835
1112
|
}
|
|
1113
|
+
/**
|
|
1114
|
+
* The activities that are available in this room.
|
|
1115
|
+
*/
|
|
836
1116
|
get defaultActivities() {
|
|
837
1117
|
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
838
1118
|
let activities = this.defaultActivityIds.map((id) => {
|
|
@@ -853,17 +1133,30 @@ var RoomBaseModel = class extends import_pixi_vn6.StoredClassModel {
|
|
|
853
1133
|
let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
|
|
854
1134
|
return this.defaultActivityIds.concat(addedActivityIds);
|
|
855
1135
|
}
|
|
1136
|
+
/**
|
|
1137
|
+
* The activities that are available in this room.
|
|
1138
|
+
*/
|
|
856
1139
|
get activities() {
|
|
857
1140
|
let activities = this.activityIds.map((id) => {
|
|
858
1141
|
return this.getActivity(id);
|
|
859
1142
|
}).filter((activity) => activity !== void 0);
|
|
860
1143
|
return activities;
|
|
861
1144
|
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Get the memory of an activity. This function can be used into olther libraries to get the memory of the activity.
|
|
1147
|
+
* @param id The id of the activity.
|
|
1148
|
+
* @returns The memory of the activity.
|
|
1149
|
+
*/
|
|
862
1150
|
getActivityMemory(id) {
|
|
863
1151
|
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
864
1152
|
let roomMemory = roomMemories[id] || {};
|
|
865
1153
|
return roomMemory;
|
|
866
1154
|
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Get the activity by id.
|
|
1157
|
+
* @param id The id of the activity.
|
|
1158
|
+
* @returns The room activity.
|
|
1159
|
+
*/
|
|
867
1160
|
getActivity(id) {
|
|
868
1161
|
if (!this.activityIds.includes(id)) {
|
|
869
1162
|
console.error(`[NQTR] Activity with id ${id} not found in room ${this.id}`);
|
|
@@ -879,11 +1172,20 @@ var RoomBaseModel = class extends import_pixi_vn6.StoredClassModel {
|
|
|
879
1172
|
roomMemory = __spreadValues(__spreadValues({}, activity.export()), roomMemory);
|
|
880
1173
|
return new ActivityRoom(id, this, activity.onRun, roomMemory);
|
|
881
1174
|
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Set the memory of an activity. This function can be used into olther libraries to set the memory of the activity.
|
|
1177
|
+
* @param id The id of the activity.
|
|
1178
|
+
* @param memory The memory of the activity.
|
|
1179
|
+
*/
|
|
882
1180
|
setActivity(activity) {
|
|
883
1181
|
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
884
1182
|
roomMemories[activity.id] = activity.export();
|
|
885
1183
|
this.setStorageProperty("activities_memory", roomMemories);
|
|
886
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Add an activity to the room.
|
|
1187
|
+
* @param activity The activity to add.
|
|
1188
|
+
*/
|
|
887
1189
|
addActivity(activity) {
|
|
888
1190
|
if (this.activityIds.includes(activity.id)) {
|
|
889
1191
|
let currentActivity = this.getActivity(activity.id);
|
|
@@ -899,6 +1201,10 @@ var RoomBaseModel = class extends import_pixi_vn6.StoredClassModel {
|
|
|
899
1201
|
addedActivityIds.push(activity.id);
|
|
900
1202
|
this.setStorageProperty("addedActivityIds", addedActivityIds);
|
|
901
1203
|
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Remove an activity from the room.
|
|
1206
|
+
* @param activity The activity to remove.
|
|
1207
|
+
*/
|
|
902
1208
|
removeActivity(activity) {
|
|
903
1209
|
let activityId = typeof activity === "string" ? activity : activity.id;
|
|
904
1210
|
if (this.defaultActivityIds.includes(activityId)) {
|
|
@@ -923,6 +1229,9 @@ var RoomBaseModel = class extends import_pixi_vn6.StoredClassModel {
|
|
|
923
1229
|
delete roomMemories[activityId];
|
|
924
1230
|
this.setStorageProperty("activities_memory", roomMemories);
|
|
925
1231
|
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Clear all expired activities.
|
|
1234
|
+
*/
|
|
926
1235
|
clearExpiredActivities() {
|
|
927
1236
|
this.activities.forEach((activity) => {
|
|
928
1237
|
if (activity.isExpired()) {
|
|
@@ -930,29 +1239,39 @@ var RoomBaseModel = class extends import_pixi_vn6.StoredClassModel {
|
|
|
930
1239
|
}
|
|
931
1240
|
});
|
|
932
1241
|
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
1244
|
+
*/
|
|
933
1245
|
get disabled() {
|
|
934
1246
|
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
935
1247
|
if (typeof value === "string") {
|
|
936
|
-
return (0,
|
|
1248
|
+
return (0, import_pixi_vn7.getFlag)(value);
|
|
937
1249
|
}
|
|
938
1250
|
return value;
|
|
939
1251
|
}
|
|
940
1252
|
set disabled(value) {
|
|
941
1253
|
this.setStorageProperty("disabled", value);
|
|
942
1254
|
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
1257
|
+
*/
|
|
943
1258
|
get hidden() {
|
|
944
1259
|
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
945
1260
|
if (typeof value === "string") {
|
|
946
|
-
return (0,
|
|
1261
|
+
return (0, import_pixi_vn7.getFlag)(value);
|
|
947
1262
|
}
|
|
948
1263
|
return value;
|
|
949
1264
|
}
|
|
950
1265
|
set hidden(value) {
|
|
951
1266
|
this.setStorageProperty("hidden", value);
|
|
952
1267
|
}
|
|
953
|
-
get
|
|
954
|
-
return this.
|
|
1268
|
+
get icon() {
|
|
1269
|
+
return this._icon;
|
|
955
1270
|
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Get the character commitments of the room.
|
|
1273
|
+
* @returns The character commitments of the room.
|
|
1274
|
+
*/
|
|
956
1275
|
getRoutine() {
|
|
957
1276
|
let commitments = getCurrentCommitments();
|
|
958
1277
|
return commitments.filter((c) => c.room.id === this.id);
|
|
@@ -988,9 +1307,9 @@ var Goal = class {
|
|
|
988
1307
|
};
|
|
989
1308
|
|
|
990
1309
|
// src/classes/quest/Quest.ts
|
|
991
|
-
var
|
|
1310
|
+
var import_pixi_vn8 = require("@drincs/pixi-vn");
|
|
992
1311
|
var QUEST_CATEGORY = "__nqtr-quest__";
|
|
993
|
-
var QuestBaseModel = class extends
|
|
1312
|
+
var QuestBaseModel = class extends import_pixi_vn8.StoredClassModel {
|
|
994
1313
|
constructor(id, stages, props) {
|
|
995
1314
|
super(QUEST_CATEGORY, id);
|
|
996
1315
|
this._stages = stages;
|
|
@@ -1021,9 +1340,9 @@ var QuestBaseModel = class extends import_pixi_vn7.StoredClassModel {
|
|
|
1021
1340
|
};
|
|
1022
1341
|
|
|
1023
1342
|
// src/classes/quest/Stage.ts
|
|
1024
|
-
var
|
|
1343
|
+
var import_pixi_vn9 = require("@drincs/pixi-vn");
|
|
1025
1344
|
var STAGE_CATEGORY = "__nqtr-stage__";
|
|
1026
|
-
var StageBaseModel = class extends
|
|
1345
|
+
var StageBaseModel = class extends import_pixi_vn9.StoredClassModel {
|
|
1027
1346
|
constructor(id, props) {
|
|
1028
1347
|
super(STAGE_CATEGORY, id);
|
|
1029
1348
|
this._completed = false;
|
|
@@ -1089,26 +1408,28 @@ var StageBaseModel = class extends import_pixi_vn8.StoredClassModel {
|
|
|
1089
1408
|
}
|
|
1090
1409
|
};
|
|
1091
1410
|
|
|
1092
|
-
// src/enums/ExecutionTypeEnum.ts
|
|
1093
|
-
var ExecutionTypeEnum = /* @__PURE__ */ ((ExecutionTypeEnum2) => {
|
|
1094
|
-
ExecutionTypeEnum2["AUTOMATIC"] = "automatic";
|
|
1095
|
-
ExecutionTypeEnum2["INTERACTION"] = "interaction";
|
|
1096
|
-
return ExecutionTypeEnum2;
|
|
1097
|
-
})(ExecutionTypeEnum || {});
|
|
1098
|
-
|
|
1099
1411
|
// src/functions/NavigationFunctions.ts
|
|
1100
|
-
var
|
|
1412
|
+
var import_pixi_vn10 = require("@drincs/pixi-vn");
|
|
1101
1413
|
var CURRENT_ROOM_MEMORY_KEY = "___nqtr-current_room_memory___";
|
|
1102
1414
|
function setCurrentRoom(room) {
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1415
|
+
if (room instanceof LocationBaseModel) {
|
|
1416
|
+
let entrance = room.getEntrance();
|
|
1417
|
+
if (!entrance) {
|
|
1418
|
+
console.error(`[NQTR] The location ${room.id} has no entrance room`);
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
room = entrance;
|
|
1422
|
+
} else {
|
|
1423
|
+
let roomRegistrated = getRoomById(room.id);
|
|
1424
|
+
if (!roomRegistrated) {
|
|
1425
|
+
console.error(`[NQTR] The room ${room.id} is not registered, so it can't be set as current room`);
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1107
1428
|
}
|
|
1108
1429
|
localStorage.setItem(CURRENT_ROOM_MEMORY_KEY, room.id);
|
|
1109
1430
|
}
|
|
1110
1431
|
function getCurrentRoom() {
|
|
1111
|
-
let roomId =
|
|
1432
|
+
let roomId = import_pixi_vn10.GameStorageManager.getVariable(CURRENT_ROOM_MEMORY_KEY);
|
|
1112
1433
|
if (!roomId) {
|
|
1113
1434
|
console.error(`[NQTR] The current room has not yet been set`);
|
|
1114
1435
|
return;
|
|
@@ -1151,6 +1472,7 @@ function currentActivities() {
|
|
|
1151
1472
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1152
1473
|
0 && (module.exports = {
|
|
1153
1474
|
ActivityModel,
|
|
1475
|
+
CommitmentBaseModel,
|
|
1154
1476
|
ExecutionTypeEnum,
|
|
1155
1477
|
Goal,
|
|
1156
1478
|
LocationBaseModel,
|
|
@@ -1164,6 +1486,8 @@ function currentActivities() {
|
|
|
1164
1486
|
clearExpiredRoutine,
|
|
1165
1487
|
currentActivities,
|
|
1166
1488
|
getActivityById,
|
|
1489
|
+
getAllLocations,
|
|
1490
|
+
getAllMaps,
|
|
1167
1491
|
getCommitmentByCharacter,
|
|
1168
1492
|
getCommitmentById,
|
|
1169
1493
|
getCueerntMap,
|