@adatechnology/game-items 0.7.2 → 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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BodySlot, SealSpec, DeepPartial, ToolCondition, SealState, SealBlock } from '@adatechnology/game-contracts';
1
+ import { BodySlot, ItemTool, SealSpec, DeepPartial, ToolCondition, SealState, SealBlock } from '@adatechnology/game-contracts';
2
2
  export { BodySlot } from '@adatechnology/game-contracts';
3
3
  import { ItemDef as ItemDef$1, rng, ItemStack as ItemStack$1, SlotSpec, LootTables } from '@adatechnology/game-interactables';
4
4
  export { ItemDef as BaseItemDef } from '@adatechnology/game-interactables';
@@ -190,7 +190,13 @@ interface ItemDef extends ItemDef$1 {
190
190
  liquid: string;
191
191
  liters: number;
192
192
  };
193
+ /** What it holds to the brim when it is a vessel (a bucket, a cup); `fluid` is what it holds now. */
194
+ container?: {
195
+ readonly capacityLiters?: number;
196
+ };
193
197
  uses?: readonly string[];
198
+ /** What it works as for an object's uses (`ITEM_TOOLS` of game-contracts): a `plunger` pumps a clogged toilet. */
199
+ tools?: readonly ItemTool[];
194
200
  finds?: {
195
201
  places: readonly PlaceTag[];
196
202
  };
@@ -950,11 +956,17 @@ interface HandUsePlayer {
950
956
  declare const HAND_USES: readonly HandUseDef[];
951
957
  /** The hand use with that id, among `defs`. */
952
958
  declare const handUseOf: (id: string, defs?: readonly HandUseDef[]) => HandUseDef | undefined;
953
- /** Farthest the hand carries an item from the eye (metres): an arm's length. */
954
- declare const HAND_USE_REACH = 0.62;
955
959
  /**
956
- * The use with its `reach` keys moved onto `target` (a point in the eye's frame, as the keys are: a lock seen ahead), kept within `HAND_USE_REACH` of the eye; the keys keep
957
- * how they lay around the first reach key, so a key still goes in, turns and comes out. Without reach keys the use is returned as it is.
960
+ * Where the shoulder of the hand that reaches sits, in the eye's frame (x right, y up, z back toward the eye), metres: an adult's right shoulder is some 17 cm to the
961
+ * side of the eyes, 24 cm under them and a little behind. The reach is measured from it, not from the eye: a hand reaches farther forward and down than up.
962
+ */
963
+ declare const HAND_USE_SHOULDER: readonly [number, number, number];
964
+ /** The arm's length from the shoulder to the middle of what the hand grips, metres (an adult's arm, the hand closed round a handle). */
965
+ declare const HAND_USE_ARM = 0.66;
966
+ /**
967
+ * The use with its `reach` keys moved onto `target` (a point in the eye's frame, as the keys are: a lock seen ahead, the stream under a tap), kept within the arm's
968
+ * length of the shoulder (`HAND_USE_SHOULDER`, `HAND_USE_ARM`); the keys keep how they lay around the first reach key, so a key still goes in, turns and comes out.
969
+ * Without reach keys the use is returned as it is.
958
970
  */
959
971
  declare const aimHandUse: (def: HandUseDef, target: readonly [number, number, number]) => HandUseDef;
960
972
  /** Plays a hand use: the pose between its keys, and its actions as the time passes them. */
@@ -1023,4 +1035,4 @@ declare const rinseFoam: (state: FoamState, water: FoamRinse, dt: number) => Foa
1023
1035
  /** Share of a full layer still on it, 0..1. */
1024
1036
  declare const foamLeft: (state: FoamState) => number;
1025
1037
 
1026
- export { ARSENAL_CATEGORIES, type AgeOptions, type AgeState, type AmmoState, type ArsenalCaliberLike, type ArsenalItemRecord, type ArsenalItemsOptions, type ArsenalLike, type ArsenalWeaponLike, type AttackKind, BODY_SLOTS, type BagOption, type CarryEntry, type CategoryDef, type ConsumableForm, type ConsumableSpec, type ConsumableState, type ConsumableUnit, type Consumption, type ContainerDef, type CraftCheck, type CraftContext, type CraftOutcome, type CraftResult, DEFAULT_RULES, DURABILITY_KINDS, type DepletionRule, type DestructionObjectState, type DoseResult, type Durability, type DurabilityKind, FOAM_GONE, FOAM_RINSE_LITRES, type FindData, type FindStack, type FindState, type FindsProvider, type FindsProviderOptions, type FindsQuery, type FoamRinse, type FoamState, type Freshness, type FreshnessEffect, HAND_USES, HAND_USE_REACH, type HandUseAction, type HandUseBody, type HandUseDef, type HandUseEvent, type HandUseKey, type HandUsePlayer, ITEM_CATEGORIES, type Inventory, type InventoryFailure, type InventoryOptions, type InventoryResult, type InventorySlot, type InventoryTotals, type ItemCategory, type ItemDef, type ItemPack, type ItemRules, type ItemStack, type ItemState, type ItemsCatalog, type ItemsOptions, type LoadLevel, type LoadState, type LootTablesQuery, type NutritionResult, type PlaceDef, type PlaceTag, type PlacedFinds, type PoolEntry, type PoolPick, RARITIES, type Rarity, type RecipeDef, type RecipeInput, type RecipeMatch, type RecipeOutput, type RecipeTool, type Rng, type StorageId, type StorageRule, type StorageRules, type TakeOptions, type TakeParams, type TakeResult, type UseContext, type UseEffectDef, type UseResult, type WornPiece, addFoam, advanceAge, aimHandUse, bagOption, barScale, blockChance, canCraft, canTake, carriedKg, chargeLevel, checkItems, consumableMassKg, consumableOf, consumableProblems, craft, createFindsProvider, createHandUse, createInventory, createItems, depletionFactor, emptyFoam, failsToStart, fitsInside, foamLeft, freshness, fullConsumable, handUseOf, isSpent, itemLitres, itemsFromArsenal, loadState, maxLoadKg, moveToStorage, pieceBlock, placeFinds, remainingShare, repairPiece, resolveUse, rinseFoam, rollByCategory, rollExplicitPool, scaleCount, shelfRatio, spawnAgeDays, spawnData, storageMultiplier, takeDose, toLootTables, wearBlocked };
1038
+ export { ARSENAL_CATEGORIES, type AgeOptions, type AgeState, type AmmoState, type ArsenalCaliberLike, type ArsenalItemRecord, type ArsenalItemsOptions, type ArsenalLike, type ArsenalWeaponLike, type AttackKind, BODY_SLOTS, type BagOption, type CarryEntry, type CategoryDef, type ConsumableForm, type ConsumableSpec, type ConsumableState, type ConsumableUnit, type Consumption, type ContainerDef, type CraftCheck, type CraftContext, type CraftOutcome, type CraftResult, DEFAULT_RULES, DURABILITY_KINDS, type DepletionRule, type DestructionObjectState, type DoseResult, type Durability, type DurabilityKind, FOAM_GONE, FOAM_RINSE_LITRES, type FindData, type FindStack, type FindState, type FindsProvider, type FindsProviderOptions, type FindsQuery, type FoamRinse, type FoamState, type Freshness, type FreshnessEffect, HAND_USES, HAND_USE_ARM, HAND_USE_SHOULDER, type HandUseAction, type HandUseBody, type HandUseDef, type HandUseEvent, type HandUseKey, type HandUsePlayer, ITEM_CATEGORIES, type Inventory, type InventoryFailure, type InventoryOptions, type InventoryResult, type InventorySlot, type InventoryTotals, type ItemCategory, type ItemDef, type ItemPack, type ItemRules, type ItemStack, type ItemState, type ItemsCatalog, type ItemsOptions, type LoadLevel, type LoadState, type LootTablesQuery, type NutritionResult, type PlaceDef, type PlaceTag, type PlacedFinds, type PoolEntry, type PoolPick, RARITIES, type Rarity, type RecipeDef, type RecipeInput, type RecipeMatch, type RecipeOutput, type RecipeTool, type Rng, type StorageId, type StorageRule, type StorageRules, type TakeOptions, type TakeParams, type TakeResult, type UseContext, type UseEffectDef, type UseResult, type WornPiece, addFoam, advanceAge, aimHandUse, bagOption, barScale, blockChance, canCraft, canTake, carriedKg, chargeLevel, checkItems, consumableMassKg, consumableOf, consumableProblems, craft, createFindsProvider, createHandUse, createInventory, createItems, depletionFactor, emptyFoam, failsToStart, fitsInside, foamLeft, freshness, fullConsumable, handUseOf, isSpent, itemLitres, itemsFromArsenal, loadState, maxLoadKg, moveToStorage, pieceBlock, placeFinds, remainingShare, repairPiece, resolveUse, rinseFoam, rollByCategory, rollExplicitPool, scaleCount, shelfRatio, spawnAgeDays, spawnData, storageMultiplier, takeDose, toLootTables, wearBlocked };
@@ -28,7 +28,8 @@ var GameItems = (() => {
28
28
  FOAM_GONE: () => FOAM_GONE,
29
29
  FOAM_RINSE_LITRES: () => FOAM_RINSE_LITRES,
30
30
  HAND_USES: () => HAND_USES,
31
- HAND_USE_REACH: () => HAND_USE_REACH,
31
+ HAND_USE_ARM: () => HAND_USE_ARM,
32
+ HAND_USE_SHOULDER: () => HAND_USE_SHOULDER,
32
33
  ITEM_CATEGORIES: () => ITEM_CATEGORIES,
33
34
  RARITIES: () => RARITIES,
34
35
  addFoam: () => addFoam,
@@ -125,6 +126,7 @@ var GameItems = (() => {
125
126
  [DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT]: { priority: 40, phase: "idle", minEveryFrames: 30 }
126
127
  };
127
128
  var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
129
+ var ITEM_TOOLS = ["plunger"];
128
130
  var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
129
131
  var warnedKeys = () => {
130
132
  const holder = globalThis;
@@ -445,6 +447,7 @@ var GameItems = (() => {
445
447
  if (item.shelfLife !== void 0 && !isPositive(item.shelfLife)) issue(`has a shelf life of ${item.shelfLife} days`);
446
448
  if (item.portions !== void 0 && !(Number.isInteger(item.portions) && item.portions > 0)) issue(`has ${item.portions} portions`);
447
449
  if (item.durability && !DURABILITY_KINDS.includes(item.durability.kind)) issue(`has unknown durability kind "${item.durability.kind}"`);
450
+ for (const tool of item.tools ?? []) if (!ITEM_TOOLS.includes(tool)) issue(`works as unknown tool "${tool}"`);
448
451
  if (item.consumable) for (const problem of consumableProblems(item.consumable)) issue(problem);
449
452
  const { protection } = item;
450
453
  if (protection) {
@@ -2149,19 +2152,474 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
2149
2152
  ]
2150
2153
  }
2151
2154
  ]
2155
+ },
2156
+ {
2157
+ id: "wash_dishes",
2158
+ body: "two_hands",
2159
+ duration: 3,
2160
+ note: "both hands low in front at the height of a sink basin, the dish tipped toward the body and scrubbed in small circles, three rounds, and back; the scrubbing keys reach under the tap (aimHandUse)",
2161
+ keys: [
2162
+ {
2163
+ t: 0,
2164
+ position: [
2165
+ 0.22,
2166
+ -0.2,
2167
+ -0.4
2168
+ ],
2169
+ rotation: [
2170
+ 0,
2171
+ 0,
2172
+ 0
2173
+ ]
2174
+ },
2175
+ {
2176
+ t: 0.4,
2177
+ position: [
2178
+ 0,
2179
+ -0.55,
2180
+ -0.45
2181
+ ],
2182
+ rotation: [
2183
+ -0.5,
2184
+ 0,
2185
+ 0
2186
+ ],
2187
+ reach: true
2188
+ },
2189
+ {
2190
+ t: 0.7,
2191
+ position: [
2192
+ 0.04,
2193
+ -0.55,
2194
+ -0.41
2195
+ ],
2196
+ rotation: [
2197
+ -0.5,
2198
+ 0,
2199
+ 0
2200
+ ],
2201
+ action: "scrub",
2202
+ reach: true
2203
+ },
2204
+ {
2205
+ t: 0.95,
2206
+ position: [
2207
+ 0,
2208
+ -0.55,
2209
+ -0.37
2210
+ ],
2211
+ rotation: [
2212
+ -0.5,
2213
+ 0,
2214
+ 0
2215
+ ],
2216
+ reach: true
2217
+ },
2218
+ {
2219
+ t: 1.2,
2220
+ position: [
2221
+ -0.04,
2222
+ -0.55,
2223
+ -0.41
2224
+ ],
2225
+ rotation: [
2226
+ -0.5,
2227
+ 0,
2228
+ 0
2229
+ ],
2230
+ reach: true
2231
+ },
2232
+ {
2233
+ t: 1.45,
2234
+ position: [
2235
+ 0,
2236
+ -0.55,
2237
+ -0.45
2238
+ ],
2239
+ rotation: [
2240
+ -0.5,
2241
+ 0,
2242
+ 0
2243
+ ],
2244
+ action: "scrub",
2245
+ reach: true
2246
+ },
2247
+ {
2248
+ t: 1.7,
2249
+ position: [
2250
+ 0.04,
2251
+ -0.55,
2252
+ -0.41
2253
+ ],
2254
+ rotation: [
2255
+ -0.5,
2256
+ 0,
2257
+ 0
2258
+ ],
2259
+ reach: true
2260
+ },
2261
+ {
2262
+ t: 1.95,
2263
+ position: [
2264
+ 0,
2265
+ -0.55,
2266
+ -0.37
2267
+ ],
2268
+ rotation: [
2269
+ -0.5,
2270
+ 0,
2271
+ 0
2272
+ ],
2273
+ reach: true
2274
+ },
2275
+ {
2276
+ t: 2.2,
2277
+ position: [
2278
+ -0.04,
2279
+ -0.55,
2280
+ -0.41
2281
+ ],
2282
+ rotation: [
2283
+ -0.5,
2284
+ 0,
2285
+ 0
2286
+ ],
2287
+ action: "scrub",
2288
+ reach: true
2289
+ },
2290
+ {
2291
+ t: 2.5,
2292
+ position: [
2293
+ 0,
2294
+ -0.55,
2295
+ -0.45
2296
+ ],
2297
+ rotation: [
2298
+ -0.5,
2299
+ 0,
2300
+ 0
2301
+ ],
2302
+ reach: true
2303
+ },
2304
+ {
2305
+ t: 3,
2306
+ position: [
2307
+ 0.22,
2308
+ -0.2,
2309
+ -0.4
2310
+ ],
2311
+ rotation: [
2312
+ 0,
2313
+ 0,
2314
+ 0
2315
+ ]
2316
+ }
2317
+ ]
2318
+ },
2319
+ {
2320
+ id: "fill_cup",
2321
+ body: "hand",
2322
+ duration: 2.5,
2323
+ note: "the cup held upright, forward and low under where the tap runs, kept still while it fills, then brought back up; the keys under the tap reach where the stream is (aimHandUse)",
2324
+ keys: [
2325
+ {
2326
+ t: 0,
2327
+ position: [
2328
+ 0.22,
2329
+ -0.2,
2330
+ -0.4
2331
+ ],
2332
+ rotation: [
2333
+ 0,
2334
+ 0,
2335
+ 0
2336
+ ]
2337
+ },
2338
+ {
2339
+ t: 0.5,
2340
+ position: [
2341
+ 0.05,
2342
+ -0.55,
2343
+ -0.45
2344
+ ],
2345
+ rotation: [
2346
+ 0,
2347
+ 0,
2348
+ 0
2349
+ ],
2350
+ reach: true
2351
+ },
2352
+ {
2353
+ t: 0.7,
2354
+ position: [
2355
+ 0.05,
2356
+ -0.55,
2357
+ -0.45
2358
+ ],
2359
+ rotation: [
2360
+ 0,
2361
+ 0,
2362
+ 0
2363
+ ],
2364
+ action: "apply",
2365
+ reach: true
2366
+ },
2367
+ {
2368
+ t: 1.8,
2369
+ position: [
2370
+ 0.05,
2371
+ -0.55,
2372
+ -0.45
2373
+ ],
2374
+ rotation: [
2375
+ 0,
2376
+ 0,
2377
+ 0
2378
+ ],
2379
+ reach: true
2380
+ },
2381
+ {
2382
+ t: 2.1,
2383
+ position: [
2384
+ 0.15,
2385
+ -0.32,
2386
+ -0.42
2387
+ ],
2388
+ rotation: [
2389
+ 0,
2390
+ 0,
2391
+ 0
2392
+ ]
2393
+ },
2394
+ {
2395
+ t: 2.5,
2396
+ position: [
2397
+ 0.22,
2398
+ -0.2,
2399
+ -0.4
2400
+ ],
2401
+ rotation: [
2402
+ 0,
2403
+ 0,
2404
+ 0
2405
+ ]
2406
+ }
2407
+ ]
2408
+ },
2409
+ {
2410
+ id: "drink_cupped_hands",
2411
+ body: "two_hands",
2412
+ duration: 5,
2413
+ note: "bent over the sink: both hands cupped under the running tap, the water caught in them lifted to the mouth and drunk, three handfuls, and back; the cupped hands reach under the stream (aimHandUse) and come up to the mouth",
2414
+ keys: [
2415
+ {
2416
+ t: 0,
2417
+ position: [
2418
+ 0.22,
2419
+ -0.2,
2420
+ -0.4
2421
+ ],
2422
+ rotation: [
2423
+ 0,
2424
+ 0,
2425
+ 0
2426
+ ]
2427
+ },
2428
+ {
2429
+ t: 0.5,
2430
+ position: [
2431
+ 0,
2432
+ -0.55,
2433
+ -0.42
2434
+ ],
2435
+ rotation: [
2436
+ -0.3,
2437
+ 0,
2438
+ 0
2439
+ ],
2440
+ reach: true
2441
+ },
2442
+ {
2443
+ t: 1,
2444
+ position: [
2445
+ 0,
2446
+ -0.55,
2447
+ -0.42
2448
+ ],
2449
+ rotation: [
2450
+ -0.3,
2451
+ 0,
2452
+ 0
2453
+ ],
2454
+ reach: true
2455
+ },
2456
+ {
2457
+ t: 1.45,
2458
+ position: [
2459
+ 0,
2460
+ 0,
2461
+ -0.22
2462
+ ],
2463
+ rotation: [
2464
+ -0.9,
2465
+ 0,
2466
+ 0
2467
+ ],
2468
+ action: "swallow"
2469
+ },
2470
+ {
2471
+ t: 1.7,
2472
+ position: [
2473
+ 0,
2474
+ 0,
2475
+ -0.22
2476
+ ],
2477
+ rotation: [
2478
+ -0.9,
2479
+ 0,
2480
+ 0
2481
+ ]
2482
+ },
2483
+ {
2484
+ t: 1.9,
2485
+ position: [
2486
+ 0,
2487
+ -0.55,
2488
+ -0.42
2489
+ ],
2490
+ rotation: [
2491
+ -0.3,
2492
+ 0,
2493
+ 0
2494
+ ],
2495
+ reach: true
2496
+ },
2497
+ {
2498
+ t: 2.4,
2499
+ position: [
2500
+ 0,
2501
+ -0.55,
2502
+ -0.42
2503
+ ],
2504
+ rotation: [
2505
+ -0.3,
2506
+ 0,
2507
+ 0
2508
+ ],
2509
+ reach: true
2510
+ },
2511
+ {
2512
+ t: 2.85,
2513
+ position: [
2514
+ 0,
2515
+ 0,
2516
+ -0.22
2517
+ ],
2518
+ rotation: [
2519
+ -0.9,
2520
+ 0,
2521
+ 0
2522
+ ],
2523
+ action: "swallow"
2524
+ },
2525
+ {
2526
+ t: 3.1,
2527
+ position: [
2528
+ 0,
2529
+ 0,
2530
+ -0.22
2531
+ ],
2532
+ rotation: [
2533
+ -0.9,
2534
+ 0,
2535
+ 0
2536
+ ]
2537
+ },
2538
+ {
2539
+ t: 3.3,
2540
+ position: [
2541
+ 0,
2542
+ -0.55,
2543
+ -0.42
2544
+ ],
2545
+ rotation: [
2546
+ -0.3,
2547
+ 0,
2548
+ 0
2549
+ ],
2550
+ reach: true
2551
+ },
2552
+ {
2553
+ t: 3.8,
2554
+ position: [
2555
+ 0,
2556
+ -0.55,
2557
+ -0.42
2558
+ ],
2559
+ rotation: [
2560
+ -0.3,
2561
+ 0,
2562
+ 0
2563
+ ],
2564
+ reach: true
2565
+ },
2566
+ {
2567
+ t: 4.25,
2568
+ position: [
2569
+ 0,
2570
+ 0,
2571
+ -0.22
2572
+ ],
2573
+ rotation: [
2574
+ -0.9,
2575
+ 0,
2576
+ 0
2577
+ ],
2578
+ action: "swallow"
2579
+ },
2580
+ {
2581
+ t: 4.5,
2582
+ position: [
2583
+ 0,
2584
+ 0,
2585
+ -0.22
2586
+ ],
2587
+ rotation: [
2588
+ -0.9,
2589
+ 0,
2590
+ 0
2591
+ ]
2592
+ },
2593
+ {
2594
+ t: 5,
2595
+ position: [
2596
+ 0.22,
2597
+ -0.2,
2598
+ -0.4
2599
+ ],
2600
+ rotation: [
2601
+ 0,
2602
+ 0,
2603
+ 0
2604
+ ]
2605
+ }
2606
+ ]
2152
2607
  }
2153
2608
  ];
2154
2609
 
2155
2610
  // src/hand-use.ts
2156
2611
  var HAND_USES = hand_uses_default;
2157
2612
  var handUseOf = (id, defs = HAND_USES) => defs.find((def) => def.id === id);
2158
- var HAND_USE_REACH = 0.62;
2613
+ var HAND_USE_SHOULDER = [0.17, -0.24, 0.04];
2614
+ var HAND_USE_ARM = 0.66;
2159
2615
  var aimHandUse = (def, target) => {
2160
2616
  const anchor = def.keys.find((key) => key.reach);
2161
2617
  if (!anchor) return def;
2162
- const length = Math.hypot(target[0], target[1], target[2]);
2163
- const k = length > HAND_USE_REACH ? HAND_USE_REACH / length : 1;
2164
- const shift = [target[0] * k - anchor.position[0], target[1] * k - anchor.position[1], target[2] * k - anchor.position[2]];
2618
+ const [sx, sy, sz] = HAND_USE_SHOULDER;
2619
+ const length = Math.hypot(target[0] - sx, target[1] - sy, target[2] - sz);
2620
+ const k = length > HAND_USE_ARM ? HAND_USE_ARM / length : 1;
2621
+ const reached = [sx + (target[0] - sx) * k, sy + (target[1] - sy) * k, sz + (target[2] - sz) * k];
2622
+ const shift = [reached[0] - anchor.position[0], reached[1] - anchor.position[1], reached[2] - anchor.position[2]];
2165
2623
  const moved = (key) => ({ ...key, position: [key.position[0] + shift[0], key.position[1] + shift[1], key.position[2] + shift[2]] });
2166
2624
  return { ...def, keys: def.keys.map((key) => key.reach ? moved(key) : key) };
2167
2625
  };