@adatechnology/game-test-room 0.7.0 → 0.9.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 CHANGED
@@ -91,6 +91,8 @@ room.bench()?.set('size', 2) // clamped and snapped; false for an unknown id, a
91
91
  room.metrics() // { room: { fps, draw_calls, ... }, module: { particles: 120 } }
92
92
  ```
93
93
 
94
+ The room's explosions take the blast options of `game-destruction` (`createTestRoom({ blast: { shelter: true } })`, `room.blast()`, `room.setBlast({ fragmentHits: true })`); three HUD toggles (Shelter, Fragments, Confinement; Abrigo, Estilhaços, Confinamento) flip them, and the numbers of the last blast show as the room metrics `blast_shelter` (% that reached the most sheltered target), `blast_confinement` and `blast_fragments`, and as a `blast_report` line in the log.
95
+
94
96
  A module can put a **sheet** on the panel (`host.bench.sheet(sheet)`, `BenchSheet` of the contracts): a card with a kicker, a title, a text, facts, steps, colour swatches and a timeline of named segments whose playhead follows one of the module's numeric metrics.
95
97
  The room also runs the film of the liquids that have one (`createFilmManager` of `game-fluids-three`): a leak of fuel, oil or blood drips into grids on the floor near the camera.
96
98
 
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import * as THREE_NS from 'three';
2
- import { DestructibleSpec, Vec3, DestructionWorld, DestructionOptions, DestructionEvent, MaterialDef } from '@adatechnology/game-destruction';
2
+ import { AudioEngine } from '@adatechnology/game-audio';
3
+ import { DestructibleSpec, Vec3, DestructionWorld, BlastOptions, DestructionOptions, DestructionEvent, MaterialDef } from '@adatechnology/game-destruction';
3
4
  export { DestructionEvent, Vec3 } from '@adatechnology/game-destruction';
4
5
  import { SpecFromObjectOptions, DestructionRenderer, Quality } from '@adatechnology/game-destruction-three';
5
6
  import { Arsenal, WeaponState, WeaponDef } from '@adatechnology/game-weapons';
6
7
  import { FluidRenderer } from '@adatechnology/game-fluids-three';
7
8
  import { ContainerSpec, FluidWorld, LiquidDef, ItemUseDef, SurfaceSpec } from '@adatechnology/game-fluids';
8
- import { ModuleControl, ControlValue, ModuleLayer, DestructibleImpl, AnimationClipSpec, TestableModule } from '@adatechnology/game-contracts';
9
+ import { ModuleControl, ControlValue, ModuleLayer, DestructibleImpl, AnimationClipSpec, EnvironmentBus, TestableModule } from '@adatechnology/game-contracts';
9
10
  export { AnimationClipSpec, DestructibleImpl, ItemAnimationContract, ModuleScenario, TestableItem, TestableModule } from '@adatechnology/game-contracts';
10
11
 
11
12
  type NewEntry = NewLogEntry;
@@ -97,6 +98,12 @@ interface HudState {
97
98
  timeScale: number;
98
99
  fast: boolean;
99
100
  tap: boolean;
101
+ /** The room's blast options that are on. */
102
+ blast: {
103
+ shelter: boolean;
104
+ fragmentHits: boolean;
105
+ confinement: boolean;
106
+ };
100
107
  quality: string;
101
108
  objects: number;
102
109
  }
@@ -194,10 +201,19 @@ interface TestRoomOptions {
194
201
  /** Called for every destruction event (to log, play sounds, sync over LAN). Fluid events reach the log too. */
195
202
  onEvent?: (event: DestructionEvent) => void;
196
203
  onSound?: (key: string, point: Vec3, volume: number) => void;
204
+ /**
205
+ * The sound engine of the room (@adatechnology/game-audio): the destruction renderer's sound keys play on it, and modules get it as `host.audio`.
206
+ * Default: a new engine of the room's own (it makes no AudioContext until the first sound); `false` for a silent room.
207
+ */
208
+ audio?: AudioEngine | false;
209
+ /** The environment store modules get as `host.environment` (the weather module writes it, the others read it). Default: a new one with a calm dry day. */
210
+ environment?: EnvironmentBus;
197
211
  /** Show the built-in HUD and panels (default true). */
198
212
  ui?: boolean;
199
213
  /** Room counters the bench panel shows and `TestRoom.metrics()` returns (default all); `false` for none. */
200
214
  metrics?: readonly RoomMetricId[] | false;
215
+ /** Blast options every explosion of the room starts with (`shelter`, `fragmentHits`, `confinement`; default all off). The HUD toggles them and `TestRoom.setBlast` changes them. */
216
+ blast?: BlastOptions;
201
217
  /**
202
218
  * Module bench state. `state` maps a module id to its encoded state, restored when that module is first loaded (a module reloaded
203
219
  * keeps its live state instead) before its first changes are sent; ids are per module, so two modules may share a control id.
@@ -209,7 +225,9 @@ interface TestRoomOptions {
209
225
  };
210
226
  }
211
227
  /** Counters the room measures itself. `fps` and `frame_ms` use the real frame time, so slow motion does not change them. */
212
- type RoomMetricId = 'fps' | 'frame_ms' | 'draw_calls' | 'triangles' | 'objects' | 'fragments' | 'particles' | 'decals';
228
+ type RoomMetricId = 'fps' | 'frame_ms' | 'draw_calls' | 'triangles' | 'objects' | 'fragments' | 'particles' | 'decals'
229
+ /** Of the last blast, once the room's blast options are on: the share that reached the most sheltered target (%), the pressure multiplier, the fragment hits. */
230
+ | 'blast_shelter' | 'blast_confinement' | 'blast_fragments';
213
231
  /** A module control as the room holds it: the declaration with the module's patches applied, and its value (none for an action). */
214
232
  type BenchControl = ModuleControl & {
215
233
  readonly disabled: boolean;
@@ -238,6 +256,10 @@ interface SpawnedObject {
238
256
  movable: boolean;
239
257
  }
240
258
  interface TestRoom {
259
+ /** The room's sound engine, or `null` in a silent room. */
260
+ readonly audio: AudioEngine | null;
261
+ /** The environment store lent to modules as `host.environment`. */
262
+ readonly environment: EnvironmentBus;
241
263
  readonly world: DestructionWorld;
242
264
  readonly renderer: DestructionRenderer;
243
265
  readonly scene: THREE_NS.Scene;
@@ -281,6 +303,9 @@ interface TestRoom {
281
303
  tilt(rad: number): void;
282
304
  /** Open or close the tap over the table (default: toggle). Returns whether it is open. */
283
305
  toggleTap(on?: boolean): boolean;
306
+ /** The blast options the room's explosions use now, and a way to change them (each key replaces the old one; `undefined` clears it). */
307
+ blast(): BlastOptions;
308
+ setBlast(options: BlastOptions): void;
284
309
  /** Stop the simulation (time, physics, animations, tools, walks): the UI, the camera and the log stay live. `step` and `update` do nothing until `resume`. Scenarios run unpaused. */
285
310
  pause(): void;
286
311
  resume(): void;