@hytopia.com/examples 1.0.5 → 1.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.
@@ -0,0 +1,39 @@
1
+ {
2
+ "health": 100,
3
+ "currentRegionId": "stalkhaven",
4
+ "skillExperience": [],
5
+ "backpack": {
6
+ "items": []
7
+ },
8
+ "hotbar": {
9
+ "items": [
10
+ {
11
+ "position": 0,
12
+ "itemId": "toy_sword"
13
+ }
14
+ ]
15
+ },
16
+ "questLog": {
17
+ "quests": [
18
+ {
19
+ "questId": "welcome-to-stalkhaven",
20
+ "state": "active",
21
+ "objectiveProgress": {
22
+ "talk-to-mark": 0
23
+ }
24
+ }
25
+ ]
26
+ },
27
+ "storage": {
28
+ "items": []
29
+ },
30
+ "wearables": {
31
+ "items": []
32
+ },
33
+ "currentRegionSpawnFacingAngle": 90,
34
+ "currentRegionSpawnPoint": {
35
+ "x": 32,
36
+ "y": 2,
37
+ "z": 1
38
+ }
39
+ }
@@ -0,0 +1,79 @@
1
+ // Consumables
2
+ import CommonMushroomItem from './consumables/CommonMushroomItem';
3
+ import CookedDrumstickItem from './consumables/CookedDrumstickItem';
4
+ import CookedMeatItem from './consumables/CookedMeatItem';
5
+ import CookedMeatSkewerItem from './consumables/CookedMeatSkewerItem';
6
+ import EmbercapMushroomItem from './consumables/EmbercapMushroomItem';
7
+ import MinorHealingPotionItem from './consumables/MinorHealingPotionItem';
8
+ import StonebellyFungusMushroomItem from './consumables/StonebellyFungusMushroomItem';
9
+ import SunsporeClusterMushroomItem from './consumables/SunsporeClusterMushroomItem';
10
+
11
+ // General
12
+ import GoldItem from './general/GoldItem';
13
+
14
+ // Materials
15
+ import BlightedRootItem from './materials/BlightedRootItem';
16
+ import MonsterHideItem from './materials/MonsterHideItem';
17
+ import RatkinBonesItem from './materials/RatkinBonesItem';
18
+ import RatkinEyesItem from './materials/RatkinEyesItem';
19
+ import RatkinTailItem from './materials/RatkinTailItem';
20
+ import RatkinToothItem from './materials/RatkinToothItem';
21
+
22
+ // Seeds
23
+ import CommonSeedsItem from './seeds/CommonSeedsItem';
24
+ import RareSeedsItem from './seeds/RareSeedsItem';
25
+ import UnusualSeedsItem from './seeds/UnusualSeedsItem';
26
+
27
+ // Weapons
28
+ import DullSwordItem from './weapons/DullSwordItem';
29
+ import IronDaggerItem from './weapons/IronDaggerItem';
30
+ import IronLongSwordItem from './weapons/IronLongSwordItem';
31
+ import TrainingSwordItem from './weapons/TrainingSwordItem';
32
+
33
+ // Wearables
34
+ import AdventurersBootsItem from './wearables/AdventurerBootsItem';
35
+ import AdventurerGlovesItem from './wearables/AdventurerGlovesItem';
36
+ import AdventurerHoodItem from './wearables/AdventurerHoodItem';
37
+ import AdventurerLeggingsItem from './wearables/AdventurerLeggingsItem';
38
+ import AdventurerTunicItem from './wearables/AdventurerTunicItem';
39
+
40
+ export default [
41
+ // Consumables
42
+ CommonMushroomItem,
43
+ CookedDrumstickItem,
44
+ CookedMeatItem,
45
+ CookedMeatSkewerItem,
46
+ EmbercapMushroomItem,
47
+ MinorHealingPotionItem,
48
+ StonebellyFungusMushroomItem,
49
+ SunsporeClusterMushroomItem,
50
+
51
+ // General
52
+ GoldItem,
53
+
54
+ // Materials
55
+ BlightedRootItem,
56
+ MonsterHideItem,
57
+ RatkinBonesItem,
58
+ RatkinEyesItem,
59
+ RatkinTailItem,
60
+ RatkinToothItem,
61
+
62
+ // Seeds
63
+ CommonSeedsItem,
64
+ RareSeedsItem,
65
+ UnusualSeedsItem,
66
+
67
+ // Weapons
68
+ DullSwordItem,
69
+ IronDaggerItem,
70
+ IronLongSwordItem,
71
+ TrainingSwordItem,
72
+
73
+ // Wearables
74
+ AdventurersBootsItem,
75
+ AdventurerGlovesItem,
76
+ AdventurerHoodItem,
77
+ AdventurerLeggingsItem,
78
+ AdventurerTunicItem,
79
+ ];
@@ -12,38 +12,20 @@ export default class ItemRegistry {
12
12
  public static initializeItems(): void {
13
13
  console.log('Loading items...');
14
14
 
15
- const itemFiles = this._findItemFiles(__dirname);
15
+ const ItemClasses = require('./ItemClasses').default; // lazy load to avoid circular dependencies
16
16
  let loadedCount = 0;
17
17
 
18
- for (const filePath of itemFiles) {
18
+ for (const ItemClass of ItemClasses) {
19
19
  try {
20
- const ItemClass = require(filePath).default;
21
-
22
20
  if (ItemClass?.prototype instanceof BaseItem && ItemClass.id) {
23
21
  this.itemRegistry.set(ItemClass.id, ItemClass);
24
22
  loadedCount++;
25
23
  }
26
24
  } catch (error) {
27
- console.warn(`Failed to load item: ${filePath}`);
25
+ console.warn(`Failed to load item: ${ItemClass.id}`);
28
26
  }
29
27
  }
30
28
 
31
29
  console.log(`Loaded ${loadedCount} items`);
32
30
  }
33
-
34
- private static _findItemFiles(dir: string): string[] {
35
- const files: string[] = [];
36
-
37
- for (const item of readdirSync(dir)) {
38
- const path = join(dir, item);
39
-
40
- if (statSync(path).isDirectory()) {
41
- files.push(...this._findItemFiles(path));
42
- } else if (!item.startsWith('Base')) {
43
- files.push(path);
44
- }
45
- }
46
-
47
- return files;
48
- }
49
31
  }
@@ -0,0 +1,27 @@
1
+ // Main Quests, In Progression Order For Clarity
2
+ import WelcomeToStalkhavenQuest from './main/WelcomeToStalkhavenQuest';
3
+ import ExploringStalkhavenQuest from './main/ExploringStalkhavenQuest';
4
+ import TestedMettleQuest from './main/TestedMettleQuest';
5
+ import StalkhavensOutpostQuest from './main/StalkhavensOutpostQuest';
6
+ import ClearingCampsQuest from './main/ClearingCampsQuest';
7
+ import IntoTheNestQuest from './main/IntoTheNestQuest';
8
+ import BlightedHarvestQuest from './main/BlightedHarvestQuest';
9
+
10
+ // Side Quests, Alphabetical
11
+ import DipDuckDodgeQuest from './side/DipDuckDodgeQuest';
12
+ import FungalForagingQuest from './side/FungalForagingQuest';
13
+
14
+ export default [
15
+ // Main, Alphabetical
16
+ BlightedHarvestQuest,
17
+ ClearingCampsQuest,
18
+ ExploringStalkhavenQuest,
19
+ IntoTheNestQuest,
20
+ StalkhavensOutpostQuest,
21
+ TestedMettleQuest,
22
+ WelcomeToStalkhavenQuest,
23
+
24
+ // Side, Alphabetical
25
+ DipDuckDodgeQuest,
26
+ FungalForagingQuest,
27
+ ];
@@ -1,5 +1,3 @@
1
- import { readdirSync, statSync } from 'fs';
2
- import { join } from 'path';
3
1
  import BaseEntity from '../entities/BaseEntity';
4
2
  import BaseQuest from './BaseQuest';
5
3
  import type { BaseEntityDialogueOption } from '../entities/BaseEntity';
@@ -45,14 +43,12 @@ export default class QuestRegistry {
45
43
  public static initializeQuests(): void {
46
44
  console.log('Loading quests...');
47
45
 
48
- const questFiles = this._findQuestFiles(__dirname);
46
+ const QuestClasses = require('./QuestClasses').default; // lazy load to avoid circular dependencies
49
47
  const npcIdCounters = new Map<typeof BaseEntity, number>();
50
48
  let loadedCount = 0;
51
49
 
52
- for (const filePath of questFiles) {
50
+ for (const QuestClass of QuestClasses) {
53
51
  try {
54
- const QuestClass = require(filePath).default;
55
-
56
52
  if (QuestClass?.prototype instanceof BaseQuest && QuestClass.id) {
57
53
  this._quests.set(QuestClass.id, QuestClass);
58
54
 
@@ -88,31 +84,11 @@ export default class QuestRegistry {
88
84
  loadedCount++;
89
85
  }
90
86
  } catch (error) {
91
- console.warn(`Failed to load quest: ${filePath}`);
87
+ console.warn(`Failed to load quest: ${QuestClass.id}`);
92
88
  }
93
89
  }
94
90
 
95
91
  console.log(`Loaded ${loadedCount} quests`);
96
92
  }
97
-
98
- private static _findQuestFiles(dir: string): string[] {
99
- const files: string[] = [];
100
-
101
- try {
102
- for (const item of readdirSync(dir)) {
103
- const path = join(dir, item);
104
-
105
- if (statSync(path).isDirectory()) {
106
- files.push(...this._findQuestFiles(path));
107
- } else if (!item.startsWith('Base') && (item.endsWith('.ts') || item.endsWith('.js'))) {
108
- files.push(path);
109
- }
110
- }
111
- } catch (error) {
112
- console.warn(`Failed to read directory: ${dir}`);
113
- }
114
-
115
- return files;
116
- }
117
93
  }
118
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/examples",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",