@jgengine/core 0.12.0 → 0.14.0
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/CHANGELOG.md +73 -1
- package/dist/combat/effects.d.ts +11 -4
- package/dist/combat/effects.js +24 -17
- package/dist/combat/magazine.d.ts +13 -0
- package/dist/combat/magazine.js +27 -0
- package/dist/combat/vfxPresets.d.ts +176 -0
- package/dist/combat/vfxPresets.js +74 -0
- package/dist/combat/weaponFire.d.ts +114 -0
- package/dist/combat/weaponFire.js +96 -0
- package/dist/combat.d.ts +4 -2
- package/dist/combat.js +3 -1
- package/dist/devtools/urlFlags.d.ts +22 -0
- package/dist/devtools/urlFlags.js +62 -0
- package/dist/game/clipRoles.d.ts +51 -0
- package/dist/game/clipRoles.js +142 -0
- package/dist/game/defineGame.d.ts +2 -2
- package/dist/game/partAnimation.d.ts +78 -0
- package/dist/game/partAnimation.js +147 -0
- package/dist/game/playableGame.d.ts +38 -5
- package/dist/game/progression.d.ts +2 -2
- package/dist/game/progression.js +4 -2
- package/dist/inventory/inventoryModel.d.ts +24 -8
- package/dist/inventory/inventoryModel.js +47 -8
- package/dist/meta/changelog.d.ts +1 -1
- package/dist/meta/changelog.js +45 -1
- package/dist/runtime/context/combat.js +2 -1
- package/dist/runtime/context/combatFx.js +15 -5
- package/dist/runtime/context/scene.d.ts +4 -1
- package/dist/runtime/context/scene.js +86 -1
- package/dist/runtime/gameContext.js +51 -4
- package/dist/runtime/gameContextTypes.d.ts +58 -4
- package/dist/runtime/headlessRunner.d.ts +13 -0
- package/dist/runtime/headlessRunner.js +14 -0
- package/dist/scene/assetCatalog.d.ts +2 -0
- package/dist/scene/builtinSceneKinds.d.ts +6 -1
- package/dist/scene/builtinSceneKinds.js +10 -3
- package/dist/scene/colliders.d.ts +41 -0
- package/dist/scene/colliders.js +140 -0
- package/dist/scene/collisionMesh.d.ts +8 -0
- package/dist/scene/collisionMesh.js +48 -0
- package/dist/scene/entityStats.js +9 -1
- package/dist/scene/sceneKinds.d.ts +19 -0
- package/dist/stats/statModifiers.d.ts +16 -0
- package/dist/stats/statModifiers.js +30 -1
- package/dist/stats/statPool.js +5 -2
- package/dist/ui/hudScale.d.ts +16 -1
- package/dist/ui/hudScale.js +22 -1
- package/dist/ui/panelModel.d.ts +120 -0
- package/dist/ui/panelModel.js +168 -0
- package/dist/ui.d.ts +1 -0
- package/dist/ui.js +1 -0
- package/dist/world/buildingLots.d.ts +84 -0
- package/dist/world/buildingLots.js +119 -0
- package/dist/world/buildings.d.ts +6 -0
- package/dist/world/cityGenerator.d.ts +41 -0
- package/dist/world/cityGenerator.js +58 -0
- package/dist/world/cityKind.d.ts +2 -2
- package/dist/world/cityKind.js +12 -6
- package/dist/world/environmentSummary.js +57 -1
- package/dist/world/features.d.ts +35 -2
- package/dist/world/features.js +5 -2
- package/dist/world/grassKind.js +4 -1
- package/dist/world/roads.d.ts +19 -2
- package/dist/world/roads.js +60 -3
- package/dist/world/scatterCoverage.d.ts +98 -0
- package/dist/world/scatterCoverage.js +101 -0
- package/dist/world/scatterRegion.js +6 -0
- package/dist/world/{pathNetwork.d.ts → streetGenerator.d.ts} +37 -37
- package/dist/world/{pathNetwork.js → streetGenerator.js} +9 -9
- package/dist/world/streets.d.ts +74 -1
- package/dist/world/streets.js +218 -0
- package/dist/world/terrain.d.ts +20 -1
- package/dist/world/terrain.js +41 -2
- package/dist/world.d.ts +1 -0
- package/dist/world.js +1 -0
- package/package.json +2 -2
- package/skills/jgengine/SKILL.md +5 -2
- package/skills/jgengine/api.md +13 -5
- package/skills/jgengine-combat/SKILL.md +15 -1
- package/skills/jgengine-combat/api.md +39 -2
- package/skills/jgengine-combat/capabilities.md +17 -1
- package/skills/jgengine-combat/recipes/portable-damage-effects.md +197 -0
- package/skills/jgengine-combat/recipes/portable-runtime-state.md +154 -0
- package/skills/jgengine-combat/recipes/portable-weapon-plumbing.md +156 -0
- package/skills/jgengine-combat/recipes/visible-attacks.md +81 -0
- package/skills/jgengine-combat/reference.md +22 -3
- package/skills/jgengine-gameplay/SKILL.md +8 -0
- package/skills/jgengine-gameplay/api.md +35 -5
- package/skills/jgengine-gameplay/capabilities.md +18 -0
- package/skills/jgengine-gameplay/recipes/portable-xp-leveling.md +168 -0
- package/skills/jgengine-gameplay/reference-systems.md +9 -0
- package/skills/jgengine-world/api.md +82 -25
- package/skills/jgengine-world/capabilities.md +12 -4
- package/skills/jgengine-world/reference.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,7 +10,79 @@ let consumers pick up the better stuff, not just to list what moved.
|
|
|
10
10
|
Agents building on the published SDK can also read this programmatically:
|
|
11
11
|
`import { VERSION, CHANGELOG } from "@jgengine/core/meta/changelog"` gives the
|
|
12
12
|
same data as typed values, so an updater can diff its installed version against
|
|
13
|
-
the latest and surface the migration steps.
|
|
13
|
+
the latest and surface the migration steps. Easier still: `npx jgengine upgrade`
|
|
14
|
+
run inside a game project diffs the installed `@jgengine/*` versions against the
|
|
15
|
+
latest release and prints every Migrate step and Adopt-worthy addition in
|
|
16
|
+
between (`--json` for structured output).
|
|
17
|
+
|
|
18
|
+
## [Unreleased]
|
|
19
|
+
|
|
20
|
+
<!--
|
|
21
|
+
Every PR that changes `packages/*/src` records its consumer-facing change here, so
|
|
22
|
+
the next release's notes are complete by construction. Add a bullet under the right
|
|
23
|
+
subhead below. `bun run check-changelog` fails a source PR whose `[Unreleased]` block
|
|
24
|
+
is untouched; pure refactors/tests bypass with `[skip changelog]` in a commit message.
|
|
25
|
+
At publish, rename this heading to the new version and mirror the entries into
|
|
26
|
+
`packages/core/src/meta/changelog.ts` (the typed `CHANGELOG` export).
|
|
27
|
+
-->
|
|
28
|
+
|
|
29
|
+
### Migrate
|
|
30
|
+
|
|
31
|
+
- _Nothing yet._
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
### Removed
|
|
38
|
+
|
|
39
|
+
## 0.14.0
|
|
40
|
+
|
|
41
|
+
### Migrate
|
|
42
|
+
|
|
43
|
+
- **Nothing required** — this release is additive drop-in primitives, editor authoring, CLI discovery, and fixes. Bump `@jgengine/*` pins to `^0.14.0` (CLI `jgengine` is 0.11.0; `@jgengine/github` unchanged at 0.1.0) and rebuild.
|
|
44
|
+
- One behavior fix to know about: in a `rig: "chase"` game, on-foot movement and aim are now camera-relative (the chase rig reports its yaw to the shell like every other rig). If a game somehow relied on world-yaw-0 movement under a chase camera, that was the bug this fixes.
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
|
|
48
|
+
- One authoring gesture for scatterable coverage: `@jgengine/core/world/scatterCoverage` owns shared density/budget semantics (per-kind unit, requested→count→capped, one clamp-and-warn phrasing) for `grass_field`/`scatter`/`city`; the editor inspector leads each kind with the same Area → Assets → Density coverage section, scatter truncates to the shared 250k instance budget, and city single-sources its 2,600-lot cap.
|
|
49
|
+
- **Created games ship a drive/playtest script** (#1248) — `npx jgengine create` scaffolds now include `scripts/drive.mjs` (`bun run drive`): dependency-free headless play/testing of the running game — ordered `--click`/`--key`/`--wait`/`--shot`/`--rpc` steps against the agent bridge, plus `--playtest --strict` progress/softlock verdicts off `capture.probe`. Shared Chrome/CDP machinery lives in `scripts/browser.mjs`; `scripts/shoot.mjs` is unchanged in behavior, now a thin CLI over it.
|
|
50
|
+
- Editor: viewport clip preview for rigged assets (Animation dock "Clips" mode — pick a rig or placed instance, play/scrub/loop/speed any catalog clip) and an Inspector "Animation" section that authors a placement's `ModelConfig.animation` (role→clip dropdowns, auto/none, walk/run/fade, one-shot event bindings) as undoable `marker.meta.animation` edits. New subpaths: `@jgengine/editor/shell/clipPreview`, `@jgengine/editor/modelAnimationAuthoring`, `@jgengine/editor/ClipPreviewLayer`.
|
|
51
|
+
- **`npx jgengine find <intent>`** — active capability discovery: searches every shipped domain's `capabilities.md` (staged inside the CLI tarball, so it works regardless of which `@jgengine/*` packages a project installed) and prints the drop-in primitive + its import for an intent like `"toggleable window"`, `inventory`, or `minimap`. Scaffolded games are now briefed (in `AGENTS.md` and the `jgengine` intake skill) to reach for it before hand-rolling a HUD/inventory/window/rig.
|
|
52
|
+
- **`EntityPreview`** (`@jgengine/shell/render/EntityPreview`) — drop-in live 3D entity portrait for character screens, unit inspectors, and loadout viewers. Owns the nested `<Canvas>`, the `GameContextBridge`, and a `StudioStage` lighting rig with optional turntable / face-camera; the game passes its own `renderEntity` as children (or a native `model` + `instanceId`) and, bound to a live entity, the portrait walks/flinches/topples in sync with the world.
|
|
53
|
+
- **`GameContextBridge`** (`@jgengine/react`) — re-provide the running `GameContext` across a nested React reconciler boundary (the R3F `<Canvas>`), so a game building its own preview canvas no longer re-derives the bridge by hand.
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- **Chase rig reports its yaw to the shell** — `ChaseRig` now writes the camera yaw back to the shared yaw ref like every other player-facing rig, so on-foot movement and aim in a `rig: "chase"` game are camera-relative instead of frozen to world yaw 0 (WASD no longer fights the camera the moment it swings behind the player). Interior views (cockpit/hood/rear) report the vehicle heading.
|
|
58
|
+
- **Combat VFX no longer render as black squares under AO/DOF post-processing** (#1247) — GTAO/Bokeh scene prepasses skip overlay effects. Games with custom additive overlay effects opt out the same way: spread `POSTFX_OVERLAY_USERDATA` (`@jgengine/shell/postfx/postfxOverlay`) onto the overlay group's `userData`.
|
|
59
|
+
- **`PanelHost` windows stack above the HUD by default** (`@jgengine/react`) — the host establishes its own stacking context at `zIndexBase` (default 40), so open windows always paint over stat bars / nameplates / frames instead of bleeding through. Overridable per instance.
|
|
60
|
+
|
|
61
|
+
## 0.13.0
|
|
62
|
+
|
|
63
|
+
### Migrate
|
|
64
|
+
|
|
65
|
+
- **Nothing required** — this release is additive fixes, defaults, and new drop-in primitives. Bump `@jgengine/*` pins to `^0.13.0` (CLI `jgengine` is 0.10.0; `@jgengine/github` unchanged at 0.1.0) and rebuild.
|
|
66
|
+
- Two defaults changed in the player's favor, both overridable: **offline games now persist to localStorage automatically** (#1207) and **rigged catalog assets animate by default** via clip metadata + semantic clip roles (#1209). If a game relied on rigged models staying frozen or on saves being memory-only, opt out explicitly; otherwise you get better behavior for free.
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
- **Drop-in inventory grid, window manager, and character sheet** (#1220) — `@jgengine/react` ships `InventoryGrid` (real drag/stack/split), a toggleable-window system (`panels`: bag, character sheet, spellbook-style windows with `@jgengine/core/ui/panelModel` state), and a `CharacterSheet` paperdoll, all HudTheme-skinnable — wire in a line or two instead of re-deriving from raw divs.
|
|
71
|
+
- **Serializable runtime snapshots** (#1179) — capture/restore of live runtime state, including magazine state (`@jgengine/core/combat/magazine`) and stat modifiers, for saves and replication.
|
|
72
|
+
- **Portable weapon plumbing** (#1211) — `@jgengine/core/combat/weaponFire` composes trigger → magazine → spread → projectile/hitscan as data, no game-local glue.
|
|
73
|
+
- **Portable leveling** (#1206) and **portable damage-pool access** (#1208) — progression and damage pools exposed as genre-agnostic seams on the game context.
|
|
74
|
+
- **Named combat VFX presets** (#1204) — `@jgengine/core/combat/vfxPresets`: a visible attack is one line.
|
|
75
|
+
- **Runtime-measured render-bounds hitboxes** (#1227) — colliders wrap what the shell actually mounts, not the raw asset bounds.
|
|
76
|
+
- **Character motion feel** — procedural part motion for rig-less part-composed characters (#1222) plus squash & stretch and death splat (#1229).
|
|
77
|
+
- **City fabric** (#1191) — `streetGenerator` + `cityGenerator`, editor bake verb, street-aware lots, road junctions, grounding, and a web playground.
|
|
78
|
+
- **`jgengine recipe` CLI** (#1214, #1231) — vetted wired compositions, compile-pinned against the SDK, listed and copied from the CLI.
|
|
79
|
+
- **Editor/debug modes mirror to the URL** with a proper editor exit (#1203); game template ships a dependency-free WebGL screenshot script (#1202).
|
|
80
|
+
|
|
81
|
+
### Changed
|
|
82
|
+
|
|
83
|
+
- Offline games persist to localStorage by default (#1207); rigged assets animate by default (#1209).
|
|
84
|
+
- RTS camera pan inversion fixed (#1228); sprite raycast warning silenced and duplicate nameplate health bars removed (#1194); scaffolded F2+E editor Tailwind `@source` renders its theme (#1195).
|
|
85
|
+
- Outside-game DX: stat-pool no-op stability, camera-transparent decor, cleaner install/version output, headless UI-intent seam (#1223); new-game briefs direct engine bugs/gaps upstream (#1200).
|
|
14
86
|
|
|
15
87
|
## 0.12.0
|
|
16
88
|
|
package/dist/combat/effects.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntityPosition } from "../scene/entityStore.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type StatPool, type StatPoolAccess } from "../stats/statPool.js";
|
|
3
3
|
export interface ReceiveRule {
|
|
4
4
|
order: string[];
|
|
5
5
|
modifiers?: Record<string, number>;
|
|
@@ -58,7 +58,13 @@ export interface AreaTarget {
|
|
|
58
58
|
export declare function resolveAreaTargets(spatial: CombatSpatialDeps, input: AreaTargetInput, accept?: (instanceId: string) => boolean): AreaTarget[];
|
|
59
59
|
export interface EffectSystemDeps {
|
|
60
60
|
resolveReceive(instanceId: string): ReceiveMap | null | undefined;
|
|
61
|
-
|
|
61
|
+
/** Preferred portable bridge to caller-owned resource state. */
|
|
62
|
+
statPools?: StatPoolAccess;
|
|
63
|
+
/**
|
|
64
|
+
* Legacy native bridge retained for source compatibility. New integrations
|
|
65
|
+
* should provide {@link statPools} and keep their own state model.
|
|
66
|
+
*/
|
|
67
|
+
resolveStats?(instanceId: string): Record<string, StatPool> | undefined;
|
|
62
68
|
getStat(itemId: string, stat: string): number | null;
|
|
63
69
|
spatial: CombatSpatialDeps;
|
|
64
70
|
drainStatByEffect?: Record<string, string>;
|
|
@@ -70,8 +76,9 @@ export interface EffectSystem {
|
|
|
70
76
|
applyEffect(input: EffectInput): EffectResult[];
|
|
71
77
|
}
|
|
72
78
|
/**
|
|
73
|
-
*
|
|
79
|
+
* Resolve direct or area resource effects through caller-owned stat pools,
|
|
80
|
+
* including ordered absorption, restoration, modifiers, and lethal context.
|
|
74
81
|
*
|
|
75
|
-
* @capability status-effects
|
|
82
|
+
* @capability status-effects commit direct or area effects through caller-owned stat pools with ordered spillover and lethal results
|
|
76
83
|
*/
|
|
77
84
|
export declare function createEffectSystem(deps: EffectSystemDeps): EffectSystem;
|
package/dist/combat/effects.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { applyPoolDelta } from "../scene/entityStats.js";
|
|
2
1
|
import { distanceBetween } from "../scene/spatial.js";
|
|
2
|
+
import { applyStatPoolDelta } from "../stats/statPool.js";
|
|
3
3
|
export function resolveAreaTargets(spatial, input, accept) {
|
|
4
4
|
const falloff = input.falloff ?? "none";
|
|
5
5
|
const los = input.los ?? true;
|
|
@@ -22,11 +22,24 @@ export function resolveAreaTargets(spatial, input, accept) {
|
|
|
22
22
|
}
|
|
23
23
|
const DEFAULT_DRAIN_STAT = "damage";
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Resolve direct or area resource effects through caller-owned stat pools,
|
|
26
|
+
* including ordered absorption, restoration, modifiers, and lethal context.
|
|
26
27
|
*
|
|
27
|
-
* @capability status-effects
|
|
28
|
+
* @capability status-effects commit direct or area effects through caller-owned stat pools with ordered spillover and lethal results
|
|
28
29
|
*/
|
|
29
30
|
export function createEffectSystem(deps) {
|
|
31
|
+
const statPools = deps.statPools ?? {
|
|
32
|
+
get(instanceId, statId) {
|
|
33
|
+
return deps.resolveStats?.(instanceId)?.[statId] ?? null;
|
|
34
|
+
},
|
|
35
|
+
set(instanceId, statId, next) {
|
|
36
|
+
const stats = deps.resolveStats?.(instanceId);
|
|
37
|
+
if (stats === undefined)
|
|
38
|
+
return false;
|
|
39
|
+
stats[statId] = next;
|
|
40
|
+
return true;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
30
43
|
function resolveRule(instanceId, effect) {
|
|
31
44
|
return deps.resolveReceive(instanceId)?.[effect] ?? null;
|
|
32
45
|
}
|
|
@@ -49,13 +62,12 @@ export function createEffectSystem(deps) {
|
|
|
49
62
|
const rule = resolveRule(instanceId, effect);
|
|
50
63
|
if (rule === null)
|
|
51
64
|
return "not-receivable";
|
|
52
|
-
|
|
53
|
-
if (stats === undefined)
|
|
65
|
+
if (deps.statPools === undefined && deps.resolveStats?.(instanceId) === undefined)
|
|
54
66
|
return "unknown-instance";
|
|
55
67
|
const restorative = magnitude !== undefined && magnitude < 0;
|
|
56
68
|
const anyPoolHasHeadroom = rule.order.some((statId) => {
|
|
57
|
-
const stat =
|
|
58
|
-
if (stat ===
|
|
69
|
+
const stat = statPools.get(instanceId, statId);
|
|
70
|
+
if (stat === null)
|
|
59
71
|
return false;
|
|
60
72
|
return restorative ? stat.current < stat.max : stat.current > stat.min;
|
|
61
73
|
});
|
|
@@ -63,7 +75,7 @@ export function createEffectSystem(deps) {
|
|
|
63
75
|
return "pools-depleted";
|
|
64
76
|
return null;
|
|
65
77
|
}
|
|
66
|
-
function drainPools(instanceId, effect, rule,
|
|
78
|
+
function drainPools(instanceId, effect, rule, drainMagnitude) {
|
|
67
79
|
const applied = [];
|
|
68
80
|
const lastStatId = rule.order[rule.order.length - 1];
|
|
69
81
|
let remaining = drainMagnitude;
|
|
@@ -71,14 +83,10 @@ export function createEffectSystem(deps) {
|
|
|
71
83
|
for (const statId of rule.order) {
|
|
72
84
|
if (remaining === 0)
|
|
73
85
|
break;
|
|
74
|
-
const
|
|
75
|
-
if (before === undefined)
|
|
76
|
-
continue;
|
|
77
|
-
const result = applyPoolDelta(stats, statId, -remaining);
|
|
86
|
+
const result = applyStatPoolDelta(statPools, instanceId, statId, -remaining);
|
|
78
87
|
if (result.status === "rejected")
|
|
79
88
|
continue;
|
|
80
|
-
|
|
81
|
-
const delta = result.stat.current - before.current;
|
|
89
|
+
const delta = result.applied;
|
|
82
90
|
if (delta !== 0)
|
|
83
91
|
applied.push({ statId, delta });
|
|
84
92
|
remaining += delta;
|
|
@@ -89,13 +97,12 @@ export function createEffectSystem(deps) {
|
|
|
89
97
|
}
|
|
90
98
|
function applyTo(instanceId, effect, via, from, scale) {
|
|
91
99
|
const rule = resolveRule(instanceId, effect);
|
|
92
|
-
|
|
93
|
-
if (rule === null || stats === undefined)
|
|
100
|
+
if (rule === null)
|
|
94
101
|
return null;
|
|
95
102
|
const drainMagnitude = modifiedDrainMagnitude(baseDrainMagnitude(effect, via) * scale, rule);
|
|
96
103
|
if (canReceive(instanceId, effect, drainMagnitude) !== null)
|
|
97
104
|
return null;
|
|
98
|
-
const result = drainPools(instanceId, effect, rule,
|
|
105
|
+
const result = drainPools(instanceId, effect, rule, drainMagnitude);
|
|
99
106
|
if (result.lethal)
|
|
100
107
|
deps.onLethal?.(instanceId, { from, via, effect });
|
|
101
108
|
return result;
|
|
@@ -17,6 +17,12 @@ export interface MagazineConfig {
|
|
|
17
17
|
*/
|
|
18
18
|
reserve?: number | MagazineReserve;
|
|
19
19
|
}
|
|
20
|
+
/** Complete serializable state for a {@link Magazine}; `reserve: null` means infinite reserve. */
|
|
21
|
+
export interface MagazineSnapshot {
|
|
22
|
+
loaded: number;
|
|
23
|
+
reloadElapsedMs: number | null;
|
|
24
|
+
reserve: number | null;
|
|
25
|
+
}
|
|
20
26
|
/**
|
|
21
27
|
* A per-weapon magazine: discrete loaded rounds, a timed reload that refills from a reserve pool,
|
|
22
28
|
* and the reserve-pool interaction itself — the primitive that replaces hand-rolling mag size,
|
|
@@ -45,6 +51,13 @@ export interface Magazine {
|
|
|
45
51
|
addReserve(amount: number): void;
|
|
46
52
|
/** Advance the reload timer; completes the reload once `reloadMs` has elapsed. */
|
|
47
53
|
tick(dtSeconds: number): void;
|
|
54
|
+
/** Return detached plain data for save, rollback, replay, or worker transfer. */
|
|
55
|
+
snapshot(): MagazineSnapshot;
|
|
56
|
+
/**
|
|
57
|
+
* Restore decoded snapshot data. Returns false without changing loaded/reload
|
|
58
|
+
* state when reserve kinds differ or an external reserve cannot reconcile.
|
|
59
|
+
*/
|
|
60
|
+
restore(snapshot: MagazineSnapshot): boolean;
|
|
48
61
|
}
|
|
49
62
|
/**
|
|
50
63
|
* Builds a {@link Magazine}: discrete loaded ammo, a timed reload, and reserve-pool interaction.
|
package/dist/combat/magazine.js
CHANGED
|
@@ -92,5 +92,32 @@ export function createMagazine(config) {
|
|
|
92
92
|
}
|
|
93
93
|
reloadElapsedMs = null;
|
|
94
94
|
},
|
|
95
|
+
snapshot() {
|
|
96
|
+
return {
|
|
97
|
+
loaded,
|
|
98
|
+
reloadElapsedMs,
|
|
99
|
+
reserve: isInfiniteReserve ? null : reserve.current(),
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
restore(snapshot) {
|
|
103
|
+
if (isInfiniteReserve !== (snapshot.reserve === null))
|
|
104
|
+
return false;
|
|
105
|
+
if (!isInfiniteReserve) {
|
|
106
|
+
const desired = Math.max(0, snapshot.reserve);
|
|
107
|
+
const current = Math.max(0, reserve.current());
|
|
108
|
+
if (desired > current && reserve.gain === undefined)
|
|
109
|
+
return false;
|
|
110
|
+
if (desired < current && !reserve.spend(current - desired))
|
|
111
|
+
return false;
|
|
112
|
+
if (desired > current)
|
|
113
|
+
reserve.gain?.(desired - current);
|
|
114
|
+
}
|
|
115
|
+
loaded = clampLoaded(snapshot.loaded);
|
|
116
|
+
reloadElapsedMs =
|
|
117
|
+
snapshot.reloadElapsedMs === null
|
|
118
|
+
? null
|
|
119
|
+
: Math.max(0, Math.min(reloadMs, snapshot.reloadElapsedMs));
|
|
120
|
+
return true;
|
|
121
|
+
},
|
|
95
122
|
};
|
|
96
123
|
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { VfxKind } from "../game/events.js";
|
|
2
|
+
/**
|
|
3
|
+
* A named visual flavor for a one-shot `combat.vfx` burst: the archetype (`kind`),
|
|
4
|
+
* a `0xRRGGBB` tint, and optional default `durationMs`/`radius`. Purely presentation —
|
|
5
|
+
* a preset never touches damage, range, or any authoritative value; it just answers
|
|
6
|
+
* "what does this attack look like" so a game does not hand-roll colors and archetypes.
|
|
7
|
+
*/
|
|
8
|
+
export interface VfxPreset {
|
|
9
|
+
kind: VfxKind;
|
|
10
|
+
/** `0xRRGGBB` tint. */
|
|
11
|
+
color: number;
|
|
12
|
+
/** Overrides the shell's per-`kind` default lifetime when set. */
|
|
13
|
+
durationMs?: number;
|
|
14
|
+
/** Default effect radius for `nova`/aura flavors. */
|
|
15
|
+
radius?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Ready-made visual flavors for the things players actually shoot, swing, and cast —
|
|
19
|
+
* so `ctx.scene.entity.vfx({ preset: "arrow", from, to })` renders a visible bolt with
|
|
20
|
+
* zero tuning, and `"lightning"`, `"web"`, `"slash"`, `"shield"`, `"heal"`, `"explosion"`
|
|
21
|
+
* likewise just work. Each entry only picks a `kind` (`projectile | beam | nova | glow |
|
|
22
|
+
* spark`), a color, and a lifetime; it is visual vocabulary (like named CSS colors), not a
|
|
23
|
+
* gameplay archetype — combat numbers stay in the caller's own effect/ability data. Any
|
|
24
|
+
* field passed to `vfx()` overrides the preset, and unknown names fall back to `spark` so a
|
|
25
|
+
* flavor typo still shows *something* rather than nothing.
|
|
26
|
+
*
|
|
27
|
+
* @capability vfx-presets render a named attack visual (arrow, fireball, lightning, web, slash, shield, heal, explosion) in one call
|
|
28
|
+
*/
|
|
29
|
+
export declare const vfxPresets: {
|
|
30
|
+
readonly arrow: {
|
|
31
|
+
readonly kind: "projectile";
|
|
32
|
+
readonly color: 14207392;
|
|
33
|
+
};
|
|
34
|
+
readonly bolt: {
|
|
35
|
+
readonly kind: "projectile";
|
|
36
|
+
readonly color: 16777215;
|
|
37
|
+
};
|
|
38
|
+
readonly fireball: {
|
|
39
|
+
readonly kind: "projectile";
|
|
40
|
+
readonly color: 16738842;
|
|
41
|
+
readonly durationMs: 460;
|
|
42
|
+
};
|
|
43
|
+
readonly firebolt: {
|
|
44
|
+
readonly kind: "projectile";
|
|
45
|
+
readonly color: 16742954;
|
|
46
|
+
};
|
|
47
|
+
readonly frostbolt: {
|
|
48
|
+
readonly kind: "projectile";
|
|
49
|
+
readonly color: 9360127;
|
|
50
|
+
};
|
|
51
|
+
readonly ice: {
|
|
52
|
+
readonly kind: "projectile";
|
|
53
|
+
readonly color: 9360127;
|
|
54
|
+
};
|
|
55
|
+
readonly poison: {
|
|
56
|
+
readonly kind: "projectile";
|
|
57
|
+
readonly color: 8841322;
|
|
58
|
+
};
|
|
59
|
+
readonly shadowbolt: {
|
|
60
|
+
readonly kind: "projectile";
|
|
61
|
+
readonly color: 10116592;
|
|
62
|
+
};
|
|
63
|
+
readonly arcane: {
|
|
64
|
+
readonly kind: "projectile";
|
|
65
|
+
readonly color: 14256895;
|
|
66
|
+
};
|
|
67
|
+
readonly magicMissile: {
|
|
68
|
+
readonly kind: "projectile";
|
|
69
|
+
readonly color: 14256895;
|
|
70
|
+
};
|
|
71
|
+
readonly holybolt: {
|
|
72
|
+
readonly kind: "projectile";
|
|
73
|
+
readonly color: 16771488;
|
|
74
|
+
};
|
|
75
|
+
readonly rock: {
|
|
76
|
+
readonly kind: "projectile";
|
|
77
|
+
readonly color: 11049606;
|
|
78
|
+
};
|
|
79
|
+
readonly bullet: {
|
|
80
|
+
readonly kind: "projectile";
|
|
81
|
+
readonly color: 16773808;
|
|
82
|
+
readonly durationMs: 140;
|
|
83
|
+
};
|
|
84
|
+
readonly lightning: {
|
|
85
|
+
readonly kind: "beam";
|
|
86
|
+
readonly color: 12576511;
|
|
87
|
+
readonly durationMs: 200;
|
|
88
|
+
};
|
|
89
|
+
readonly laser: {
|
|
90
|
+
readonly kind: "beam";
|
|
91
|
+
readonly color: 16731469;
|
|
92
|
+
};
|
|
93
|
+
readonly beam: {
|
|
94
|
+
readonly kind: "beam";
|
|
95
|
+
readonly color: 9360127;
|
|
96
|
+
};
|
|
97
|
+
readonly web: {
|
|
98
|
+
readonly kind: "beam";
|
|
99
|
+
readonly color: 15790320;
|
|
100
|
+
readonly durationMs: 320;
|
|
101
|
+
};
|
|
102
|
+
readonly chain: {
|
|
103
|
+
readonly kind: "beam";
|
|
104
|
+
readonly color: 16771488;
|
|
105
|
+
};
|
|
106
|
+
readonly slash: {
|
|
107
|
+
readonly kind: "spark";
|
|
108
|
+
readonly color: 14078148;
|
|
109
|
+
};
|
|
110
|
+
readonly sword: {
|
|
111
|
+
readonly kind: "spark";
|
|
112
|
+
readonly color: 14078148;
|
|
113
|
+
};
|
|
114
|
+
readonly melee: {
|
|
115
|
+
readonly kind: "spark";
|
|
116
|
+
readonly color: 14078148;
|
|
117
|
+
};
|
|
118
|
+
readonly spark: {
|
|
119
|
+
readonly kind: "spark";
|
|
120
|
+
readonly color: 16773808;
|
|
121
|
+
};
|
|
122
|
+
readonly hit: {
|
|
123
|
+
readonly kind: "spark";
|
|
124
|
+
readonly color: 16765562;
|
|
125
|
+
};
|
|
126
|
+
readonly explosion: {
|
|
127
|
+
readonly kind: "nova";
|
|
128
|
+
readonly color: 16747066;
|
|
129
|
+
readonly radius: 3;
|
|
130
|
+
};
|
|
131
|
+
readonly blast: {
|
|
132
|
+
readonly kind: "nova";
|
|
133
|
+
readonly color: 16747066;
|
|
134
|
+
readonly radius: 3;
|
|
135
|
+
};
|
|
136
|
+
readonly shockwave: {
|
|
137
|
+
readonly kind: "nova";
|
|
138
|
+
readonly color: 12576511;
|
|
139
|
+
readonly radius: 3;
|
|
140
|
+
};
|
|
141
|
+
readonly frostNova: {
|
|
142
|
+
readonly kind: "nova";
|
|
143
|
+
readonly color: 9360127;
|
|
144
|
+
readonly radius: 3;
|
|
145
|
+
};
|
|
146
|
+
readonly heal: {
|
|
147
|
+
readonly kind: "glow";
|
|
148
|
+
readonly color: 8841322;
|
|
149
|
+
};
|
|
150
|
+
readonly buff: {
|
|
151
|
+
readonly kind: "glow";
|
|
152
|
+
readonly color: 16771488;
|
|
153
|
+
};
|
|
154
|
+
readonly shield: {
|
|
155
|
+
readonly kind: "glow";
|
|
156
|
+
readonly color: 9360127;
|
|
157
|
+
};
|
|
158
|
+
readonly cast: {
|
|
159
|
+
readonly kind: "glow";
|
|
160
|
+
readonly color: 14256895;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
/** A named key into {@link vfxPresets} (`"arrow" | "fireball" | "lightning" | "web" | "slash" | "shield" | "heal" | ...`). */
|
|
164
|
+
export type VfxPresetName = keyof typeof vfxPresets;
|
|
165
|
+
/** The fallback flavor used when a `vfx()` call names an unknown preset — so a typo still shows a spark instead of nothing. */
|
|
166
|
+
export declare const DEFAULT_VFX_PRESET: VfxPresetName;
|
|
167
|
+
/**
|
|
168
|
+
* Resolve a named visual flavor into a concrete `{ kind, color, durationMs?, radius? }`,
|
|
169
|
+
* with any provided `overrides` winning field by field. An unknown name resolves to
|
|
170
|
+
* {@link DEFAULT_VFX_PRESET} rather than throwing, so a flavor typo degrades to a visible
|
|
171
|
+
* spark. Used by `ctx.scene.entity.vfx({ preset })`; call it directly when you need the raw
|
|
172
|
+
* numbers (e.g. to seed a retained `vfxInstance` from the same vocabulary).
|
|
173
|
+
*
|
|
174
|
+
* @capability vfx-preset-resolve turn a named attack flavor into concrete vfx kind/color/duration with per-field overrides
|
|
175
|
+
*/
|
|
176
|
+
export declare function resolveVfxPreset(name: string | undefined, overrides?: Partial<VfxPreset>): VfxPreset;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ready-made visual flavors for the things players actually shoot, swing, and cast —
|
|
3
|
+
* so `ctx.scene.entity.vfx({ preset: "arrow", from, to })` renders a visible bolt with
|
|
4
|
+
* zero tuning, and `"lightning"`, `"web"`, `"slash"`, `"shield"`, `"heal"`, `"explosion"`
|
|
5
|
+
* likewise just work. Each entry only picks a `kind` (`projectile | beam | nova | glow |
|
|
6
|
+
* spark`), a color, and a lifetime; it is visual vocabulary (like named CSS colors), not a
|
|
7
|
+
* gameplay archetype — combat numbers stay in the caller's own effect/ability data. Any
|
|
8
|
+
* field passed to `vfx()` overrides the preset, and unknown names fall back to `spark` so a
|
|
9
|
+
* flavor typo still shows *something* rather than nothing.
|
|
10
|
+
*
|
|
11
|
+
* @capability vfx-presets render a named attack visual (arrow, fireball, lightning, web, slash, shield, heal, explosion) in one call
|
|
12
|
+
*/
|
|
13
|
+
export const vfxPresets = {
|
|
14
|
+
// Traveling bolts — a thing flies from caster to target.
|
|
15
|
+
arrow: { kind: "projectile", color: 0xd8c9a0 },
|
|
16
|
+
bolt: { kind: "projectile", color: 0xffffff },
|
|
17
|
+
fireball: { kind: "projectile", color: 0xff6a1a, durationMs: 460 },
|
|
18
|
+
firebolt: { kind: "projectile", color: 0xff7a2a },
|
|
19
|
+
frostbolt: { kind: "projectile", color: 0x8ed2ff },
|
|
20
|
+
ice: { kind: "projectile", color: 0x8ed2ff },
|
|
21
|
+
poison: { kind: "projectile", color: 0x86e86a },
|
|
22
|
+
shadowbolt: { kind: "projectile", color: 0x9a5df0 },
|
|
23
|
+
arcane: { kind: "projectile", color: 0xd98aff },
|
|
24
|
+
magicMissile: { kind: "projectile", color: 0xd98aff },
|
|
25
|
+
holybolt: { kind: "projectile", color: 0xffe9a0 },
|
|
26
|
+
rock: { kind: "projectile", color: 0xa89a86 },
|
|
27
|
+
bullet: { kind: "projectile", color: 0xfff2b0, durationMs: 140 },
|
|
28
|
+
// Connecting lines — a beam/tether links caster and target.
|
|
29
|
+
lightning: { kind: "beam", color: 0xbfe6ff, durationMs: 200 },
|
|
30
|
+
laser: { kind: "beam", color: 0xff4d4d },
|
|
31
|
+
beam: { kind: "beam", color: 0x8ed2ff },
|
|
32
|
+
web: { kind: "beam", color: 0xf0f0f0, durationMs: 320 },
|
|
33
|
+
chain: { kind: "beam", color: 0xffe9a0 },
|
|
34
|
+
// Melee / impact — a spark scatters at the point of contact.
|
|
35
|
+
slash: { kind: "spark", color: 0xd6d0c4 },
|
|
36
|
+
sword: { kind: "spark", color: 0xd6d0c4 },
|
|
37
|
+
melee: { kind: "spark", color: 0xd6d0c4 },
|
|
38
|
+
spark: { kind: "spark", color: 0xfff2b0 },
|
|
39
|
+
hit: { kind: "spark", color: 0xffd27a },
|
|
40
|
+
// Ground bursts — an expanding ring/shockwave from a point.
|
|
41
|
+
explosion: { kind: "nova", color: 0xff8a3a, radius: 3 },
|
|
42
|
+
blast: { kind: "nova", color: 0xff8a3a, radius: 3 },
|
|
43
|
+
shockwave: { kind: "nova", color: 0xbfe6ff, radius: 3 },
|
|
44
|
+
frostNova: { kind: "nova", color: 0x8ed2ff, radius: 3 },
|
|
45
|
+
// Auras — a soft glow that lingers on caster or target.
|
|
46
|
+
heal: { kind: "glow", color: 0x86e86a },
|
|
47
|
+
buff: { kind: "glow", color: 0xffe9a0 },
|
|
48
|
+
shield: { kind: "glow", color: 0x8ed2ff },
|
|
49
|
+
cast: { kind: "glow", color: 0xd98aff },
|
|
50
|
+
};
|
|
51
|
+
/** The fallback flavor used when a `vfx()` call names an unknown preset — so a typo still shows a spark instead of nothing. */
|
|
52
|
+
export const DEFAULT_VFX_PRESET = "spark";
|
|
53
|
+
/**
|
|
54
|
+
* Resolve a named visual flavor into a concrete `{ kind, color, durationMs?, radius? }`,
|
|
55
|
+
* with any provided `overrides` winning field by field. An unknown name resolves to
|
|
56
|
+
* {@link DEFAULT_VFX_PRESET} rather than throwing, so a flavor typo degrades to a visible
|
|
57
|
+
* spark. Used by `ctx.scene.entity.vfx({ preset })`; call it directly when you need the raw
|
|
58
|
+
* numbers (e.g. to seed a retained `vfxInstance` from the same vocabulary).
|
|
59
|
+
*
|
|
60
|
+
* @capability vfx-preset-resolve turn a named attack flavor into concrete vfx kind/color/duration with per-field overrides
|
|
61
|
+
*/
|
|
62
|
+
export function resolveVfxPreset(name, overrides) {
|
|
63
|
+
const base = name !== undefined && name in vfxPresets
|
|
64
|
+
? vfxPresets[name]
|
|
65
|
+
: vfxPresets[DEFAULT_VFX_PRESET];
|
|
66
|
+
const durationMs = overrides?.durationMs ?? base.durationMs;
|
|
67
|
+
const radius = overrides?.radius ?? base.radius;
|
|
68
|
+
return {
|
|
69
|
+
kind: overrides?.kind ?? base.kind,
|
|
70
|
+
color: overrides?.color ?? base.color,
|
|
71
|
+
...(durationMs === undefined ? {} : { durationMs }),
|
|
72
|
+
...(radius === undefined ? {} : { radius }),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { type DamageHitInput, type DamageHitResolution } from "./damageResolution.js";
|
|
2
|
+
import { type Magazine, type MagazineConfig } from "./magazine.js";
|
|
3
|
+
/** Tuning for {@link createFireCadence}: the minimum interval between actions and whether it starts ready. */
|
|
4
|
+
export interface FireCadenceConfig {
|
|
5
|
+
/** Minimum milliseconds between successful `fire()` calls. `<= 0` disables the limit (always ready). */
|
|
6
|
+
intervalMs: number;
|
|
7
|
+
/** Start ready to fire (default) or mid-cooldown. */
|
|
8
|
+
ready?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A minimal minimum-interval rate gate for a repeated action — weapon fire, ability
|
|
12
|
+
* spam, any "no faster than N per second" rule. Deterministic and serializable: its
|
|
13
|
+
* whole state is the elapsed time since the last action, exposed via {@link FireCadence.elapsedMs}.
|
|
14
|
+
*/
|
|
15
|
+
export interface FireCadence {
|
|
16
|
+
/** True when at least `intervalMs` has elapsed since the last successful `fire()`. */
|
|
17
|
+
ready(): boolean;
|
|
18
|
+
/** Progress toward ready in `[0, 1]`; `1` when ready. */
|
|
19
|
+
readyFraction(): number;
|
|
20
|
+
/** Milliseconds until ready; `0` when ready. */
|
|
21
|
+
remainingMs(): number;
|
|
22
|
+
/** Consume the gate: resets the interval and returns `true`, or returns `false` without effect when not `ready()`. */
|
|
23
|
+
fire(): boolean;
|
|
24
|
+
/** Advance the internal clock by `dtSeconds`. */
|
|
25
|
+
tick(dtSeconds: number): void;
|
|
26
|
+
/** Elapsed milliseconds since the last successful `fire()` (capped at `intervalMs`) — the full serializable state. */
|
|
27
|
+
elapsedMs(): number;
|
|
28
|
+
/** Restore a prior {@link FireCadence.elapsedMs} value (e.g. from a save/replay snapshot). */
|
|
29
|
+
restore(elapsedMs: number): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build a {@link FireCadence} rate gate. Reach for this instead of hand-tracking a
|
|
33
|
+
* `lastFiredAt` timestamp and comparing against a fire interval per game.
|
|
34
|
+
*
|
|
35
|
+
* @capability fire-cadence a serializable minimum-interval rate gate for repeated actions (weapon fire, ability spam)
|
|
36
|
+
*/
|
|
37
|
+
export declare function createFireCadence(config: FireCadenceConfig): FireCadence;
|
|
38
|
+
/** Why a {@link WeaponRuntime.fire} attempt resolved the way it did. */
|
|
39
|
+
export type WeaponFireStatus = "fired" | "cooling" | "empty" | "reloading";
|
|
40
|
+
/**
|
|
41
|
+
* The result of a {@link WeaponRuntime.fire} attempt. On `"fired"`, `hits` is whatever the
|
|
42
|
+
* caller's raycast returned and `resolutions` holds the portable damage provenance for each hit
|
|
43
|
+
* that produced a {@link DamageHitInput}; on any blocked status both are empty and no round was spent.
|
|
44
|
+
*/
|
|
45
|
+
export interface WeaponFireResult<THit> {
|
|
46
|
+
status: WeaponFireStatus;
|
|
47
|
+
/** The hits the caller's `resolveHits` returned (empty when the shot was blocked). */
|
|
48
|
+
hits: readonly THit[];
|
|
49
|
+
/** One {@link DamageHitResolution} per hit that mapped to a {@link DamageHitInput}. */
|
|
50
|
+
resolutions: readonly DamageHitResolution[];
|
|
51
|
+
/** Loaded rounds remaining after the attempt, or `null` when the weapon has no magazine. */
|
|
52
|
+
loaded: number | null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Configuration for {@link createWeaponRuntime}. Everything time/ammo-related is plain data; the
|
|
56
|
+
* two callbacks are where the caller keeps ownership of aiming, its own raycaster/projectile query,
|
|
57
|
+
* and how a hit maps to damage. There is deliberately no default weapon, projectile, or damage
|
|
58
|
+
* table here — those are game content.
|
|
59
|
+
*/
|
|
60
|
+
export interface WeaponRuntimeConfig<TAim, THit> {
|
|
61
|
+
/** Minimum milliseconds between shots. From a rounds-per-second fire rate, pass `1000 / roundsPerSecond`. */
|
|
62
|
+
cadenceMs: number;
|
|
63
|
+
/** Optional discrete-ammo model; omit for an unlimited-fire weapon. */
|
|
64
|
+
magazine?: MagazineConfig;
|
|
65
|
+
/** Start the cadence ready to fire (default) or mid-cooldown. */
|
|
66
|
+
ready?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Caller-owned aim → hits. This is where the game runs its OWN raycaster, projectile sweep, or
|
|
69
|
+
* spatial query and returns whatever hit shape it likes. Called once per fired shot.
|
|
70
|
+
*/
|
|
71
|
+
resolveHits: (aim: TAim) => readonly THit[];
|
|
72
|
+
/**
|
|
73
|
+
* Map one resolved hit into a portable {@link DamageHitInput}, or `null` to skip damage for that
|
|
74
|
+
* hit (e.g. a wall). The runtime feeds the result to {@link resolveDamageHit}.
|
|
75
|
+
*/
|
|
76
|
+
damageFor: (hit: THit, aim: TAim) => DamageHitInput | null;
|
|
77
|
+
/** Deterministic RNG forwarded to status rolls in {@link resolveDamageHit} when a hit's input omits its own. */
|
|
78
|
+
rng?: () => number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A composed weapon fire controller: a {@link FireCadence} gate, an optional {@link Magazine}, the
|
|
82
|
+
* caller's raycast, and portable {@link resolveDamageHit} damage resolution wired together. The
|
|
83
|
+
* caller retains ownership of models, animations, muzzle flash, audio, input, camera, aiming, and
|
|
84
|
+
* the raycaster itself.
|
|
85
|
+
*/
|
|
86
|
+
export interface WeaponRuntime<TAim, THit> {
|
|
87
|
+
/**
|
|
88
|
+
* Attempt one shot with the given aim. Gates on cadence, reload state, and ammo (in that order);
|
|
89
|
+
* only a `"fired"` result spends a round, resets the cadence, runs `resolveHits`, and resolves damage.
|
|
90
|
+
*/
|
|
91
|
+
fire(aim: TAim): WeaponFireResult<THit>;
|
|
92
|
+
/** Whether {@link WeaponRuntime.fire} would fire right now (cadence ready, not reloading, ammo available). */
|
|
93
|
+
canFire(): boolean;
|
|
94
|
+
/** Begin a magazine reload if possible; always `false` for a weapon with no magazine. */
|
|
95
|
+
startReload(): boolean;
|
|
96
|
+
/** Abort an in-progress reload. */
|
|
97
|
+
cancelReload(): void;
|
|
98
|
+
/** Advance the cadence gate and any magazine reload timer by `dtSeconds`. */
|
|
99
|
+
tick(dtSeconds: number): void;
|
|
100
|
+
/** The underlying cadence gate (for HUD readouts and snapshot/restore). */
|
|
101
|
+
readonly cadence: FireCadence;
|
|
102
|
+
/** The magazine, or `null` when the weapon has no ammo model. */
|
|
103
|
+
readonly magazine: Magazine | null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Compose a portable weapon fire controller from the existing generic primitives — a
|
|
107
|
+
* {@link FireCadence} gate, an optional {@link Magazine}, a caller-provided raycast, and portable
|
|
108
|
+
* {@link resolveDamageHit} damage resolution. No `GameContext`, entity store, renderer, or default
|
|
109
|
+
* weapon is involved; the caller owns aiming, its raycaster, and all presentation, and the result
|
|
110
|
+
* carries full damage provenance for authority to apply and replicate.
|
|
111
|
+
*
|
|
112
|
+
* @capability weapon-runtime compose cadence, magazine, a caller-owned raycast, and portable damage resolution into a fire controller
|
|
113
|
+
*/
|
|
114
|
+
export declare function createWeaponRuntime<TAim, THit>(config: WeaponRuntimeConfig<TAim, THit>): WeaponRuntime<TAim, THit>;
|