@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.
- package/dist/games/animation-demo.d.ts +1 -1
- package/dist/games/animation-demo.js +2 -2
- package/dist/games/animation-retarget-demo.d.ts +1 -1
- package/dist/games/animation-retarget-demo.js +3 -3
- package/dist/games/behavior-tree-demo.d.ts +1 -1
- package/dist/games/behavior-tree-demo.js +2 -2
- package/dist/games/character_animation.d.ts +1 -1
- package/dist/games/character_animation.js +2 -2
- package/dist/games/collision-demo.d.ts +1 -1
- package/dist/games/collision-demo.js +2 -2
- package/dist/games/deprecated/advanced-grid-demo.d.ts +1 -1
- package/dist/games/deprecated/advanced-grid-demo.js +2 -2
- package/dist/games/deprecated/airplane-demo.d.ts +1 -1
- package/dist/games/deprecated/airplane-demo.js +2 -2
- package/dist/games/deprecated/character-controller.d.ts +1 -1
- package/dist/games/deprecated/character-controller.js +2 -2
- package/dist/games/deprecated/chase-game.d.ts +1 -1
- package/dist/games/deprecated/chase-game.js +2 -2
- package/dist/games/deprecated/collision-config.d.ts +1 -1
- package/dist/games/deprecated/collision-config.js +2 -2
- package/dist/games/deprecated/door-demo.d.ts +1 -1
- package/dist/games/deprecated/door-demo.js +2 -2
- package/dist/games/deprecated/fps-demo.d.ts +1 -1
- package/dist/games/deprecated/fps-demo.js +2 -2
- package/dist/games/deprecated/fps-shotgun-demo.d.ts +1 -1
- package/dist/games/deprecated/fps-shotgun-demo.js +2 -2
- package/dist/games/deprecated/lightmapping-demo.d.ts +1 -1
- package/dist/games/deprecated/lightmapping-demo.js +2 -2
- package/dist/games/deprecated/lights-demo.d.ts +1 -1
- package/dist/games/deprecated/lights-demo.js +2 -2
- package/dist/games/deprecated/matcap-demo.d.ts +1 -1
- package/dist/games/deprecated/matcap-demo.js +2 -2
- package/dist/games/deprecated/material-demo-2.d.ts +1 -1
- package/dist/games/deprecated/material-demo-2.js +2 -2
- package/dist/games/deprecated/material-demo.d.ts +1 -1
- package/dist/games/deprecated/material-demo.js +2 -2
- package/dist/games/deprecated/memory-leak-test.d.ts +1 -1
- package/dist/games/deprecated/memory-leak-test.js +2 -2
- package/dist/games/deprecated/model-stress-test.d.ts +1 -1
- package/dist/games/deprecated/model-stress-test.js +2 -2
- package/dist/games/deprecated/multiplayer-demo.d.ts +1 -1
- package/dist/games/deprecated/multiplayer-demo.js +2 -2
- package/dist/games/deprecated/physics-demo.d.ts +1 -1
- package/dist/games/deprecated/physics-demo.js +2 -2
- package/dist/games/deprecated/shadow-demo.d.ts +1 -1
- package/dist/games/deprecated/shadow-demo.js +2 -2
- package/dist/games/deprecated/shooting-demo.d.ts +1 -1
- package/dist/games/deprecated/shooting-demo.js +2 -2
- package/dist/games/deprecated/skybox-demo.d.ts +1 -1
- package/dist/games/deprecated/skybox-demo.js +2 -2
- package/dist/games/deprecated/sound-demo.d.ts +1 -1
- package/dist/games/deprecated/sound-demo.js +2 -2
- package/dist/games/deprecated/timer-demo.d.ts +1 -1
- package/dist/games/deprecated/timer-demo.js +2 -2
- package/dist/games/deprecated/voxel-demo.d.ts +1 -1
- package/dist/games/deprecated/voxel-demo.js +2 -2
- package/dist/games/deprecated/world-commands.d.ts +1 -1
- package/dist/games/deprecated/world-commands.js +2 -2
- package/dist/games/deprecated/world-loading.d.ts +1 -1
- package/dist/games/deprecated/world-loading.js +2 -2
- package/dist/games/examples/fps-advanced/enemies.d.ts +1 -1
- package/dist/games/examples/fps-advanced/enemies.js +2 -2
- package/dist/games/examples/fps-advanced/game-mode.d.ts +1 -1
- package/dist/games/examples/fps-advanced/game-mode.js +2 -2
- package/dist/games/examples/fps-advanced/game.d.ts +1 -1
- package/dist/games/examples/fps-advanced/game.js +2 -2
- package/dist/games/examples/fps-advanced/pickups.d.ts +1 -1
- package/dist/games/examples/fps-advanced/pickups.js +2 -2
- package/dist/games/examples/fps-advanced/player.d.ts +1 -1
- package/dist/games/examples/fps-advanced/player.js +2 -2
- package/dist/games/examples/fps-advanced/ui/endgame-ui.d.ts +1 -1
- package/dist/games/examples/fps-advanced/ui/endgame-ui.js +2 -2
- package/dist/games/examples/fps-advanced/ui/menu-ui.d.ts +1 -1
- package/dist/games/examples/fps-advanced/ui/menu-ui.js +2 -2
- package/dist/games/examples/fps-advanced/ui/weapon-hud.d.ts +1 -1
- package/dist/games/examples/fps-advanced/weapons.d.ts +1 -1
- package/dist/games/examples/fps-advanced/weapons.js +2 -2
- package/dist/games/examples/plugin-demo/game.d.ts +1 -1
- package/dist/games/examples/plugin-demo/game.js +3 -3
- package/dist/games/examples/plugin-demo/plugins/dynamic-lighting.d.ts +1 -1
- package/dist/games/examples/plugin-demo/plugins/dynamic-lighting.js +2 -2
- package/dist/games/examples/plugin-demo/plugins/instanced-forest.d.ts +1 -1
- package/dist/games/examples/plugin-demo/plugins/instanced-forest.js +2 -2
- package/dist/games/examples/plugin-demo/plugins/particle-fountain.d.ts +1 -1
- package/dist/games/examples/plugin-demo/plugins/particle-fountain.js +2 -2
- package/dist/games/examples/plugin-demo/plugins/physics-playground.d.ts +1 -1
- package/dist/games/examples/plugin-demo/plugins/physics-playground.js +2 -2
- package/dist/games/examples/plugin-demo/plugins/robot-follower.d.ts +1 -1
- package/dist/games/examples/plugin-demo/plugins/robot-follower.js +2 -2
- package/dist/games/examples/plugin-demo/plugins/scatter-models.d.ts +1 -1
- package/dist/games/examples/plugin-demo/plugins/scatter-models.js +2 -2
- package/dist/games/examples/plugin-demo/plugins/simple-cube.d.ts +1 -1
- package/dist/games/examples/plugin-demo/plugins/simple-cube.js +2 -2
- package/dist/games/examples/plugin-demo/plugins/tic-tac-toe.d.ts +1 -1
- package/dist/games/examples/plugin-demo/plugins/tic-tac-toe.js +2 -2
- package/dist/games/examples/plugin-demo/plugins/wobbling-sphere.d.ts +1 -1
- package/dist/games/examples/plugin-demo/plugins/wobbling-sphere.js +2 -2
- package/dist/games/examples/side-scroller-advanced/game-mode.d.ts +1 -1
- package/dist/games/examples/side-scroller-advanced/game-mode.js +2 -2
- package/dist/games/examples/side-scroller-advanced/game.d.ts +1 -1
- package/dist/games/examples/side-scroller-advanced/game.js +2 -2
- package/dist/games/examples/side-scroller-advanced/level-generator.d.ts +1 -1
- package/dist/games/examples/side-scroller-advanced/level-generator.js +2 -2
- package/dist/games/examples/side-scroller-advanced/pickups.d.ts +1 -1
- package/dist/games/examples/side-scroller-advanced/pickups.js +2 -2
- package/dist/games/examples/side-scroller-advanced/player.d.ts +1 -1
- package/dist/games/examples/side-scroller-advanced/player.js +2 -2
- package/dist/games/examples/side-scroller-advanced/ui/endgame-ui.d.ts +1 -1
- package/dist/games/examples/side-scroller-advanced/ui/endgame-ui.js +2 -2
- package/dist/games/examples/side-scroller-advanced/ui/menu-ui.d.ts +1 -1
- package/dist/games/examples/side-scroller-advanced/ui/menu-ui.js +2 -2
- package/dist/games/examples/vehicle/base-vehicle.d.ts +1 -1
- package/dist/games/examples/vehicle/base-vehicle.js +2 -2
- package/dist/games/examples/vehicle/game.d.ts +1 -1
- package/dist/games/examples/vehicle/game.js +2 -2
- package/dist/games/examples/vehicle/mesh-vehicle.d.ts +1 -1
- package/dist/games/examples/vehicle/mesh-vehicle.js +2 -2
- package/dist/games/examples/vehicle/player.d.ts +1 -1
- package/dist/games/examples/vehicle/player.js +2 -2
- package/dist/games/examples/vehicle/primitive-vehicle.d.ts +1 -1
- package/dist/games/examples/vehicle/primitive-vehicle.js +2 -2
- package/dist/games/examples/vr-game/VRAttachableCube.d.ts +1 -1
- package/dist/games/examples/vr-game/VRAttachableCube.js +2 -2
- package/dist/games/examples/vr-game/VRInteractableCylinder.d.ts +1 -1
- package/dist/games/examples/vr-game/VRInteractableCylinder.js +2 -2
- package/dist/games/examples/vr-game/VRPressableButton.d.ts +1 -1
- package/dist/games/examples/vr-game/VRPressableButton.js +2 -2
- package/dist/games/examples/vr-game/VRProjectileActor.d.ts +1 -1
- package/dist/games/examples/vr-game/VRProjectileActor.js +2 -2
- package/dist/games/examples/vr-game/VRRifleActor.d.ts +1 -1
- package/dist/games/examples/vr-game/VRRifleActor.js +2 -2
- package/dist/games/examples/vr-game/game.d.ts +1 -1
- package/dist/games/examples/vr-game/game.js +2 -2
- package/dist/games/examples/vr-game/scene.d.ts +1 -1
- package/dist/games/examples/vr-game/scene.js +2 -2
- package/dist/games/instanced-mesh-demo.d.ts +1 -1
- package/dist/games/instanced-mesh-demo.js +2 -2
- package/dist/games/manifold-demo.d.ts +1 -1
- package/dist/games/manifold-demo.js +2 -2
- package/dist/games/navigation-demo.d.ts +1 -1
- package/dist/games/navigation-demo.js +2 -2
- package/dist/games/navmesh-primitives-demo.d.ts +1 -1
- package/dist/games/navmesh-primitives-demo.js +2 -2
- package/dist/games/postprocess-demo.d.ts +1 -1
- package/dist/games/postprocess-demo.js +3 -3
- package/dist/games/ragdoll-demo-simple.d.ts +1 -1
- package/dist/games/ragdoll-demo-simple.js +2 -2
- package/dist/games/ragdoll-demo.d.ts +1 -1
- package/dist/games/ragdoll-demo.js +2 -2
- package/dist/games/swipe-tap-demo.d.ts +1 -1
- package/dist/games/swipe-tap-demo.js +2 -2
- package/dist/games/tween-demo.d.ts +1 -1
- package/dist/games/tween-demo.js +2 -2
- package/dist/games/ui-demo.d.ts +1 -1
- package/dist/games/ui-demo.js +2 -2
- package/dist/games/vfx-demo.d.ts +1 -1
- package/dist/games/vfx-demo.js +2 -2
- package/dist/games/vfx-wawa-demo.d.ts +1 -1
- package/dist/games/vfx-wawa-demo.js +2 -2
- package/dist/games/vr-ui-demo-minimal.d.ts +1 -1
- package/dist/games/vr-ui-demo-minimal.js +2 -2
- package/dist/games/vr-ui-demo.d.ts +1 -1
- package/dist/games/vr-ui-demo.js +2 -2
- package/dist/launcher.js +2 -2
- package/dist/scripts/dump-templates.js +2 -2
- package/dist/test/absolute-transform.test.js +2 -2
- package/dist/test/asset-path.test.js +2 -2
- package/dist/test/component.test.js +2 -2
- package/dist/test/construction.test.js +2 -2
- package/dist/test/default-options-validation.test.js +2 -2
- package/dist/test/metadata.test.js +2 -2
- package/dist/test/nodeStorage.d.ts +2 -2
- package/dist/test/nodeStorage.js +3 -3
- package/dist/test/prefab.test.js +2 -2
- package/dist/test/scene-component.test.js +2 -2
- package/dist/test/scene-graph.test.js +2 -2
- package/dist/test/serialization-v1.test.d.ts +1 -1
- package/dist/test/serialization-v1.test.js +3 -3
- package/dist/test/serialization.test.js +2 -2
- package/dist/test/spawn.test.js +2 -2
- package/dist/test/utils.d.ts +1 -1
- package/dist/test/utils.js +2 -2
- package/docs/guides/15-global-audio-manager.md +1 -1
- package/docs/guides/16-ragdoll-physics.md +1 -1
- package/docs/guides/18-lightmapping-system.md +3 -3
- package/docs/guides/19-webxr-virtual-reality.md +1 -1
- package/docs/guides/4-visuals-and-rendering.md +5 -5
- package/docs/guides/6-ai-and-behavior-trees.md +4 -4
- package/games/animation-demo.ts +1 -1
- package/games/animation-retarget-demo.ts +2 -2
- package/games/behavior-tree-demo.ts +1 -1
- package/games/character_animation.ts +1 -1
- package/games/collision-demo.ts +1 -1
- package/games/deprecated/advanced-grid-demo.ts +1 -1
- package/games/deprecated/airplane-demo.ts +1 -1
- package/games/deprecated/character-controller.ts +1 -1
- package/games/deprecated/chase-game.ts +1 -1
- package/games/deprecated/collision-config.ts +1 -1
- package/games/deprecated/door-demo.ts +1 -1
- package/games/deprecated/fps-demo.ts +1 -1
- package/games/deprecated/fps-shotgun-demo.ts +1 -1
- package/games/deprecated/index.ts +25 -25
- package/games/deprecated/lightmapping-demo.ts +1 -1
- package/games/deprecated/lights-demo.ts +1 -1
- package/games/deprecated/matcap-demo.ts +1 -1
- package/games/deprecated/material-demo-2.ts +1 -1
- package/games/deprecated/material-demo.ts +1 -1
- package/games/deprecated/memory-leak-test.ts +1 -1
- package/games/deprecated/model-stress-test.ts +1 -1
- package/games/deprecated/multiplayer-demo.ts +1 -1
- package/games/deprecated/physics-demo.ts +1 -1
- package/games/deprecated/shadow-demo.ts +1 -1
- package/games/deprecated/shooting-demo.ts +1 -1
- package/games/deprecated/skybox-demo.ts +1 -1
- package/games/deprecated/sound-demo.ts +1 -1
- package/games/deprecated/timer-demo.ts +1 -1
- package/games/deprecated/voxel-demo.ts +1 -1
- package/games/deprecated/world-commands.ts +1 -1
- package/games/deprecated/world-loading.ts +1 -1
- package/games/examples/fps-advanced/enemies.ts +1 -1
- package/games/examples/fps-advanced/game-mode.ts +1 -1
- package/games/examples/fps-advanced/game.ts +1 -1
- package/games/examples/fps-advanced/pickups.ts +1 -1
- package/games/examples/fps-advanced/player.ts +1 -1
- package/games/examples/fps-advanced/ui/endgame-ui.ts +1 -1
- package/games/examples/fps-advanced/ui/menu-ui.ts +1 -1
- package/games/examples/fps-advanced/ui/weapon-hud.ts +253 -253
- package/games/examples/fps-advanced/weapons.ts +1 -1
- package/games/examples/index.ts +5 -5
- package/games/examples/plugin-demo/game.ts +2 -2
- package/games/examples/plugin-demo/plugins/dynamic-lighting.ts +1 -1
- package/games/examples/plugin-demo/plugins/instanced-forest.ts +1 -1
- package/games/examples/plugin-demo/plugins/particle-fountain.ts +1 -1
- package/games/examples/plugin-demo/plugins/physics-playground.ts +1 -1
- package/games/examples/plugin-demo/plugins/robot-follower.ts +1 -1
- package/games/examples/plugin-demo/plugins/scatter-models.ts +1 -1
- package/games/examples/plugin-demo/plugins/simple-cube.ts +1 -1
- package/games/examples/plugin-demo/plugins/tic-tac-toe.ts +1 -1
- package/games/examples/plugin-demo/plugins/wobbling-sphere.ts +1 -1
- package/games/examples/side-scroller-advanced/game-mode.ts +1 -1
- package/games/examples/side-scroller-advanced/game.ts +1 -1
- package/games/examples/side-scroller-advanced/level-generator.ts +1 -1
- package/games/examples/side-scroller-advanced/pickups.ts +1 -1
- package/games/examples/side-scroller-advanced/player.ts +1 -1
- package/games/examples/side-scroller-advanced/ui/endgame-ui.ts +1 -1
- package/games/examples/side-scroller-advanced/ui/menu-ui.ts +1 -1
- package/games/examples/vehicle/base-vehicle.ts +1 -1
- package/games/examples/vehicle/game.ts +1 -1
- package/games/examples/vehicle/mesh-vehicle.ts +1 -1
- package/games/examples/vehicle/player.ts +1 -1
- package/games/examples/vehicle/primitive-vehicle.ts +1 -1
- package/games/examples/vr-game/VRAttachableCube.ts +1 -1
- package/games/examples/vr-game/VRInteractableCylinder.ts +1 -1
- package/games/examples/vr-game/VRPressableButton.ts +1 -1
- package/games/examples/vr-game/VRProjectileActor.ts +1 -1
- package/games/examples/vr-game/VRRifleActor.ts +1 -1
- package/games/examples/vr-game/game.ts +1 -1
- package/games/examples/vr-game/scene.ts +1 -1
- package/games/instanced-mesh-demo.ts +1 -1
- package/games/manifold-demo.ts +1 -1
- package/games/navigation-demo.ts +1 -1
- package/games/navmesh-primitives-demo.ts +1 -1
- package/games/postprocess-demo.ts +2 -2
- package/games/ragdoll-demo-simple.ts +1 -1
- package/games/ragdoll-demo.ts +1 -1
- package/games/swipe-tap-demo.ts +1 -1
- package/games/tween-demo.ts +1 -1
- package/games/ui-demo.ts +1 -1
- package/games/vfx-demo.ts +1 -1
- package/games/vfx-wawa-demo.ts +1 -1
- package/games/vr-ui-demo-minimal.ts +1 -1
- package/games/vr-ui-demo.ts +1 -1
- package/package.json +1 -1
- package/scripts/dump-templates.ts +1 -1
- package/src/global.d.ts +11 -11
- package/src/multiplayer/MovementPrediction.ts +202 -202
- package/src/templates/MyActor.ts +1 -1
- package/src/templates/MySceneComponent.ts +1 -1
- package/src/ui/UIResource.ts +20 -20
- package/src/utils/browser-polyfills/module.ts +35 -35
- 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
|
}
|
package/games/examples/index.ts
CHANGED
|
@@ -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 {
|