@jgengine/core 0.26.0 → 0.28.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +174 -0
  2. package/dist/ai/policeResponse.d.ts +253 -0
  3. package/dist/ai/policeResponse.js +421 -0
  4. package/dist/anim/actionLayer.d.ts +47 -0
  5. package/dist/anim/actionLayer.js +63 -0
  6. package/dist/anim/ikSolver.d.ts +14 -0
  7. package/dist/anim/ikSolver.js +37 -0
  8. package/dist/anim/locomotionGraph.d.ts +58 -3
  9. package/dist/anim/locomotionGraph.js +142 -15
  10. package/dist/anim/ragdollRig.d.ts +53 -0
  11. package/dist/anim/ragdollRig.js +132 -0
  12. package/dist/anim/skeletonStandard.d.ts +140 -0
  13. package/dist/anim/skeletonStandard.js +326 -0
  14. package/dist/combat/damageRuntime.d.ts +14 -1
  15. package/dist/combat/damageRuntime.js +62 -4
  16. package/dist/combat/death.js +7 -3
  17. package/dist/combat/deathReason.d.ts +7 -1
  18. package/dist/combat/effects.d.ts +25 -0
  19. package/dist/combat/effects.js +16 -0
  20. package/dist/combat/statusRuntime.d.ts +2 -0
  21. package/dist/combat/statusRuntime.js +1 -0
  22. package/dist/economy/loanBook.d.ts +182 -0
  23. package/dist/economy/loanBook.js +303 -0
  24. package/dist/economy/market.d.ts +161 -0
  25. package/dist/economy/market.js +248 -0
  26. package/dist/economy/transactionLedger.d.ts +162 -0
  27. package/dist/economy/transactionLedger.js +301 -0
  28. package/dist/editor/creatorStorage.js +3 -1
  29. package/dist/editor/simulation.d.ts +5 -2
  30. package/dist/editor/simulation.js +29 -19
  31. package/dist/game/cameraConfig.d.ts +14 -0
  32. package/dist/game/clipRoles.d.ts +5 -4
  33. package/dist/game/clipRoles.js +34 -4
  34. package/dist/game/events.d.ts +27 -0
  35. package/dist/game/gameSave.d.ts +142 -0
  36. package/dist/game/gameSave.js +174 -0
  37. package/dist/game/playableGame.d.ts +74 -6
  38. package/dist/game/saveSlotIndex.d.ts +54 -0
  39. package/dist/game/saveSlotIndex.js +71 -0
  40. package/dist/game/saveSlots.d.ts +2 -0
  41. package/dist/game/saveSlots.js +1 -1
  42. package/dist/game/saveStore.d.ts +8 -0
  43. package/dist/game/saveStore.js +16 -0
  44. package/dist/gameplay.d.ts +17 -2
  45. package/dist/gameplay.js +15 -0
  46. package/dist/inventory/carryLoad.d.ts +48 -0
  47. package/dist/inventory/carryLoad.js +44 -0
  48. package/dist/inventory/equipment.d.ts +95 -0
  49. package/dist/inventory/equipment.js +169 -0
  50. package/dist/inventory/inventoryModel.d.ts +15 -6
  51. package/dist/inventory/inventoryModel.js +54 -5
  52. package/dist/inventory/shapedGrid.d.ts +26 -0
  53. package/dist/inventory/shapedGrid.js +47 -0
  54. package/dist/loot/lootGen.d.ts +186 -0
  55. package/dist/loot/lootGen.js +437 -0
  56. package/dist/loot/lootWeapon.d.ts +35 -0
  57. package/dist/loot/lootWeapon.js +70 -0
  58. package/dist/meta/changelog.d.ts +1 -1
  59. package/dist/meta/changelog.js +156 -1
  60. package/dist/mission/compositions.d.ts +85 -0
  61. package/dist/mission/compositions.js +130 -0
  62. package/dist/mission/mission.d.ts +435 -0
  63. package/dist/mission/mission.js +770 -0
  64. package/dist/mission/triggers.d.ts +61 -0
  65. package/dist/mission/triggers.js +108 -0
  66. package/dist/nav/laneGraph.d.ts +178 -0
  67. package/dist/nav/laneGraph.js +671 -0
  68. package/dist/nav/traffic.d.ts +222 -0
  69. package/dist/nav/traffic.js +918 -0
  70. package/dist/physics/kinematicVehicle.d.ts +36 -0
  71. package/dist/physics/kinematicVehicle.js +15 -1
  72. package/dist/physics/vehicleDamage.d.ts +136 -0
  73. package/dist/physics/vehicleDamage.js +214 -0
  74. package/dist/physics/vehicleParts.d.ts +62 -0
  75. package/dist/physics/vehicleParts.js +65 -0
  76. package/dist/progression/gearScore.d.ts +56 -0
  77. package/dist/progression/gearScore.js +59 -0
  78. package/dist/progression/skillTree.d.ts +129 -0
  79. package/dist/progression/skillTree.js +265 -0
  80. package/dist/progression/xpCurve.d.ts +60 -0
  81. package/dist/progression/xpCurve.js +141 -0
  82. package/dist/runtime/context/combat.js +11 -0
  83. package/dist/scene/builtinSceneKinds.js +2 -0
  84. package/dist/settings/accessibilitySettings.d.ts +81 -0
  85. package/dist/settings/accessibilitySettings.js +152 -0
  86. package/dist/settings/graphicsProfile.d.ts +3 -0
  87. package/dist/settings/graphicsProfile.js +4 -0
  88. package/dist/settings/settingsModel.d.ts +1 -1
  89. package/dist/settings/settingsModel.js +1 -0
  90. package/dist/sim/nearAgents.d.ts +8 -1
  91. package/dist/sim/nearAgents.js +34 -17
  92. package/dist/sim/offScreen.d.ts +2 -1
  93. package/dist/sim/offScreen.js +14 -3
  94. package/dist/sim/population.d.ts +147 -0
  95. package/dist/sim/population.js +182 -0
  96. package/dist/sim/queue.d.ts +90 -0
  97. package/dist/sim/queue.js +171 -0
  98. package/dist/sim/rides.d.ts +287 -0
  99. package/dist/sim/rides.js +471 -0
  100. package/dist/sim/routine.js +19 -11
  101. package/dist/ui/loadingTips.d.ts +41 -0
  102. package/dist/ui/loadingTips.js +64 -0
  103. package/dist/ui/menuNav.d.ts +79 -0
  104. package/dist/ui/menuNav.js +147 -0
  105. package/dist/ui/menuTransition.d.ts +50 -0
  106. package/dist/ui/menuTransition.js +67 -0
  107. package/dist/ui.d.ts +2 -0
  108. package/dist/ui.js +2 -0
  109. package/dist/vfx/effectLibrary.d.ts +98 -0
  110. package/dist/vfx/effectLibrary.js +181 -0
  111. package/dist/vfx/particleBudget.d.ts +40 -0
  112. package/dist/vfx/particleBudget.js +39 -0
  113. package/dist/vfx/particleDirector.d.ts +16 -0
  114. package/dist/vfx/particleDirector.js +18 -0
  115. package/dist/world/authoredSimulation.js +7 -1
  116. package/dist/world/captureCamera.d.ts +30 -0
  117. package/dist/world/captureCamera.js +19 -0
  118. package/dist/world/decalKind.d.ts +48 -0
  119. package/dist/world/decalKind.js +86 -0
  120. package/dist/world/features.d.ts +18 -5
  121. package/dist/world/features.js +1 -0
  122. package/dist/world/grassKind.d.ts +5 -0
  123. package/dist/world/grassKind.js +3 -0
  124. package/dist/world/terraform.d.ts +8 -0
  125. package/dist/world/terrain.d.ts +1 -0
  126. package/dist/world/terrain.js +2 -0
  127. package/dist/world.d.ts +7 -2
  128. package/dist/world.js +5 -0
  129. package/package.json +1 -1
  130. package/skills/jgengine/api.md +2 -2
  131. package/skills/jgengine-combat/SKILL.md +9 -1
  132. package/skills/jgengine-combat/api.md +5 -4
  133. package/skills/jgengine-combat/reference.md +4 -0
  134. package/skills/jgengine-gameplay/SKILL.md +86 -0
  135. package/skills/jgengine-gameplay/api.md +485 -16
  136. package/skills/jgengine-gameplay/capabilities.md +131 -4
  137. package/skills/jgengine-gameplay/reference-systems.md +118 -0
  138. package/skills/jgengine-world/SKILL.md +8 -0
  139. package/skills/jgengine-world/api.md +243 -11
  140. package/skills/jgengine-world/capabilities.md +61 -1
  141. package/skills/jgengine-world/recipes/character-animation.md +25 -2
  142. package/skills/jgengine-world/recipes/vehicle-feel.md +5 -0
  143. package/skills/jgengine-world/reference.md +1 -1
@@ -0,0 +1,222 @@
1
+ import { type LaneGraph } from "./laneGraph.js";
2
+ import type { Waypoint } from "./pathFollow.js";
3
+ /** One car's live state, as a renderer, a game or the devtools overlay reads it. */
4
+ export interface TrafficCarView {
5
+ id: string;
6
+ laneId: string;
7
+ /** Arc, in metres, along the lane. */
8
+ arc: number;
9
+ position: Waypoint;
10
+ /** Yaw of travel, matching engine `rotationY`. */
11
+ heading: number;
12
+ /** World units per second. */
13
+ speed: number;
14
+ state: "driving" | "boxed" | "parked";
15
+ /** Parking spot held or reserved, while parking. */
16
+ spotId: string | null;
17
+ /** Stable integer for the game's model or colour choice; derived from the injected RNG. */
18
+ variant: number;
19
+ }
20
+ /** Caller-supplied exit choice at a junction: return one of `options`, or `null` to leave the graph. */
21
+ export type TrafficRoutePolicy = (context: {
22
+ carId: string;
23
+ laneId: string;
24
+ nodeId: string;
25
+ /** Outbound lanes that are not the lane the car arrived on, sorted by id. */
26
+ options: readonly string[];
27
+ }) => string | null;
28
+ /** Every per-car behaviour number, retunable in play. */
29
+ export interface TrafficTuning {
30
+ /** Body length, metres; sets the spacing a follower keeps. Default 4.4. */
31
+ carLength: number;
32
+ /** Body width, metres — one lane-change blend and the fallback lane spacing. Default 1.9. */
33
+ carWidth: number;
34
+ /** Acceleration while unobstructed, world units/s². Default 2.4. */
35
+ maxAccel: number;
36
+ /** Comfortable braking, world units/s². Default 3.2. */
37
+ comfortBrake: number;
38
+ /** Bumper-to-bumper gap at a standstill, metres. Default 1.6. */
39
+ minGap: number;
40
+ /** Time headway a follower keeps, seconds. Default 1.25. */
41
+ timeHeadway: number;
42
+ /** Multiplier on every lane's speed limit. Default 1. */
43
+ speedScale: number;
44
+ /** Free space the exit lane must show before a car is let into an intersection, metres. Default 6. */
45
+ boxClearance: number;
46
+ /** Seconds after a car clears an intersection before the next may enter. Default 0.55. */
47
+ boxCooldownSeconds: number;
48
+ /** Seconds a lane change takes to blend across. Default 1.2. */
49
+ laneChangeSeconds: number;
50
+ /** Seconds a car must be held up by a slower leader before it looks for another lane. Default 1.8. */
51
+ laneChangeBlockedSeconds: number;
52
+ /** Seconds between lane changes by one car. Default 4. */
53
+ laneChangeCooldown: number;
54
+ /** Clear window a lane change needs, as a multiple of the car's own length, each side. Default 1.6. */
55
+ laneChangeGapFactor: number;
56
+ /** Free stretch an entry lane must show before a car spawns on it, metres. Default 14. */
57
+ spawnGap: number;
58
+ /** Fraction of the lane limit a spawned car starts at. Default 0.55. */
59
+ spawnSpeedFactor: number;
60
+ /** Most cars spawned or retired in one tick. Default 3. */
61
+ fleetPerTick: number;
62
+ /**
63
+ * Seconds a car may stay stopped before the deadlock watch reports it. A red light or a queue is
64
+ * under this; a permanent stop is not. Default 60.
65
+ */
66
+ watchSeconds: number;
67
+ /** Fraction of the lane limit a car may carry into a turn sharper than 45°. Default 0.55. */
68
+ turnSpeedFactor: number;
69
+ }
70
+ /** Counters a devtools probe, a HUD or a test reads. */
71
+ export interface TrafficStats {
72
+ cars: number;
73
+ parked: number;
74
+ boxed: number;
75
+ /** Cars holding at a stop line. */
76
+ waiting: number;
77
+ /** Cars added by the demand controller. */
78
+ spawned: number;
79
+ /** Cars that reached the end of the graph. */
80
+ exited: number;
81
+ /** Cars the demand controller removed to shrink the fleet. */
82
+ retired: number;
83
+ laneChanges: number;
84
+ parks: number;
85
+ /** Cars the deadlock watch has reported (stopped longer than `watchSeconds`). */
86
+ stalls: number;
87
+ /** Longest single stop any car has made, seconds — a red light or a queue. */
88
+ maxStillSeconds: number;
89
+ /** Longest stop a car made with clear road ahead — the deadlock measure. */
90
+ maxDeadlockSeconds: number;
91
+ ticks: number;
92
+ /** Slowest single `tick` seen so far, milliseconds. */
93
+ slowestTickMs: number;
94
+ /** Mean speed of every moving car, world units per second. */
95
+ meanSpeed: number;
96
+ }
97
+ /** An intersection's signal right now: which phase is green and for how long. */
98
+ export interface TrafficSignalState {
99
+ node: string;
100
+ phase: number;
101
+ state: "green" | "yellow" | "red";
102
+ /** Seconds this phase has left, including its yellow and all-red. */
103
+ remaining: number;
104
+ /** In-lanes this green phase serves. */
105
+ lanes: readonly string[];
106
+ }
107
+ /** Serializable traffic state: the fleet, the parking occupancy, the signal clocks and the demand. */
108
+ export interface TrafficSnapshot {
109
+ tunables: TrafficTuning;
110
+ demand: number;
111
+ counter: number;
112
+ rng: number | null;
113
+ cars: {
114
+ id: string;
115
+ laneId: string;
116
+ arc: number;
117
+ speed: number;
118
+ maxSpeed: number;
119
+ desiredSpeed: number;
120
+ state: "driving" | "boxed" | "parked";
121
+ cleared: boolean;
122
+ nextLane: string | null;
123
+ spotId: string | null;
124
+ lateral: number;
125
+ lateralRate: number;
126
+ changeCooldown: number;
127
+ blockedSeconds: number;
128
+ stillSeconds: number;
129
+ deadlockSeconds: number;
130
+ waitingSeconds: number;
131
+ stalled: boolean;
132
+ variant: number;
133
+ }[];
134
+ spots: {
135
+ id: string;
136
+ carId: string | null;
137
+ }[];
138
+ intersections: {
139
+ node: string;
140
+ elapsed: number;
141
+ cooldown: number;
142
+ holder: string | null;
143
+ }[];
144
+ counters: {
145
+ spawned: number;
146
+ exited: number;
147
+ retired: number;
148
+ laneChanges: number;
149
+ parks: number;
150
+ stalls: number;
151
+ ticks: number;
152
+ maxStillSeconds: number;
153
+ maxDeadlockSeconds: number;
154
+ };
155
+ }
156
+ /** Everything {@link createTraffic} needs: the graph, the injected generator and the caller's policies. */
157
+ export interface TrafficOptions {
158
+ graph: LaneGraph;
159
+ /** Seed for the injected generator that varies cars. Same seed, same fleet. */
160
+ seed?: string | number;
161
+ /** Inject a generator instead of seeding one; its cursor is snapshotted when it has one. */
162
+ rng?: () => number;
163
+ tuning?: Partial<TrafficTuning>;
164
+ /** Exit choice at a junction. Omit for "least turn, never straight back". */
165
+ route?: TrafficRoutePolicy;
166
+ /** Initial fleet target; the caller moves this with the time of day. Omit to keep the fleet caller-driven. */
167
+ demand?: number;
168
+ /** Prefix for demand-spawned ids. Default `"traffic"`. */
169
+ idPrefix?: string;
170
+ /** Register a devtools probe under this name so the perf overlay shows traffic counters. */
171
+ devtoolsName?: string;
172
+ }
173
+ /**
174
+ * Traffic on an authored lane graph: cars follow lane spans with IDM car-following, hold at stop
175
+ * lines, cross intersections under a signal phase or first-come right-of-way, change lanes, park in
176
+ * authored spots, and grow or shrink with the caller's `demand`. Deterministic — cars advance in
177
+ * insertion order, ties break on id, and the injected generator is the only source of variety.
178
+ * Bounded per tick: one pass over the cars, one sorted pass per occupied lane, no path search.
179
+ */
180
+ export interface Traffic {
181
+ /** Add a car at the start of a lane. False when the id exists or the lane is unknown. */
182
+ add(id: string, spec: {
183
+ laneId: string;
184
+ arc?: number;
185
+ speed?: number;
186
+ }): boolean;
187
+ remove(id: string): boolean;
188
+ has(id: string): boolean;
189
+ count(): number;
190
+ ids(): readonly string[];
191
+ car(id: string): TrafficCarView | null;
192
+ /** Visit every car in insertion order — one view record per car, no snapshot copy. */
193
+ forEachCar(visit: (car: Readonly<TrafficCarView>) => void): void;
194
+ /** Advance the whole fleet by `dt` seconds. */
195
+ tick(dt: number): void;
196
+ retune(patch: Partial<TrafficTuning>): void;
197
+ /**
198
+ * Fleet size the demand controller drives towards — a time-of-day count the caller computes, never a
199
+ * built-in curve. `-1` turns the controller off and leaves the fleet entirely caller-driven.
200
+ */
201
+ setDemand(count: number): void;
202
+ /** Current fleet target, or `-1` when the fleet is caller-driven. */
203
+ demand(): number;
204
+ /** Send a car to a parking spot on the lane it is already on. False when the spot is taken. */
205
+ park(id: string, spotId?: string): boolean;
206
+ /** Give up a parked spot and rejoin the lane. */
207
+ releaseParking(id: string): boolean;
208
+ /** Id of the car holding or reserving a spot, or null. */
209
+ spotOwner(spotId: string): string | null;
210
+ signal(nodeId: string): TrafficSignalState | null;
211
+ stats(): TrafficStats;
212
+ snapshot(): TrafficSnapshot;
213
+ restore(next: TrafficSnapshot): void;
214
+ /** Drop the devtools probe registered by `devtoolsName`. Safe to call twice. */
215
+ dispose(): void;
216
+ }
217
+ /**
218
+ * Traffic for an authored lane graph (see {@link createLaneGraph}).
219
+ *
220
+ * @capability traffic lane-graph traffic with car following, signals, right-of-way, lane changes and parking
221
+ */
222
+ export declare function createTraffic(options: TrafficOptions): Traffic;