@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.mjs
CHANGED
|
@@ -270,7 +270,7 @@ var ActivityStoredAbstract = class {
|
|
|
270
270
|
this.defaultToDay = props.toDay;
|
|
271
271
|
this.defaultDisabled = props.disabled || false;
|
|
272
272
|
this.defaultHidden = props.hidden || false;
|
|
273
|
-
this.
|
|
273
|
+
this._icon = props.icon;
|
|
274
274
|
this._onRun = onRun;
|
|
275
275
|
}
|
|
276
276
|
get name() {
|
|
@@ -332,8 +332,8 @@ var ActivityStoredAbstract = class {
|
|
|
332
332
|
set hidden(value) {
|
|
333
333
|
this.setStorageProperty("hidden", value);
|
|
334
334
|
}
|
|
335
|
-
get
|
|
336
|
-
return this.
|
|
335
|
+
get icon() {
|
|
336
|
+
return this._icon;
|
|
337
337
|
}
|
|
338
338
|
get onRun() {
|
|
339
339
|
return this._onRun;
|
|
@@ -353,7 +353,7 @@ var ActivityStoredAbstract = class {
|
|
|
353
353
|
toDay: this.getStorageProperty("toDay") || this.defaultToDay,
|
|
354
354
|
disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
|
|
355
355
|
hidden: this.getStorageProperty("hidden") || this.defaultHidden,
|
|
356
|
-
|
|
356
|
+
icon: this._icon
|
|
357
357
|
};
|
|
358
358
|
}
|
|
359
359
|
};
|
|
@@ -367,7 +367,7 @@ var ActivityModel = class {
|
|
|
367
367
|
this._toDay = props.toDay;
|
|
368
368
|
this._disabled = props.disabled || false;
|
|
369
369
|
this._hidden = props.hidden || false;
|
|
370
|
-
this.
|
|
370
|
+
this._icon = props.icon;
|
|
371
371
|
this._onRun = onRun;
|
|
372
372
|
}
|
|
373
373
|
get id() {
|
|
@@ -406,8 +406,8 @@ var ActivityModel = class {
|
|
|
406
406
|
}
|
|
407
407
|
return this._hidden;
|
|
408
408
|
}
|
|
409
|
-
get
|
|
410
|
-
return this.
|
|
409
|
+
get icon() {
|
|
410
|
+
return this._icon;
|
|
411
411
|
}
|
|
412
412
|
get onRun() {
|
|
413
413
|
return this._onRun;
|
|
@@ -427,14 +427,175 @@ var ActivityModel = class {
|
|
|
427
427
|
toDay: this._toDay,
|
|
428
428
|
disabled: this._disabled,
|
|
429
429
|
hidden: this._hidden,
|
|
430
|
-
|
|
430
|
+
icon: this._icon
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
433
|
};
|
|
434
434
|
|
|
435
|
-
// src/classes/
|
|
435
|
+
// src/classes/Commitment.ts
|
|
436
436
|
import { getFlag as getFlag2, StoredClassModel } from "@drincs/pixi-vn";
|
|
437
437
|
|
|
438
|
+
// src/enums/ExecutionTypeEnum.ts
|
|
439
|
+
var ExecutionTypeEnum = /* @__PURE__ */ ((ExecutionTypeEnum2) => {
|
|
440
|
+
ExecutionTypeEnum2["AUTOMATIC"] = "automatic";
|
|
441
|
+
ExecutionTypeEnum2["INTERACTION"] = "interaction";
|
|
442
|
+
return ExecutionTypeEnum2;
|
|
443
|
+
})(ExecutionTypeEnum || {});
|
|
444
|
+
|
|
445
|
+
// src/classes/Commitment.ts
|
|
446
|
+
var COMMITMENT_CATEGORY = "__nqtr-commitment__";
|
|
447
|
+
var CommitmentBaseModel = class extends StoredClassModel {
|
|
448
|
+
/**
|
|
449
|
+
* @param id The id of the commitment, it must be unique.
|
|
450
|
+
* @param character The character or characters that are in the commitment and so in the room.
|
|
451
|
+
* @param room The room where the commitment is.
|
|
452
|
+
* @param props The properties of the commitment.
|
|
453
|
+
*/
|
|
454
|
+
constructor(id, character, room, props) {
|
|
455
|
+
super(COMMITMENT_CATEGORY, id);
|
|
456
|
+
this._characters = character ? Array.isArray(character) ? character : [character] : [];
|
|
457
|
+
this._room = room;
|
|
458
|
+
this._name = props.name || "";
|
|
459
|
+
this.defaultFromHour = props.fromHour;
|
|
460
|
+
this.defaultToHour = props.toHour;
|
|
461
|
+
this.defaultFromDay = props.fromDay;
|
|
462
|
+
this.defaultToDay = props.toDay;
|
|
463
|
+
this._image = props.image;
|
|
464
|
+
this._executionType = props.executionType || "interaction" /* INTERACTION */;
|
|
465
|
+
this._onRun = props.onRun;
|
|
466
|
+
this.defaultDisabled = props.disabled || false;
|
|
467
|
+
this.defaultHidden = props.hidden || false;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* The character or characters that are in the commitment and so in the room.
|
|
471
|
+
*/
|
|
472
|
+
get characters() {
|
|
473
|
+
return this._characters;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* The room where the commitment is.
|
|
477
|
+
*/
|
|
478
|
+
get room() {
|
|
479
|
+
return this._room;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* The name
|
|
483
|
+
*/
|
|
484
|
+
get name() {
|
|
485
|
+
return this._name;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* The hour when the commitment starts. If the commitment is not started yet, it will be hidden.
|
|
489
|
+
* If you set undefined, it will return the initial value of fromHour.
|
|
490
|
+
*/
|
|
491
|
+
get fromHour() {
|
|
492
|
+
return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
|
|
493
|
+
}
|
|
494
|
+
set fromHour(value) {
|
|
495
|
+
this.setStorageProperty("fromHour", value);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* The hour when the commitment ends. If the commitment is ended yet, it will be hidden.
|
|
499
|
+
* If you set undefined, it will return the initial value of toHour.
|
|
500
|
+
*/
|
|
501
|
+
get toHour() {
|
|
502
|
+
return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
|
|
503
|
+
}
|
|
504
|
+
set toHour(value) {
|
|
505
|
+
this.setStorageProperty("toHour", value);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* The day when the commitment starts. If the commitment is not started yet, it will be hidden.
|
|
509
|
+
* If you set undefined, it will return the initial value of fromDay.
|
|
510
|
+
*/
|
|
511
|
+
get fromDay() {
|
|
512
|
+
return this.getStorageProperty("fromDay") || this.defaultFromDay;
|
|
513
|
+
}
|
|
514
|
+
set fromDay(value) {
|
|
515
|
+
this.setStorageProperty("fromDay", value);
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* The day when the commitment ends. If the commitment is ended yet, it will be deleted or hidden.
|
|
519
|
+
* If you set undefined, it will return the initial value of toDay.
|
|
520
|
+
*/
|
|
521
|
+
get toDay() {
|
|
522
|
+
return this.getStorageProperty("toDay") || this.defaultToDay;
|
|
523
|
+
}
|
|
524
|
+
set toDay(value) {
|
|
525
|
+
this.setStorageProperty("toDay", value);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* The image. It can be a string, an Element or a Pixi'VN Canvas Item.
|
|
529
|
+
*/
|
|
530
|
+
get image() {
|
|
531
|
+
return this._image;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
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.
|
|
535
|
+
*/
|
|
536
|
+
get executionType() {
|
|
537
|
+
return this._executionType;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Is a function that is called when the player interacts with the character.
|
|
541
|
+
*/
|
|
542
|
+
onRun() {
|
|
543
|
+
if (!this._onRun) {
|
|
544
|
+
console.warn("[NQTR] onRun() is not defined for commitmen, so it will not run.", this);
|
|
545
|
+
} else {
|
|
546
|
+
this._onRun(this);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Whether is disabled. You can also pass a Pixi'VN flag name.
|
|
551
|
+
*/
|
|
552
|
+
get disabled() {
|
|
553
|
+
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
554
|
+
if (typeof value === "string") {
|
|
555
|
+
return getFlag2(value);
|
|
556
|
+
}
|
|
557
|
+
return value;
|
|
558
|
+
}
|
|
559
|
+
set disabled(value) {
|
|
560
|
+
this.setStorageProperty("disabled", value);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Whether is hidden. You can also pass a Pixi'VN flag name.
|
|
564
|
+
*/
|
|
565
|
+
get hidden() {
|
|
566
|
+
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
569
|
+
if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
|
|
570
|
+
return true;
|
|
571
|
+
}
|
|
572
|
+
if (!this.isExpired) {
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
576
|
+
if (typeof value === "string") {
|
|
577
|
+
return getFlag2(value);
|
|
578
|
+
}
|
|
579
|
+
return value;
|
|
580
|
+
}
|
|
581
|
+
set hidden(value) {
|
|
582
|
+
this.setStorageProperty("hidden", value);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Whether the commitment is expired.
|
|
586
|
+
* @returns Whether the commitment is expired.
|
|
587
|
+
*/
|
|
588
|
+
isExpired() {
|
|
589
|
+
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
590
|
+
return true;
|
|
591
|
+
}
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
// src/classes/navigation/Location.ts
|
|
597
|
+
import { getFlag as getFlag3, StoredClassModel as StoredClassModel2 } from "@drincs/pixi-vn";
|
|
598
|
+
|
|
438
599
|
// src/decorators/RoomDecorator.ts
|
|
439
600
|
var registeredRooms = {};
|
|
440
601
|
function saveRoom(room) {
|
|
@@ -460,109 +621,203 @@ function getRoomById(id) {
|
|
|
460
621
|
return;
|
|
461
622
|
}
|
|
462
623
|
}
|
|
463
|
-
function
|
|
464
|
-
return Object.values(registeredRooms).filter((room) => room.location === location);
|
|
624
|
+
function getRoomsByLocation(location) {
|
|
625
|
+
return Object.values(registeredRooms).filter((room) => room.location.id === location.id);
|
|
626
|
+
}
|
|
627
|
+
function getAllLocations() {
|
|
628
|
+
let result = {};
|
|
629
|
+
Object.values(registeredRooms).forEach((room) => {
|
|
630
|
+
result[room.location.id] = room.location;
|
|
631
|
+
});
|
|
632
|
+
return Object.values(result);
|
|
633
|
+
}
|
|
634
|
+
function getLocationsByMap(map) {
|
|
635
|
+
return getAllLocations().filter((location) => location.map.id === map.id);
|
|
636
|
+
}
|
|
637
|
+
function getAllMaps() {
|
|
638
|
+
let result = {};
|
|
639
|
+
Object.values(registeredRooms).forEach((room) => {
|
|
640
|
+
result[room.location.map.id] = room.location.map;
|
|
641
|
+
});
|
|
642
|
+
return Object.values(result);
|
|
465
643
|
}
|
|
466
644
|
|
|
467
645
|
// src/classes/navigation/Location.ts
|
|
468
646
|
var LOCATION_CATEGORY = "__nqtr-location__";
|
|
469
|
-
var LocationBaseModel = class extends
|
|
470
|
-
|
|
647
|
+
var LocationBaseModel = class extends StoredClassModel2 {
|
|
648
|
+
/**
|
|
649
|
+
* @param id The id of the location, it must be unique.
|
|
650
|
+
* @param map The map where the location is.
|
|
651
|
+
* @param props The properties of the location.
|
|
652
|
+
*/
|
|
653
|
+
constructor(id, map, props = {}) {
|
|
471
654
|
super(LOCATION_CATEGORY, id);
|
|
472
655
|
this.defaultName = props.name || "";
|
|
473
656
|
this.defaultDisabled = props.disabled || false;
|
|
474
657
|
this.defaultHidden = props.hidden || false;
|
|
475
|
-
this.
|
|
658
|
+
this._icon = props.icon;
|
|
476
659
|
this._map = map;
|
|
477
660
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
return rooms.find((room) => room.isEntrance) || rooms[0];
|
|
484
|
-
}
|
|
661
|
+
/**
|
|
662
|
+
* The name of the location.
|
|
663
|
+
* If you set undefined, it will return the initial value of name.
|
|
664
|
+
*/
|
|
485
665
|
get name() {
|
|
486
666
|
return this.getStorageProperty("name") || this.defaultName;
|
|
487
667
|
}
|
|
488
668
|
set name(value) {
|
|
489
669
|
this.setStorageProperty("name", value);
|
|
490
670
|
}
|
|
671
|
+
/**
|
|
672
|
+
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
673
|
+
*/
|
|
491
674
|
get disabled() {
|
|
492
675
|
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
493
676
|
if (typeof value === "string") {
|
|
494
|
-
return
|
|
677
|
+
return getFlag3(value);
|
|
495
678
|
}
|
|
496
679
|
return value;
|
|
497
680
|
}
|
|
498
681
|
set disabled(value) {
|
|
499
682
|
this.setStorageProperty("disabled", value);
|
|
500
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
686
|
+
*/
|
|
501
687
|
get hidden() {
|
|
502
688
|
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
503
689
|
if (typeof value === "string") {
|
|
504
|
-
return
|
|
690
|
+
return getFlag3(value);
|
|
505
691
|
}
|
|
506
692
|
return value;
|
|
507
693
|
}
|
|
508
694
|
set hidden(value) {
|
|
509
695
|
this.setStorageProperty("hidden", value);
|
|
510
696
|
}
|
|
511
|
-
|
|
512
|
-
|
|
697
|
+
/**
|
|
698
|
+
* The icon element. Can be a string or an Element or a Pixi'VN CanvasItem
|
|
699
|
+
*/
|
|
700
|
+
get icon() {
|
|
701
|
+
return this._icon;
|
|
513
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* The map where the location is.
|
|
705
|
+
*/
|
|
514
706
|
get map() {
|
|
515
707
|
return this._map;
|
|
516
708
|
}
|
|
709
|
+
/**
|
|
710
|
+
* Get the entrance room of the location.
|
|
711
|
+
* You can cast the room to a specific type that extends RoomBaseModel.
|
|
712
|
+
* @returns The entrance room or the first room if there is no entrance.
|
|
713
|
+
* @example
|
|
714
|
+
* ```typescript
|
|
715
|
+
* const entranceHome = new RoomBaseModel("entrance-home", home, { isEntrance: true })
|
|
716
|
+
* saveRoom(entranceHome)
|
|
717
|
+
* const home = new LocationBaseModel("home", map, { name: "Home" })
|
|
718
|
+
*
|
|
719
|
+
* const entrance = home.getEntrance() // entrance === entranceHome
|
|
720
|
+
* ```
|
|
721
|
+
*/
|
|
722
|
+
getEntrance() {
|
|
723
|
+
let rooms = this.getRooms();
|
|
724
|
+
if (rooms.length === 0) {
|
|
725
|
+
console.error(`[NQTR] The location ${this.id} has no rooms`);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
return rooms.find((room) => room.isEntrance) || rooms[0];
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Get all rooms in the location.
|
|
732
|
+
* You can cast the rooms to a specific type that extends RoomBaseModel.
|
|
733
|
+
* @returns The rooms in the location.
|
|
734
|
+
*/
|
|
735
|
+
getRooms() {
|
|
736
|
+
return getRoomsByLocation(this);
|
|
737
|
+
}
|
|
517
738
|
};
|
|
518
739
|
|
|
519
740
|
// src/classes/navigation/Map.ts
|
|
520
|
-
import { getFlag as
|
|
741
|
+
import { getFlag as getFlag4, StoredClassModel as StoredClassModel3 } from "@drincs/pixi-vn";
|
|
521
742
|
var MAP_CATEGORY = "__nqtr-map__";
|
|
522
|
-
var MapBaseModel = class extends
|
|
523
|
-
|
|
743
|
+
var MapBaseModel = class extends StoredClassModel3 {
|
|
744
|
+
/**
|
|
745
|
+
* @param id The id of the map, it must be unique.
|
|
746
|
+
* @param props The properties of the map.
|
|
747
|
+
*/
|
|
748
|
+
constructor(id, props = {}) {
|
|
524
749
|
super(MAP_CATEGORY, id);
|
|
525
750
|
this.defaultName = props.name || "";
|
|
526
751
|
this.defaultImage = props.image;
|
|
527
752
|
this.defaultDisabled = props.disabled || false;
|
|
528
753
|
this.defaultHidden = props.hidden || false;
|
|
529
754
|
}
|
|
755
|
+
/**
|
|
756
|
+
* The name of the map.
|
|
757
|
+
* If you set undefined, it will return the initial value of name.
|
|
758
|
+
*/
|
|
530
759
|
get name() {
|
|
531
760
|
return this.getStorageProperty("name") || this.defaultName;
|
|
532
761
|
}
|
|
533
762
|
set name(value) {
|
|
534
763
|
this.setStorageProperty("name", value);
|
|
535
764
|
}
|
|
765
|
+
/**
|
|
766
|
+
* The image of the map. It can be a string, an Element or a Pixi'VN Canvas Item.
|
|
767
|
+
* If you set undefined, it will return the initial value of image.
|
|
768
|
+
*/
|
|
536
769
|
get image() {
|
|
537
770
|
return this.getStorageProperty("image") || this.defaultImage;
|
|
538
771
|
}
|
|
539
772
|
set image(value) {
|
|
540
773
|
this.setStorageProperty("image", value);
|
|
541
774
|
}
|
|
775
|
+
/**
|
|
776
|
+
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
777
|
+
*/
|
|
542
778
|
get disabled() {
|
|
543
779
|
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
544
780
|
if (typeof value === "string") {
|
|
545
|
-
return
|
|
781
|
+
return getFlag4(value);
|
|
546
782
|
}
|
|
547
783
|
return value;
|
|
548
784
|
}
|
|
549
785
|
set disabled(value) {
|
|
550
786
|
this.setStorageProperty("disabled", value);
|
|
551
787
|
}
|
|
788
|
+
/**
|
|
789
|
+
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
790
|
+
*/
|
|
552
791
|
get hidden() {
|
|
553
792
|
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
554
793
|
if (typeof value === "string") {
|
|
555
|
-
return
|
|
794
|
+
return getFlag4(value);
|
|
556
795
|
}
|
|
557
796
|
return value;
|
|
558
797
|
}
|
|
559
798
|
set hidden(value) {
|
|
560
799
|
this.setStorageProperty("hidden", value);
|
|
561
800
|
}
|
|
801
|
+
/**
|
|
802
|
+
* The neighboring maps that are available in this map.
|
|
803
|
+
*/
|
|
804
|
+
get neighboringMaps() {
|
|
805
|
+
return this._neighboringMaps || {};
|
|
806
|
+
}
|
|
807
|
+
set neighboringMaps(value) {
|
|
808
|
+
this._neighboringMaps = value;
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Get all locations in the map.
|
|
812
|
+
* @returns The locations in the map.
|
|
813
|
+
*/
|
|
814
|
+
getLocations() {
|
|
815
|
+
return getLocationsByMap(this);
|
|
816
|
+
}
|
|
562
817
|
};
|
|
563
818
|
|
|
564
819
|
// src/classes/navigation/Room.ts
|
|
565
|
-
import { getFlag as
|
|
820
|
+
import { getFlag as getFlag5, StoredClassModel as StoredClassModel4 } from "@drincs/pixi-vn";
|
|
566
821
|
|
|
567
822
|
// src/decorators/ActivityDecorator.ts
|
|
568
823
|
var registeredActivities = {};
|
|
@@ -752,8 +1007,13 @@ var ActivityRoom = class extends ActivityStoredAbstract {
|
|
|
752
1007
|
|
|
753
1008
|
// src/classes/navigation/Room.ts
|
|
754
1009
|
var ROOM_CATEGORY = "__nqtr-room__";
|
|
755
|
-
var RoomBaseModel = class extends
|
|
756
|
-
|
|
1010
|
+
var RoomBaseModel = class extends StoredClassModel4 {
|
|
1011
|
+
/**
|
|
1012
|
+
* @param id The id of the room, it must be unique.
|
|
1013
|
+
* @param location The location where the room is.
|
|
1014
|
+
* @param props The properties of the room.
|
|
1015
|
+
*/
|
|
1016
|
+
constructor(id, location, props = {}) {
|
|
757
1017
|
var _a;
|
|
758
1018
|
super(ROOM_CATEGORY, id);
|
|
759
1019
|
this._location = location;
|
|
@@ -762,27 +1022,44 @@ var RoomBaseModel = class extends StoredClassModel3 {
|
|
|
762
1022
|
this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
|
|
763
1023
|
this.defaultDisabled = props.disabled || false;
|
|
764
1024
|
this.defaultHidden = props.hidden || false;
|
|
765
|
-
this.
|
|
1025
|
+
this._icon = props.icon;
|
|
766
1026
|
this._isEntrance = props.isEntrance;
|
|
767
1027
|
}
|
|
1028
|
+
/**
|
|
1029
|
+
* The location where the room is.
|
|
1030
|
+
*/
|
|
768
1031
|
get location() {
|
|
769
1032
|
return this._location;
|
|
770
1033
|
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
|
|
1036
|
+
*/
|
|
771
1037
|
get isEntrance() {
|
|
772
1038
|
return this._isEntrance || false;
|
|
773
1039
|
}
|
|
1040
|
+
/**
|
|
1041
|
+
* The name.
|
|
1042
|
+
* If you set undefined, it will return the initial value of name.
|
|
1043
|
+
*/
|
|
774
1044
|
get name() {
|
|
775
1045
|
return this.getStorageProperty("name") || this.defaultName;
|
|
776
1046
|
}
|
|
777
1047
|
set name(value) {
|
|
778
1048
|
this.setStorageProperty("name", value);
|
|
779
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* The image. It can be a string, an Element or a Pixi'VN Canvas Item.
|
|
1052
|
+
* If you set undefined, it will return the initial value of image.
|
|
1053
|
+
*/
|
|
780
1054
|
get image() {
|
|
781
1055
|
return this.getStorageProperty("image") || this.defaultImage;
|
|
782
1056
|
}
|
|
783
1057
|
set image(value) {
|
|
784
1058
|
this.setStorageProperty("image", value);
|
|
785
1059
|
}
|
|
1060
|
+
/**
|
|
1061
|
+
* The activities that are available in this room.
|
|
1062
|
+
*/
|
|
786
1063
|
get defaultActivities() {
|
|
787
1064
|
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
788
1065
|
let activities = this.defaultActivityIds.map((id) => {
|
|
@@ -803,17 +1080,30 @@ var RoomBaseModel = class extends StoredClassModel3 {
|
|
|
803
1080
|
let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
|
|
804
1081
|
return this.defaultActivityIds.concat(addedActivityIds);
|
|
805
1082
|
}
|
|
1083
|
+
/**
|
|
1084
|
+
* The activities that are available in this room.
|
|
1085
|
+
*/
|
|
806
1086
|
get activities() {
|
|
807
1087
|
let activities = this.activityIds.map((id) => {
|
|
808
1088
|
return this.getActivity(id);
|
|
809
1089
|
}).filter((activity) => activity !== void 0);
|
|
810
1090
|
return activities;
|
|
811
1091
|
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Get the memory of an activity. This function can be used into olther libraries to get the memory of the activity.
|
|
1094
|
+
* @param id The id of the activity.
|
|
1095
|
+
* @returns The memory of the activity.
|
|
1096
|
+
*/
|
|
812
1097
|
getActivityMemory(id) {
|
|
813
1098
|
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
814
1099
|
let roomMemory = roomMemories[id] || {};
|
|
815
1100
|
return roomMemory;
|
|
816
1101
|
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Get the activity by id.
|
|
1104
|
+
* @param id The id of the activity.
|
|
1105
|
+
* @returns The room activity.
|
|
1106
|
+
*/
|
|
817
1107
|
getActivity(id) {
|
|
818
1108
|
if (!this.activityIds.includes(id)) {
|
|
819
1109
|
console.error(`[NQTR] Activity with id ${id} not found in room ${this.id}`);
|
|
@@ -829,11 +1119,20 @@ var RoomBaseModel = class extends StoredClassModel3 {
|
|
|
829
1119
|
roomMemory = __spreadValues(__spreadValues({}, activity.export()), roomMemory);
|
|
830
1120
|
return new ActivityRoom(id, this, activity.onRun, roomMemory);
|
|
831
1121
|
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Set the memory of an activity. This function can be used into olther libraries to set the memory of the activity.
|
|
1124
|
+
* @param id The id of the activity.
|
|
1125
|
+
* @param memory The memory of the activity.
|
|
1126
|
+
*/
|
|
832
1127
|
setActivity(activity) {
|
|
833
1128
|
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
834
1129
|
roomMemories[activity.id] = activity.export();
|
|
835
1130
|
this.setStorageProperty("activities_memory", roomMemories);
|
|
836
1131
|
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Add an activity to the room.
|
|
1134
|
+
* @param activity The activity to add.
|
|
1135
|
+
*/
|
|
837
1136
|
addActivity(activity) {
|
|
838
1137
|
if (this.activityIds.includes(activity.id)) {
|
|
839
1138
|
let currentActivity = this.getActivity(activity.id);
|
|
@@ -849,6 +1148,10 @@ var RoomBaseModel = class extends StoredClassModel3 {
|
|
|
849
1148
|
addedActivityIds.push(activity.id);
|
|
850
1149
|
this.setStorageProperty("addedActivityIds", addedActivityIds);
|
|
851
1150
|
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Remove an activity from the room.
|
|
1153
|
+
* @param activity The activity to remove.
|
|
1154
|
+
*/
|
|
852
1155
|
removeActivity(activity) {
|
|
853
1156
|
let activityId = typeof activity === "string" ? activity : activity.id;
|
|
854
1157
|
if (this.defaultActivityIds.includes(activityId)) {
|
|
@@ -873,6 +1176,9 @@ var RoomBaseModel = class extends StoredClassModel3 {
|
|
|
873
1176
|
delete roomMemories[activityId];
|
|
874
1177
|
this.setStorageProperty("activities_memory", roomMemories);
|
|
875
1178
|
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Clear all expired activities.
|
|
1181
|
+
*/
|
|
876
1182
|
clearExpiredActivities() {
|
|
877
1183
|
this.activities.forEach((activity) => {
|
|
878
1184
|
if (activity.isExpired()) {
|
|
@@ -880,29 +1186,39 @@ var RoomBaseModel = class extends StoredClassModel3 {
|
|
|
880
1186
|
}
|
|
881
1187
|
});
|
|
882
1188
|
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
1191
|
+
*/
|
|
883
1192
|
get disabled() {
|
|
884
1193
|
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
885
1194
|
if (typeof value === "string") {
|
|
886
|
-
return
|
|
1195
|
+
return getFlag5(value);
|
|
887
1196
|
}
|
|
888
1197
|
return value;
|
|
889
1198
|
}
|
|
890
1199
|
set disabled(value) {
|
|
891
1200
|
this.setStorageProperty("disabled", value);
|
|
892
1201
|
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
1204
|
+
*/
|
|
893
1205
|
get hidden() {
|
|
894
1206
|
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
895
1207
|
if (typeof value === "string") {
|
|
896
|
-
return
|
|
1208
|
+
return getFlag5(value);
|
|
897
1209
|
}
|
|
898
1210
|
return value;
|
|
899
1211
|
}
|
|
900
1212
|
set hidden(value) {
|
|
901
1213
|
this.setStorageProperty("hidden", value);
|
|
902
1214
|
}
|
|
903
|
-
get
|
|
904
|
-
return this.
|
|
1215
|
+
get icon() {
|
|
1216
|
+
return this._icon;
|
|
905
1217
|
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Get the character commitments of the room.
|
|
1220
|
+
* @returns The character commitments of the room.
|
|
1221
|
+
*/
|
|
906
1222
|
getRoutine() {
|
|
907
1223
|
let commitments = getCurrentCommitments();
|
|
908
1224
|
return commitments.filter((c) => c.room.id === this.id);
|
|
@@ -938,9 +1254,9 @@ var Goal = class {
|
|
|
938
1254
|
};
|
|
939
1255
|
|
|
940
1256
|
// src/classes/quest/Quest.ts
|
|
941
|
-
import { StoredClassModel as
|
|
1257
|
+
import { StoredClassModel as StoredClassModel5 } from "@drincs/pixi-vn";
|
|
942
1258
|
var QUEST_CATEGORY = "__nqtr-quest__";
|
|
943
|
-
var QuestBaseModel = class extends
|
|
1259
|
+
var QuestBaseModel = class extends StoredClassModel5 {
|
|
944
1260
|
constructor(id, stages, props) {
|
|
945
1261
|
super(QUEST_CATEGORY, id);
|
|
946
1262
|
this._stages = stages;
|
|
@@ -971,9 +1287,9 @@ var QuestBaseModel = class extends StoredClassModel4 {
|
|
|
971
1287
|
};
|
|
972
1288
|
|
|
973
1289
|
// src/classes/quest/Stage.ts
|
|
974
|
-
import { StoredClassModel as
|
|
1290
|
+
import { StoredClassModel as StoredClassModel6 } from "@drincs/pixi-vn";
|
|
975
1291
|
var STAGE_CATEGORY = "__nqtr-stage__";
|
|
976
|
-
var StageBaseModel = class extends
|
|
1292
|
+
var StageBaseModel = class extends StoredClassModel6 {
|
|
977
1293
|
constructor(id, props) {
|
|
978
1294
|
super(STAGE_CATEGORY, id);
|
|
979
1295
|
this._completed = false;
|
|
@@ -1039,21 +1355,23 @@ var StageBaseModel = class extends StoredClassModel5 {
|
|
|
1039
1355
|
}
|
|
1040
1356
|
};
|
|
1041
1357
|
|
|
1042
|
-
// src/enums/ExecutionTypeEnum.ts
|
|
1043
|
-
var ExecutionTypeEnum = /* @__PURE__ */ ((ExecutionTypeEnum2) => {
|
|
1044
|
-
ExecutionTypeEnum2["AUTOMATIC"] = "automatic";
|
|
1045
|
-
ExecutionTypeEnum2["INTERACTION"] = "interaction";
|
|
1046
|
-
return ExecutionTypeEnum2;
|
|
1047
|
-
})(ExecutionTypeEnum || {});
|
|
1048
|
-
|
|
1049
1358
|
// src/functions/NavigationFunctions.ts
|
|
1050
1359
|
import { GameStorageManager as GameStorageManager3 } from "@drincs/pixi-vn";
|
|
1051
1360
|
var CURRENT_ROOM_MEMORY_KEY = "___nqtr-current_room_memory___";
|
|
1052
1361
|
function setCurrentRoom(room) {
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1362
|
+
if (room instanceof LocationBaseModel) {
|
|
1363
|
+
let entrance = room.getEntrance();
|
|
1364
|
+
if (!entrance) {
|
|
1365
|
+
console.error(`[NQTR] The location ${room.id} has no entrance room`);
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
room = entrance;
|
|
1369
|
+
} else {
|
|
1370
|
+
let roomRegistrated = getRoomById(room.id);
|
|
1371
|
+
if (!roomRegistrated) {
|
|
1372
|
+
console.error(`[NQTR] The room ${room.id} is not registered, so it can't be set as current room`);
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1057
1375
|
}
|
|
1058
1376
|
localStorage.setItem(CURRENT_ROOM_MEMORY_KEY, room.id);
|
|
1059
1377
|
}
|
|
@@ -1100,6 +1418,7 @@ function currentActivities() {
|
|
|
1100
1418
|
}
|
|
1101
1419
|
export {
|
|
1102
1420
|
ActivityModel,
|
|
1421
|
+
CommitmentBaseModel,
|
|
1103
1422
|
ExecutionTypeEnum,
|
|
1104
1423
|
Goal,
|
|
1105
1424
|
LocationBaseModel,
|
|
@@ -1113,6 +1432,8 @@ export {
|
|
|
1113
1432
|
clearExpiredRoutine,
|
|
1114
1433
|
currentActivities,
|
|
1115
1434
|
getActivityById,
|
|
1435
|
+
getAllLocations,
|
|
1436
|
+
getAllMaps,
|
|
1116
1437
|
getCommitmentByCharacter,
|
|
1117
1438
|
getCommitmentById,
|
|
1118
1439
|
getCueerntMap,
|