@adatechnology/game-interactables-household 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/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { ItemCatalog, LootTables, Strings, Vec3, ObjectSpec, Motion } from '@adatechnology/game-interactables';
1
+ import { ItemCatalog, LootTables, Strings, Vec3, ObjectSpec, Motion, PartSpec, PartDestruction } from '@adatechnology/game-interactables';
2
2
  import { PropItem, PropsApi, Primitive } from '@adatechnology/game-props3d';
3
+ import { AnimationClipSpec, AnimationKey, AnimationPose, PartSolid, JointKind, PartSpec as PartSpec$1, DestructibleSpec, ModuleItemFluid } from '@adatechnology/game-contracts';
3
4
 
4
5
  /**
5
6
  * The api the host implements. It is the props3d api plus `part`: everything drawn inside `draw` belongs to a movable part and is
@@ -185,4 +186,122 @@ declare function motionPoint(p: Vec3, pivot: Vec3, m: Motion, t: number): Vec3;
185
186
  /** Floor rect [x0, z0, x1, z1] covered by object-local points while the part goes from t = 0 to t = 1. */
186
187
  declare function sweepOf(points: Vec3[], pivot: Vec3, m: Motion, margin?: number): [number, number, number, number];
187
188
 
188
- export { type ContentsEntry, HOUSEHOLD_ITEM_IDS, HOUSEHOLD_REGIONS, HOUSEHOLD_TYPES, type Household, type HouseholdApi, type HouseholdGroup, type HouseholdItem, type HouseholdOptions, type HouseholdRecorder, type HouseholdType, type HouseholdTypeDef, type RecordedPart, type Region, STOVE_WALL_GAP, WALL_PLATE, cornersOf, createHousehold, createRecorder, motionPoint, sweepOf };
189
+ type Triple = [number, number, number];
190
+ /** A box as `[minX, minY, minZ, maxX, maxY, maxZ]`. */
191
+ type Box6 = number[];
192
+ type PrimitiveKind = 'box' | 'cylinder' | 'plane' | 'leaf' | 'lathe';
193
+ /** What one primitive call takes up: its render material key, its box and its volume. */
194
+ interface PrimitiveShape {
195
+ key: string;
196
+ aabb: Box6;
197
+ vol: number;
198
+ }
199
+ /** One recorded primitive call, with the member it is a stretch of (a pole's shaft laid in stretches). */
200
+ interface RecordedPrimitive extends PrimitiveShape {
201
+ fn: PrimitiveKind;
202
+ args: unknown[];
203
+ member?: number;
204
+ }
205
+
206
+ /** A clip of an assembled object: every key poses the parts it moves. */
207
+ type AssembledClip = AnimationClipSpec & {
208
+ keys: Array<AnimationKey & {
209
+ parts: Record<string, AnimationPose>;
210
+ }>;
211
+ };
212
+
213
+ /** What is cast with a stretch of a member (`castWithMember` of game-interactables): a collar round it, a foot or a cap on its end. */
214
+ type CastWith = (member: Box6, other: Box6) => boolean;
215
+
216
+ interface PieceBase {
217
+ id: string;
218
+ indices: number[];
219
+ box: Box6;
220
+ vol: number;
221
+ material: string;
222
+ solids?: PartSolid[];
223
+ }
224
+ /** A piece of the static body: what is drawn outside every movable part. */
225
+ interface BodyPiece extends PieceBase {
226
+ /** The render material key the piece is mostly drawn with. */
227
+ key: string;
228
+ mover: false;
229
+ }
230
+ /** A movable part of the spec (door, drawer, lid, knob), a piece of its own. */
231
+ interface MoverPiece extends PieceBase {
232
+ source: PartSpec;
233
+ mover: true;
234
+ tag: Partial<PartDestruction>;
235
+ }
236
+ type AssembledPiece = BodyPiece | MoverPiece;
237
+
238
+ interface AssembledJoint {
239
+ a: string;
240
+ b: string;
241
+ kind: JointKind;
242
+ }
243
+
244
+ /** A part of an assembled object: always a box (the pieces are measured as the boxes round what they draw). */
245
+ type AssembledPart = Omit<PartSpec$1, 'shape'> & {
246
+ shape: {
247
+ kind: 'box';
248
+ size: Triple;
249
+ };
250
+ tags: string[];
251
+ };
252
+
253
+ type AssembledDestructible = Omit<DestructibleSpec, 'parts' | 'joints'> & {
254
+ name: string;
255
+ parts: AssembledPart[];
256
+ joints: AssembledJoint[];
257
+ tags: string[];
258
+ };
259
+ /** One household type assembled: what the rooms build the object from. */
260
+ interface HouseholdAssembly {
261
+ type: string;
262
+ spec: ObjectSpec;
263
+ /** The pieces of the static body (drawn as one `part` group each by `draw`). */
264
+ pieces: BodyPiece[];
265
+ /** The movable parts (doors, drawers, lids, knobs), each a piece of its own. */
266
+ movers: MoverPiece[];
267
+ /** The assembly's id of each part of the spec. */
268
+ partIds: Map<string, string>;
269
+ destructible: AssembledDestructible;
270
+ /** Clips that open and close the doors, turn the knobs. */
271
+ animations: AssembledClip[];
272
+ /** The water a fixture holds (sinks, toilet), or none. */
273
+ fluid: ModuleItemFluid | undefined;
274
+ /** The static primitives the pieces were planned on (a member laid in stretches). */
275
+ statics: RecordedPrimitive[];
276
+ }
277
+ interface AssembleParams {
278
+ household: Household;
279
+ type: string;
280
+ castWith?: CastWith;
281
+ }
282
+ /** Assembles one household type: the drawing is measured, never drawn. */
283
+ declare function assembleHouseholdType({ household, type, castWith }: AssembleParams): HouseholdAssembly;
284
+ /**
285
+ * Draws an assembled object through `api` (the host's mesh api): the movable parts as the builder draws them, the static body as one `part` group per piece of the
286
+ * assembly, so the drawing and the destruction share the same pieces. Returns the spec the builder gave.
287
+ */
288
+ declare function drawHouseholdAssembly(params: {
289
+ household: Household;
290
+ assembly: HouseholdAssembly;
291
+ api: HouseholdApi;
292
+ }): ObjectSpec;
293
+ type HouseholdLocale = 'en' | 'pt-BR';
294
+ interface HouseholdAssemblies {
295
+ /** The household of the locale (names, strings), made once. */
296
+ household(locale: HouseholdLocale): Household;
297
+ /** The assembly of a type in the locale, made once. */
298
+ assemble(locale: HouseholdLocale, type: string): HouseholdAssembly;
299
+ /** Draws the type through `api` as it was assembled (see `drawHouseholdAssembly`). */
300
+ draw(locale: HouseholdLocale, type: string, api: HouseholdApi): ObjectSpec;
301
+ }
302
+ /** The assemblies of the whole catalogue, by locale, each made once: what a room holds to show household objects. */
303
+ declare function createHouseholdAssemblies(options?: {
304
+ castWith?: CastWith;
305
+ }): HouseholdAssemblies;
306
+
307
+ export { type AssembledDestructible, type AssembledJoint, type AssembledPart, type AssembledPiece, type BodyPiece, type CastWith, type ContentsEntry, HOUSEHOLD_ITEM_IDS, HOUSEHOLD_REGIONS, HOUSEHOLD_TYPES, type Household, type HouseholdApi, type HouseholdAssemblies, type HouseholdAssembly, type HouseholdGroup, type HouseholdItem, type HouseholdLocale, type HouseholdOptions, type HouseholdRecorder, type HouseholdType, type HouseholdTypeDef, type MoverPiece, type RecordedPart, type Region, STOVE_WALL_GAP, WALL_PLATE, assembleHouseholdType, cornersOf, createHousehold, createHouseholdAssemblies, createRecorder, drawHouseholdAssembly, motionPoint, sweepOf };