@adatechnology/game-items 0.2.25 → 0.4.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 +1 -0
- package/dist/index.d.ts +57 -1
- package/dist/index.global.js +1077 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1077 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -71,6 +71,7 @@ const { contents, leftover } = placeFinds(stacks, slots, items)
|
|
|
71
71
|
| `blockChance`, `wearBlocked`, `repairPiece`, `pieceBlock` | layered clothing protection |
|
|
72
72
|
| `maxLoadKg`, `carriedKg`, `loadState`, `bagOption`, `canTake` | carry weight and slots |
|
|
73
73
|
| `resolveUse` | what using an item does, as data; with `UseContext.seal` a sealed item (`ItemDef.seal`, a `SealSpec` of game-contracts) still closed, holed or leaking is not eaten (`blocked`) |
|
|
74
|
+
| `HAND_USES`, `createHandUse`, `handUseOf` | uses of an item in the hand without a liquid (spec 015 R5): `eat_food` in three bites, `drink`, `take_medicine`, `apply_dressing`, `use_hygiene`, `toggle_flashlight` (the thumb on the switch), `light_lighter` (the wheel struck, the flame caught), `use_radio` (to the face, the knob turned, talking), `turn_key` (into the lock and turned); keys of the item's place from the hand's rest in the eye's frame (the frame of the fluid uses), `body` (`mouth`, `two_hands`, `hand` or `reach`) for the arms, and the `bite`/`swallow`/`apply`/`scrub`/`switch`/`ignite`/`tune`/`talk`/`turn` events the host acts on. `aimHandUse(def, target)` moves the keys marked `reach` onto a point the host aims them at (a lock), within an arm's length (`HAND_USE_REACH`) |
|
|
74
75
|
| `canCraft`, `craft` | recipes |
|
|
75
76
|
| `createFindsProvider`, `rollByCategory`, `rollExplicitPool`, `spawnData`, `depletionFactor`, `placeFinds`, `toLootTables` | finds |
|
|
76
77
|
| `itemsFromArsenal` | the arsenal as items |
|
package/dist/index.d.ts
CHANGED
|
@@ -879,4 +879,60 @@ declare const ARSENAL_CATEGORIES: readonly CategoryDef[];
|
|
|
879
879
|
*/
|
|
880
880
|
declare const itemsFromArsenal: (arsenal: ArsenalLike, options?: ArsenalItemsOptions) => ItemPack;
|
|
881
881
|
|
|
882
|
-
|
|
882
|
+
/**
|
|
883
|
+
* What happens at a key: a bite taken, a pill or a sip swallowed, the dressing pressed on, soap rubbed; a switch pressed (a flashlight), a flame struck (a lighter), a knob
|
|
884
|
+
* turned and words spoken (a radio), a key turned in its lock.
|
|
885
|
+
*/
|
|
886
|
+
type HandUseAction = 'bite' | 'swallow' | 'apply' | 'scrub' | 'switch' | 'ignite' | 'tune' | 'talk' | 'turn';
|
|
887
|
+
/**
|
|
888
|
+
* Which arms the use takes: the item to the `mouth`, both hands together in front of the body (`two_hands`), the one `hand` that holds it raised before the chest, or
|
|
889
|
+
* that arm stretched out to `reach` something ahead (a lock).
|
|
890
|
+
*/
|
|
891
|
+
type HandUseBody = 'mouth' | 'two_hands' | 'hand' | 'reach';
|
|
892
|
+
interface HandUseKey {
|
|
893
|
+
readonly t: number;
|
|
894
|
+
readonly position: readonly [number, number, number];
|
|
895
|
+
readonly rotation: readonly [number, number, number];
|
|
896
|
+
readonly action?: HandUseAction;
|
|
897
|
+
/** The item is at what the use reaches for at this key (a key in its lock): `aimHandUse` moves it there when the host has a target. */
|
|
898
|
+
readonly reach?: boolean;
|
|
899
|
+
}
|
|
900
|
+
interface HandUseDef {
|
|
901
|
+
readonly id: string;
|
|
902
|
+
readonly body: HandUseBody;
|
|
903
|
+
readonly duration: number;
|
|
904
|
+
readonly keys: readonly HandUseKey[];
|
|
905
|
+
readonly note?: string;
|
|
906
|
+
}
|
|
907
|
+
/** An action reached: which one, and the share of the use's actions done with it (the third bite of three is 1). */
|
|
908
|
+
interface HandUseEvent {
|
|
909
|
+
readonly action: HandUseAction;
|
|
910
|
+
readonly share: number;
|
|
911
|
+
}
|
|
912
|
+
interface HandUsePlayer {
|
|
913
|
+
readonly def: HandUseDef;
|
|
914
|
+
readonly time: number;
|
|
915
|
+
readonly done: boolean;
|
|
916
|
+
/** Where the item is now, from the hand's rest: position in the eye's frame and rotation as Euler XYZ. */
|
|
917
|
+
pose(): {
|
|
918
|
+
position: [number, number, number];
|
|
919
|
+
rotation: [number, number, number];
|
|
920
|
+
};
|
|
921
|
+
/** Advances the use; answers the actions reached in this step. */
|
|
922
|
+
update(dt: number): HandUseEvent[];
|
|
923
|
+
cancel(): void;
|
|
924
|
+
}
|
|
925
|
+
declare const HAND_USES: readonly HandUseDef[];
|
|
926
|
+
/** The hand use with that id, among `defs`. */
|
|
927
|
+
declare const handUseOf: (id: string, defs?: readonly HandUseDef[]) => HandUseDef | undefined;
|
|
928
|
+
/** Farthest the hand carries an item from the eye (metres): an arm's length. */
|
|
929
|
+
declare const HAND_USE_REACH = 0.62;
|
|
930
|
+
/**
|
|
931
|
+
* 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
|
|
932
|
+
* 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.
|
|
933
|
+
*/
|
|
934
|
+
declare const aimHandUse: (def: HandUseDef, target: readonly [number, number, number]) => HandUseDef;
|
|
935
|
+
/** Plays a hand use: the pose between its keys, and its actions as the time passes them. */
|
|
936
|
+
declare const createHandUse: (def: HandUseDef) => HandUsePlayer;
|
|
937
|
+
|
|
938
|
+
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 Consumption, type ContainerDef, type CraftCheck, type CraftContext, type CraftOutcome, type CraftResult, DEFAULT_RULES, DURABILITY_KINDS, type DepletionRule, type DestructionObjectState, type Durability, type DurabilityKind, type FindData, type FindStack, type FindState, type FindsProvider, type FindsProviderOptions, type FindsQuery, 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, advanceAge, aimHandUse, bagOption, blockChance, canCraft, canTake, carriedKg, chargeLevel, checkItems, craft, createFindsProvider, createHandUse, createInventory, createItems, depletionFactor, failsToStart, fitsInside, freshness, handUseOf, itemLitres, itemsFromArsenal, loadState, maxLoadKg, moveToStorage, pieceBlock, placeFinds, repairPiece, resolveUse, rollByCategory, rollExplicitPool, scaleCount, shelfRatio, spawnAgeDays, spawnData, storageMultiplier, toLootTables, wearBlocked };
|