@jgengine/core 0.6.0 → 0.7.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 (222) hide show
  1. package/CHANGELOG.md +167 -2
  2. package/dist/ai/crowd.d.ts +36 -0
  3. package/dist/ai/crowd.js +213 -0
  4. package/dist/ai/jobBoard.d.ts +49 -0
  5. package/dist/ai/jobBoard.js +155 -0
  6. package/dist/ai/spawnDirector.d.ts +56 -0
  7. package/dist/ai/spawnDirector.js +150 -0
  8. package/dist/ai/threat.d.ts +25 -0
  9. package/dist/ai/threat.js +67 -0
  10. package/dist/audio/audioFalloff.d.ts +38 -0
  11. package/dist/audio/audioFalloff.js +32 -0
  12. package/dist/board/laneBoard.d.ts +63 -0
  13. package/dist/board/laneBoard.js +114 -0
  14. package/dist/board/timelineBoard.d.ts +36 -0
  15. package/dist/board/timelineBoard.js +70 -0
  16. package/dist/cards/cardPile.d.ts +63 -0
  17. package/dist/cards/cardPile.js +166 -0
  18. package/dist/cards/modifierPipeline.d.ts +33 -0
  19. package/dist/cards/modifierPipeline.js +48 -0
  20. package/dist/combat/abilityKit.d.ts +42 -0
  21. package/dist/combat/abilityKit.js +129 -0
  22. package/dist/combat/animationState.d.ts +47 -0
  23. package/dist/combat/animationState.js +101 -0
  24. package/dist/combat/attackTags.d.ts +14 -0
  25. package/dist/combat/attackTags.js +26 -0
  26. package/dist/combat/breakMeters.d.ts +32 -0
  27. package/dist/combat/breakMeters.js +51 -0
  28. package/dist/combat/comboString.d.ts +35 -0
  29. package/dist/combat/comboString.js +59 -0
  30. package/dist/combat/death.d.ts +8 -0
  31. package/dist/combat/death.js +5 -2
  32. package/dist/combat/defensiveWindow.d.ts +34 -0
  33. package/dist/combat/defensiveWindow.js +66 -0
  34. package/dist/combat/downed.d.ts +35 -0
  35. package/dist/combat/downed.js +104 -0
  36. package/dist/combat/effects.d.ts +11 -0
  37. package/dist/combat/effects.js +22 -13
  38. package/dist/combat/hitReaction.d.ts +23 -0
  39. package/dist/combat/hitReaction.js +20 -0
  40. package/dist/combat/resistance.d.ts +13 -0
  41. package/dist/combat/resistance.js +46 -0
  42. package/dist/combat/telegraph.d.ts +27 -0
  43. package/dist/combat/telegraph.js +37 -0
  44. package/dist/crafting/crop.d.ts +59 -0
  45. package/dist/crafting/crop.js +181 -0
  46. package/dist/crafting/production.d.ts +64 -0
  47. package/dist/crafting/production.js +130 -0
  48. package/dist/crafting/recipe.d.ts +62 -0
  49. package/dist/crafting/recipe.js +101 -0
  50. package/dist/economy/sharedWallet.d.ts +28 -0
  51. package/dist/economy/sharedWallet.js +62 -0
  52. package/dist/economy/techTree.d.ts +40 -0
  53. package/dist/economy/techTree.js +66 -0
  54. package/dist/game/cosmetics.d.ts +25 -0
  55. package/dist/game/cosmetics.js +51 -0
  56. package/dist/game/defineGame.d.ts +2 -0
  57. package/dist/game/events.d.ts +62 -0
  58. package/dist/game/lootFilter.d.ts +33 -0
  59. package/dist/game/lootFilter.js +48 -0
  60. package/dist/game/ping.d.ts +67 -0
  61. package/dist/game/ping.js +86 -0
  62. package/dist/game/playableGame.d.ts +281 -4
  63. package/dist/game/race.d.ts +95 -0
  64. package/dist/game/race.js +216 -0
  65. package/dist/game/runDraft.d.ts +34 -0
  66. package/dist/game/runDraft.js +97 -0
  67. package/dist/game/social.d.ts +27 -0
  68. package/dist/game/social.js +16 -0
  69. package/dist/game/worldItem.d.ts +92 -0
  70. package/dist/game/worldItem.js +132 -0
  71. package/dist/input/axisInput.d.ts +43 -0
  72. package/dist/input/axisInput.js +70 -0
  73. package/dist/input/pointer.d.ts +24 -0
  74. package/dist/input/pointer.js +17 -0
  75. package/dist/interaction/contextMenu.d.ts +30 -0
  76. package/dist/interaction/contextMenu.js +22 -0
  77. package/dist/interaction/qte.d.ts +20 -0
  78. package/dist/interaction/qte.js +24 -0
  79. package/dist/interaction/skillCheck.d.ts +20 -0
  80. package/dist/interaction/skillCheck.js +26 -0
  81. package/dist/inventory/shapedGrid.d.ts +56 -0
  82. package/dist/inventory/shapedGrid.js +176 -0
  83. package/dist/inventory/storageTier.d.ts +52 -0
  84. package/dist/inventory/storageTier.js +77 -0
  85. package/dist/item/affix.d.ts +54 -0
  86. package/dist/item/affix.js +133 -0
  87. package/dist/item/durability.d.ts +51 -0
  88. package/dist/item/durability.js +78 -0
  89. package/dist/item/modularItem.d.ts +46 -0
  90. package/dist/item/modularItem.js +75 -0
  91. package/dist/meta/changelog.d.ts +1 -1
  92. package/dist/meta/changelog.js +35 -1
  93. package/dist/movement/dash.d.ts +37 -0
  94. package/dist/movement/dash.js +65 -0
  95. package/dist/multiplayer/combatSnapshot.d.ts +45 -0
  96. package/dist/multiplayer/combatSnapshot.js +89 -0
  97. package/dist/multiplayer/lagCompensation.d.ts +43 -0
  98. package/dist/multiplayer/lagCompensation.js +154 -0
  99. package/dist/multiplayer/matchmaking.d.ts +33 -0
  100. package/dist/multiplayer/matchmaking.js +60 -0
  101. package/dist/multiplayer/simultaneousCommit.d.ts +34 -0
  102. package/dist/multiplayer/simultaneousCommit.js +53 -0
  103. package/dist/nav/navGrid.d.ts +46 -0
  104. package/dist/nav/navGrid.js +248 -0
  105. package/dist/nav/pathFollow.d.ts +29 -0
  106. package/dist/nav/pathFollow.js +67 -0
  107. package/dist/physics/buoyancy.d.ts +49 -0
  108. package/dist/physics/buoyancy.js +112 -0
  109. package/dist/physics/carryable.d.ts +46 -0
  110. package/dist/physics/carryable.js +110 -0
  111. package/dist/physics/damageZones.d.ts +56 -0
  112. package/dist/physics/damageZones.js +107 -0
  113. package/dist/physics/forceVolume.d.ts +48 -0
  114. package/dist/physics/forceVolume.js +119 -0
  115. package/dist/physics/physicsWorld.d.ts +83 -0
  116. package/dist/physics/physicsWorld.js +261 -1
  117. package/dist/physics/ragdoll.d.ts +49 -0
  118. package/dist/physics/ragdoll.js +103 -0
  119. package/dist/physics/spatialGrid.d.ts +41 -0
  120. package/dist/physics/spatialGrid.js +138 -0
  121. package/dist/physics/structure.d.ts +83 -0
  122. package/dist/physics/structure.js +0 -0
  123. package/dist/physics/traversal.d.ts +75 -0
  124. package/dist/physics/traversal.js +138 -0
  125. package/dist/physics/vehicleBody.d.ts +93 -0
  126. package/dist/physics/vehicleBody.js +234 -0
  127. package/dist/runtime/gameContext.d.ts +64 -2
  128. package/dist/runtime/gameContext.js +154 -4
  129. package/dist/runtime/hostPersistence.d.ts +18 -0
  130. package/dist/runtime/hostPersistence.js +4 -0
  131. package/dist/runtime/persistenceScope.d.ts +32 -0
  132. package/dist/runtime/persistenceScope.js +64 -0
  133. package/dist/scene/autoTarget.d.ts +15 -0
  134. package/dist/scene/autoTarget.js +54 -0
  135. package/dist/scene/behaviors.d.ts +13 -1
  136. package/dist/scene/behaviors.js +3 -0
  137. package/dist/scene/captureCheck.d.ts +7 -0
  138. package/dist/scene/captureCheck.js +11 -0
  139. package/dist/scene/entityStore.d.ts +1 -1
  140. package/dist/scene/form.d.ts +40 -0
  141. package/dist/scene/form.js +56 -0
  142. package/dist/scene/mount.d.ts +62 -0
  143. package/dist/scene/mount.js +107 -0
  144. package/dist/scene/possession.d.ts +30 -0
  145. package/dist/scene/possession.js +51 -0
  146. package/dist/scene/roster.d.ts +25 -0
  147. package/dist/scene/roster.js +57 -0
  148. package/dist/scene/selection.d.ts +30 -0
  149. package/dist/scene/selection.js +38 -0
  150. package/dist/scene/stationClaim.d.ts +43 -0
  151. package/dist/scene/stationClaim.js +109 -0
  152. package/dist/sensor/frustumSensor.d.ts +60 -0
  153. package/dist/sensor/frustumSensor.js +104 -0
  154. package/dist/sensor/hiddenStateProbe.d.ts +31 -0
  155. package/dist/sensor/hiddenStateProbe.js +40 -0
  156. package/dist/sensor/recordingBuffer.d.ts +29 -0
  157. package/dist/sensor/recordingBuffer.js +61 -0
  158. package/dist/sensor/revealQuery.d.ts +22 -0
  159. package/dist/sensor/revealQuery.js +36 -0
  160. package/dist/session/contestedChannel.d.ts +36 -0
  161. package/dist/session/contestedChannel.js +100 -0
  162. package/dist/session/extraction.d.ts +54 -0
  163. package/dist/session/extraction.js +108 -0
  164. package/dist/session/ring.d.ts +36 -0
  165. package/dist/session/ring.js +88 -0
  166. package/dist/session/roundState.d.ts +55 -0
  167. package/dist/session/roundState.js +129 -0
  168. package/dist/stats/accumulatorMeter.d.ts +31 -0
  169. package/dist/stats/accumulatorMeter.js +81 -0
  170. package/dist/stats/eventMeter.d.ts +34 -0
  171. package/dist/stats/eventMeter.js +76 -0
  172. package/dist/stats/rollCheck.d.ts +15 -0
  173. package/dist/stats/rollCheck.js +15 -0
  174. package/dist/survival/decayMeter.d.ts +59 -0
  175. package/dist/survival/decayMeter.js +95 -0
  176. package/dist/survival/moodle.d.ts +48 -0
  177. package/dist/survival/moodle.js +91 -0
  178. package/dist/survival/regionHealth.d.ts +72 -0
  179. package/dist/survival/regionHealth.js +129 -0
  180. package/dist/tactics/predictiveQuery.d.ts +34 -0
  181. package/dist/tactics/predictiveQuery.js +44 -0
  182. package/dist/tactics/snapshot.d.ts +18 -0
  183. package/dist/tactics/snapshot.js +65 -0
  184. package/dist/tactics/surface.d.ts +52 -0
  185. package/dist/tactics/surface.js +135 -0
  186. package/dist/tactics/tacticalGrid.d.ts +57 -0
  187. package/dist/tactics/tacticalGrid.js +244 -0
  188. package/dist/time/beatClock.d.ts +40 -0
  189. package/dist/time/beatClock.js +73 -0
  190. package/dist/turn/commit.d.ts +27 -0
  191. package/dist/turn/commit.js +72 -0
  192. package/dist/turn/turnLoop.d.ts +58 -0
  193. package/dist/turn/turnLoop.js +216 -0
  194. package/dist/world/buildPermissions.d.ts +47 -0
  195. package/dist/world/buildPermissions.js +134 -0
  196. package/dist/world/carve.d.ts +105 -0
  197. package/dist/world/carve.js +175 -0
  198. package/dist/world/connectors.d.ts +40 -0
  199. package/dist/world/connectors.js +67 -0
  200. package/dist/world/envField.d.ts +71 -0
  201. package/dist/world/envField.js +96 -0
  202. package/dist/world/fog.d.ts +40 -0
  203. package/dist/world/fog.js +137 -0
  204. package/dist/world/markers.d.ts +52 -0
  205. package/dist/world/markers.js +96 -0
  206. package/dist/world/minimap.d.ts +42 -0
  207. package/dist/world/minimap.js +72 -0
  208. package/dist/world/placedStructureStore.d.ts +39 -0
  209. package/dist/world/placedStructureStore.js +95 -0
  210. package/dist/world/placementController.d.ts +48 -0
  211. package/dist/world/placementController.js +97 -0
  212. package/dist/world/realm.d.ts +61 -0
  213. package/dist/world/realm.js +66 -0
  214. package/dist/world/support.d.ts +27 -0
  215. package/dist/world/support.js +75 -0
  216. package/dist/world/terraform.d.ts +54 -0
  217. package/dist/world/terraform.js +186 -0
  218. package/dist/world/walls.d.ts +61 -0
  219. package/dist/world/walls.js +221 -0
  220. package/dist/world/weather.d.ts +92 -0
  221. package/dist/world/weather.js +169 -0
  222. package/package.json +1 -1
@@ -0,0 +1,169 @@
1
+ const NEUTRAL = {
2
+ grip: 1,
3
+ visibility: 1,
4
+ structureDamage: 0,
5
+ chill: 0,
6
+ ignition: 0,
7
+ spread: 1,
8
+ };
9
+ function lerp(from, to, t) {
10
+ return from + (to - from) * t;
11
+ }
12
+ /**
13
+ * Resolve a weather state against a game-owned modifier table into concrete gameplay
14
+ * numbers. Multiplier-style effects (grip, visibility, spread) interpolate from the
15
+ * neutral 1 by intensity; rate-style effects (structureDamage, ignition, chill) scale
16
+ * linearly. Games read `grip`/`visibility` in movement and AI, `structureDamage` on a
17
+ * building tick, and `spread`/`ignition` feed the fire grid.
18
+ */
19
+ export function resolveWeather(state, table) {
20
+ const entry = table[state.kind];
21
+ if (entry === undefined)
22
+ return { ...NEUTRAL };
23
+ const t = Math.max(0, Math.min(1, state.intensity));
24
+ return {
25
+ grip: lerp(1, entry.grip ?? 1, t),
26
+ visibility: lerp(1, entry.visibility ?? 1, t),
27
+ structureDamage: (entry.structureDamage ?? 0) * t,
28
+ chill: (entry.chill ?? 0) * t,
29
+ ignition: (entry.ignition ?? 0) * t,
30
+ spread: lerp(1, entry.spread ?? 1, t),
31
+ };
32
+ }
33
+ const NEIGHBOURS = [
34
+ [1, 0],
35
+ [-1, 0],
36
+ [0, 1],
37
+ [0, -1],
38
+ [1, 1],
39
+ [1, -1],
40
+ [-1, 1],
41
+ [-1, -1],
42
+ ];
43
+ export function createFireGrid(config) {
44
+ const { cols, rows, cellSize } = config;
45
+ if (cols <= 0 || rows <= 0)
46
+ throw new Error("createFireGrid: cols/rows must be positive");
47
+ const originX = config.origin?.[0] ?? 0;
48
+ const originZ = config.origin?.[1] ?? 0;
49
+ const ignitionThreshold = config.ignitionThreshold ?? 1;
50
+ const spreadRate = config.spreadRate ?? 0.6;
51
+ const burnRate = config.burnRate ?? 0.25;
52
+ const windBias = Math.max(0, Math.min(1, config.windBias ?? 0.6));
53
+ const wind = config.wind;
54
+ const windLen = wind === undefined ? 0 : Math.hypot(wind[0], wind[1]);
55
+ const windX = windLen > 0 ? wind[0] / windLen : 0;
56
+ const windZ = windLen > 0 ? wind[1] / windLen : 0;
57
+ const cells = new Array(cols * rows);
58
+ for (let row = 0; row < rows; row += 1) {
59
+ for (let col = 0; col < cols; col += 1) {
60
+ const fuel = config.fuelAt?.(col, row) ?? 1;
61
+ cells[row * cols + col] = { fuel: Math.max(0, fuel), heat: 0, state: "unburnt" };
62
+ }
63
+ }
64
+ const index = (col, row) => row * cols + col;
65
+ const inBounds = (col, row) => col >= 0 && col < cols && row >= 0 && row < rows;
66
+ const cellCoord = (x, z) => {
67
+ const col = Math.round((x - originX) / cellSize);
68
+ const row = Math.round((z - originZ) / cellSize);
69
+ return inBounds(col, row) ? { col, row } : null;
70
+ };
71
+ const directionalWeight = (dx, dz) => {
72
+ if (windLen === 0)
73
+ return 1;
74
+ const len = Math.hypot(dx, dz) || 1;
75
+ const alignment = (dx / len) * windX + (dz / len) * windZ;
76
+ return 1 + windBias * alignment;
77
+ };
78
+ let burning = 0;
79
+ for (const cell of cells)
80
+ if (cell.state === "burning")
81
+ burning += 1;
82
+ const igniteCell = (col, row) => {
83
+ if (!inBounds(col, row))
84
+ return;
85
+ const cell = cells[index(col, row)];
86
+ if (cell.state === "burnt" || cell.fuel <= 0)
87
+ return;
88
+ if (cell.state !== "burning")
89
+ burning += 1;
90
+ cell.state = "burning";
91
+ cell.heat = Math.max(cell.heat, ignitionThreshold);
92
+ };
93
+ return {
94
+ cols,
95
+ rows,
96
+ step(dt, options) {
97
+ if (dt <= 0)
98
+ return;
99
+ const globalSpread = options?.spread ?? 1;
100
+ const wetnessAt = options?.wetnessAt;
101
+ const addedHeat = new Float64Array(cols * rows);
102
+ for (let row = 0; row < rows; row += 1) {
103
+ for (let col = 0; col < cols; col += 1) {
104
+ const cell = cells[index(col, row)];
105
+ if (cell.state !== "burning")
106
+ continue;
107
+ for (const [dx, dz] of NEIGHBOURS) {
108
+ const nc = col + dx;
109
+ const nr = row + dz;
110
+ if (!inBounds(nc, nr))
111
+ continue;
112
+ const neighbour = cells[index(nc, nr)];
113
+ if (neighbour.state === "burnt" || neighbour.fuel <= 0)
114
+ continue;
115
+ addedHeat[index(nc, nr)] +=
116
+ spreadRate * globalSpread * directionalWeight(dx, dz) * dt;
117
+ }
118
+ }
119
+ }
120
+ for (let row = 0; row < rows; row += 1) {
121
+ for (let col = 0; col < cols; col += 1) {
122
+ const i = index(col, row);
123
+ const cell = cells[i];
124
+ if (cell.state === "burning") {
125
+ cell.fuel = Math.max(0, cell.fuel - burnRate * dt);
126
+ if (cell.fuel <= 0) {
127
+ cell.state = "burnt";
128
+ cell.heat = 0;
129
+ burning -= 1;
130
+ }
131
+ continue;
132
+ }
133
+ if (cell.state !== "unburnt" || addedHeat[i] === 0)
134
+ continue;
135
+ const resist = wetnessAt === undefined ? 0 : Math.max(0, Math.min(1, wetnessAt(col, row)));
136
+ cell.heat += addedHeat[i] * (1 - resist);
137
+ if (cell.heat >= ignitionThreshold && cell.fuel > 0) {
138
+ cell.state = "burning";
139
+ burning += 1;
140
+ }
141
+ }
142
+ }
143
+ },
144
+ igniteCell,
145
+ ignite(x, z) {
146
+ const coord = cellCoord(x, z);
147
+ if (coord === null)
148
+ return false;
149
+ igniteCell(coord.col, coord.row);
150
+ return true;
151
+ },
152
+ cell(col, row) {
153
+ if (!inBounds(col, row))
154
+ throw new Error(`fire cell out of bounds: ${col},${row}`);
155
+ return cells[index(col, row)];
156
+ },
157
+ cellAt(x, z) {
158
+ const coord = cellCoord(x, z);
159
+ return coord === null ? null : cells[index(coord.col, coord.row)];
160
+ },
161
+ cellCoord,
162
+ get burning() {
163
+ return burning;
164
+ },
165
+ snapshot() {
166
+ return cells.map((cell) => ({ ...cell }));
167
+ },
168
+ };
169
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jgengine/core",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Genre-agnostic TypeScript game engine SDK: game runtime, state store, entity scene, combat, movement, inventory, economy, quests, multiplayer primitives.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",