@adatechnology/game-interactables 0.9.0 → 0.11.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 +4 -0
- package/dist/index.d.ts +149 -3
- package/dist/index.global.js +317 -16
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +317 -16
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -201,6 +201,10 @@ straight past its length it stretches as its material does (E·A·strain, `elast
|
|
|
201
201
|
host says: a wire never holds back a falling pole, since what it takes in before it snaps is a few joules. `hangTail` gives what is left hanging from one end
|
|
202
202
|
after it snapped. `createSpanWire` of game-interactables-three draws it.
|
|
203
203
|
|
|
204
|
+
A wire fixed along what it runs on (a conduit strapped up a pole, an earth cable clipped down it) is laid with `wireRuns({ points, step, holderOf })`: the
|
|
205
|
+
runs of the wire by the part under each stretch of it, two runs that follow each other sharing the point at the seam. Whole they read as one wire; when the
|
|
206
|
+
parts come apart each run goes with its own and the wire is broken at the seam.
|
|
207
|
+
|
|
204
208
|
## Português
|
|
205
209
|
|
|
206
210
|
Runtime sem renderer para objetos interativos do mundo: portas, gavetas e tampas que se movem, recipientes com itens e loot determinístico por
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CarryHands, Thumbnail, ItemControls } from '@adatechnology/game-contracts';
|
|
1
|
+
import { CarryHands, Thumbnail, ItemControls, ItemControlsHost, ReachedItem } from '@adatechnology/game-contracts';
|
|
2
2
|
import { BodyId, SeamWorld, JointId, Vec3 as Vec3$1, Quat } from '@adatechnology/game-physics';
|
|
3
3
|
|
|
4
4
|
/** A movable part (door, drawer, lid) moved by a physics engine instead of by `t` stepping at `Motion.speed`. */
|
|
@@ -433,7 +433,63 @@ type UseSpec = {
|
|
|
433
433
|
basin: string;
|
|
434
434
|
kind: 'urine' | 'feces';
|
|
435
435
|
label: string;
|
|
436
|
-
};
|
|
436
|
+
} | WashUseSpec | DrinkUseSpec;
|
|
437
|
+
/**
|
|
438
|
+
* What a use needs at hand (`WashUseSpec.needs`, `DrinkUseSpec.needs`): each entry is one thing it needs, a catalogue id or a list of ids any of which does (`['cup',
|
|
439
|
+
* 'wine_glass']`). The host finds it in the hand or within reach (`ItemControlsHost.itemAt`).
|
|
440
|
+
*/
|
|
441
|
+
type UseNeed = string | readonly string[];
|
|
442
|
+
/** The dishes a sink washes (`WashUseSpec.dishes`): the catalogue ids that are dishes, the basin they lie dirty in, and where they go clean (the drainboard). */
|
|
443
|
+
interface WashDishesSpec {
|
|
444
|
+
readonly ids: readonly string[];
|
|
445
|
+
readonly basin: string;
|
|
446
|
+
/** Object-local spots on the drainboard, one per dish washed in turn (the last is reused when there are more dishes). */
|
|
447
|
+
readonly rack: readonly Vec3[];
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Washing at a fixture (`do: 'wash'`): the fixture's water is opened (`opensFixture`), a dose is taken out of the consumable it needs (`dose`: detergent, soap), the
|
|
451
|
+
* thing is scrubbed into foam with the hand use `clip`, the running water rinses the foam off (as fast as the fixture runs) and the fixture is closed again. `surface`
|
|
452
|
+
* is what is washed: a part of the body (`hands`, `hair`, `body`, `mouth`) or, with `dishes`, each dirty dish in the basin, which ends clean on the rack.
|
|
453
|
+
*/
|
|
454
|
+
interface WashUseSpec {
|
|
455
|
+
readonly id: string;
|
|
456
|
+
readonly do: 'wash';
|
|
457
|
+
readonly fixture: string;
|
|
458
|
+
readonly surface: string;
|
|
459
|
+
readonly clip: string;
|
|
460
|
+
readonly label: string;
|
|
461
|
+
readonly needs?: readonly UseNeed[];
|
|
462
|
+
/** The need a dose is taken out of (an index into `needs`), and how much (the item's usual dose when left out). */
|
|
463
|
+
readonly dose?: {
|
|
464
|
+
readonly need: number;
|
|
465
|
+
readonly amount?: number;
|
|
466
|
+
};
|
|
467
|
+
/** The use opens the fixture itself and closes it at the end. Default true. False: the water is the player's to open and close (a shower), the use never shuts it. */
|
|
468
|
+
readonly opensFixture?: boolean;
|
|
469
|
+
/** The use is only offered while the fixture runs (`needs_running` otherwise): washing under a shower already on. */
|
|
470
|
+
readonly requiresFlowing?: boolean;
|
|
471
|
+
readonly dishes?: WashDishesSpec;
|
|
472
|
+
/** Seconds of scrubbing per thing washed. Default `WASH_SCRUB_SECONDS`. */
|
|
473
|
+
readonly scrubSeconds?: number;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Drinking from a fixture (`do: 'drink'`): the hand takes the vessel it needs (a cup in the hand or within reach), holds it under the fixture while it runs until it is
|
|
477
|
+
* nearly full (`fillClip`), the fixture is closed, the vessel is drunk from (`clip`) and put back where it was.
|
|
478
|
+
*/
|
|
479
|
+
interface DrinkUseSpec {
|
|
480
|
+
readonly id: string;
|
|
481
|
+
readonly do: 'drink';
|
|
482
|
+
readonly fixture: string;
|
|
483
|
+
readonly needs: readonly UseNeed[];
|
|
484
|
+
readonly clip: string;
|
|
485
|
+
readonly label: string;
|
|
486
|
+
/** The hand use while it fills. Default `fill_cup`. */
|
|
487
|
+
readonly fillClip?: string;
|
|
488
|
+
/** Default true. */
|
|
489
|
+
readonly opensFixture?: boolean;
|
|
490
|
+
/** Litres drunk at most (what is left stays in the vessel). Default `DRINK_LITRES`. */
|
|
491
|
+
readonly litres?: number;
|
|
492
|
+
}
|
|
437
493
|
interface MirrorSpec {
|
|
438
494
|
id: string;
|
|
439
495
|
center: Vec3;
|
|
@@ -946,6 +1002,7 @@ interface WorldState {
|
|
|
946
1002
|
defaultTank: string | null;
|
|
947
1003
|
}
|
|
948
1004
|
|
|
1005
|
+
declare const FLOW_DEFAULTS: Readonly<Record<string, number>>;
|
|
949
1006
|
declare function createWorld(options?: WorldOptions): World;
|
|
950
1007
|
|
|
951
1008
|
/** FNV-1a hash of a string to a 32-bit unsigned integer. */
|
|
@@ -1139,6 +1196,34 @@ type HangTailParams = {
|
|
|
1139
1196
|
/** Straight down from its anchor to the ground, and the rest of its length lying along the ground toward `toward`. */
|
|
1140
1197
|
declare function hangTail(params: HangTailParams): Vec3[];
|
|
1141
1198
|
|
|
1199
|
+
/** One stretch of a wire and what holds it. */
|
|
1200
|
+
type WireRun<THolder> = {
|
|
1201
|
+
readonly holder: THolder;
|
|
1202
|
+
readonly points: Vec3[];
|
|
1203
|
+
};
|
|
1204
|
+
type WireRunsParams<THolder> = {
|
|
1205
|
+
readonly points: readonly Vec3[];
|
|
1206
|
+
/** Longest step (metres) between two points the holder is read at: where the holder changes is found within it. */
|
|
1207
|
+
readonly step: number;
|
|
1208
|
+
/** What holds the wire at a point (the part it is fixed on there). */
|
|
1209
|
+
readonly holderOf: (point: Vec3) => THolder;
|
|
1210
|
+
};
|
|
1211
|
+
/** The runs of a wire by what holds it, in order along it; two runs that follow each other share the point half way between their last and first readings. */
|
|
1212
|
+
declare function wireRuns<THolder>(params: WireRunsParams<THolder>): WireRun<THolder>[];
|
|
1213
|
+
|
|
1214
|
+
/** An axis-aligned box as [min x, min y, min z, max x, max y, max z], metres. */
|
|
1215
|
+
type CastBox = readonly number[];
|
|
1216
|
+
/** Metres a collar, a foot or a cap may stand out of the member, each side. */
|
|
1217
|
+
declare const COLLAR_REACH = 0.03;
|
|
1218
|
+
/** Metres a foot or a cap may stand apart from the end of the member (the seam between two primitives drawn end to end). */
|
|
1219
|
+
declare const END_GAP = 0.005;
|
|
1220
|
+
/** A collar drawn round the stretch: most of its height on it (a band on the seam of two goes with the one it is mostly on). */
|
|
1221
|
+
declare function wrapsMember(member: CastBox, collar: CastBox): boolean;
|
|
1222
|
+
/** A foot under the stretch or a cap over it, no taller than it. */
|
|
1223
|
+
declare function endsMember(member: CastBox, end: CastBox): boolean;
|
|
1224
|
+
/** Whether `other` is cast with the stretch `member`: a collar round it, or a foot or a cap on its end. */
|
|
1225
|
+
declare function castWithMember(member: CastBox, other: CastBox): boolean;
|
|
1226
|
+
|
|
1142
1227
|
/**
|
|
1143
1228
|
* What an object does with the player's hand or on its own time (`ObjectSpec.uses`), for `createObjectControls`: a device's program that runs for its seconds, what
|
|
1144
1229
|
* the hand holds put inside when it fits, a container emptied, a bowl filled from the hand, a basin soiled and washed by its flush. The rules are the data's: the
|
|
@@ -1157,6 +1242,8 @@ interface UsesState {
|
|
|
1157
1242
|
readonly device: string;
|
|
1158
1243
|
readonly left: number;
|
|
1159
1244
|
} | null;
|
|
1245
|
+
/** The use at the water running now (`wash`, `drink`), by id. */
|
|
1246
|
+
readonly routine: string | null;
|
|
1160
1247
|
}
|
|
1161
1248
|
|
|
1162
1249
|
/**
|
|
@@ -1197,4 +1284,63 @@ declare function createObjectControls(options: ObjectControlsOptions): ObjectCon
|
|
|
1197
1284
|
/** Whether a thing of `size` (any turn of it) goes into a box of `half` sizes: each of its sides, longest first, against the box's, longest first. */
|
|
1198
1285
|
declare function fitsInVolume(size: readonly [number, number, number], half: Vec3): boolean;
|
|
1199
1286
|
|
|
1200
|
-
|
|
1287
|
+
/**
|
|
1288
|
+
* The uses at a fixture's water (`do: 'wash'` and `do: 'drink'` of `ObjectSpec.uses`): whether they can run now (the things they need at hand, dishes dirty in the
|
|
1289
|
+
* basin, a vessel to drink from) and the routine each runs over its seconds once started: open the water, scrub foam in, let the water rinse it off, close the water;
|
|
1290
|
+
* or fill the vessel under the stream, close the water, drink and put the vessel back. Pure: the host lends the hand, the items, the body's hand uses and the foam
|
|
1291
|
+
* (`ItemControlsHost`); the water is the object's own fixture in its interactables world, so it runs as fast as the fixture does and stops when its tank is dry.
|
|
1292
|
+
*/
|
|
1293
|
+
|
|
1294
|
+
/** Seconds of scrubbing per thing washed, when the use does not say. */
|
|
1295
|
+
declare const WASH_SCRUB_SECONDS = 3;
|
|
1296
|
+
/** Litres drunk at most from a vessel filled at a tap: a glass of water. */
|
|
1297
|
+
declare const DRINK_LITRES = 0.25;
|
|
1298
|
+
/** A vessel filled at a tap is stopped this full (share of what it takes). */
|
|
1299
|
+
declare const FILL_SHARE = 0.85;
|
|
1300
|
+
/** Litres a mouth drinks per second. */
|
|
1301
|
+
declare const DRINK_LPS = 0.06;
|
|
1302
|
+
/** Seconds the hand takes to reach the tap's lever, and to put a thing down. */
|
|
1303
|
+
declare const REACH_SECONDS = 0.6;
|
|
1304
|
+
/** Seconds the water may take to start running after the lever opens (the fixture flows from the next step) before the tap counts as dry. */
|
|
1305
|
+
declare const DRY_SECONDS = 0.5;
|
|
1306
|
+
type SinkUseSpec = WashUseSpec | DrinkUseSpec;
|
|
1307
|
+
type SinkVerdict = {
|
|
1308
|
+
readonly available: true;
|
|
1309
|
+
} | {
|
|
1310
|
+
readonly available: false;
|
|
1311
|
+
readonly reason: string;
|
|
1312
|
+
readonly vars?: Record<string, string>;
|
|
1313
|
+
};
|
|
1314
|
+
/** What a routine says when it ends: a locale key and its words. */
|
|
1315
|
+
interface RoutineEnd {
|
|
1316
|
+
readonly key: string;
|
|
1317
|
+
readonly ok: boolean;
|
|
1318
|
+
readonly vars?: Record<string, string>;
|
|
1319
|
+
}
|
|
1320
|
+
/** A use at the water running over its seconds. `step` answers the end once it is over. */
|
|
1321
|
+
interface SinkRoutine {
|
|
1322
|
+
readonly use: string;
|
|
1323
|
+
step(dt: number): RoutineEnd | null;
|
|
1324
|
+
}
|
|
1325
|
+
interface SinkRoutines {
|
|
1326
|
+
start(use: SinkUseSpec, host: ItemControlsHost): SinkRoutine;
|
|
1327
|
+
}
|
|
1328
|
+
interface SinkUsesOptions {
|
|
1329
|
+
readonly spec: ObjectSpec;
|
|
1330
|
+
readonly world: World;
|
|
1331
|
+
readonly objectId: string;
|
|
1332
|
+
}
|
|
1333
|
+
/** The item of each need, or the ids of the first need nothing answers. */
|
|
1334
|
+
declare function findNeeds(needs: readonly UseNeed[], host: ItemControlsHost): {
|
|
1335
|
+
readonly items: readonly ReachedItem[];
|
|
1336
|
+
readonly missing?: readonly string[];
|
|
1337
|
+
};
|
|
1338
|
+
/** The dirty dishes lying in the use's basin. */
|
|
1339
|
+
declare function dirtyDishes(use: WashUseSpec, spec: ObjectSpec, host: ItemControlsHost): readonly ReachedItem[];
|
|
1340
|
+
/** Whether a use at the water can run now, and why not (a locale key with its words). `flowing`: the use's fixture runs now. */
|
|
1341
|
+
declare function sinkVerdict(use: SinkUseSpec, spec: ObjectSpec, host: ItemControlsHost, flowing: boolean): SinkVerdict;
|
|
1342
|
+
/** Litres per second the fixture runs fully open. */
|
|
1343
|
+
declare const fixtureFlowLps: (fixture: FixtureSpec | undefined) => number;
|
|
1344
|
+
declare function createSinkRoutines(options: SinkUsesOptions): SinkRoutines;
|
|
1345
|
+
|
|
1346
|
+
export { type Action, type ActiveEmitter, type BasinSpec, type BowlSpec, type BurnerSpec, COLLAR_REACH, CONTROLLED_OBJECT, type CastBox, type Chain, type ChainSpec, type ColliderOptions, type ColliderSpec, type ContainerSpec, DRINK_LITRES, DRINK_LPS, DRY_SECONDS, type DamageKind, type DamageSpec, type DestructionDelegate, type DestructionJoint, type DeviceKind, type DeviceSpec, type DrinkUseSpec, END_GAP, type EmitterBowl, type EmitterKind, type EmitterSpec, type EnginePartDriver, type EnginePartOptions, type EnginePartPhysics, FILL_SHARE, FLOW_DEFAULTS, FLUSH_RUN_SECONDS, type FixtureEmitters, type FixtureKind, type FixtureSpec, type FuelSourceSpec, type HangTailParams, type Interactable, type InteractablesLocale, type InteractionSpec, type ItemCatalog, type ItemDef, type ItemStack, type LootEntry, type LootTable, type LootTables, type MirrorSpec, type Motion, type MotionKind, type ObjectControls, type ObjectControlsOptions, type ObjectControlsState, type ObjectSpec, type PartDestruction, type PartDriver, type PartPhysics, type PartSpec, type Pose, REACH_SECONDS, type Rect, type RoutineEnd, type RunningEmitter, type SeatPose, type SeatResult, type SeatSpec, type SinkRoutine, type SinkRoutines, type SinkUseSpec, type SinkUsesOptions, type SinkVerdict, type SlotSpec, type SocketSpec, type SoftDriver, type SoftSpec, type Soil, type SolveSpanParams, type Span, type SpanMaterial, type SpanShape, type Strings, type SwitchSpec, type TankSpec, type TargetOptions, type Transform, type UseNeed, type UseSpec, type UsesState, type Vec3, WASH_SCRUB_SECONDS, type WashDishesSpec, type WashUseSpec, type WireRun, type WireRunsParams, type World, type WorldCollider, type WorldEvent, type WorldObject, type WorldOptions, type WorldState, alignY, buildChain, castWithMember, chainPoints, createEnginePartPhysics, createFixtureEmitters, createObjectControls, createSinkRoutines, createWorld, dirtyDishes, disposeChain, endsMember, findNeeds, fitsInVolume, fitsSize, fitsSlot, fixtureFlowLps, format, generateLoot, hangTail, hashString, localToWorld, locales, mergeColliders, pickLocale, polylineLength, poseOf, resolveStrings, rng, rotY, rotateAxis, sinkVerdict, solveSpan, spanStrength, wireRuns, worldToLocal, wrapsMember };
|