@jgengine/core 0.24.0 → 0.26.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 +92 -0
- package/dist/ai/rvo.d.ts +106 -0
- package/dist/ai/rvo.js +581 -0
- package/dist/ai/utilityBrain.d.ts +173 -0
- package/dist/ai/utilityBrain.js +277 -0
- package/dist/combat/cover.d.ts +169 -0
- package/dist/combat/cover.js +264 -0
- package/dist/combat/damageRuntime.d.ts +150 -0
- package/dist/combat/damageRuntime.js +208 -0
- package/dist/combat/damageTable.d.ts +116 -0
- package/dist/combat/damageTable.js +165 -0
- package/dist/combat/hitZones.d.ts +70 -0
- package/dist/combat/hitZones.js +77 -0
- package/dist/combat/magazine.d.ts +8 -0
- package/dist/combat/magazine.js +20 -2
- package/dist/combat/squadCombat.d.ts +167 -0
- package/dist/combat/squadCombat.js +557 -0
- package/dist/combat/squadTactics.d.ts +73 -0
- package/dist/combat/squadTactics.js +49 -0
- package/dist/combat/statusRuntime.d.ts +142 -0
- package/dist/combat/statusRuntime.js +236 -0
- package/dist/combat/weaponDefinition.d.ts +106 -0
- package/dist/combat/weaponDefinition.js +108 -0
- package/dist/combat/weaponSystem.d.ts +189 -0
- package/dist/combat/weaponSystem.js +469 -0
- package/dist/combat.d.ts +9 -0
- package/dist/combat.js +9 -0
- package/dist/devtools/devtools.d.ts +4 -2
- package/dist/devtools/devtools.js +2 -1
- package/dist/devtools/discover.d.ts +2 -1
- package/dist/devtools/discover.js +38 -0
- package/dist/devtools/frame.d.ts +0 -2
- package/dist/devtools/frame.js +1 -2
- package/dist/devtools/logBus.d.ts +58 -0
- package/dist/devtools/logBus.js +79 -0
- package/dist/devtools/logs.d.ts +6 -3
- package/dist/devtools/logs.js +17 -13
- package/dist/devtools/report.d.ts +120 -0
- package/dist/devtools/report.js +49 -0
- package/dist/devtools/reportEndpoint.d.ts +17 -0
- package/dist/devtools/reportEndpoint.js +7 -0
- package/dist/devtools/types.d.ts +48 -11
- package/dist/editor/document.js +210 -0
- package/dist/editor/environment.d.ts +48 -1
- package/dist/editor/environment.js +161 -0
- package/dist/editor/index.d.ts +6 -2
- package/dist/editor/index.js +1 -1
- package/dist/editor/types.d.ts +54 -0
- package/dist/game/notices.d.ts +4 -0
- package/dist/game/notices.js +4 -3
- package/dist/game/playableGame.d.ts +9 -1
- package/dist/gameplay.d.ts +4 -0
- package/dist/gameplay.js +4 -0
- package/dist/meta/changelog.d.ts +1 -1
- package/dist/meta/changelog.js +78 -1
- package/dist/nav/navCrowd.d.ts +138 -0
- package/dist/nav/navCrowd.js +412 -0
- package/dist/nav/navRuntime.d.ts +108 -0
- package/dist/nav/navRuntime.js +256 -0
- package/dist/render/colorPipeline.d.ts +53 -0
- package/dist/render/colorPipeline.js +79 -0
- package/dist/render/lightProbes.d.ts +97 -0
- package/dist/render/lightProbes.js +221 -0
- package/dist/render/lookPreset.js +4 -4
- package/dist/render/physicalSky.d.ts +39 -0
- package/dist/render/physicalSky.js +89 -0
- package/dist/render/postProcessing.d.ts +40 -8
- package/dist/render/postProcessing.js +1 -1
- package/dist/render/skyOwnedLighting.d.ts +31 -0
- package/dist/render/skyOwnedLighting.js +46 -0
- package/dist/sensor/perception.d.ts +66 -5
- package/dist/sensor/perception.js +167 -42
- package/dist/sim/nearAgents.d.ts +68 -0
- package/dist/sim/nearAgents.js +152 -0
- package/dist/sim/needs.d.ts +60 -0
- package/dist/sim/needs.js +108 -0
- package/dist/sim/offScreen.d.ts +181 -0
- package/dist/sim/offScreen.js +450 -0
- package/dist/sim/routine.d.ts +79 -0
- package/dist/sim/routine.js +137 -0
- package/dist/visibility/visibilitySystem.js +21 -0
- package/dist/world/features.d.ts +8 -0
- package/dist/world.d.ts +5 -0
- package/dist/world.js +5 -0
- package/package.json +1 -1
- package/skills/jgengine/api.md +59 -6
- package/skills/jgengine/capabilities.md +4 -0
- package/skills/jgengine-combat/SKILL.md +17 -0
- package/skills/jgengine-combat/api.md +246 -0
- package/skills/jgengine-combat/capabilities.md +112 -0
- package/skills/jgengine-combat/reference.md +32 -0
- package/skills/jgengine-gameplay/SKILL.md +8 -0
- package/skills/jgengine-gameplay/api.md +71 -1
- package/skills/jgengine-gameplay/capabilities.md +16 -0
- package/skills/jgengine-world/SKILL.md +3 -1
- package/skills/jgengine-world/api.md +107 -3
- package/skills/jgengine-world/capabilities.md +22 -2
- package/skills/jgengine-world/recipes/npc-senses.md +8 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type NavCrowdSnapshot } from "../nav/navCrowd.js";
|
|
2
|
+
import type { NavRuntime } from "../nav/navRuntime.js";
|
|
3
|
+
import type { PerceptionService } from "../sensor/perception.js";
|
|
4
|
+
import type { Vec3 } from "../world/geometry.js";
|
|
5
|
+
import { type CoverSource } from "./cover.js";
|
|
6
|
+
import { type SquadComposition, type SquadRole } from "./squadTactics.js";
|
|
7
|
+
/** One combatant the runtime drives: whose side it is on, where it stands, and how hurt it is. */
|
|
8
|
+
export interface SquadMemberSpec {
|
|
9
|
+
id: string;
|
|
10
|
+
/** Side the member fights for; only other sides are threats. */
|
|
11
|
+
team: string;
|
|
12
|
+
/** Squad it shares roles and cover with. Defaults to its team. */
|
|
13
|
+
squad?: string;
|
|
14
|
+
position: Vec3;
|
|
15
|
+
/** Health fraction at spawn, which is what the runtime reports until `healthOf` is given. */
|
|
16
|
+
health?: number;
|
|
17
|
+
}
|
|
18
|
+
/** What a member is doing this tick: moving to cover, holding it, leaning out, falling back, or down. */
|
|
19
|
+
export type SquadMode = "advance" | "cover" | "peek" | "retreat" | "down";
|
|
20
|
+
/** In-play dials, every one retunable. */
|
|
21
|
+
export interface SquadCombatTunables {
|
|
22
|
+
/** Seconds between cover re-selections for one member. Default `0.6`. */
|
|
23
|
+
reselectSeconds?: number;
|
|
24
|
+
/** Most cover points one selection pass scores. Default `24`. */
|
|
25
|
+
maxCoverCandidates?: number;
|
|
26
|
+
/** Radius a member searches for cover, world units. Default `12`. */
|
|
27
|
+
coverRadius?: number;
|
|
28
|
+
/** Most remembered threats one member considers per tick. Default `6`. */
|
|
29
|
+
maxThreats?: number;
|
|
30
|
+
/** Seconds a hit keeps a member pinned and unable to shoot. Default `2.5`. */
|
|
31
|
+
suppressSeconds?: number;
|
|
32
|
+
/** Suppression at or above this pins a member. Default `0.5`. */
|
|
33
|
+
pinAt?: number;
|
|
34
|
+
/** Exposure seconds the run counts as a breach. Default `3`. */
|
|
35
|
+
exposureLimitSeconds?: number;
|
|
36
|
+
/** Crowd walking speed, world units per second. Default `3.2`. */
|
|
37
|
+
speed?: number;
|
|
38
|
+
/** Crowd avoidance radius, world units. Default `0.4`. */
|
|
39
|
+
radius?: number;
|
|
40
|
+
/** How far a goal must move before the crowd is asked to re-plan. Default `0.15`. */
|
|
41
|
+
goalEpsilon?: number;
|
|
42
|
+
/** How much better a rival cover point must score before a held one is abandoned. Default `0.8`. */
|
|
43
|
+
coverSwitchMargin?: number;
|
|
44
|
+
/** Seconds of continuous exposure before a member stops trusting its point and repositions. Default `1.5`. */
|
|
45
|
+
relocateAfterSeconds?: number;
|
|
46
|
+
}
|
|
47
|
+
/** Everything the squad AI reads from the game, plus its tunables. */
|
|
48
|
+
export interface SquadCombatOptions extends SquadCombatTunables {
|
|
49
|
+
nav: NavRuntime;
|
|
50
|
+
perception: PerceptionService;
|
|
51
|
+
/** Bounded cover query — authored geometry (`createCoverField`) or the game's own. */
|
|
52
|
+
cover: CoverSource;
|
|
53
|
+
/** Roles per squad id, or a function that answers for one squad. */
|
|
54
|
+
composition: SquadComposition | ((squad: string) => SquadComposition | undefined);
|
|
55
|
+
/** Role for a squad the composition does not name. Default `{ id: "member" }`. */
|
|
56
|
+
defaultRole?: SquadRole;
|
|
57
|
+
members: readonly SquadMemberSpec[];
|
|
58
|
+
/** Which side an id fights for, so a remembered target can be classed as hostile. */
|
|
59
|
+
teamOf: (id: string) => string | null;
|
|
60
|
+
/** Authoritative health fraction for a member. Default the spawn value. */
|
|
61
|
+
healthOf?: (id: string) => number;
|
|
62
|
+
/** True when nothing blocks the segment — the game's collision layer. */
|
|
63
|
+
blocked: (from: Vec3, to: Vec3) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Fire one paced shot and resolve it in the game's own damage pipeline. Returns damage dealt, which
|
|
66
|
+
* the runtime only counts; call {@link SquadCombat.underFire} on the victim yourself.
|
|
67
|
+
*/
|
|
68
|
+
engage?: (memberId: string, targetId: string, distance: number) => number;
|
|
69
|
+
/** Seeded `[0,1)` stream, used to de-sync each member's peek phase. */
|
|
70
|
+
rng?: () => number;
|
|
71
|
+
/** Register a devtools probe under this name so the overlay shows the squad's behavior. */
|
|
72
|
+
devtoolsName?: string;
|
|
73
|
+
}
|
|
74
|
+
/** One member as a HUD, a probe or a test reads it. Allocates. */
|
|
75
|
+
export interface SquadMemberView {
|
|
76
|
+
id: string;
|
|
77
|
+
team: string;
|
|
78
|
+
squad: string;
|
|
79
|
+
role: string;
|
|
80
|
+
mode: SquadMode;
|
|
81
|
+
target: string | null;
|
|
82
|
+
/** Cover point the member is heading for or holding. */
|
|
83
|
+
cover: string | null;
|
|
84
|
+
position: Vec3;
|
|
85
|
+
health: number;
|
|
86
|
+
/** `0..1` incoming-fire meter; high values pin the member to cover and stop its fire. */
|
|
87
|
+
suppression: number;
|
|
88
|
+
/** Consecutive seconds visible to a remembered threat. */
|
|
89
|
+
exposure: number;
|
|
90
|
+
shots: number;
|
|
91
|
+
}
|
|
92
|
+
/** Counters a probe or a test reads. */
|
|
93
|
+
export interface SquadCombatStats {
|
|
94
|
+
members: number;
|
|
95
|
+
ticks: number;
|
|
96
|
+
coverQueries: number;
|
|
97
|
+
coverScored: number;
|
|
98
|
+
losChecks: number;
|
|
99
|
+
shots: number;
|
|
100
|
+
/** Worst consecutive exposure against a remembered threat, seconds. */
|
|
101
|
+
worstExposure: number;
|
|
102
|
+
/** Exposure spells longer than `exposureLimitSeconds`. */
|
|
103
|
+
exposuresOverLimit: number;
|
|
104
|
+
slowestTickMs: number;
|
|
105
|
+
}
|
|
106
|
+
/** Serializable squad state: member decisions, the crowd, and the tuning they ran under. */
|
|
107
|
+
export interface SquadCombatSnapshot {
|
|
108
|
+
nowMs: number;
|
|
109
|
+
tunables: Required<SquadCombatTunables>;
|
|
110
|
+
members: {
|
|
111
|
+
id: string;
|
|
112
|
+
team: string;
|
|
113
|
+
squad: string;
|
|
114
|
+
role: string;
|
|
115
|
+
mode: SquadMode;
|
|
116
|
+
health: number;
|
|
117
|
+
target: string | null;
|
|
118
|
+
targetPosition: Vec3 | null;
|
|
119
|
+
coverId: string | null;
|
|
120
|
+
coverPosition: Vec3 | null;
|
|
121
|
+
coverHidden: number;
|
|
122
|
+
goal: Vec3 | null;
|
|
123
|
+
reselect: number;
|
|
124
|
+
peek: number;
|
|
125
|
+
peeking: boolean;
|
|
126
|
+
fire: number;
|
|
127
|
+
suppression: number;
|
|
128
|
+
exposure: number;
|
|
129
|
+
shots: number;
|
|
130
|
+
}[];
|
|
131
|
+
crowd: NavCrowdSnapshot;
|
|
132
|
+
ticks: number;
|
|
133
|
+
coverQueries: number;
|
|
134
|
+
coverScored: number;
|
|
135
|
+
losChecks: number;
|
|
136
|
+
shots: number;
|
|
137
|
+
worstExposure: number;
|
|
138
|
+
exposuresOverLimit: number;
|
|
139
|
+
}
|
|
140
|
+
/** Drive a squad: cover by threat, flanking, fire discipline, suppression and retreat. */
|
|
141
|
+
export interface SquadCombat {
|
|
142
|
+
/** Advance every member one tick; movement goes through the shared nav crowd. */
|
|
143
|
+
tick(dt: number): void;
|
|
144
|
+
/** Report incoming fire on a member: raises its suppression and pins it to cover. */
|
|
145
|
+
underFire(memberId: string, amount?: number): void;
|
|
146
|
+
member(id: string): SquadMemberView | null;
|
|
147
|
+
members(): readonly SquadMemberView[];
|
|
148
|
+
stats(): SquadCombatStats;
|
|
149
|
+
retune(patch: SquadCombatTunables): void;
|
|
150
|
+
snapshot(): SquadCombatSnapshot;
|
|
151
|
+
restore(next: SquadCombatSnapshot): void;
|
|
152
|
+
/** Drop the devtools probe registered by `devtoolsName`. Safe to call twice. */
|
|
153
|
+
dispose(): void;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* One squad's combat behavior per tick, over the perception memory a game already keeps and the nav
|
|
157
|
+
* crowd it already moves. Each member picks a stand point that hides it from the threats it remembers,
|
|
158
|
+
* at the distance and angle its role wants; a flanker goes around the side, a support holds and fires,
|
|
159
|
+
* an assault closes. Incoming fire raises suppression, which pins the member to its cover and stops
|
|
160
|
+
* its shooting until the meter decays; low health turns it toward the point furthest from the threat.
|
|
161
|
+
*
|
|
162
|
+
* Cover refresh runs on a per-member timer, so the per-tick cost is the crowd step plus one bounded
|
|
163
|
+
* memory read and a handful of segment tests per member — not a world scan.
|
|
164
|
+
*
|
|
165
|
+
* @capability squad-combat threat-driven cover, flanking, suppression, retreat and role-driven fire discipline
|
|
166
|
+
*/
|
|
167
|
+
export declare function createSquadCombat(options: SquadCombatOptions): SquadCombat;
|