@adatechnology/game-player 0.6.4 → 0.8.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/README.md +32 -1
- package/dist/chunk-HYJIZT2V.js +52 -0
- package/dist/chunk-HYJIZT2V.js.map +1 -0
- package/dist/{chunk-RUFQCNZH.js → chunk-TFDLGOOE.js} +20 -53
- package/dist/chunk-TFDLGOOE.js.map +1 -0
- package/dist/hud.d.ts +127 -0
- package/dist/hud.js +370 -0
- package/dist/hud.js.map +1 -0
- package/dist/index.d.ts +83 -6
- package/dist/index.global.js +147 -38
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +97 -37
- package/dist/index.js.map +1 -1
- package/dist/{testing-CD4p4NR5.d.ts → player-Bjhc2M8F.d.ts} +15 -20
- package/dist/testing.d.ts +22 -2
- package/dist/testing.js +2 -1
- package/package.json +8 -3
- package/dist/chunk-RUFQCNZH.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PLAYER_DEFAULTS,
|
|
3
|
-
PLAYER_TEXT,
|
|
4
3
|
createPlayer,
|
|
5
4
|
createPlayerTestModule,
|
|
6
5
|
createRng,
|
|
7
6
|
deriveVitals,
|
|
8
|
-
drawWound
|
|
7
|
+
drawWound
|
|
8
|
+
} from "./chunk-TFDLGOOE.js";
|
|
9
|
+
import {
|
|
10
|
+
PLAYER_TEXT,
|
|
9
11
|
playerTextOf
|
|
10
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-HYJIZT2V.js";
|
|
11
13
|
|
|
12
14
|
// src/furniture-push.ts
|
|
13
15
|
var FURNITURE_PUSH_DEFAULTS = {
|
|
@@ -170,12 +172,15 @@ function createFurniturePush(overrides = {}) {
|
|
|
170
172
|
var DOOR_USE_DEFAULTS = {
|
|
171
173
|
reachSeconds: 0.3,
|
|
172
174
|
swingSeconds: { base: 0.45, perKg: 0.02, min: 0.45, max: 1.6 },
|
|
175
|
+
pushSeconds: 0.18,
|
|
173
176
|
releaseSeconds: 0.22,
|
|
174
177
|
// the length of the recorded handle shaken (game-audio door_locked_rattle, 0.6 to 0.83 s): the hand lets go as the sound ends
|
|
175
178
|
rattleSeconds: 0.75,
|
|
176
179
|
stepFraction: 0.04,
|
|
177
180
|
endTolerance: 0.02
|
|
178
181
|
};
|
|
182
|
+
var DOOR_SHOULDER_HEIGHT = 1.42;
|
|
183
|
+
var DOOR_ARM_REACH = 0.55;
|
|
179
184
|
var swingSecondsFor = (massKg, rules = DOOR_USE_DEFAULTS) => Math.min(rules.swingSeconds.max, Math.max(rules.swingSeconds.min, rules.swingSeconds.base + rules.swingSeconds.perKg * Math.max(0, massKg)));
|
|
180
185
|
function createDoorUse(rules = {}) {
|
|
181
186
|
const r = { ...DOOR_USE_DEFAULTS, ...rules, swingSeconds: { ...DOOR_USE_DEFAULTS.swingSeconds, ...rules.swingSeconds } };
|
|
@@ -185,7 +190,26 @@ function createDoorUse(rules = {}) {
|
|
|
185
190
|
let time = 0;
|
|
186
191
|
let swing = 1;
|
|
187
192
|
let start = 0;
|
|
193
|
+
let coasting = false;
|
|
188
194
|
const out = (progress, arrived = false, b = null) => ({ phase, opening, progress: Math.max(0, Math.min(1, progress)), block: b, arrived });
|
|
195
|
+
const advance = (dt, isFree) => {
|
|
196
|
+
const want = goal - opening;
|
|
197
|
+
const reach = Math.min(Math.abs(want), dt / swing);
|
|
198
|
+
let moved = 0;
|
|
199
|
+
while (moved < reach - 1e-9) {
|
|
200
|
+
const inc = Math.min(r.stepFraction, reach - moved);
|
|
201
|
+
const next = opening + Math.sign(want) * inc;
|
|
202
|
+
if (!isFree(opening, next)) return "stopped";
|
|
203
|
+
opening = next;
|
|
204
|
+
moved += inc;
|
|
205
|
+
}
|
|
206
|
+
return Math.abs(goal - opening) < 1e-6 ? "arrived" : "moving";
|
|
207
|
+
};
|
|
208
|
+
const releaseOut = (arrived, b = null) => {
|
|
209
|
+
const p = time / r.releaseSeconds;
|
|
210
|
+
if (p >= 1 && !coasting) phase = "idle";
|
|
211
|
+
return out(p, arrived, b);
|
|
212
|
+
};
|
|
189
213
|
return {
|
|
190
214
|
get phase() {
|
|
191
215
|
return phase;
|
|
@@ -199,6 +223,7 @@ function createDoorUse(rules = {}) {
|
|
|
199
223
|
begin(target) {
|
|
200
224
|
opening = Math.max(0, Math.min(1, target.opening));
|
|
201
225
|
time = 0;
|
|
226
|
+
coasting = false;
|
|
202
227
|
if (target.locked) {
|
|
203
228
|
phase = "rattle";
|
|
204
229
|
return null;
|
|
@@ -211,58 +236,59 @@ function createDoorUse(rules = {}) {
|
|
|
211
236
|
phase = phase === "swing" ? "swing" : "reach";
|
|
212
237
|
return goal;
|
|
213
238
|
},
|
|
214
|
-
step(dt, isFree) {
|
|
239
|
+
step(dt, isFree, hand) {
|
|
215
240
|
if (phase === "idle") return out(0);
|
|
216
241
|
time += dt;
|
|
217
242
|
if (phase === "rattle") {
|
|
218
|
-
const
|
|
219
|
-
if (
|
|
243
|
+
const p = time / r.rattleSeconds;
|
|
244
|
+
if (p >= 1) {
|
|
220
245
|
phase = "idle";
|
|
221
246
|
return out(1, false, "locked");
|
|
222
247
|
}
|
|
223
|
-
return out(
|
|
248
|
+
return out(p, false, time === dt ? "locked" : null);
|
|
224
249
|
}
|
|
225
250
|
if (phase === "reach") {
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
251
|
+
const p = time / r.reachSeconds;
|
|
252
|
+
if (p < 1) return out(p);
|
|
228
253
|
phase = "swing";
|
|
229
254
|
time = 0;
|
|
230
255
|
start = opening;
|
|
231
256
|
}
|
|
232
|
-
if (phase === "swing") {
|
|
233
|
-
const
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
|
|
257
|
+
if (phase === "swing" || phase === "push" || coasting) {
|
|
258
|
+
const result = advance(dt, isFree);
|
|
259
|
+
const travel = Math.abs(goal - start) || 1;
|
|
260
|
+
const progress = 1 - Math.abs(goal - opening) / travel;
|
|
261
|
+
const inHand = phase !== "release";
|
|
262
|
+
if (result === "stopped" || result === "arrived") {
|
|
263
|
+
if (result === "arrived") opening = goal;
|
|
264
|
+
coasting = false;
|
|
265
|
+
if (inHand) {
|
|
266
|
+
phase = "release";
|
|
267
|
+
time = 0;
|
|
243
268
|
}
|
|
244
|
-
|
|
245
|
-
|
|
269
|
+
if (result === "arrived") return inHand ? out(1, true) : releaseOut(true);
|
|
270
|
+
return inHand ? out(progress, false, "obstacle") : releaseOut(false, "obstacle");
|
|
246
271
|
}
|
|
247
|
-
|
|
248
|
-
if (stopped) {
|
|
249
|
-
phase = "release";
|
|
272
|
+
if (inHand && hand && !hand.reaches()) {
|
|
250
273
|
time = 0;
|
|
251
|
-
|
|
274
|
+
if (hand.pull) {
|
|
275
|
+
phase = "release";
|
|
276
|
+
coasting = true;
|
|
277
|
+
} else phase = "push";
|
|
278
|
+
return out(0);
|
|
252
279
|
}
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
280
|
+
if (phase === "push") {
|
|
281
|
+
if (time >= r.pushSeconds) {
|
|
282
|
+
phase = "release";
|
|
283
|
+
time = 0;
|
|
284
|
+
coasting = true;
|
|
285
|
+
return out(0);
|
|
286
|
+
}
|
|
287
|
+
return out(time / r.pushSeconds);
|
|
258
288
|
}
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
const p = time / r.releaseSeconds;
|
|
262
|
-
if (p >= 1) {
|
|
263
|
-
phase = "idle";
|
|
289
|
+
if (phase === "swing") return out(progress);
|
|
264
290
|
}
|
|
265
|
-
return
|
|
291
|
+
return releaseOut(false);
|
|
266
292
|
},
|
|
267
293
|
cancel() {
|
|
268
294
|
phase = "idle";
|
|
@@ -270,9 +296,40 @@ function createDoorUse(rules = {}) {
|
|
|
270
296
|
}
|
|
271
297
|
};
|
|
272
298
|
}
|
|
299
|
+
|
|
300
|
+
// src/hands.ts
|
|
301
|
+
var HANDS_DEFAULTS = { oneHand: { maxKg: 4, maxLength: 0.7 } };
|
|
302
|
+
function interactionHandsFor(thing, rules = HANDS_DEFAULTS) {
|
|
303
|
+
const longest = Math.max(0, ...thing.size ?? []);
|
|
304
|
+
return thing.massKg > rules.oneHand.maxKg || longest > rules.oneHand.maxLength ? 2 : 1;
|
|
305
|
+
}
|
|
306
|
+
var holds = (weapon) => !!weapon && weapon.hands > 0;
|
|
307
|
+
function planHands(params) {
|
|
308
|
+
const { R, L } = params.weapons;
|
|
309
|
+
const free = [...params.slots];
|
|
310
|
+
const stow = (hand, weapon) => {
|
|
311
|
+
const at = weapon.slot === null ? -1 : free.indexOf(weapon.slot);
|
|
312
|
+
if (at < 0) return { hand, weapon: weapon.id, move: "drop" };
|
|
313
|
+
free.splice(at, 1);
|
|
314
|
+
return { hand, weapon: weapon.id, move: "holster", slot: weapon.slot };
|
|
315
|
+
};
|
|
316
|
+
if (params.hands === 2) {
|
|
317
|
+
const moves = [...holds(R) ? [stow("R", R)] : [], ...holds(L) ? [stow("L", L)] : []];
|
|
318
|
+
return { hand: "both", moves };
|
|
319
|
+
}
|
|
320
|
+
if (holds(L)) return { hand: "L", moves: [stow("L", L)] };
|
|
321
|
+
if (!holds(R)) return { hand: "R", moves: [] };
|
|
322
|
+
return { hand: "L", moves: R.hands === 2 ? [stow("R", R)] : [] };
|
|
323
|
+
}
|
|
324
|
+
function drawBackOf(plan) {
|
|
325
|
+
return plan.moves.filter((move) => move.move === "holster").map((move) => ({ hand: move.hand, weapon: move.weapon }));
|
|
326
|
+
}
|
|
273
327
|
export {
|
|
328
|
+
DOOR_ARM_REACH,
|
|
329
|
+
DOOR_SHOULDER_HEIGHT,
|
|
274
330
|
DOOR_USE_DEFAULTS,
|
|
275
331
|
FURNITURE_PUSH_DEFAULTS,
|
|
332
|
+
HANDS_DEFAULTS,
|
|
276
333
|
PLAYER_DEFAULTS,
|
|
277
334
|
PLAYER_TEXT,
|
|
278
335
|
canPush,
|
|
@@ -283,9 +340,12 @@ export {
|
|
|
283
340
|
createRng,
|
|
284
341
|
deriveVitals,
|
|
285
342
|
dragMarkFor,
|
|
343
|
+
drawBackOf,
|
|
286
344
|
drawWound,
|
|
287
345
|
frictionFor,
|
|
288
346
|
gripSecondsFor,
|
|
347
|
+
interactionHandsFor,
|
|
348
|
+
planHands,
|
|
289
349
|
playerTextOf,
|
|
290
350
|
pushAccelerationFor,
|
|
291
351
|
pushSpeedFor,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/furniture-push.ts","../src/door-use.ts"],"sourcesContent":["/**\n * Pushing furniture on foot: hold the interaction button against a piece, a timer that grows with its mass fills, and the player then walks with it.\n * Engine-agnostic: the host says where the player wants to go and answers whether the volume of the piece can go there; this says how fast, and when it locks.\n */\n\nimport type { SurfaceId } from '@adatechnology/game-contracts'\n\n/** What dragging a piece leaves on a floor: a strip of this colour and width (metres) under each side of its base. */\nexport type DragMark = { readonly color: number; readonly width: number }\n\nexport type FurniturePushPhase = 'idle' | 'grip' | 'push' | 'strain'\nexport type FurniturePushBlock = 'too_heavy' | 'obstacle' | null\n\n/** Every number of the push; a game overrides what it wants (`createFurniturePush(rules)`). */\nexport interface FurniturePushRules {\n /** The most the player's legs put on the floor, newtons: with the friction it says the heaviest thing that moves. */\n readonly forceN: number\n readonly gravity: number\n /** Static friction of a base on a floor, by the material of the piece. */\n readonly frictionByMaterial: Readonly<Record<string, number>>\n readonly defaultFriction: number\n /** The hold before the push: `base + perKg * mass`, at most `max` seconds. */\n readonly gripSeconds: { readonly base: number; readonly perKg: number; readonly max: number }\n /** Metres per second: `max` with nothing on the hands, `min` at the limit of the force. */\n readonly speed: { readonly max: number; readonly min: number }\n /**\n * How fast the walk with the piece changes, m/s²: `max` the most a person speeds it up (the force left over the friction, over the mass, may give less), `brake` the\n * most it slows it (stopping, turning back). Below what holds a thing on top (friction × g, about 3.4 m/s² for the softest), so a cup on a pushed table rides along.\n */\n readonly accel: { readonly max: number; readonly brake: number; readonly min: number }\n /** A press shorter than this is not a push (the host keeps it for a tap, such as grabbing). */\n readonly tapSeconds: number\n /** How long the effort stays after the last step that was refused, so that it does not flicker. */\n readonly strainHoldSeconds: number\n /**\n * The scratch a dragged piece leaves, by the floor it is dragged on (`SurfaceId` of game-contracts): wood and tile scratch lighter, concrete scuffs darker,\n * dirt and sand take a furrow; a floor left out (carpet, grass, gravel, asphalt, water) keeps no mark.\n */\n readonly dragMarks: Readonly<Partial<Record<SurfaceId, DragMark>>>\n}\n\nexport const FURNITURE_PUSH_DEFAULTS: FurniturePushRules = {\n forceN: 500,\n gravity: 9.81,\n frictionByMaterial: { wood_soft: 0.4, wood_hard: 0.4, mdf: 0.4, plywood: 0.4, steel: 0.35, aluminium: 0.35, cast_iron: 0.4, copper: 0.35, plastic: 0.35, rubber: 0.8, fabric: 0.45, foam: 0.5, ceramic: 0.5, glass: 0.3, tempered_glass: 0.3, brick: 0.6, concrete: 0.65 },\n defaultFriction: 0.45,\n gripSeconds: { base: 0.4, perKg: 0.015, max: 2.5 },\n speed: { max: 1.8, min: 0.35 },\n accel: { max: 1.5, brake: 3, min: 0.2 },\n tapSeconds: 0.2,\n strainHoldSeconds: 0.25,\n dragMarks: {\n wood: { color: 0xd8c4a0, width: 0.012 },\n tile: { color: 0x9a9a96, width: 0.01 },\n concrete: { color: 0x45433f, width: 0.02 },\n metal: { color: 0xd0d4d8, width: 0.008 },\n glass: { color: 0xf2f2f2, width: 0.006 },\n dirt: { color: 0x4a3524, width: 0.04 },\n sand: { color: 0x8d7a5c, width: 0.05 },\n },\n}\n\nexport type FurniturePushTarget = { readonly massKg: number; readonly material?: string }\n\n/** Static friction of a thing of `material` on what it stands on (the floor, a table top). */\nexport const frictionFor = (material: string | undefined, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => (material !== undefined ? rules.frictionByMaterial[material] : undefined) ?? rules.defaultFriction\n\nconst frictionOf = (target: FurniturePushTarget, rules: FurniturePushRules): number => frictionFor(target.material, rules)\n\n/** A piece, or a row of pieces pushed one against the next (a sofa shoving a chair): their frictions on the floor add up against the legs. */\nexport type FurniturePushLoad = FurniturePushTarget | readonly FurniturePushTarget[]\n\nconst piecesOf = (load: FurniturePushLoad): readonly FurniturePushTarget[] => (Array.isArray(load) ? load : [load as FurniturePushTarget])\nconst frictionForceOf = (load: FurniturePushLoad, rules: FurniturePushRules): number => piecesOf(load).reduce((sum, t) => sum + frictionOf(t, rules) * t.massKg * rules.gravity, 0)\nconst massOf = (load: FurniturePushLoad): number => piecesOf(load).reduce((sum, t) => sum + t.massKg, 0)\nconst loadShare = (load: FurniturePushLoad, rules: FurniturePushRules): number => frictionForceOf(load, rules) / rules.forceN\n\nexport const gripSecondsFor = (massKg: number, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => Math.min(rules.gripSeconds.max, rules.gripSeconds.base + rules.gripSeconds.perKg * Math.max(0, massKg))\n\n/** Whether the legs overcome the friction of the piece (or of the row of pieces) on the floor. */\nexport const canPush = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): boolean => loadShare(target, rules) <= 1\n\n/** Metres per second with the piece on the hands: slower the closer it is to the limit of the force, 0 past it. */\nexport const pushSpeedFor = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => {\n const share = loadShare(target, rules)\n return share > 1 ? 0 : rules.speed.max + (rules.speed.min - rules.speed.max) * share\n}\n\n/** How fast the walk with the piece speeds up, m/s²: the force left over its friction, over its mass, at most what a person does (`accel.max`). */\nexport const pushAccelerationFor = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => {\n const spare = (rules.forceN - frictionForceOf(target, rules)) / Math.max(1e-3, massOf(target))\n return Math.max(rules.accel.min, Math.min(rules.accel.max, spare))\n}\n\n/** The scratch dragging leaves on `surface`, or null where the floor keeps none (carpet, grass). */\nexport const dragMarkFor = (surface: SurfaceId, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): DragMark | null => rules.dragMarks[surface] ?? null\n\n/** Whether a thing resting on a moving piece slides on it: the piece changes speed faster than the friction under the thing can follow (`accelMps2` > friction × g). */\nexport const slipsOnTop = (accelMps2: number, friction: number, gravity = FURNITURE_PUSH_DEFAULTS.gravity): boolean => accelMps2 > friction * gravity\n\nexport type FurniturePushInput = {\n /** Where the player wants to go on the floor: a unit vector, or `[0, 0]` standing. */\n readonly walk: readonly [number, number]\n /** Whether the volume of the piece (and the player behind it) can move by this offset. */\n readonly isFree: (dx: number, dz: number) => boolean\n}\n\nexport type FurniturePushStep = {\n readonly dx: number\n readonly dz: number\n /** The grip closed on this update. */\n readonly engaged: boolean\n /** A step was refused now and the one before was not: the moment the piece hits something. */\n readonly hitObstacle: boolean\n /** The velocity of the piece after this update, m/s on the floor. */\n readonly velocity: readonly [number, number]\n /** How fast its velocity changed in this update, m/s²: what a thing on top feels. */\n readonly acceleration: number\n /** The velocity it had when it hit something and stopped at once (what rests on it keeps it and slides on), or null. */\n readonly stoppedFrom: readonly [number, number] | null\n}\n\nexport interface FurniturePush {\n readonly phase: FurniturePushPhase\n /** How far the hold timer is, 0 to 1. */\n readonly progress: number\n readonly block: FurniturePushBlock\n readonly heldSeconds: number\n /** Whether the hold is still short enough to be a tap. */\n readonly isTap: boolean\n /** The velocity of the piece now, m/s on the floor. */\n readonly velocity: readonly [number, number]\n begin(target: FurniturePushTarget): void\n /** The load changed while pushing (the piece met another and shoves it along): the speed and the speeding up follow the whole row. */\n setLoad(load: FurniturePushLoad): void\n release(): void\n update(dt: number, input: FurniturePushInput): FurniturePushStep\n}\n\nconst STILL: FurniturePushStep = { dx: 0, dz: 0, engaged: false, hitObstacle: false, velocity: [0, 0], acceleration: 0, stoppedFrom: null }\n\nexport function createFurniturePush(overrides: Partial<FurniturePushRules> = {}): FurniturePush {\n const rules: FurniturePushRules = { ...FURNITURE_PUSH_DEFAULTS, ...overrides }\n let phase: FurniturePushPhase = 'idle'\n let target: FurniturePushTarget = { massKg: 0 }\n let held = 0\n let gripSeconds = 1\n let speed = 0\n let accel = rules.accel.max\n let vx = 0\n let vz = 0\n let block: FurniturePushBlock = null\n let refused = 0\n let wasRefused = false\n\n /** The velocity goes toward the walk, no faster than the push speeds it up (or the legs brake it). Answers the change, m/s². */\n const steer = (dt: number, walk: readonly [number, number]): number => {\n const wantX = walk[0] * speed\n const wantZ = walk[1] * speed\n const braking = wantX * vx + wantZ * vz < vx * vx + vz * vz\n let dvx = wantX - vx\n let dvz = wantZ - vz\n const change = Math.hypot(dvx, dvz)\n const most = (braking ? rules.accel.brake : accel) * dt\n if (change > most) {\n dvx *= most / change\n dvz *= most / change\n }\n vx += dvx\n vz += dvz\n return Math.min(change, most) / dt\n }\n\n const walkWith = (dt: number, input: FurniturePushInput): FurniturePushStep => {\n refused = Math.max(0, refused - dt)\n if (block === 'too_heavy' || dt <= 0) return STILL\n const acceleration = steer(dt, input.walk)\n if (Math.hypot(vx, vz) < 1e-4) {\n vx = vz = 0\n if (refused === 0) {\n phase = 'push'\n block = null\n wasRefused = false\n }\n return { ...STILL, acceleration }\n }\n const dx = vx * dt\n const dz = vz * dt\n if (input.isFree(dx, dz)) {\n if (refused === 0) {\n phase = 'push'\n block = null\n }\n wasRefused = false\n return { dx, dz, engaged: false, hitObstacle: false, velocity: [vx, vz], acceleration, stoppedFrom: null }\n }\n const from: readonly [number, number] = [vx, vz]\n vx = vz = 0\n const hitObstacle = !wasRefused\n wasRefused = true\n refused = rules.strainHoldSeconds\n phase = 'strain'\n block = 'obstacle'\n return { ...STILL, hitObstacle, acceleration: Math.hypot(from[0], from[1]) / dt, stoppedFrom: hitObstacle ? from : null }\n }\n\n return {\n get phase() {\n return phase\n },\n get progress() {\n return phase === 'idle' ? 0 : Math.min(1, held / gripSeconds)\n },\n get block() {\n return block\n },\n get heldSeconds() {\n return held\n },\n get velocity(): readonly [number, number] {\n return [vx, vz]\n },\n get isTap() {\n return phase === 'grip' && held < rules.tapSeconds\n },\n begin(next) {\n target = next\n phase = 'grip'\n held = 0\n block = null\n refused = 0\n wasRefused = false\n gripSeconds = gripSecondsFor(next.massKg, rules)\n speed = pushSpeedFor(next, rules)\n accel = pushAccelerationFor(next, rules)\n vx = vz = 0\n },\n setLoad(load) {\n speed = pushSpeedFor(load, rules)\n accel = pushAccelerationFor(load, rules)\n },\n release() {\n phase = 'idle'\n vx = vz = 0\n held = 0\n block = null\n },\n update(dt, input) {\n if (phase === 'idle') return STILL\n held += dt\n if (phase !== 'grip') return walkWith(dt, input)\n if (held < gripSeconds) return STILL\n if (canPush(target, rules)) phase = 'push'\n else {\n phase = 'strain'\n block = 'too_heavy'\n }\n return { ...STILL, engaged: true }\n },\n }\n}\n","/**\n * Opening and closing a hinged or sliding leaf by hand (a house door, a wardrobe or fridge door, a drawer, a car door, a hood): the hand reaches the handle, the leaf\n * follows the hand at a speed set by its mass, stops where something is in its way, and a locked leaf only rattles.\n * Engine-agnostic: the host says how open the leaf is (0 closed, 1 open) and answers whether it can go to a new opening; this says how far it goes each step.\n */\n\nexport type DoorUsePhase = 'idle' | 'reach' | 'swing' | 'release' | 'rattle'\nexport type DoorUseBlock = 'locked' | 'obstacle' | null\n\n/** Every number of the use; a game overrides what it wants (`createDoorUse(rules)`). */\nexport interface DoorUseRules {\n /** The hand going to the handle before the leaf moves, seconds. */\n readonly reachSeconds: number\n /** A full swing: `base + perKg * mass` of the leaf, between `min` and `max` seconds (a fridge door is quick, a car door slower, a steel door slower still). */\n readonly swingSeconds: { readonly base: number; readonly perKg: number; readonly min: number; readonly max: number }\n /** The hand letting go and coming back, seconds. */\n readonly releaseSeconds: number\n /** How long a locked leaf is shaken before the hand gives up, seconds. */\n readonly rattleSeconds: number\n /** The part of the swing tested at a time against what is around (smaller is finer and costs more). */\n readonly stepFraction: number\n /** Within this of closed or open a leaf counts as there: the last use's way no longer turns it round. */\n readonly endTolerance: number\n}\n\nexport const DOOR_USE_DEFAULTS: DoorUseRules = {\n reachSeconds: 0.3,\n swingSeconds: { base: 0.45, perKg: 0.02, min: 0.45, max: 1.6 },\n releaseSeconds: 0.22,\n // the length of the recorded handle shaken (game-audio door_locked_rattle, 0.6 to 0.83 s): the hand lets go as the sound ends\n rattleSeconds: 0.75,\n stepFraction: 0.04,\n endTolerance: 0.02,\n}\n\nexport type DoorUseTarget = {\n /** How open the leaf is now, 0 closed to 1 open. */\n readonly opening: number\n readonly massKg: number\n readonly locked?: boolean\n /** Where the last use sent this leaf: a leaf stopped between closed and open goes the other way (a door blocked half open closes). */\n readonly lastGoal?: 0 | 1\n}\n\nexport type DoorUseStep = {\n readonly phase: DoorUsePhase\n /** How open the leaf is after the step. */\n readonly opening: number\n /** The phase's own progress, 0 to 1 (how far the hand is to the handle, how far the swing went, how much of the rattle is left). */\n readonly progress: number\n /** Set on the step the leaf stopped short or would not move. */\n readonly block: DoorUseBlock\n /** The leaf got where it was going on this step (fully open or fully closed). */\n readonly arrived: boolean\n}\n\n/** Seconds of a full swing for a leaf of this mass. */\nexport const swingSecondsFor = (massKg: number, rules: DoorUseRules = DOOR_USE_DEFAULTS): number =>\n Math.min(rules.swingSeconds.max, Math.max(rules.swingSeconds.min, rules.swingSeconds.base + rules.swingSeconds.perKg * Math.max(0, massKg)))\n\nexport interface DoorUse {\n readonly phase: DoorUsePhase\n /** Where the leaf is going: 1 opening, 0 closing. */\n readonly goal: 0 | 1\n readonly opening: number\n /**\n * Starts using a leaf: the other way from where the last use sent it (`lastGoal`), else a closed or half-open leaf opens and an open\n * one closes. A use in the middle of a swing turns it round.\n * Answers the goal (1 open, 0 closed), or null when the leaf is locked (it rattles instead).\n */\n begin(target: DoorUseTarget): 0 | 1 | null\n /** Advances the use; `isFree(from, to)` answers whether the leaf can go from one opening to the other (nothing in the way of its sweep). */\n step(dt: number, isFree: (from: number, to: number) => boolean): DoorUseStep\n /** Lets go at once. */\n cancel(): void\n}\n\nexport function createDoorUse(rules: Partial<DoorUseRules> = {}): DoorUse {\n const r: DoorUseRules = { ...DOOR_USE_DEFAULTS, ...rules, swingSeconds: { ...DOOR_USE_DEFAULTS.swingSeconds, ...rules.swingSeconds } }\n let phase: DoorUsePhase = 'idle'\n let goal: 0 | 1 = 1\n let opening = 0\n let time = 0\n let swing = 1\n let start = 0\n\n const out = (progress: number, arrived = false, b: DoorUseBlock = null): DoorUseStep => ({ phase, opening, progress: Math.max(0, Math.min(1, progress)), block: b, arrived })\n\n return {\n get phase() {\n return phase\n },\n get goal() {\n return goal\n },\n get opening() {\n return opening\n },\n begin(target) {\n opening = Math.max(0, Math.min(1, target.opening))\n time = 0\n if (target.locked) {\n phase = 'rattle'\n return null\n }\n // in the middle of a swing the hand is already on the handle: the leaf turns round at once\n if (phase === 'swing' || phase === 'reach') goal = goal === 1 ? 0 : 1\n else if (target.lastGoal !== undefined && opening > r.endTolerance && opening < 1 - r.endTolerance) goal = target.lastGoal === 1 ? 0 : 1\n else goal = opening > 0.5 ? 0 : 1\n swing = swingSecondsFor(target.massKg, r)\n start = opening\n phase = phase === 'swing' ? 'swing' : 'reach'\n return goal\n },\n step(dt, isFree) {\n if (phase === 'idle') return out(0)\n time += dt\n if (phase === 'rattle') {\n const p = time / r.rattleSeconds\n if (p >= 1) {\n phase = 'idle'\n return out(1, false, 'locked')\n }\n return out(p, false, time === dt ? 'locked' : null)\n }\n if (phase === 'reach') {\n const p = time / r.reachSeconds\n if (p < 1) return out(p)\n phase = 'swing'\n time = 0\n start = opening\n }\n if (phase === 'swing') {\n const want = goal - opening\n const reach = Math.min(Math.abs(want), dt / swing)\n // the sweep is tested a little at a time, so a leaf stops at the first thing in its way and not past it\n let moved = 0\n let stopped = false\n while (moved < reach - 1e-9) {\n const inc = Math.min(r.stepFraction, reach - moved)\n const next = opening + Math.sign(want) * inc\n if (!isFree(opening, next)) {\n stopped = true\n break\n }\n opening = next\n moved += inc\n }\n const travel = Math.abs(goal - start) || 1\n if (stopped) {\n phase = 'release'\n time = 0\n return out(1 - Math.abs(goal - opening) / travel, false, 'obstacle')\n }\n if (Math.abs(goal - opening) < 1e-6) {\n opening = goal\n phase = 'release'\n time = 0\n return out(1, true)\n }\n return out(1 - Math.abs(goal - opening) / travel)\n }\n // release\n const p = time / r.releaseSeconds\n if (p >= 1) {\n phase = 'idle'\n }\n return out(p, false, null)\n },\n cancel() {\n phase = 'idle'\n time = 0\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;AAyCO,IAAM,0BAA8C;AAAA,EACzD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,oBAAoB,EAAE,WAAW,KAAK,WAAW,KAAK,KAAK,KAAK,SAAS,KAAK,OAAO,MAAM,WAAW,MAAM,WAAW,KAAK,QAAQ,MAAM,SAAS,MAAM,QAAQ,KAAK,QAAQ,MAAM,MAAM,KAAK,SAAS,KAAK,OAAO,KAAK,gBAAgB,KAAK,OAAO,KAAK,UAAU,KAAK;AAAA,EACzQ,iBAAiB;AAAA,EACjB,aAAa,EAAE,MAAM,KAAK,OAAO,OAAO,KAAK,IAAI;AAAA,EACjD,OAAO,EAAE,KAAK,KAAK,KAAK,KAAK;AAAA,EAC7B,OAAO,EAAE,KAAK,KAAK,OAAO,GAAG,KAAK,IAAI;AAAA,EACtC,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,WAAW;AAAA,IACT,MAAM,EAAE,OAAO,UAAU,OAAO,MAAM;AAAA,IACtC,MAAM,EAAE,OAAO,UAAU,OAAO,KAAK;AAAA,IACrC,UAAU,EAAE,OAAO,SAAU,OAAO,KAAK;AAAA,IACzC,OAAO,EAAE,OAAO,UAAU,OAAO,KAAM;AAAA,IACvC,OAAO,EAAE,OAAO,UAAU,OAAO,KAAM;AAAA,IACvC,MAAM,EAAE,OAAO,SAAU,OAAO,KAAK;AAAA,IACrC,MAAM,EAAE,OAAO,SAAU,OAAO,KAAK;AAAA,EACvC;AACF;AAKO,IAAM,cAAc,CAAC,UAA8B,QAA4B,6B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KAAK,IAAI,KAAK,IAAI,IAAI,GAAG,KAAK,KAAK;AAEjD,YAAI,QAAQ;AACZ,YAAI,UAAU;AACd,eAAO,QAAQ,QAAQ,MAAM;AAC3B,gBAAM,MAAM,KAAK,IAAI,EAAE,cAAc,QAAQ,KAAK;AAClD,gBAAM,OAAO,UAAU,KAAK,KAAK,IAAI,IAAI;AACzC,cAAI,CAAC,OAAO,SAAS,IAAI,GAAG;AAC1B,sBAAU;AACV;AAAA,UACF;AACA,oBAAU;AACV,mBAAS;AAAA,QACX;AACA,cAAM,SAAS,KAAK,IAAI,OAAO,KAAK,KAAK;AACzC,YAAI,SAAS;AACX,kBAAQ;AACR,iBAAO;AACP,iBAAO,IAAI,IAAI,KAAK,IAAI,OAAO,OAAO,IAAI,QAAQ,OAAO,UAAU;AAAA,QACrE;AACA,YAAI,KAAK,IAAI,OAAO,OAAO,IAAI,MAAM;AACnC,oBAAU;AACV,kBAAQ;AACR,iBAAO;AACP,iBAAO,IAAI,GAAG,IAAI;AAAA,QACpB;AACA,eAAO,IAAI,IAAI,KAAK,IAAI,OAAO,OAAO,IAAI,MAAM;AAAA,MAClD;AAEA,YAAM,IAAI,OAAO,EAAE;AACnB,UAAI,KAAK,GAAG;AACV,gBAAQ;AAAA,MACV;AACA,aAAO,IAAI,GAAG,OAAO,IAAI;AAAA,IAC3B;AAAA,IACA,SAAS;AACP,cAAQ;AACR,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["p"]}
|
|
1
|
+
{"version":3,"sources":["../src/furniture-push.ts","../src/door-use.ts","../src/hands.ts"],"sourcesContent":["/**\n * Pushing furniture on foot: hold the interaction button against a piece, a timer that grows with its mass fills, and the player then walks with it.\n * Engine-agnostic: the host says where the player wants to go and answers whether the volume of the piece can go there; this says how fast, and when it locks.\n */\n\nimport type { SurfaceId } from '@adatechnology/game-contracts'\n\n/** What dragging a piece leaves on a floor: a strip of this colour and width (metres) under each side of its base. */\nexport type DragMark = { readonly color: number; readonly width: number }\n\nexport type FurniturePushPhase = 'idle' | 'grip' | 'push' | 'strain'\nexport type FurniturePushBlock = 'too_heavy' | 'obstacle' | null\n\n/** Every number of the push; a game overrides what it wants (`createFurniturePush(rules)`). */\nexport interface FurniturePushRules {\n /** The most the player's legs put on the floor, newtons: with the friction it says the heaviest thing that moves. */\n readonly forceN: number\n readonly gravity: number\n /** Static friction of a base on a floor, by the material of the piece. */\n readonly frictionByMaterial: Readonly<Record<string, number>>\n readonly defaultFriction: number\n /** The hold before the push: `base + perKg * mass`, at most `max` seconds. */\n readonly gripSeconds: { readonly base: number; readonly perKg: number; readonly max: number }\n /** Metres per second: `max` with nothing on the hands, `min` at the limit of the force. */\n readonly speed: { readonly max: number; readonly min: number }\n /**\n * How fast the walk with the piece changes, m/s²: `max` the most a person speeds it up (the force left over the friction, over the mass, may give less), `brake` the\n * most it slows it (stopping, turning back). Below what holds a thing on top (friction × g, about 3.4 m/s² for the softest), so a cup on a pushed table rides along.\n */\n readonly accel: { readonly max: number; readonly brake: number; readonly min: number }\n /** A press shorter than this is not a push (the host keeps it for a tap, such as grabbing). */\n readonly tapSeconds: number\n /** How long the effort stays after the last step that was refused, so that it does not flicker. */\n readonly strainHoldSeconds: number\n /**\n * The scratch a dragged piece leaves, by the floor it is dragged on (`SurfaceId` of game-contracts): wood and tile scratch lighter, concrete scuffs darker,\n * dirt and sand take a furrow; a floor left out (carpet, grass, gravel, asphalt, water) keeps no mark.\n */\n readonly dragMarks: Readonly<Partial<Record<SurfaceId, DragMark>>>\n}\n\nexport const FURNITURE_PUSH_DEFAULTS: FurniturePushRules = {\n forceN: 500,\n gravity: 9.81,\n frictionByMaterial: { wood_soft: 0.4, wood_hard: 0.4, mdf: 0.4, plywood: 0.4, steel: 0.35, aluminium: 0.35, cast_iron: 0.4, copper: 0.35, plastic: 0.35, rubber: 0.8, fabric: 0.45, foam: 0.5, ceramic: 0.5, glass: 0.3, tempered_glass: 0.3, brick: 0.6, concrete: 0.65 },\n defaultFriction: 0.45,\n gripSeconds: { base: 0.4, perKg: 0.015, max: 2.5 },\n speed: { max: 1.8, min: 0.35 },\n accel: { max: 1.5, brake: 3, min: 0.2 },\n tapSeconds: 0.2,\n strainHoldSeconds: 0.25,\n dragMarks: {\n wood: { color: 0xd8c4a0, width: 0.012 },\n tile: { color: 0x9a9a96, width: 0.01 },\n concrete: { color: 0x45433f, width: 0.02 },\n metal: { color: 0xd0d4d8, width: 0.008 },\n glass: { color: 0xf2f2f2, width: 0.006 },\n dirt: { color: 0x4a3524, width: 0.04 },\n sand: { color: 0x8d7a5c, width: 0.05 },\n },\n}\n\nexport type FurniturePushTarget = { readonly massKg: number; readonly material?: string }\n\n/** Static friction of a thing of `material` on what it stands on (the floor, a table top). */\nexport const frictionFor = (material: string | undefined, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => (material !== undefined ? rules.frictionByMaterial[material] : undefined) ?? rules.defaultFriction\n\nconst frictionOf = (target: FurniturePushTarget, rules: FurniturePushRules): number => frictionFor(target.material, rules)\n\n/** A piece, or a row of pieces pushed one against the next (a sofa shoving a chair): their frictions on the floor add up against the legs. */\nexport type FurniturePushLoad = FurniturePushTarget | readonly FurniturePushTarget[]\n\nconst piecesOf = (load: FurniturePushLoad): readonly FurniturePushTarget[] => (Array.isArray(load) ? load : [load as FurniturePushTarget])\nconst frictionForceOf = (load: FurniturePushLoad, rules: FurniturePushRules): number => piecesOf(load).reduce((sum, t) => sum + frictionOf(t, rules) * t.massKg * rules.gravity, 0)\nconst massOf = (load: FurniturePushLoad): number => piecesOf(load).reduce((sum, t) => sum + t.massKg, 0)\nconst loadShare = (load: FurniturePushLoad, rules: FurniturePushRules): number => frictionForceOf(load, rules) / rules.forceN\n\nexport const gripSecondsFor = (massKg: number, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => Math.min(rules.gripSeconds.max, rules.gripSeconds.base + rules.gripSeconds.perKg * Math.max(0, massKg))\n\n/** Whether the legs overcome the friction of the piece (or of the row of pieces) on the floor. */\nexport const canPush = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): boolean => loadShare(target, rules) <= 1\n\n/** Metres per second with the piece on the hands: slower the closer it is to the limit of the force, 0 past it. */\nexport const pushSpeedFor = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => {\n const share = loadShare(target, rules)\n return share > 1 ? 0 : rules.speed.max + (rules.speed.min - rules.speed.max) * share\n}\n\n/** How fast the walk with the piece speeds up, m/s²: the force left over its friction, over its mass, at most what a person does (`accel.max`). */\nexport const pushAccelerationFor = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => {\n const spare = (rules.forceN - frictionForceOf(target, rules)) / Math.max(1e-3, massOf(target))\n return Math.max(rules.accel.min, Math.min(rules.accel.max, spare))\n}\n\n/** The scratch dragging leaves on `surface`, or null where the floor keeps none (carpet, grass). */\nexport const dragMarkFor = (surface: SurfaceId, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): DragMark | null => rules.dragMarks[surface] ?? null\n\n/** Whether a thing resting on a moving piece slides on it: the piece changes speed faster than the friction under the thing can follow (`accelMps2` > friction × g). */\nexport const slipsOnTop = (accelMps2: number, friction: number, gravity = FURNITURE_PUSH_DEFAULTS.gravity): boolean => accelMps2 > friction * gravity\n\nexport type FurniturePushInput = {\n /** Where the player wants to go on the floor: a unit vector, or `[0, 0]` standing. */\n readonly walk: readonly [number, number]\n /** Whether the volume of the piece (and the player behind it) can move by this offset. */\n readonly isFree: (dx: number, dz: number) => boolean\n}\n\nexport type FurniturePushStep = {\n readonly dx: number\n readonly dz: number\n /** The grip closed on this update. */\n readonly engaged: boolean\n /** A step was refused now and the one before was not: the moment the piece hits something. */\n readonly hitObstacle: boolean\n /** The velocity of the piece after this update, m/s on the floor. */\n readonly velocity: readonly [number, number]\n /** How fast its velocity changed in this update, m/s²: what a thing on top feels. */\n readonly acceleration: number\n /** The velocity it had when it hit something and stopped at once (what rests on it keeps it and slides on), or null. */\n readonly stoppedFrom: readonly [number, number] | null\n}\n\nexport interface FurniturePush {\n readonly phase: FurniturePushPhase\n /** How far the hold timer is, 0 to 1. */\n readonly progress: number\n readonly block: FurniturePushBlock\n readonly heldSeconds: number\n /** Whether the hold is still short enough to be a tap. */\n readonly isTap: boolean\n /** The velocity of the piece now, m/s on the floor. */\n readonly velocity: readonly [number, number]\n begin(target: FurniturePushTarget): void\n /** The load changed while pushing (the piece met another and shoves it along): the speed and the speeding up follow the whole row. */\n setLoad(load: FurniturePushLoad): void\n release(): void\n update(dt: number, input: FurniturePushInput): FurniturePushStep\n}\n\nconst STILL: FurniturePushStep = { dx: 0, dz: 0, engaged: false, hitObstacle: false, velocity: [0, 0], acceleration: 0, stoppedFrom: null }\n\nexport function createFurniturePush(overrides: Partial<FurniturePushRules> = {}): FurniturePush {\n const rules: FurniturePushRules = { ...FURNITURE_PUSH_DEFAULTS, ...overrides }\n let phase: FurniturePushPhase = 'idle'\n let target: FurniturePushTarget = { massKg: 0 }\n let held = 0\n let gripSeconds = 1\n let speed = 0\n let accel = rules.accel.max\n let vx = 0\n let vz = 0\n let block: FurniturePushBlock = null\n let refused = 0\n let wasRefused = false\n\n /** The velocity goes toward the walk, no faster than the push speeds it up (or the legs brake it). Answers the change, m/s². */\n const steer = (dt: number, walk: readonly [number, number]): number => {\n const wantX = walk[0] * speed\n const wantZ = walk[1] * speed\n const braking = wantX * vx + wantZ * vz < vx * vx + vz * vz\n let dvx = wantX - vx\n let dvz = wantZ - vz\n const change = Math.hypot(dvx, dvz)\n const most = (braking ? rules.accel.brake : accel) * dt\n if (change > most) {\n dvx *= most / change\n dvz *= most / change\n }\n vx += dvx\n vz += dvz\n return Math.min(change, most) / dt\n }\n\n const walkWith = (dt: number, input: FurniturePushInput): FurniturePushStep => {\n refused = Math.max(0, refused - dt)\n if (block === 'too_heavy' || dt <= 0) return STILL\n const acceleration = steer(dt, input.walk)\n if (Math.hypot(vx, vz) < 1e-4) {\n vx = vz = 0\n if (refused === 0) {\n phase = 'push'\n block = null\n wasRefused = false\n }\n return { ...STILL, acceleration }\n }\n const dx = vx * dt\n const dz = vz * dt\n if (input.isFree(dx, dz)) {\n if (refused === 0) {\n phase = 'push'\n block = null\n }\n wasRefused = false\n return { dx, dz, engaged: false, hitObstacle: false, velocity: [vx, vz], acceleration, stoppedFrom: null }\n }\n const from: readonly [number, number] = [vx, vz]\n vx = vz = 0\n const hitObstacle = !wasRefused\n wasRefused = true\n refused = rules.strainHoldSeconds\n phase = 'strain'\n block = 'obstacle'\n return { ...STILL, hitObstacle, acceleration: Math.hypot(from[0], from[1]) / dt, stoppedFrom: hitObstacle ? from : null }\n }\n\n return {\n get phase() {\n return phase\n },\n get progress() {\n return phase === 'idle' ? 0 : Math.min(1, held / gripSeconds)\n },\n get block() {\n return block\n },\n get heldSeconds() {\n return held\n },\n get velocity(): readonly [number, number] {\n return [vx, vz]\n },\n get isTap() {\n return phase === 'grip' && held < rules.tapSeconds\n },\n begin(next) {\n target = next\n phase = 'grip'\n held = 0\n block = null\n refused = 0\n wasRefused = false\n gripSeconds = gripSecondsFor(next.massKg, rules)\n speed = pushSpeedFor(next, rules)\n accel = pushAccelerationFor(next, rules)\n vx = vz = 0\n },\n setLoad(load) {\n speed = pushSpeedFor(load, rules)\n accel = pushAccelerationFor(load, rules)\n },\n release() {\n phase = 'idle'\n vx = vz = 0\n held = 0\n block = null\n },\n update(dt, input) {\n if (phase === 'idle') return STILL\n held += dt\n if (phase !== 'grip') return walkWith(dt, input)\n if (held < gripSeconds) return STILL\n if (canPush(target, rules)) phase = 'push'\n else {\n phase = 'strain'\n block = 'too_heavy'\n }\n return { ...STILL, engaged: true }\n },\n }\n}\n","/**\n * Opening and closing a hinged or sliding leaf by hand (a house door, a wardrobe or fridge door, a drawer, a car door, a hood): the hand reaches the handle, the leaf\n * follows the hand at a speed set by its mass, stops where something is in its way, and a locked leaf only rattles.\n * The player does not follow the leaf: when the handle leaves arm reach a leaf that goes away is shoved on (`push`) and one that comes toward the body is let go (`release`),\n * and either one finishes its swing on its own.\n * Engine-agnostic: the host says how open the leaf is (0 closed, 1 open) and answers whether it can go to a new opening; this says how far it goes each step.\n */\n\nexport type DoorUsePhase = 'idle' | 'reach' | 'swing' | 'push' | 'release' | 'rattle'\nexport type DoorUseBlock = 'locked' | 'obstacle' | null\n\n/** Every number of the use; a game overrides what it wants (`createDoorUse(rules)`). */\nexport interface DoorUseRules {\n /** The hand going to the handle before the leaf moves, seconds. */\n readonly reachSeconds: number\n /** A full swing: `base + perKg * mass` of the leaf, between `min` and `max` seconds (a fridge door is quick, a car door slower, a steel door slower still). */\n readonly swingSeconds: { readonly base: number; readonly perKg: number; readonly min: number; readonly max: number }\n /** The shove of a leaf that goes away once the handle is out of reach, seconds. */\n readonly pushSeconds: number\n /** The hand letting go and coming back, seconds. */\n readonly releaseSeconds: number\n /** How long a locked leaf is shaken before the hand gives up, seconds. */\n readonly rattleSeconds: number\n /** The part of the swing tested at a time against what is around (smaller is finer and costs more). */\n readonly stepFraction: number\n /** Within this of closed or open a leaf counts as there: the last use's way no longer turns it round. */\n readonly endTolerance: number\n}\n\nexport const DOOR_USE_DEFAULTS: DoorUseRules = {\n reachSeconds: 0.3,\n swingSeconds: { base: 0.45, perKg: 0.02, min: 0.45, max: 1.6 },\n pushSeconds: 0.18,\n releaseSeconds: 0.22,\n // the length of the recorded handle shaken (game-audio door_locked_rattle, 0.6 to 0.83 s): the hand lets go as the sound ends\n rattleSeconds: 0.75,\n stepFraction: 0.04,\n endTolerance: 0.02,\n}\n\n/** The body's shoulder, metres over the feet (the avatar's door pose is drawn for it). */\nexport const DOOR_SHOULDER_HEIGHT = 1.42\n/** The farthest a handle is from the shoulder joint for the palm to stay on it (measured on the body in both views: the palm is 0.06 m off up to 0.5, 0.11 at 0.55, 0.24 at 0.65). */\nexport const DOOR_ARM_REACH = 0.55\n\nexport type DoorUseTarget = {\n /** How open the leaf is now, 0 closed to 1 open. */\n readonly opening: number\n readonly massKg: number\n readonly locked?: boolean\n /** Where the last use sent this leaf: a leaf stopped between closed and open goes the other way (a door blocked half open closes). */\n readonly lastGoal?: 0 | 1\n}\n\nexport type DoorUseStep = {\n readonly phase: DoorUsePhase\n /** How open the leaf is after the step. */\n readonly opening: number\n /** The phase's own progress, 0 to 1 (how far the hand is to the handle, how far the swing went, how much of the rattle is left). */\n readonly progress: number\n /** Set on the step the leaf stopped short or would not move. */\n readonly block: DoorUseBlock\n /** The leaf got where it was going on this step (fully open or fully closed). */\n readonly arrived: boolean\n}\n\n/** Seconds of a full swing for a leaf of this mass. */\nexport const swingSecondsFor = (massKg: number, rules: DoorUseRules = DOOR_USE_DEFAULTS): number =>\n Math.min(rules.swingSeconds.max, Math.max(rules.swingSeconds.min, rules.swingSeconds.base + rules.swingSeconds.perKg * Math.max(0, massKg)))\n\nexport type DoorUseHand = { readonly reaches: () => boolean; readonly pull: boolean }\n\nexport interface DoorUse {\n readonly phase: DoorUsePhase\n /** Where the leaf is going: 1 opening, 0 closing. */\n readonly goal: 0 | 1\n readonly opening: number\n /**\n * Starts using a leaf: the other way from where the last use sent it (`lastGoal`), else a closed or half-open leaf opens and an open\n * one closes. A use in the middle of a swing turns it round.\n * Answers the goal (1 open, 0 closed), or null when the leaf is locked (it rattles instead).\n */\n begin(target: DoorUseTarget): 0 | 1 | null\n /**\n * Advances the use; `isFree(from, to)` answers whether the leaf can go from one opening to the other (nothing in the way of its sweep). `hand` says whether the handle is still\n * within arm reach after the step and whether the leaf comes toward the body (`pull`): once the handle is out of reach the swing hands over to `push` (a leaf going away is shoved\n * on) or `release` (a leaf coming toward the body is let go) and the leaf finishes on its own. Without `hand` the hand never lets go.\n */\n step(dt: number, isFree: (from: number, to: number) => boolean, hand?: DoorUseHand): DoorUseStep\n /** Lets go at once. */\n cancel(): void\n}\n\nexport function createDoorUse(rules: Partial<DoorUseRules> = {}): DoorUse {\n const r: DoorUseRules = { ...DOOR_USE_DEFAULTS, ...rules, swingSeconds: { ...DOOR_USE_DEFAULTS.swingSeconds, ...rules.swingSeconds } }\n let phase: DoorUsePhase = 'idle'\n let goal: 0 | 1 = 1\n let opening = 0\n let time = 0\n let swing = 1\n let start = 0\n /** The hand let go and the leaf is still going to its goal on its own. */\n let coasting = false\n\n const out = (progress: number, arrived = false, b: DoorUseBlock = null): DoorUseStep => ({ phase, opening, progress: Math.max(0, Math.min(1, progress)), block: b, arrived })\n\n /** Moves the leaf toward its goal for `dt` seconds, a little at a time so it stops at the first thing in its way and not past it. */\n const advance = (dt: number, isFree: (from: number, to: number) => boolean): 'moving' | 'stopped' | 'arrived' => {\n const want = goal - opening\n const reach = Math.min(Math.abs(want), dt / swing)\n let moved = 0\n while (moved < reach - 1e-9) {\n const inc = Math.min(r.stepFraction, reach - moved)\n const next = opening + Math.sign(want) * inc\n if (!isFree(opening, next)) return 'stopped'\n opening = next\n moved += inc\n }\n return Math.abs(goal - opening) < 1e-6 ? 'arrived' : 'moving'\n }\n\n /** The hand coming back to rest; it waits there (progress 1) while the leaf still goes on its own. */\n const releaseOut = (arrived: boolean, b: DoorUseBlock = null): DoorUseStep => {\n const p = time / r.releaseSeconds\n if (p >= 1 && !coasting) phase = 'idle'\n return out(p, arrived, b)\n }\n\n return {\n get phase() {\n return phase\n },\n get goal() {\n return goal\n },\n get opening() {\n return opening\n },\n begin(target) {\n opening = Math.max(0, Math.min(1, target.opening))\n time = 0\n coasting = false\n if (target.locked) {\n phase = 'rattle'\n return null\n }\n // in the middle of a swing the hand is already on the handle: the leaf turns round at once\n if (phase === 'swing' || phase === 'reach') goal = goal === 1 ? 0 : 1\n else if (target.lastGoal !== undefined && opening > r.endTolerance && opening < 1 - r.endTolerance) goal = target.lastGoal === 1 ? 0 : 1\n else goal = opening > 0.5 ? 0 : 1\n swing = swingSecondsFor(target.massKg, r)\n start = opening\n phase = phase === 'swing' ? 'swing' : 'reach'\n return goal\n },\n step(dt, isFree, hand) {\n if (phase === 'idle') return out(0)\n time += dt\n if (phase === 'rattle') {\n const p = time / r.rattleSeconds\n if (p >= 1) {\n phase = 'idle'\n return out(1, false, 'locked')\n }\n return out(p, false, time === dt ? 'locked' : null)\n }\n if (phase === 'reach') {\n const p = time / r.reachSeconds\n if (p < 1) return out(p)\n phase = 'swing'\n time = 0\n start = opening\n }\n if (phase === 'swing' || phase === 'push' || coasting) {\n const result = advance(dt, isFree)\n const travel = Math.abs(goal - start) || 1\n const progress = 1 - Math.abs(goal - opening) / travel\n const inHand = phase !== 'release'\n if (result === 'stopped' || result === 'arrived') {\n if (result === 'arrived') opening = goal\n coasting = false\n if (inHand) {\n phase = 'release'\n time = 0\n }\n if (result === 'arrived') return inHand ? out(1, true) : releaseOut(true)\n return inHand ? out(progress, false, 'obstacle') : releaseOut(false, 'obstacle')\n }\n if (inHand && hand && !hand.reaches()) {\n time = 0\n if (hand.pull) {\n phase = 'release'\n coasting = true\n } else phase = 'push'\n return out(0)\n }\n if (phase === 'push') {\n if (time >= r.pushSeconds) {\n phase = 'release'\n time = 0\n coasting = true\n return out(0)\n }\n return out(time / r.pushSeconds)\n }\n if (phase === 'swing') return out(progress)\n }\n return releaseOut(false)\n },\n cancel() {\n phase = 'idle'\n time = 0\n },\n }\n}\n","/**\n * The hands and the weapon (decision of the owner, 2026-11-24): an interaction of one hand (a small thing picked up, a door, a switch) takes the free hand, the one that does not\n * hold the weapon, and the weapon stays in its hand; one of both hands (a big thing carried, a push, a climb) first puts the weapon away in a slot of the body that takes it\n * (a holster at the hip, a sling or back slot for a long gun) and, with none, lets it fall to the ground. A two-handed weapon (a rifle, a shotgun) leaves no hand free, so any\n * interaction puts it away or drops it. When the interaction ends, what was put away comes back to its hand; what fell stays on the ground.\n * Engine-agnostic: the host says what is in each hand and which slots the body wears; this says which hand acts and what happens to each weapon.\n */\n\n/** `R` the weapon hand, `L` the other one. */\nexport type BodyHand = 'R' | 'L'\n\n/** A weapon in a hand: `hands` it takes (0 the bare hand, 1, 2) and the slot of the body that takes it (`hip`, `back`...), null when none does. */\nexport interface HandWeapon {\n readonly id: string\n readonly hands: 0 | 1 | 2\n readonly slot: string | null\n}\n\nexport interface HandsRules {\n /** A thing up to `maxKg` whose longest side is up to `maxLength` metres goes in one hand; anything bigger or heavier takes both. */\n readonly oneHand: { readonly maxKg: number; readonly maxLength: number }\n}\n\nexport const HANDS_DEFAULTS: HandsRules = { oneHand: { maxKg: 4, maxLength: 0.7 } }\n\n/** What a weapon does when the hands are wanted: `holster` goes to `slot` and comes back after, `drop` falls to the ground and stays there. */\nexport interface HandsMove {\n readonly hand: BodyHand\n readonly weapon: string\n readonly move: 'holster' | 'drop'\n readonly slot?: string\n}\n\nexport interface HandsPlan {\n /** The hand the interaction takes, or `both`. */\n readonly hand: BodyHand | 'both'\n /** What happens to each weapon that is in the way, the weapon hand first. */\n readonly moves: readonly HandsMove[]\n}\n\nexport interface PlanHandsParams {\n /** The hands the interaction takes (`interactionHandsFor` for a thing picked up). */\n readonly hands: 1 | 2\n /** What each hand holds; absent or null is an empty hand. */\n readonly weapons: { readonly R?: HandWeapon | null; readonly L?: HandWeapon | null }\n /** The slots the body wears and that are empty (a holster, a sling); one weapon each. */\n readonly slots: readonly string[]\n}\n\n/** How many hands it takes to carry a thing of `massKg` and `size` (metres, any order). */\nexport function interactionHandsFor(thing: { readonly massKg: number; readonly size?: readonly number[] }, rules: HandsRules = HANDS_DEFAULTS): 1 | 2 {\n const longest = Math.max(0, ...(thing.size ?? []))\n return thing.massKg > rules.oneHand.maxKg || longest > rules.oneHand.maxLength ? 2 : 1\n}\n\nconst holds = (weapon: HandWeapon | null | undefined): weapon is HandWeapon => !!weapon && weapon.hands > 0\n\n/** Which hand acts and what happens to each weapon in the way. */\nexport function planHands(params: PlanHandsParams): HandsPlan {\n const { R, L } = params.weapons\n const free = [...params.slots]\n const stow = (hand: BodyHand, weapon: HandWeapon): HandsMove => {\n const at = weapon.slot === null ? -1 : free.indexOf(weapon.slot)\n if (at < 0) return { hand, weapon: weapon.id, move: 'drop' }\n free.splice(at, 1)\n return { hand, weapon: weapon.id, move: 'holster', slot: weapon.slot as string }\n }\n if (params.hands === 2) {\n const moves = [...(holds(R) ? [stow('R', R)] : []), ...(holds(L) ? [stow('L', L)] : [])]\n return { hand: 'both', moves }\n }\n if (holds(L)) return { hand: 'L', moves: [stow('L', L)] }\n if (!holds(R)) return { hand: 'R', moves: [] }\n return { hand: 'L', moves: R.hands === 2 ? [stow('R', R)] : [] }\n}\n\n/** What comes back to the hands once the interaction ends: the weapons that were put away, each to its hand; the dropped ones stay on the ground. */\nexport function drawBackOf(plan: HandsPlan): readonly { readonly hand: BodyHand; readonly weapon: string }[] {\n return plan.moves.filter((move) => move.move === 'holster').map((move) => ({ hand: move.hand, weapon: move.weapon }))\n}\n"],"mappings":";;;;;;;;;;;;;;AAyCO,IAAM,0BAA8C;AAAA,EACzD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,oBAAoB,EAAE,WAAW,KAAK,WAAW,KAAK,KAAK,KAAK,SAAS,KAAK,OAAO,MAAM,WAAW,MAAM,WAAW,KAAK,QAAQ,MAAM,SAAS,MAAM,QAAQ,KAAK,QAAQ,MAAM,MAAM,KAAK,SAAS,KAAK,OAAO,KAAK,gBAAgB,KAAK,OAAO,KAAK,UAAU,KAAK;AAAA,EACzQ,iBAAiB;AAAA,EACjB,aAAa,EAAE,MAAM,KAAK,OAAO,OAAO,KAAK,IAAI;AAAA,EACjD,OAAO,EAAE,KAAK,KAAK,KAAK,KAAK;AAAA,EAC7B,OAAO,EAAE,KAAK,KAAK,OAAO,GAAG,KAAK,IAAI;AAAA,EACtC,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,WAAW;AAAA,IACT,MAAM,EAAE,OAAO,UAAU,OAAO,MAAM;AAAA,IACtC,MAAM,EAAE,OAAO,UAAU,OAAO,KAAK;AAAA,IACrC,UAAU,EAAE,OAAO,SAAU,OAAO,KAAK;AAAA,IACzC,OAAO,EAAE,OAAO,UAAU,OAAO,KAAM;AAAA,IACvC,OAAO,EAAE,OAA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AAE,MAAM,QAAQ,OAAO,IAAI,MAAM,WAAW,MAAM,OAAO,KAAe;AAAA,EACjF;AACA,MAAI,OAAO,UAAU,GAAG;AACtB,UAAM,QAAQ,CAAC,GAAI,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,GAAI,GAAI,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,CAAE;AACvF,WAAO,EAAE,MAAM,QAAQ,MAAM;AAAA,EAC/B;AACA,MAAI,MAAM,CAAC,EAAG,QAAO,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE;AACxD,MAAI,CAAC,MAAM,CAAC,EAAG,QAAO,EAAE,MAAM,KAAK,OAAO,CAAC,EAAE;AAC7C,SAAO,EAAE,MAAM,KAAK,OAAO,EAAE,UAAU,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE;AACjE;AAGO,SAAS,WAAW,MAAkF;AAC3G,SAAO,KAAK,MAAM,OAAO,CAAC,SAAS,KAAK,SAAS,SAAS,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,QAAQ,KAAK,OAAO,EAAE;AACtH;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlowId, BodyFoleyId, SurfaceId
|
|
1
|
+
import { BlowId, BodyFoleyId, SurfaceId } from '@adatechnology/game-contracts';
|
|
2
2
|
|
|
3
3
|
var numbers = {
|
|
4
4
|
hurtFlash: 0.4,
|
|
@@ -49,6 +49,8 @@ var numbers = {
|
|
|
49
49
|
regenMoving: 4,
|
|
50
50
|
regenStill: 8,
|
|
51
51
|
acceleration: 10,
|
|
52
|
+
heightMetres: 1.8,
|
|
53
|
+
crouchHeightRatio: 0.65,
|
|
52
54
|
radius: 0.3,
|
|
53
55
|
blockHeight: 0.4,
|
|
54
56
|
pushApartRadius: 0.55,
|
|
@@ -365,10 +367,21 @@ type PlayerOptions = {
|
|
|
365
367
|
readonly z?: number;
|
|
366
368
|
readonly yaw?: number;
|
|
367
369
|
};
|
|
370
|
+
/** Standing skull-top height in metres (default `numbers.heightMetres`, 1.80 m). Scales collider height and radius (Spec 012 R3/H5). */
|
|
371
|
+
readonly heightMetres?: number;
|
|
368
372
|
readonly world?: PlayerWorld;
|
|
369
373
|
};
|
|
374
|
+
/** Player capsule/cylinder collider dimensions in metres (follows standing vs crouched state and `heightMetres`). */
|
|
375
|
+
type PlayerCollider = {
|
|
376
|
+
readonly heightMetres: number;
|
|
377
|
+
readonly radiusMetres: number;
|
|
378
|
+
};
|
|
370
379
|
type Player = {
|
|
371
380
|
readonly state: PlayerState;
|
|
381
|
+
/** Declared standing height in metres. */
|
|
382
|
+
readonly heightMetres: number;
|
|
383
|
+
/** Current collider height and radius in metres (adapts to crouch and `heightMetres`). */
|
|
384
|
+
collider(): PlayerCollider;
|
|
372
385
|
readonly attributes: Attributes;
|
|
373
386
|
readonly derived: Derived;
|
|
374
387
|
readonly numbers: PlayerNumbers;
|
|
@@ -409,22 +422,4 @@ declare const drawWound: (wounds: WoundTable, random: () => number) => string;
|
|
|
409
422
|
*/
|
|
410
423
|
declare function createPlayer(options?: PlayerOptions): Player;
|
|
411
424
|
|
|
412
|
-
type
|
|
413
|
-
readonly locale?: string;
|
|
414
|
-
};
|
|
415
|
-
/** What the scenarios use of the context the test room passes. */
|
|
416
|
-
interface PlayerScenarioLike {
|
|
417
|
-
expect(condition: boolean, label: string, data?: Record<string, unknown>): void;
|
|
418
|
-
}
|
|
419
|
-
type PlayerTestModule = TestableModule<PlayerScenarioLike> & {
|
|
420
|
-
/** The player in use (replaced when the bench changes the sheet, the seed or the infection). */
|
|
421
|
-
readonly player: Player;
|
|
422
|
-
};
|
|
423
|
-
/**
|
|
424
|
-
* The player area of a test room, against the generic contracts only. The room's camera is the player: where it walks, the player walks; its speed
|
|
425
|
-
* decides walking or running, so stamina, footsteps and their noise follow the viewer. The bench hurts, bites, grabs and knocks the player down,
|
|
426
|
-
* switches the individual infection (off by default: a normal world) and sets the sheet. Footsteps and flesh sounds go to `host.audio`.
|
|
427
|
-
*/
|
|
428
|
-
declare function createPlayerTestModule(options?: PlayerTestModuleOptions): PlayerTestModule;
|
|
429
|
-
|
|
430
|
-
export { type AttributeId as A, type DeathCause as D, type InfectionRule as I, type KnownDeathCause as K, type LinearFormula as L, type MeleeItem as M, type PlayerMessageId as P, type WoundRule as W, type Attributes as a, type Derived as b, type DerivedFormulas as c, type DerivedId as d, PLAYER_DEFAULTS as e, type Player as f, type PlayerAction as g, type PlayerCrowd as h, type PlayerEvent as i, type PlayerEventMap as j, type PlayerEventName as k, type PlayerInput as l, type PlayerNumbers as m, type PlayerOptions as n, type PlayerSave as o, type PlayerSoundId as p, type PlayerState as q, type PlayerTestModule as r, type PlayerTestModuleOptions as s, type PlayerWorld as t, type WoundTable as u, createPlayer as v, createPlayerTestModule as w, deriveVitals as x, drawWound as y };
|
|
425
|
+
export { type AttributeId as A, type DeathCause as D, type InfectionRule as I, type KnownDeathCause as K, type LinearFormula as L, type MeleeItem as M, type Player as P, type WoundRule as W, type PlayerMessageId as a, type Attributes as b, type Derived as c, type DerivedFormulas as d, type DerivedId as e, PLAYER_DEFAULTS as f, type PlayerAction as g, type PlayerCollider as h, type PlayerCrowd as i, type PlayerEvent as j, type PlayerEventMap as k, type PlayerEventName as l, type PlayerInput as m, type PlayerNumbers as n, type PlayerOptions as o, type PlayerSave as p, type PlayerSoundId as q, type PlayerState as r, type PlayerWorld as s, type WoundTable as t, createPlayer as u, deriveVitals as v, drawWound as w };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
1
|
+
import { TestableModule } from '@adatechnology/game-contracts';
|
|
2
|
+
import { P as Player, o as PlayerOptions } from './player-Bjhc2M8F.js';
|
|
3
|
+
|
|
4
|
+
type PlayerTestModuleOptions = PlayerOptions & {
|
|
5
|
+
readonly locale?: string;
|
|
6
|
+
};
|
|
7
|
+
/** What the scenarios use of the context the test room passes. */
|
|
8
|
+
interface PlayerScenarioLike {
|
|
9
|
+
expect(condition: boolean, label: string, data?: Record<string, unknown>): void;
|
|
10
|
+
}
|
|
11
|
+
type PlayerTestModule = TestableModule<PlayerScenarioLike> & {
|
|
12
|
+
/** The player in use (replaced when the bench changes the sheet, the seed or the infection). */
|
|
13
|
+
readonly player: Player;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The player area of a test room, against the generic contracts only. The room's camera is the player: where it walks, the player walks; its speed
|
|
17
|
+
* decides walking or running, so stamina, footsteps and their noise follow the viewer. The bench hurts, bites, grabs and knocks the player down,
|
|
18
|
+
* switches the individual infection (off by default: a normal world) and sets the sheet. Footsteps and flesh sounds go to `host.audio`.
|
|
19
|
+
*/
|
|
20
|
+
declare function createPlayerTestModule(options?: PlayerTestModuleOptions): PlayerTestModule;
|
|
21
|
+
|
|
22
|
+
export { type PlayerTestModule, type PlayerTestModuleOptions, createPlayerTestModule };
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adatechnology/game-player",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Pure, seeded player body for games: vitals from an attribute sheet, stamina, wounds and bleeding, an optional individual infection, being grabbed and breaking free, knock-downs, low-wall vaults, footstep noise, panic, shove and melee against any crowd. A literal port of the team game's player. Knows nothing about any game.",
|
|
6
6
|
"keywords": [
|
|
@@ -36,23 +36,28 @@
|
|
|
36
36
|
"types": "./dist/testing.d.ts",
|
|
37
37
|
"import": "./dist/testing.js"
|
|
38
38
|
},
|
|
39
|
+
"./hud": {
|
|
40
|
+
"types": "./dist/hud.d.ts",
|
|
41
|
+
"import": "./dist/hud.js"
|
|
42
|
+
},
|
|
39
43
|
"./global": "./dist/index.global.js"
|
|
40
44
|
},
|
|
41
45
|
"files": [
|
|
42
46
|
"dist"
|
|
43
47
|
],
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"@adatechnology/game-contracts": "^0.
|
|
49
|
+
"@adatechnology/game-contracts": "^0.37.0"
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {
|
|
48
52
|
"@types/node": "^22.10.7",
|
|
53
|
+
"happy-dom": "^17.4.4",
|
|
49
54
|
"tsup": "^8.5.1",
|
|
50
55
|
"typescript": "^5.7.3",
|
|
51
56
|
"vitest": "^3.2.4",
|
|
52
57
|
"@adatechnology/golden-tool": "^0.0.0"
|
|
53
58
|
},
|
|
54
59
|
"scripts": {
|
|
55
|
-
"build": "tsup",
|
|
60
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsup",
|
|
56
61
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
57
62
|
"test": "vitest run"
|
|
58
63
|
}
|