@directivegames/genesys.js 3.1.24 → 3.1.25

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 (281) hide show
  1. package/dist/games/animation-demo.d.ts +1 -1
  2. package/dist/games/animation-demo.js +2 -2
  3. package/dist/games/animation-retarget-demo.d.ts +1 -1
  4. package/dist/games/animation-retarget-demo.js +3 -3
  5. package/dist/games/behavior-tree-demo.d.ts +1 -1
  6. package/dist/games/behavior-tree-demo.js +2 -2
  7. package/dist/games/character_animation.d.ts +1 -1
  8. package/dist/games/character_animation.js +2 -2
  9. package/dist/games/collision-demo.d.ts +1 -1
  10. package/dist/games/collision-demo.js +2 -2
  11. package/dist/games/deprecated/advanced-grid-demo.d.ts +1 -1
  12. package/dist/games/deprecated/advanced-grid-demo.js +2 -2
  13. package/dist/games/deprecated/airplane-demo.d.ts +1 -1
  14. package/dist/games/deprecated/airplane-demo.js +2 -2
  15. package/dist/games/deprecated/character-controller.d.ts +1 -1
  16. package/dist/games/deprecated/character-controller.js +2 -2
  17. package/dist/games/deprecated/chase-game.d.ts +1 -1
  18. package/dist/games/deprecated/chase-game.js +2 -2
  19. package/dist/games/deprecated/collision-config.d.ts +1 -1
  20. package/dist/games/deprecated/collision-config.js +2 -2
  21. package/dist/games/deprecated/door-demo.d.ts +1 -1
  22. package/dist/games/deprecated/door-demo.js +2 -2
  23. package/dist/games/deprecated/fps-demo.d.ts +1 -1
  24. package/dist/games/deprecated/fps-demo.js +2 -2
  25. package/dist/games/deprecated/fps-shotgun-demo.d.ts +1 -1
  26. package/dist/games/deprecated/fps-shotgun-demo.js +2 -2
  27. package/dist/games/deprecated/lightmapping-demo.d.ts +1 -1
  28. package/dist/games/deprecated/lightmapping-demo.js +2 -2
  29. package/dist/games/deprecated/lights-demo.d.ts +1 -1
  30. package/dist/games/deprecated/lights-demo.js +2 -2
  31. package/dist/games/deprecated/matcap-demo.d.ts +1 -1
  32. package/dist/games/deprecated/matcap-demo.js +2 -2
  33. package/dist/games/deprecated/material-demo-2.d.ts +1 -1
  34. package/dist/games/deprecated/material-demo-2.js +2 -2
  35. package/dist/games/deprecated/material-demo.d.ts +1 -1
  36. package/dist/games/deprecated/material-demo.js +2 -2
  37. package/dist/games/deprecated/memory-leak-test.d.ts +1 -1
  38. package/dist/games/deprecated/memory-leak-test.js +2 -2
  39. package/dist/games/deprecated/model-stress-test.d.ts +1 -1
  40. package/dist/games/deprecated/model-stress-test.js +2 -2
  41. package/dist/games/deprecated/multiplayer-demo.d.ts +1 -1
  42. package/dist/games/deprecated/multiplayer-demo.js +2 -2
  43. package/dist/games/deprecated/physics-demo.d.ts +1 -1
  44. package/dist/games/deprecated/physics-demo.js +2 -2
  45. package/dist/games/deprecated/shadow-demo.d.ts +1 -1
  46. package/dist/games/deprecated/shadow-demo.js +2 -2
  47. package/dist/games/deprecated/shooting-demo.d.ts +1 -1
  48. package/dist/games/deprecated/shooting-demo.js +2 -2
  49. package/dist/games/deprecated/skybox-demo.d.ts +1 -1
  50. package/dist/games/deprecated/skybox-demo.js +2 -2
  51. package/dist/games/deprecated/sound-demo.d.ts +1 -1
  52. package/dist/games/deprecated/sound-demo.js +2 -2
  53. package/dist/games/deprecated/timer-demo.d.ts +1 -1
  54. package/dist/games/deprecated/timer-demo.js +2 -2
  55. package/dist/games/deprecated/voxel-demo.d.ts +1 -1
  56. package/dist/games/deprecated/voxel-demo.js +2 -2
  57. package/dist/games/deprecated/world-commands.d.ts +1 -1
  58. package/dist/games/deprecated/world-commands.js +2 -2
  59. package/dist/games/deprecated/world-loading.d.ts +1 -1
  60. package/dist/games/deprecated/world-loading.js +2 -2
  61. package/dist/games/examples/fps-advanced/enemies.d.ts +1 -1
  62. package/dist/games/examples/fps-advanced/enemies.js +2 -2
  63. package/dist/games/examples/fps-advanced/game-mode.d.ts +1 -1
  64. package/dist/games/examples/fps-advanced/game-mode.js +2 -2
  65. package/dist/games/examples/fps-advanced/game.d.ts +1 -1
  66. package/dist/games/examples/fps-advanced/game.js +2 -2
  67. package/dist/games/examples/fps-advanced/pickups.d.ts +1 -1
  68. package/dist/games/examples/fps-advanced/pickups.js +2 -2
  69. package/dist/games/examples/fps-advanced/player.d.ts +1 -1
  70. package/dist/games/examples/fps-advanced/player.js +2 -2
  71. package/dist/games/examples/fps-advanced/ui/endgame-ui.d.ts +1 -1
  72. package/dist/games/examples/fps-advanced/ui/endgame-ui.js +2 -2
  73. package/dist/games/examples/fps-advanced/ui/menu-ui.d.ts +1 -1
  74. package/dist/games/examples/fps-advanced/ui/menu-ui.js +2 -2
  75. package/dist/games/examples/fps-advanced/ui/weapon-hud.d.ts +1 -1
  76. package/dist/games/examples/fps-advanced/weapons.d.ts +1 -1
  77. package/dist/games/examples/fps-advanced/weapons.js +2 -2
  78. package/dist/games/examples/plugin-demo/game.d.ts +1 -1
  79. package/dist/games/examples/plugin-demo/game.js +3 -3
  80. package/dist/games/examples/plugin-demo/plugins/dynamic-lighting.d.ts +1 -1
  81. package/dist/games/examples/plugin-demo/plugins/dynamic-lighting.js +2 -2
  82. package/dist/games/examples/plugin-demo/plugins/instanced-forest.d.ts +1 -1
  83. package/dist/games/examples/plugin-demo/plugins/instanced-forest.js +2 -2
  84. package/dist/games/examples/plugin-demo/plugins/particle-fountain.d.ts +1 -1
  85. package/dist/games/examples/plugin-demo/plugins/particle-fountain.js +2 -2
  86. package/dist/games/examples/plugin-demo/plugins/physics-playground.d.ts +1 -1
  87. package/dist/games/examples/plugin-demo/plugins/physics-playground.js +2 -2
  88. package/dist/games/examples/plugin-demo/plugins/robot-follower.d.ts +1 -1
  89. package/dist/games/examples/plugin-demo/plugins/robot-follower.js +2 -2
  90. package/dist/games/examples/plugin-demo/plugins/scatter-models.d.ts +1 -1
  91. package/dist/games/examples/plugin-demo/plugins/scatter-models.js +2 -2
  92. package/dist/games/examples/plugin-demo/plugins/simple-cube.d.ts +1 -1
  93. package/dist/games/examples/plugin-demo/plugins/simple-cube.js +2 -2
  94. package/dist/games/examples/plugin-demo/plugins/tic-tac-toe.d.ts +1 -1
  95. package/dist/games/examples/plugin-demo/plugins/tic-tac-toe.js +2 -2
  96. package/dist/games/examples/plugin-demo/plugins/wobbling-sphere.d.ts +1 -1
  97. package/dist/games/examples/plugin-demo/plugins/wobbling-sphere.js +2 -2
  98. package/dist/games/examples/side-scroller-advanced/game-mode.d.ts +1 -1
  99. package/dist/games/examples/side-scroller-advanced/game-mode.js +2 -2
  100. package/dist/games/examples/side-scroller-advanced/game.d.ts +1 -1
  101. package/dist/games/examples/side-scroller-advanced/game.js +2 -2
  102. package/dist/games/examples/side-scroller-advanced/level-generator.d.ts +1 -1
  103. package/dist/games/examples/side-scroller-advanced/level-generator.js +2 -2
  104. package/dist/games/examples/side-scroller-advanced/pickups.d.ts +1 -1
  105. package/dist/games/examples/side-scroller-advanced/pickups.js +2 -2
  106. package/dist/games/examples/side-scroller-advanced/player.d.ts +1 -1
  107. package/dist/games/examples/side-scroller-advanced/player.js +2 -2
  108. package/dist/games/examples/side-scroller-advanced/ui/endgame-ui.d.ts +1 -1
  109. package/dist/games/examples/side-scroller-advanced/ui/endgame-ui.js +2 -2
  110. package/dist/games/examples/side-scroller-advanced/ui/menu-ui.d.ts +1 -1
  111. package/dist/games/examples/side-scroller-advanced/ui/menu-ui.js +2 -2
  112. package/dist/games/examples/vehicle/base-vehicle.d.ts +1 -1
  113. package/dist/games/examples/vehicle/base-vehicle.js +2 -2
  114. package/dist/games/examples/vehicle/game.d.ts +1 -1
  115. package/dist/games/examples/vehicle/game.js +2 -2
  116. package/dist/games/examples/vehicle/mesh-vehicle.d.ts +1 -1
  117. package/dist/games/examples/vehicle/mesh-vehicle.js +2 -2
  118. package/dist/games/examples/vehicle/player.d.ts +1 -1
  119. package/dist/games/examples/vehicle/player.js +2 -2
  120. package/dist/games/examples/vehicle/primitive-vehicle.d.ts +1 -1
  121. package/dist/games/examples/vehicle/primitive-vehicle.js +2 -2
  122. package/dist/games/examples/vr-game/VRAttachableCube.d.ts +1 -1
  123. package/dist/games/examples/vr-game/VRAttachableCube.js +2 -2
  124. package/dist/games/examples/vr-game/VRInteractableCylinder.d.ts +1 -1
  125. package/dist/games/examples/vr-game/VRInteractableCylinder.js +2 -2
  126. package/dist/games/examples/vr-game/VRPressableButton.d.ts +1 -1
  127. package/dist/games/examples/vr-game/VRPressableButton.js +2 -2
  128. package/dist/games/examples/vr-game/VRProjectileActor.d.ts +1 -1
  129. package/dist/games/examples/vr-game/VRProjectileActor.js +2 -2
  130. package/dist/games/examples/vr-game/VRRifleActor.d.ts +1 -1
  131. package/dist/games/examples/vr-game/VRRifleActor.js +2 -2
  132. package/dist/games/examples/vr-game/game.d.ts +1 -1
  133. package/dist/games/examples/vr-game/game.js +2 -2
  134. package/dist/games/examples/vr-game/scene.d.ts +1 -1
  135. package/dist/games/examples/vr-game/scene.js +2 -2
  136. package/dist/games/instanced-mesh-demo.d.ts +1 -1
  137. package/dist/games/instanced-mesh-demo.js +2 -2
  138. package/dist/games/manifold-demo.d.ts +1 -1
  139. package/dist/games/manifold-demo.js +2 -2
  140. package/dist/games/navigation-demo.d.ts +1 -1
  141. package/dist/games/navigation-demo.js +2 -2
  142. package/dist/games/navmesh-primitives-demo.d.ts +1 -1
  143. package/dist/games/navmesh-primitives-demo.js +2 -2
  144. package/dist/games/postprocess-demo.d.ts +1 -1
  145. package/dist/games/postprocess-demo.js +3 -3
  146. package/dist/games/ragdoll-demo-simple.d.ts +1 -1
  147. package/dist/games/ragdoll-demo-simple.js +2 -2
  148. package/dist/games/ragdoll-demo.d.ts +1 -1
  149. package/dist/games/ragdoll-demo.js +2 -2
  150. package/dist/games/swipe-tap-demo.d.ts +1 -1
  151. package/dist/games/swipe-tap-demo.js +2 -2
  152. package/dist/games/tween-demo.d.ts +1 -1
  153. package/dist/games/tween-demo.js +2 -2
  154. package/dist/games/ui-demo.d.ts +1 -1
  155. package/dist/games/ui-demo.js +2 -2
  156. package/dist/games/vfx-demo.d.ts +1 -1
  157. package/dist/games/vfx-demo.js +2 -2
  158. package/dist/games/vfx-wawa-demo.d.ts +1 -1
  159. package/dist/games/vfx-wawa-demo.js +2 -2
  160. package/dist/games/vr-ui-demo-minimal.d.ts +1 -1
  161. package/dist/games/vr-ui-demo-minimal.js +2 -2
  162. package/dist/games/vr-ui-demo.d.ts +1 -1
  163. package/dist/games/vr-ui-demo.js +2 -2
  164. package/dist/launcher.js +2 -2
  165. package/dist/scripts/dump-templates.js +2 -2
  166. package/dist/test/absolute-transform.test.js +2 -2
  167. package/dist/test/asset-path.test.js +2 -2
  168. package/dist/test/component.test.js +2 -2
  169. package/dist/test/construction.test.js +2 -2
  170. package/dist/test/default-options-validation.test.js +2 -2
  171. package/dist/test/metadata.test.js +2 -2
  172. package/dist/test/nodeStorage.d.ts +2 -2
  173. package/dist/test/nodeStorage.js +3 -3
  174. package/dist/test/prefab.test.js +2 -2
  175. package/dist/test/scene-component.test.js +2 -2
  176. package/dist/test/scene-graph.test.js +2 -2
  177. package/dist/test/serialization-v1.test.d.ts +1 -1
  178. package/dist/test/serialization-v1.test.js +3 -3
  179. package/dist/test/serialization.test.js +2 -2
  180. package/dist/test/spawn.test.js +2 -2
  181. package/dist/test/utils.d.ts +1 -1
  182. package/dist/test/utils.js +2 -2
  183. package/docs/guides/15-global-audio-manager.md +1 -1
  184. package/docs/guides/16-ragdoll-physics.md +1 -1
  185. package/docs/guides/18-lightmapping-system.md +3 -3
  186. package/docs/guides/19-webxr-virtual-reality.md +1 -1
  187. package/docs/guides/4-visuals-and-rendering.md +5 -5
  188. package/docs/guides/6-ai-and-behavior-trees.md +4 -4
  189. package/games/animation-demo.ts +1 -1
  190. package/games/animation-retarget-demo.ts +2 -2
  191. package/games/behavior-tree-demo.ts +1 -1
  192. package/games/character_animation.ts +1 -1
  193. package/games/collision-demo.ts +1 -1
  194. package/games/deprecated/advanced-grid-demo.ts +1 -1
  195. package/games/deprecated/airplane-demo.ts +1 -1
  196. package/games/deprecated/character-controller.ts +1 -1
  197. package/games/deprecated/chase-game.ts +1 -1
  198. package/games/deprecated/collision-config.ts +1 -1
  199. package/games/deprecated/door-demo.ts +1 -1
  200. package/games/deprecated/fps-demo.ts +1 -1
  201. package/games/deprecated/fps-shotgun-demo.ts +1 -1
  202. package/games/deprecated/index.ts +25 -25
  203. package/games/deprecated/lightmapping-demo.ts +1 -1
  204. package/games/deprecated/lights-demo.ts +1 -1
  205. package/games/deprecated/matcap-demo.ts +1 -1
  206. package/games/deprecated/material-demo-2.ts +1 -1
  207. package/games/deprecated/material-demo.ts +1 -1
  208. package/games/deprecated/memory-leak-test.ts +1 -1
  209. package/games/deprecated/model-stress-test.ts +1 -1
  210. package/games/deprecated/multiplayer-demo.ts +1 -1
  211. package/games/deprecated/physics-demo.ts +1 -1
  212. package/games/deprecated/shadow-demo.ts +1 -1
  213. package/games/deprecated/shooting-demo.ts +1 -1
  214. package/games/deprecated/skybox-demo.ts +1 -1
  215. package/games/deprecated/sound-demo.ts +1 -1
  216. package/games/deprecated/timer-demo.ts +1 -1
  217. package/games/deprecated/voxel-demo.ts +1 -1
  218. package/games/deprecated/world-commands.ts +1 -1
  219. package/games/deprecated/world-loading.ts +1 -1
  220. package/games/examples/fps-advanced/enemies.ts +1 -1
  221. package/games/examples/fps-advanced/game-mode.ts +1 -1
  222. package/games/examples/fps-advanced/game.ts +1 -1
  223. package/games/examples/fps-advanced/pickups.ts +1 -1
  224. package/games/examples/fps-advanced/player.ts +1 -1
  225. package/games/examples/fps-advanced/ui/endgame-ui.ts +1 -1
  226. package/games/examples/fps-advanced/ui/menu-ui.ts +1 -1
  227. package/games/examples/fps-advanced/ui/weapon-hud.ts +253 -253
  228. package/games/examples/fps-advanced/weapons.ts +1 -1
  229. package/games/examples/index.ts +5 -5
  230. package/games/examples/plugin-demo/game.ts +2 -2
  231. package/games/examples/plugin-demo/plugins/dynamic-lighting.ts +1 -1
  232. package/games/examples/plugin-demo/plugins/instanced-forest.ts +1 -1
  233. package/games/examples/plugin-demo/plugins/particle-fountain.ts +1 -1
  234. package/games/examples/plugin-demo/plugins/physics-playground.ts +1 -1
  235. package/games/examples/plugin-demo/plugins/robot-follower.ts +1 -1
  236. package/games/examples/plugin-demo/plugins/scatter-models.ts +1 -1
  237. package/games/examples/plugin-demo/plugins/simple-cube.ts +1 -1
  238. package/games/examples/plugin-demo/plugins/tic-tac-toe.ts +1 -1
  239. package/games/examples/plugin-demo/plugins/wobbling-sphere.ts +1 -1
  240. package/games/examples/side-scroller-advanced/game-mode.ts +1 -1
  241. package/games/examples/side-scroller-advanced/game.ts +1 -1
  242. package/games/examples/side-scroller-advanced/level-generator.ts +1 -1
  243. package/games/examples/side-scroller-advanced/pickups.ts +1 -1
  244. package/games/examples/side-scroller-advanced/player.ts +1 -1
  245. package/games/examples/side-scroller-advanced/ui/endgame-ui.ts +1 -1
  246. package/games/examples/side-scroller-advanced/ui/menu-ui.ts +1 -1
  247. package/games/examples/vehicle/base-vehicle.ts +1 -1
  248. package/games/examples/vehicle/game.ts +1 -1
  249. package/games/examples/vehicle/mesh-vehicle.ts +1 -1
  250. package/games/examples/vehicle/player.ts +1 -1
  251. package/games/examples/vehicle/primitive-vehicle.ts +1 -1
  252. package/games/examples/vr-game/VRAttachableCube.ts +1 -1
  253. package/games/examples/vr-game/VRInteractableCylinder.ts +1 -1
  254. package/games/examples/vr-game/VRPressableButton.ts +1 -1
  255. package/games/examples/vr-game/VRProjectileActor.ts +1 -1
  256. package/games/examples/vr-game/VRRifleActor.ts +1 -1
  257. package/games/examples/vr-game/game.ts +1 -1
  258. package/games/examples/vr-game/scene.ts +1 -1
  259. package/games/instanced-mesh-demo.ts +1 -1
  260. package/games/manifold-demo.ts +1 -1
  261. package/games/navigation-demo.ts +1 -1
  262. package/games/navmesh-primitives-demo.ts +1 -1
  263. package/games/postprocess-demo.ts +2 -2
  264. package/games/ragdoll-demo-simple.ts +1 -1
  265. package/games/ragdoll-demo.ts +1 -1
  266. package/games/swipe-tap-demo.ts +1 -1
  267. package/games/tween-demo.ts +1 -1
  268. package/games/ui-demo.ts +1 -1
  269. package/games/vfx-demo.ts +1 -1
  270. package/games/vfx-wawa-demo.ts +1 -1
  271. package/games/vr-ui-demo-minimal.ts +1 -1
  272. package/games/vr-ui-demo.ts +1 -1
  273. package/package.json +1 -1
  274. package/scripts/dump-templates.ts +1 -1
  275. package/src/global.d.ts +11 -11
  276. package/src/multiplayer/MovementPrediction.ts +202 -202
  277. package/src/templates/MyActor.ts +1 -1
  278. package/src/templates/MySceneComponent.ts +1 -1
  279. package/src/ui/UIResource.ts +20 -20
  280. package/src/utils/browser-polyfills/module.ts +35 -35
  281. package/src/utils/browser-polyfills/path.ts +231 -231
@@ -1,254 +1,254 @@
1
- import { UI_CONFIG } from '../const.js';
2
-
3
- import type { WeaponComponent } from '../weapons.js';
4
- import type * as ENGINE from 'genesys.js';
5
-
6
-
7
-
8
- // ============================================================================
9
- // WEAPON HUD COMPONENT
10
- // ============================================================================
11
-
12
- export interface WeaponHUDOptions {
13
- position?: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
14
- }
15
-
16
- export class WeaponInfoHUD {
17
- private uiManager: ENGINE.UIManager;
18
- private weaponInfoContainer: ENGINE.UIElement | null = null;
19
- private weaponNameElement: ENGINE.UIElement | null = null;
20
- private ammoCounterElement: ENGINE.UIElement | null = null;
21
- private firingModeElement: ENGINE.UIElement | null = null;
22
- private reloadIndicatorElement: ENGINE.UIElement | null = null;
23
-
24
- private currentWeapon: WeaponComponent | null = null;
25
- private updateInterval: number | null = null;
26
-
27
- constructor(uiManager: ENGINE.UIManager, options: WeaponHUDOptions = {}) {
28
- this.uiManager = uiManager;
29
- this.createHUD(options);
30
- this.startUpdateLoop();
31
- }
32
-
33
- private createHUD(options: WeaponHUDOptions): void {
34
- const position = options.position ?? 'bottom-right';
35
-
36
- // Create main container
37
- this.weaponInfoContainer = this.uiManager.createElement('weapon-hud-container', {
38
- tag: 'div',
39
- style: {
40
- position: 'absolute',
41
- padding: '15px',
42
- backgroundColor: 'rgba(0, 0, 0, 0.7)',
43
- borderRadius: '8px',
44
- color: 'white',
45
- fontFamily: 'Arial, sans-serif',
46
- fontSize: '14px',
47
- minWidth: '200px',
48
- border: '2px solid rgba(255, 255, 255, 0.3)',
49
- boxShadow: '0 4px 8px rgba(0, 0, 0, 0.5)',
50
- zIndex: '1000',
51
- ...this.getPositionStyles(position)
52
- }
53
- });
54
-
55
- // Create weapon name element
56
- this.weaponNameElement = this.uiManager.createElement('weapon-name', {
57
- tag: 'div',
58
- textContent: 'No Weapon',
59
- style: {
60
- fontSize: '16px',
61
- fontWeight: 'bold',
62
- marginBottom: '8px',
63
- color: '#ffd700',
64
- textTransform: 'uppercase',
65
- letterSpacing: '1px'
66
- }
67
- });
68
-
69
- // Create ammo counter element
70
- this.ammoCounterElement = this.uiManager.createElement('ammo-counter', {
71
- tag: 'div',
72
- textContent: '-- / --',
73
- style: {
74
- fontSize: '18px',
75
- fontWeight: 'bold',
76
- marginBottom: '4px',
77
- color: '#00ff00'
78
- }
79
- });
80
-
81
- // Create firing mode element
82
- this.firingModeElement = this.uiManager.createElement('firing-mode', {
83
- tag: 'div',
84
- textContent: 'SEMI',
85
- style: {
86
- fontSize: '12px',
87
- marginBottom: '4px',
88
- color: '#cccccc',
89
- textTransform: 'uppercase'
90
- }
91
- });
92
-
93
- // Create reload indicator element
94
- this.reloadIndicatorElement = this.uiManager.createElement('reload-indicator', {
95
- tag: 'div',
96
- textContent: '',
97
- style: {
98
- fontSize: '12px',
99
- color: '#ff6600',
100
- fontWeight: 'bold',
101
- display: 'none'
102
- }
103
- });
104
-
105
- // Add all elements to container
106
- this.weaponNameElement.appendTo(this.weaponInfoContainer);
107
- this.ammoCounterElement.appendTo(this.weaponInfoContainer);
108
- this.firingModeElement.appendTo(this.weaponInfoContainer);
109
- this.reloadIndicatorElement.appendTo(this.weaponInfoContainer);
110
- }
111
-
112
- private getPositionStyles(position: string): Record<string, string> {
113
- switch (position) {
114
- case 'top-left':
115
- return { top: '20px', left: '20px' };
116
- case 'top-center':
117
- return { top: '20px', left: '50%', transform: 'translateX(-50%)' };
118
- case 'top-right':
119
- return { top: '20px', right: '20px' };
120
- case 'bottom-left':
121
- return { bottom: '20px', left: '20px' };
122
- case 'bottom-center':
123
- return { bottom: '20px', left: '50%', transform: 'translateX(-50%)' };
124
- case 'bottom-right':
125
- default:
126
- return { bottom: '20px', right: '20px' };
127
- }
128
- }
129
-
130
- public setWeapon(weapon: WeaponComponent | null): void {
131
- this.currentWeapon = weapon;
132
- this.updateDisplay();
133
- }
134
-
135
- private startUpdateLoop(): void {
136
- // Update every 100ms to keep info current
137
- this.updateInterval = window.setInterval(() => {
138
- this.updateDisplay();
139
- }, UI_CONFIG.AMMO_UPDATE_INTERVAL);
140
- }
141
-
142
- private updateDisplay(): void {
143
- if (!this.currentWeapon) {
144
- this.weaponNameElement?.setText('No Weapon');
145
- this.ammoCounterElement?.setText('-- / --');
146
- this.firingModeElement?.setText('--');
147
- this.reloadIndicatorElement?.hide();
148
- return;
149
- }
150
-
151
- // Update weapon name
152
- const weaponName = this.getWeaponName(this.currentWeapon);
153
- this.weaponNameElement?.setText(weaponName);
154
-
155
- // Update ammo counter
156
- const currentAmmo = this.getCurrentAmmo(this.currentWeapon);
157
- const maxAmmo = this.getMaxAmmo(this.currentWeapon);
158
-
159
- if (maxAmmo > 0) {
160
- this.ammoCounterElement?.setText(`${currentAmmo} / ${maxAmmo}`);
161
-
162
- // Color-code ammo based on amount
163
- if (currentAmmo === 0) {
164
- this.ammoCounterElement?.setStyle('color', '#ff0000'); // Red for empty
165
- } else if (currentAmmo <= maxAmmo * 0.2) {
166
- this.ammoCounterElement?.setStyle('color', '#ffaa00'); // Orange for low
167
- } else {
168
- this.ammoCounterElement?.setStyle('color', '#00ff00'); // Green for normal
169
- }
170
- } else {
171
- this.ammoCounterElement?.setText('∞');
172
- this.ammoCounterElement?.setStyle('color', '#00ff00');
173
- }
174
-
175
- // Update firing mode
176
- const firingMode = this.getFiringMode(this.currentWeapon);
177
- this.firingModeElement?.setText(firingMode);
178
-
179
- // Update reload indicator
180
- if (this.isReloading(this.currentWeapon)) {
181
- this.reloadIndicatorElement?.setText('RELOADING...');
182
- this.reloadIndicatorElement?.show();
183
- } else {
184
- this.reloadIndicatorElement?.hide();
185
- }
186
- }
187
-
188
- private getWeaponName(weapon: WeaponComponent): string {
189
- const className = weapon.constructor.name;
190
-
191
- // Extract weapon name from class name
192
- if (className.includes('SniperRifle')) return 'Sniper Rifle';
193
- if (className.includes('SMG')) return 'SMG';
194
- if (className.includes('Shotgun')) return 'Shotgun';
195
-
196
- // Fallback: clean up class name
197
- return className.replace(/^AdvancedWeapon_/, '').replace(/([A-Z])/g, ' $1').trim();
198
- }
199
-
200
- private getCurrentAmmo(weapon: WeaponComponent): number {
201
- // Try to get current ammo using the standard method
202
- if ('getCurrentAmmo' in weapon && typeof weapon.getCurrentAmmo === 'function') {
203
- return weapon.getCurrentAmmo();
204
- }
205
- return 0;
206
- }
207
-
208
- private getMaxAmmo(weapon: WeaponComponent): number {
209
- // Try to get max ammo using the standard method
210
- if ('getMaxAmmo' in weapon && typeof weapon.getMaxAmmo === 'function') {
211
- return weapon.getMaxAmmo();
212
- }
213
- return 0;
214
- }
215
-
216
- private getFiringMode(weapon: WeaponComponent): string {
217
- // Check if weapon has single fire mode information
218
- if ('options' in weapon && weapon.options && typeof weapon.options === 'object') {
219
- const options = weapon.options as any;
220
- if ('isSingleFire' in options) {
221
- return options.isSingleFire ? 'SEMI' : 'AUTO';
222
- }
223
- }
224
- return 'AUTO'; // Default assumption
225
- }
226
-
227
- private isReloading(weapon: WeaponComponent): boolean {
228
- // Since isReloading is protected, we can't access it directly
229
- // For now, return false as a safe default
230
- // In a real implementation, you might add a public method to get reload status
231
- return false;
232
- }
233
-
234
- public destroy(): void {
235
- if (this.updateInterval) {
236
- window.clearInterval(this.updateInterval);
237
- this.updateInterval = null;
238
- }
239
-
240
- // UIElement uses remove() method instead of destroy()
241
- this.weaponInfoContainer?.remove();
242
- this.weaponNameElement?.remove();
243
- this.ammoCounterElement?.remove();
244
- this.firingModeElement?.remove();
245
- this.reloadIndicatorElement?.remove();
246
-
247
- this.weaponInfoContainer = null;
248
- this.weaponNameElement = null;
249
- this.ammoCounterElement = null;
250
- this.firingModeElement = null;
251
- this.reloadIndicatorElement = null;
252
- this.currentWeapon = null;
253
- }
1
+ import { UI_CONFIG } from '../const.js';
2
+
3
+ import type { WeaponComponent } from '../weapons.js';
4
+ import type * as ENGINE from '@directivegames/genesys.js';
5
+
6
+
7
+
8
+ // ============================================================================
9
+ // WEAPON HUD COMPONENT
10
+ // ============================================================================
11
+
12
+ export interface WeaponHUDOptions {
13
+ position?: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
14
+ }
15
+
16
+ export class WeaponInfoHUD {
17
+ private uiManager: ENGINE.UIManager;
18
+ private weaponInfoContainer: ENGINE.UIElement | null = null;
19
+ private weaponNameElement: ENGINE.UIElement | null = null;
20
+ private ammoCounterElement: ENGINE.UIElement | null = null;
21
+ private firingModeElement: ENGINE.UIElement | null = null;
22
+ private reloadIndicatorElement: ENGINE.UIElement | null = null;
23
+
24
+ private currentWeapon: WeaponComponent | null = null;
25
+ private updateInterval: number | null = null;
26
+
27
+ constructor(uiManager: ENGINE.UIManager, options: WeaponHUDOptions = {}) {
28
+ this.uiManager = uiManager;
29
+ this.createHUD(options);
30
+ this.startUpdateLoop();
31
+ }
32
+
33
+ private createHUD(options: WeaponHUDOptions): void {
34
+ const position = options.position ?? 'bottom-right';
35
+
36
+ // Create main container
37
+ this.weaponInfoContainer = this.uiManager.createElement('weapon-hud-container', {
38
+ tag: 'div',
39
+ style: {
40
+ position: 'absolute',
41
+ padding: '15px',
42
+ backgroundColor: 'rgba(0, 0, 0, 0.7)',
43
+ borderRadius: '8px',
44
+ color: 'white',
45
+ fontFamily: 'Arial, sans-serif',
46
+ fontSize: '14px',
47
+ minWidth: '200px',
48
+ border: '2px solid rgba(255, 255, 255, 0.3)',
49
+ boxShadow: '0 4px 8px rgba(0, 0, 0, 0.5)',
50
+ zIndex: '1000',
51
+ ...this.getPositionStyles(position)
52
+ }
53
+ });
54
+
55
+ // Create weapon name element
56
+ this.weaponNameElement = this.uiManager.createElement('weapon-name', {
57
+ tag: 'div',
58
+ textContent: 'No Weapon',
59
+ style: {
60
+ fontSize: '16px',
61
+ fontWeight: 'bold',
62
+ marginBottom: '8px',
63
+ color: '#ffd700',
64
+ textTransform: 'uppercase',
65
+ letterSpacing: '1px'
66
+ }
67
+ });
68
+
69
+ // Create ammo counter element
70
+ this.ammoCounterElement = this.uiManager.createElement('ammo-counter', {
71
+ tag: 'div',
72
+ textContent: '-- / --',
73
+ style: {
74
+ fontSize: '18px',
75
+ fontWeight: 'bold',
76
+ marginBottom: '4px',
77
+ color: '#00ff00'
78
+ }
79
+ });
80
+
81
+ // Create firing mode element
82
+ this.firingModeElement = this.uiManager.createElement('firing-mode', {
83
+ tag: 'div',
84
+ textContent: 'SEMI',
85
+ style: {
86
+ fontSize: '12px',
87
+ marginBottom: '4px',
88
+ color: '#cccccc',
89
+ textTransform: 'uppercase'
90
+ }
91
+ });
92
+
93
+ // Create reload indicator element
94
+ this.reloadIndicatorElement = this.uiManager.createElement('reload-indicator', {
95
+ tag: 'div',
96
+ textContent: '',
97
+ style: {
98
+ fontSize: '12px',
99
+ color: '#ff6600',
100
+ fontWeight: 'bold',
101
+ display: 'none'
102
+ }
103
+ });
104
+
105
+ // Add all elements to container
106
+ this.weaponNameElement.appendTo(this.weaponInfoContainer);
107
+ this.ammoCounterElement.appendTo(this.weaponInfoContainer);
108
+ this.firingModeElement.appendTo(this.weaponInfoContainer);
109
+ this.reloadIndicatorElement.appendTo(this.weaponInfoContainer);
110
+ }
111
+
112
+ private getPositionStyles(position: string): Record<string, string> {
113
+ switch (position) {
114
+ case 'top-left':
115
+ return { top: '20px', left: '20px' };
116
+ case 'top-center':
117
+ return { top: '20px', left: '50%', transform: 'translateX(-50%)' };
118
+ case 'top-right':
119
+ return { top: '20px', right: '20px' };
120
+ case 'bottom-left':
121
+ return { bottom: '20px', left: '20px' };
122
+ case 'bottom-center':
123
+ return { bottom: '20px', left: '50%', transform: 'translateX(-50%)' };
124
+ case 'bottom-right':
125
+ default:
126
+ return { bottom: '20px', right: '20px' };
127
+ }
128
+ }
129
+
130
+ public setWeapon(weapon: WeaponComponent | null): void {
131
+ this.currentWeapon = weapon;
132
+ this.updateDisplay();
133
+ }
134
+
135
+ private startUpdateLoop(): void {
136
+ // Update every 100ms to keep info current
137
+ this.updateInterval = window.setInterval(() => {
138
+ this.updateDisplay();
139
+ }, UI_CONFIG.AMMO_UPDATE_INTERVAL);
140
+ }
141
+
142
+ private updateDisplay(): void {
143
+ if (!this.currentWeapon) {
144
+ this.weaponNameElement?.setText('No Weapon');
145
+ this.ammoCounterElement?.setText('-- / --');
146
+ this.firingModeElement?.setText('--');
147
+ this.reloadIndicatorElement?.hide();
148
+ return;
149
+ }
150
+
151
+ // Update weapon name
152
+ const weaponName = this.getWeaponName(this.currentWeapon);
153
+ this.weaponNameElement?.setText(weaponName);
154
+
155
+ // Update ammo counter
156
+ const currentAmmo = this.getCurrentAmmo(this.currentWeapon);
157
+ const maxAmmo = this.getMaxAmmo(this.currentWeapon);
158
+
159
+ if (maxAmmo > 0) {
160
+ this.ammoCounterElement?.setText(`${currentAmmo} / ${maxAmmo}`);
161
+
162
+ // Color-code ammo based on amount
163
+ if (currentAmmo === 0) {
164
+ this.ammoCounterElement?.setStyle('color', '#ff0000'); // Red for empty
165
+ } else if (currentAmmo <= maxAmmo * 0.2) {
166
+ this.ammoCounterElement?.setStyle('color', '#ffaa00'); // Orange for low
167
+ } else {
168
+ this.ammoCounterElement?.setStyle('color', '#00ff00'); // Green for normal
169
+ }
170
+ } else {
171
+ this.ammoCounterElement?.setText('∞');
172
+ this.ammoCounterElement?.setStyle('color', '#00ff00');
173
+ }
174
+
175
+ // Update firing mode
176
+ const firingMode = this.getFiringMode(this.currentWeapon);
177
+ this.firingModeElement?.setText(firingMode);
178
+
179
+ // Update reload indicator
180
+ if (this.isReloading(this.currentWeapon)) {
181
+ this.reloadIndicatorElement?.setText('RELOADING...');
182
+ this.reloadIndicatorElement?.show();
183
+ } else {
184
+ this.reloadIndicatorElement?.hide();
185
+ }
186
+ }
187
+
188
+ private getWeaponName(weapon: WeaponComponent): string {
189
+ const className = weapon.constructor.name;
190
+
191
+ // Extract weapon name from class name
192
+ if (className.includes('SniperRifle')) return 'Sniper Rifle';
193
+ if (className.includes('SMG')) return 'SMG';
194
+ if (className.includes('Shotgun')) return 'Shotgun';
195
+
196
+ // Fallback: clean up class name
197
+ return className.replace(/^AdvancedWeapon_/, '').replace(/([A-Z])/g, ' $1').trim();
198
+ }
199
+
200
+ private getCurrentAmmo(weapon: WeaponComponent): number {
201
+ // Try to get current ammo using the standard method
202
+ if ('getCurrentAmmo' in weapon && typeof weapon.getCurrentAmmo === 'function') {
203
+ return weapon.getCurrentAmmo();
204
+ }
205
+ return 0;
206
+ }
207
+
208
+ private getMaxAmmo(weapon: WeaponComponent): number {
209
+ // Try to get max ammo using the standard method
210
+ if ('getMaxAmmo' in weapon && typeof weapon.getMaxAmmo === 'function') {
211
+ return weapon.getMaxAmmo();
212
+ }
213
+ return 0;
214
+ }
215
+
216
+ private getFiringMode(weapon: WeaponComponent): string {
217
+ // Check if weapon has single fire mode information
218
+ if ('options' in weapon && weapon.options && typeof weapon.options === 'object') {
219
+ const options = weapon.options as any;
220
+ if ('isSingleFire' in options) {
221
+ return options.isSingleFire ? 'SEMI' : 'AUTO';
222
+ }
223
+ }
224
+ return 'AUTO'; // Default assumption
225
+ }
226
+
227
+ private isReloading(weapon: WeaponComponent): boolean {
228
+ // Since isReloading is protected, we can't access it directly
229
+ // For now, return false as a safe default
230
+ // In a real implementation, you might add a public method to get reload status
231
+ return false;
232
+ }
233
+
234
+ public destroy(): void {
235
+ if (this.updateInterval) {
236
+ window.clearInterval(this.updateInterval);
237
+ this.updateInterval = null;
238
+ }
239
+
240
+ // UIElement uses remove() method instead of destroy()
241
+ this.weaponInfoContainer?.remove();
242
+ this.weaponNameElement?.remove();
243
+ this.ammoCounterElement?.remove();
244
+ this.firingModeElement?.remove();
245
+ this.reloadIndicatorElement?.remove();
246
+
247
+ this.weaponInfoContainer = null;
248
+ this.weaponNameElement = null;
249
+ this.ammoCounterElement = null;
250
+ this.firingModeElement = null;
251
+ this.reloadIndicatorElement = null;
252
+ this.currentWeapon = null;
253
+ }
254
254
  }
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  import { SHOTGUN_CONFIG, SMG_CONFIG, SNIPER_RIFLE_CONFIG, UI_CONFIG } from './const.js';
@@ -1,5 +1,5 @@
1
- export * from './fps-advanced/game.js';
2
- export * from './plugin-demo/game.js';
3
- export * from './side-scroller-advanced/game.js';
4
- export * from './vehicle/game.js';
5
- export * from './vr-game/game.js';
1
+ export * from './fps-advanced/game.js';
2
+ export * from './plugin-demo/game.js';
3
+ export * from './side-scroller-advanced/game.js';
4
+ export * from './vehicle/game.js';
5
+ export * from './vr-game/game.js';
@@ -1,8 +1,8 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
 
3
3
 
4
4
  const defaultPluginCode = `
5
- import * as ENGINE from 'genesys.js';
5
+ import * as ENGINE from '@directivegames/genesys.js';
6
6
  import * as THREE from 'three';
7
7
 
8
8
  interface DemoPluginState {
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  class ColorChangingLight extends ENGINE.Actor {
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  class InstancedForest extends ENGINE.Actor {
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  class ParticleFountain extends ENGINE.Actor {
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  class PhysicsBox extends ENGINE.Actor {
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  class FloatingRobot extends ENGINE.Actor {
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  const GLTF_MODELS = [
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
 
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  enum GamePiece {
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  class WobblingSphere extends ENGINE.Actor {
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  import { GAME_CONFIG, LEVEL_CONFIG } from './const.js';
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  import { GAME_CONFIG, LEVEL_CONFIG, LIGHTING } from './const.js';
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  import { LEVEL_CONFIG, PICKUP_CONFIG } from './const.js';
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  import { PICKUP_CONFIG } from './const.js';
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  import { CAMERA_SETTINGS, GAME_CONFIG, PLAYER_MOVEMENT } from './const.js';
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
 
3
3
  export class EndGameUI {
4
4
  private container: HTMLElement | null = null;
@@ -1,4 +1,4 @@
1
- import * as ENGINE from 'genesys.js';
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
2
 
3
3
  export class MenuUI {
4
4
  // Event delegate for when the start game button is clicked