@adatechnology/game-vehicles 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,824 @@
1
+ import { ToolKind, JointKind, Vec3, MaterialId, DestructibleImpl, AnimationClipSpec } from '@adatechnology/game-contracts';
2
+
3
+ var plate = {
4
+ band: "BRAZIL"
5
+ };
6
+ var parts = {
7
+ tire_front: "Front {side} tire",
8
+ tire_rear: "Rear {side} tire",
9
+ bike_tire_front: "Front tire",
10
+ bike_tire_rear: "Rear tire",
11
+ headlight: "{Side} headlight",
12
+ taillight: "{Side} taillight",
13
+ led_bar: "LED bar",
14
+ taillight_bar: "Taillight bar",
15
+ hood: "Hood",
16
+ engine: "Engine",
17
+ engine_electric: "Electric motor and inverter",
18
+ radiator: "Radiator",
19
+ bumper_front: "Front bumper",
20
+ bumper_rear: "Rear bumper",
21
+ fuel_tank: "Fuel tank",
22
+ diesel_tank: "Diesel tank",
23
+ windshield: "Windshield",
24
+ rear_window: "Rear window",
25
+ window_front: "Front window",
26
+ window_rear: "Rear window",
27
+ quarter_glass: "Rear quarter glass",
28
+ cab_window: "Cab window",
29
+ window: "Window",
30
+ glass: "Glass",
31
+ glass_side: "{label} ({side})",
32
+ glass_side_m: "{label} ({side})",
33
+ track: "{Side} track"
34
+ };
35
+ var texts = {
36
+ high_voltage: "HIGH VOLTAGE",
37
+ who: "whoever is on that side",
38
+ no_effect: ""
39
+ };
40
+ var blast = {
41
+ lethal: "Lethal radius {m} m",
42
+ injury: "Injuries up to {m} m",
43
+ tank_explosion: "Tank explosion",
44
+ explosion: "Explosion"
45
+ };
46
+ var zones = {
47
+ windshield: "Windshield",
48
+ glass_left: "Left side glass",
49
+ glass_right: "Right side glass",
50
+ rear_window: "Rear window",
51
+ light_bar_front: "Front light bar",
52
+ taillight: "Taillight",
53
+ light_bar_rear: "Taillight bar",
54
+ headlight: "{Side} headlight",
55
+ taillight_side: "{Side} taillight",
56
+ wheels: "Wheels",
57
+ wheels_axle_front: "Front axle wheels",
58
+ wheels_axle_rear: "Rear axle wheels",
59
+ wheels_axle_n: "Axle {n} wheels",
60
+ wheel_front_side: "Front {side} wheel",
61
+ wheel_rear_side: "Rear {side} wheel",
62
+ wheel_front: "Front wheel",
63
+ wheel_rear: "Rear wheel",
64
+ bumper_front: "Front bumper",
65
+ bumper_rear: "Rear bumper",
66
+ hood: "Hood",
67
+ fender_front: "Front {side} fender",
68
+ door_front: "Front {side} door",
69
+ door: "{Side} door",
70
+ door_rear: "Rear {side} door",
71
+ side_rear: "Rear {side} side panel",
72
+ roof: "Pillars and roof",
73
+ cargo_bed: "Cargo bed",
74
+ trunk_lid: "Trunk lid",
75
+ tail_lid: "Rear lid",
76
+ underbody: "Underbody and suspension",
77
+ engine: "Engine",
78
+ engine_electric: "Electric motor",
79
+ radiator: "Radiator",
80
+ fuel_tank: "Fuel tank",
81
+ battery: "Battery",
82
+ diesel_tank: "Diesel tank",
83
+ fairing: "Fairing and headlight",
84
+ handlebar_levers: "Handlebar and levers",
85
+ tank: "Tank",
86
+ seat_rack: "Seat and rack",
87
+ handlebar: "Handlebar",
88
+ frame: "Frame",
89
+ seat_tail: "Seat and tail",
90
+ exhaust: "Exhaust",
91
+ grille_front: "Grille and front",
92
+ engine_hood: "Engine hood",
93
+ fender_rear: "Rear {side} fender",
94
+ operator_station: "Operator station",
95
+ bus_front: "Bus front",
96
+ cab_front: "Cab (front)",
97
+ bus_front_side: "Front, {side} side",
98
+ cab_side: "Cab, {side} side",
99
+ body_saloon: "Saloon",
100
+ body_tank: "Tank",
101
+ body_body: "Body",
102
+ body_box: "Box",
103
+ body_side: "{label} ({side} side)",
104
+ body_rear: "{label} (rear)",
105
+ chassis: "Chassis",
106
+ armor_front: "Front armor",
107
+ armor_side: "{Side} armor",
108
+ armor_rear: "Rear armor",
109
+ cannon: "Cannon",
110
+ weapon: "Weapon",
111
+ turret: "Roof and turret",
112
+ track: "{Side} track",
113
+ wheels_side: "{Side} side wheels",
114
+ bow: "Bow",
115
+ port_side: "Port side",
116
+ starboard_side: "Starboard side",
117
+ stern: "Stern",
118
+ deck: "Deck and cabin",
119
+ outboard_engine: "Outboard engine",
120
+ nose_propeller: "Nose and propeller",
121
+ nose_engine: "Nose and engine",
122
+ cabin_glass: "Cabin and glass",
123
+ wing: "{Side} wing",
124
+ rear_fuselage: "Rear fuselage",
125
+ tail: "Tail",
126
+ landing_gear: "Landing gear",
127
+ wing_tanks: "Tanks (in the wings)",
128
+ nose_bubble: "Nose and bubble",
129
+ cabin: "Cabin",
130
+ tail_cone: "Tail cone",
131
+ main_rotor: "Main rotor",
132
+ tail_rotor: "Tail rotor",
133
+ skids: "Skids",
134
+ engine_transmission: "Engine and transmission",
135
+ front: "Front",
136
+ side: "{Side} side",
137
+ rear: "Rear",
138
+ top: "Roof"
139
+ };
140
+ var who = {
141
+ front_seats: "whoever rides in front",
142
+ rear_seats: "whoever rides in the back",
143
+ driver: "the driver",
144
+ passenger: "the front passenger",
145
+ rear_left: "whoever rides in the back on the left",
146
+ rear_right: "whoever rides in the back on the right",
147
+ left_side: "whoever is on the left side",
148
+ right_side: "whoever is on the right side",
149
+ cargo: "the cargo",
150
+ tractor_driver: "the tractor driver",
151
+ boarding_door: "the boarding door",
152
+ helper: "the helper",
153
+ seated_side: "whoever is seated on that side",
154
+ back_seats: "whoever rides at the back",
155
+ crew_side: "the crew on that side",
156
+ boat_side: "whoever is on that side of the boat",
157
+ pilot: "the pilot",
158
+ passengers: "the passengers"
159
+ };
160
+ var bands = {
161
+ intact: "Intact",
162
+ scratched: "Scratched",
163
+ dented: "Dented",
164
+ destroyed: "Destroyed",
165
+ torn_off: "Torn off"
166
+ };
167
+ var groups = {
168
+ "default": "Vehicles"
169
+ };
170
+ var sides = {
171
+ left: "left",
172
+ right: "right",
173
+ leftM: "left",
174
+ rightM: "right"
175
+ };
176
+ var matchers = {
177
+ windshield: "windshield",
178
+ rear: "rear",
179
+ side: "left|right",
180
+ tank: "tank|tanker",
181
+ diesel: "diesel",
182
+ fuel: "gasoline|petrol|ethanol|alcohol|fuel",
183
+ glass_id: "glass|window|windshield|rear_window"
184
+ };
185
+ var ui = {
186
+ front: "▲ FRONT",
187
+ inside: "Inside",
188
+ aria: "Damage map seen from above, front up",
189
+ noZones: "This vehicle has no zones.",
190
+ health: "Overall health"
191
+ };
192
+ var mechanics = {
193
+ chassis: "Chassis frame",
194
+ battery: "Battery",
195
+ alternator: "Alternator",
196
+ gearbox: "Gearbox",
197
+ brakes: "Brakes",
198
+ steering: "Steering",
199
+ shock_absorbers: "Shock absorbers",
200
+ tow_hitch: "Tow hitch",
201
+ oil_pan: "Oil pan",
202
+ mirror: "{Side} mirror",
203
+ tyre: "{zone} tyre",
204
+ pillar_a: "{Side} A pillar",
205
+ pillar_c: "{Side} C pillar",
206
+ engine: "Engine",
207
+ radiator: "Radiator",
208
+ fuel_tank: "Fuel tank"
209
+ };
210
+ var en = {
211
+ plate: plate,
212
+ parts: parts,
213
+ texts: texts,
214
+ blast: blast,
215
+ zones: zones,
216
+ who: who,
217
+ bands: bands,
218
+ groups: groups,
219
+ sides: sides,
220
+ matchers: matchers,
221
+ ui: ui,
222
+ mechanics: mechanics
223
+ };
224
+
225
+ /** Every user-visible string of the engine, grouped by area. Missing keys of a locale fall back to English. */
226
+ type LocaleStrings = typeof en;
227
+ /** A locale given by the caller: any subset of {@link LocaleStrings}. */
228
+ type PartialLocaleStrings = {
229
+ [K in keyof LocaleStrings]?: Partial<LocaleStrings[K]>;
230
+ };
231
+ /** Registers (or extends) a locale under a code such as `es` or `pt-BR`. Missing keys fall back to English. */
232
+ declare function registerLocale(code: string, strings: PartialLocaleStrings | Record<string, any>): void;
233
+ /** Codes of the registered locales. */
234
+ declare function listLocales(): string[];
235
+ /**
236
+ * Resolves a locale to a complete string table.
237
+ * Accepts a registered code (`'pt-BR'`; `'pt'` finds `'pt-BR'`, `'en-US'` finds `'en'`), or a partial table that overrides English.
238
+ */
239
+ declare function resolveStrings(locale?: string | PartialLocaleStrings): LocaleStrings;
240
+ /** Replaces `{name}` in a template. `{Name}` (capital first letter) capitalises the value of `name`. Unknown names stay as written. */
241
+ declare function format(template: string, vars?: Record<string, unknown>): string;
242
+ /** A function that looks up a dotted key (`'zones.hood'`) and fills in its variables. */
243
+ type Translate = (key: string, vars?: Record<string, unknown>) => string;
244
+ /**
245
+ * Builds the translate function of a string table. The variable `s` (-1 left, +1 right) is expanded to
246
+ * `{side}` (feminine word) and `{sideM}` (masculine word), so one template reads right in languages with grammatical gender.
247
+ */
248
+ declare function createTranslate(strings: LocaleStrings): Translate;
249
+
250
+ /**
251
+ * Public types of `@adatechnology/game-vehicles`.
252
+ * three.js objects are typed `any` on purpose: the host passes its own `THREE` namespace at runtime, so the package does not bind to one version.
253
+ */
254
+
255
+ /** A three.js `Vector3`, `Object3D`, `Mesh`, ... of the host's `THREE`. */
256
+ type ThreeObject = any;
257
+ /** A three.js `Vector3` of the host's `THREE`. */
258
+ type ThreeVector = any;
259
+ type BuildState = 'intact' | 'damaged' | 'modified';
260
+ /** Index of a damage band: 0 intact, 1 scratched, 2 dented, 3 destroyed, 4 torn off. */
261
+ type BandIndex = 0 | 1 | 2 | 3 | 4;
262
+ type BandId = 'intact' | 'scratched' | 'dented' | 'destroyed' | 'torn_off';
263
+ interface Band {
264
+ id: BandId;
265
+ /** Display name (from the locale). */
266
+ name: string;
267
+ /** Lowest health that still belongs to the band. */
268
+ min: number;
269
+ /** Health a button/scenario uses to put a zone in this band. */
270
+ health: number;
271
+ /** CSS colour used by the UI widgets. */
272
+ color: string;
273
+ }
274
+ /** Where a vehicle is built: the context returned by {@link VehicleKit.build}. */
275
+ interface VehicleContext {
276
+ /** Add this to the scene. */
277
+ root: ThreeObject;
278
+ /** The vehicle itself (a child of `root`); zones, parts and meshes live here. */
279
+ vehicle: ThreeObject;
280
+ key: string;
281
+ state: BuildState;
282
+ spec: VehicleSpec;
283
+ meta: VehicleMeta;
284
+ zones: DamageZone[];
285
+ zoneState: ZoneState;
286
+ /** Deterministic random generator seeded from the vehicle key and state. */
287
+ rand: () => number;
288
+ parts: VehiclePart[];
289
+ log: unknown[];
290
+ zoneErrors?: string[];
291
+ [key: string]: any;
292
+ }
293
+ interface VehicleMeta {
294
+ kind?: 'car' | 'bike' | 'truck' | 'bus' | 'tank' | 'boat' | 'plane' | 'heli' | string;
295
+ /** x of the front / rear of the bounding body (+x is forward). */
296
+ front?: number;
297
+ rear?: number;
298
+ length?: number;
299
+ width?: number;
300
+ /** Ground clearance and height of the body above it. */
301
+ clearance?: number;
302
+ bodyHeight?: number;
303
+ belt?: number;
304
+ top?: number;
305
+ /** Optional text for the body zone label; `bodyKind: 'box'` makes the single body zone a box. */
306
+ bodyLabel?: string;
307
+ bodyKind?: 'box' | 'body';
308
+ exhaust?: ThreeVector | false;
309
+ exhaustDir?: ThreeVector;
310
+ /** Replaces the default armour (state `modified`). */
311
+ armor?: (c: VehicleContext, kit: VehicleKit) => void;
312
+ [key: string]: any;
313
+ }
314
+ interface VehicleSpec {
315
+ /** Unique id of the vehicle. */
316
+ key: string;
317
+ /** Seeds the random streams (look and damage) instead of `key`. Lets a vehicle be renamed without changing how it looks. */
318
+ seedKey?: string;
319
+ /** Display name. */
320
+ name?: string;
321
+ /** Fleet group (see `configure({ groups })`). */
322
+ group?: string;
323
+ /** Fuel id (a key of `configure({ fuels })`) or `'electric'` / `'none'`. */
324
+ fuel?: string;
325
+ build?: BuildFunction;
326
+ [key: string]: any;
327
+ }
328
+ /** Builds the geometry of a vehicle into the context. */
329
+ type BuildFunction = (c: VehicleContext, kit: VehicleKit) => void;
330
+ interface VehiclePart {
331
+ kind: string;
332
+ label: string;
333
+ key?: string;
334
+ pos: ThreeVector;
335
+ [key: string]: any;
336
+ }
337
+ /** A part label: a plain string, or a locale key (`parts.<key>`) with an optional text override. */
338
+ type PartLabel = string | {
339
+ key: string;
340
+ label?: string;
341
+ };
342
+ /** A damage zone of a built vehicle. */
343
+ interface DamageZone {
344
+ id: string;
345
+ /** Display name. */
346
+ name: string;
347
+ /** Relative weight in the overall health. */
348
+ weight: number;
349
+ /** Health (0..100) when the zone is untouched. */
350
+ health: number;
351
+ band: number;
352
+ internal?: boolean;
353
+ owned?: boolean;
354
+ tags: string[];
355
+ /** `[xMin, xMax, zMin, zMax]` rectangle on the top-down damage map. */
356
+ map: [number, number, number, number];
357
+ box: ThreeObject;
358
+ /** Overrides the id used to seed the random damage (keeps the output of an earlier pack identical). */
359
+ seedId?: string;
360
+ [key: string]: any;
361
+ }
362
+ /** Health per zone id (0..100) and scenario flags. */
363
+ interface ZoneState {
364
+ health: Record<string, number>;
365
+ flags: Record<string, boolean>;
366
+ }
367
+ interface ScenarioResult {
368
+ health: Record<string, number>;
369
+ flags: Record<string, boolean>;
370
+ scenario: string;
371
+ }
372
+ /** The object a scenario's `zone` / `init` callbacks receive. */
373
+ interface ScenarioContext {
374
+ c: VehicleContext;
375
+ meta: VehicleMeta;
376
+ front: number;
377
+ rear: number;
378
+ length: number;
379
+ width: number;
380
+ clearance: number;
381
+ top: number;
382
+ /** Deterministic random in [0, 1). */
383
+ rand: () => number;
384
+ /** Stores the health (0..100, rounded) of a zone. */
385
+ set(zone: DamageZone, health: number): void;
386
+ flags: Record<string, boolean>;
387
+ health: Record<string, number>;
388
+ /** Body types that count as bodywork (`panel`, `door`, `roof`, `lid`, `hood`, `bumper`). */
389
+ bodyTypes: Record<string, number>;
390
+ clamp(v: number, lo: number, hi: number): number;
391
+ /** Centre of the zone being visited. */
392
+ center: ThreeVector | null;
393
+ /** True when the zone being visited is a windshield. */
394
+ isWindshield: boolean;
395
+ /** Scratch space: `init` can store values here for `zone` to read. */
396
+ [key: string]: any;
397
+ }
398
+ interface ScenarioDefinition {
399
+ id: string;
400
+ /** Seeds the random stream of the scenario instead of `id`. Lets a scenario be renamed without changing its result. */
401
+ seedId?: string;
402
+ /** Display name. */
403
+ name: string;
404
+ init?(x: ScenarioContext): void;
405
+ zone(zone: DamageZone, x: ScenarioContext): void;
406
+ }
407
+ /** Visual effect of a scenario flag (`flipped`, `burnt`, `abandoned` or a plugin's own). */
408
+ interface FlagEffect {
409
+ /** Lower runs first (default 50). */
410
+ order?: number;
411
+ /** Run the settle step after applying (default true). */
412
+ settle?: boolean;
413
+ apply(c: VehicleContext, flags: Record<string, boolean>, kit: VehicleKit): void;
414
+ }
415
+ interface FluidDefinition {
416
+ fresh?: string;
417
+ dry?: string;
418
+ /** Seconds until dry. */
419
+ dryTime?: number;
420
+ roughFresh?: number;
421
+ roughDry?: number;
422
+ metalFresh?: number;
423
+ metalDry?: number;
424
+ /** Wipers and rain remove it while fresh. */
425
+ wipeable?: boolean;
426
+ /** Fully custom fluid: return `true` to remove it. */
427
+ update?(c: VehicleContext, fluid: any, dt: number, index: number): boolean | void;
428
+ [key: string]: any;
429
+ }
430
+ interface ZoneEffect {
431
+ [key: string]: any;
432
+ }
433
+ interface BandOverride {
434
+ name?: string;
435
+ color?: string;
436
+ min?: number;
437
+ health?: number;
438
+ }
439
+ /** Text overrides. Anything left out comes from the locale. */
440
+ interface KitTexts {
441
+ /** Placeholder for the party that caused a damage (`{who}` in zone texts). */
442
+ who?: string;
443
+ /** Text when a zone has no visible effect. */
444
+ noEffect?: string;
445
+ plate?: string;
446
+ /** Overrides of the `ui.*` locale strings. */
447
+ ui?: Record<string, string>;
448
+ }
449
+ /** Everything a content pack can set; also accepted by `createVehicleKit`. */
450
+ interface KitConfiguration {
451
+ bands?: BandOverride[];
452
+ zoneEffects?: Record<string, ZoneEffect | ((z: DamageZone, health: number) => unknown)>;
453
+ partEffects?: Record<string, string>;
454
+ scenarios?: ScenarioDefinition[];
455
+ flagEffects?: Record<string, FlagEffect>;
456
+ fluids?: Record<string, FluidDefinition>;
457
+ /** Fuel id to its definition (flammability, colour, label, ...). */
458
+ fuels?: Record<string, any>;
459
+ groups?: string[];
460
+ waterGroups?: Record<string, any>;
461
+ palette?: {
462
+ rust?: string | number;
463
+ };
464
+ plate?: string;
465
+ texts?: KitTexts;
466
+ /** Fluid type of the stain an impact leaves (null: none). */
467
+ impactStain?: string | null;
468
+ defaultSplat?: string;
469
+ defaultGroup?: string;
470
+ /** Scenario applied to a `'damaged'` build when no zone state is given. */
471
+ damagedScenario?: string | null;
472
+ }
473
+ /** The live configuration of a kit (what `configure` has set so far). */
474
+ interface ResolvedConfiguration {
475
+ defaultGroup: string;
476
+ plate: string;
477
+ defaultSplat: string;
478
+ impactStain: string | null;
479
+ damagedScenario: string | null;
480
+ texts: KitTexts & {
481
+ who: string;
482
+ noEffect: string;
483
+ };
484
+ }
485
+ interface Plugin {
486
+ name?: string;
487
+ configure?: KitConfiguration;
488
+ install?(kit: VehicleKit): void;
489
+ }
490
+ interface VehicleKitOptions extends KitConfiguration {
491
+ /** The three.js namespace (`import * as THREE from 'three'` or `window.THREE`). */
492
+ THREE: any;
493
+ /** A registered locale code (`'en'`, `'pt-BR'`), or a partial string table overriding English. Default `'en'`. */
494
+ locale?: string | PartialLocaleStrings;
495
+ /** Document used for canvas textures and the UI. Defaults to the global `document`. */
496
+ document?: Document;
497
+ plugins?: Plugin[];
498
+ }
499
+ interface ImpactOptions {
500
+ /** Do not leave a stain. */
501
+ noStain?: boolean;
502
+ [key: string]: any;
503
+ }
504
+ interface SplatOptions {
505
+ fluid?: string;
506
+ glass?: boolean;
507
+ obj?: ThreeObject;
508
+ }
509
+ interface ExplodeOptions {
510
+ /** Explode immediately. */
511
+ now?: boolean;
512
+ /** Seconds of fire before the blast (default 3..8 at random). */
513
+ delay?: number;
514
+ }
515
+ interface OverallHealth {
516
+ health: number;
517
+ band: number;
518
+ name: string;
519
+ }
520
+ interface ZoneDamageEntry {
521
+ id: string;
522
+ name: string;
523
+ damage: number;
524
+ }
525
+ interface DamageMapOptions {
526
+ /** Id of the selected zone. */
527
+ selected?: string;
528
+ onSelect?(zoneId: string): void;
529
+ }
530
+ interface UiHelpers {
531
+ damageMap(host: HTMLElement, c: VehicleContext, o?: DamageMapOptions): SVGElement | null;
532
+ bandButtons(host: HTMLElement, onPick?: (health: number, band: number) => void): HTMLButtonElement[];
533
+ legend(host: HTMLElement): void;
534
+ healthBar(els: {
535
+ text?: HTMLElement;
536
+ bar?: HTMLElement;
537
+ }, c: VehicleContext): OverallHealth;
538
+ scenarioButtons(host: HTMLElement, onRun: (id: string) => void): HTMLButtonElement[];
539
+ zoneLabel(z: DamageZone): string;
540
+ bandRange(i: number): string;
541
+ css(): string;
542
+ injectStyles(): void;
543
+ }
544
+ /** Helpers for plugins that implement their own flag effects. */
545
+ interface KitInternals {
546
+ rng(seed: number): () => number;
547
+ strHash(text: string): number;
548
+ zonesOf(c: VehicleContext): DamageZone[];
549
+ [key: string]: any;
550
+ }
551
+ /** Low-level builders of the engine; see the JSDoc of each. They take and return three.js objects. */
552
+ type Builder = (...args: any[]) => any;
553
+ interface VehicleKit {
554
+ readonly THREE: any;
555
+ /** Translated strings in use. */
556
+ readonly strings: LocaleStrings;
557
+ /** Looks up a locale key (`'zones.hood'`) and fills variables. */
558
+ readonly t: Translate;
559
+ readonly bands: Band[];
560
+ readonly fleet: VehicleSpec[];
561
+ readonly scenarios: ScenarioDefinition[];
562
+ readonly plugins: string[];
563
+ readonly fluidTypes: Record<string, FluidDefinition>;
564
+ readonly flagEffects: Record<string, FlagEffect>;
565
+ readonly fuels: Record<string, any>;
566
+ readonly groups: string[];
567
+ readonly config: ResolvedConfiguration;
568
+ readonly internals: KitInternals;
569
+ readonly ui: UiHelpers;
570
+ register(spec: VehicleSpec, build: BuildFunction): VehicleSpec;
571
+ find(key: string): VehicleSpec | null;
572
+ configure(options: KitConfiguration): VehicleKit;
573
+ /**
574
+ * Registers a locale table (any top-level key, so a content pack can add its own) and refreshes the strings of this kit,
575
+ * which keeps the locale it was created with. English is the fallback for every locale.
576
+ */
577
+ registerLocale(code: string, strings: Record<string, any>): VehicleKit;
578
+ /**
579
+ * Registers the original (pre-rename) text of zone ids and glass labels, which keeps the random damage of a renamed zone or
580
+ * pane unchanged. `zones`: new zone id to original id; `glassLabels`: glass part key to original label. Shared by every kit.
581
+ */
582
+ registerLegacySeeds(tables: {
583
+ zones?: Record<string, string>;
584
+ glassLabels?: Record<string, string>;
585
+ }): void;
586
+ plugin(plugin: Plugin): VehicleKit;
587
+ scenario(def: ScenarioDefinition): ScenarioDefinition;
588
+ defineFluid(key: string, def: FluidDefinition): FluidDefinition;
589
+ on(event: string, fn: (...args: any[]) => void): VehicleKit;
590
+ hook(event: string, ...args: any[]): void;
591
+ build(key: string, state?: BuildState, zoneState?: Partial<ZoneState>): VehicleContext;
592
+ dispose(c: VehicleContext): void;
593
+ /** Advances particles, fluids, hood, blast and rollover animations by `dt` seconds. */
594
+ tick(c: VehicleContext, dt: number): void;
595
+ /** Runs `sec` seconds of `tick` in one go. */
596
+ settle(c: VehicleContext, sec: number): void;
597
+ defaultDamage(c: VehicleContext): void;
598
+ bandOf(health: number): BandIndex;
599
+ zonesOf(c: VehicleContext): DamageZone[];
600
+ applyZones(c: VehicleContext, state: Partial<ZoneState>): void;
601
+ zoneScenario(c: VehicleContext, idOrName: string): ScenarioResult;
602
+ zoneOverall(c: VehicleContext): OverallHealth;
603
+ zoneAt(c: VehicleContext, point: ThreeVector, object?: ThreeObject): DamageZone | null;
604
+ zoneDamageAt(c: VehicleContext, point: ThreeVector, dir: ThreeVector, force: number, object?: ThreeObject): ZoneDamageEntry[];
605
+ zonePoint(c: VehicleContext, zone: DamageZone): ThreeVector;
606
+ zoneImpact(c: VehicleContext, side: 'front' | 'rear' | 'left' | 'right' | string, force: number): unknown;
607
+ impact(c: VehicleContext, point: ThreeVector, dir: ThreeVector, force: number, options?: ImpactOptions): unknown[];
608
+ splat(c: VehicleContext, point: ThreeVector, normal: ThreeVector, radius: number, options?: SplatOptions): {
609
+ grp: ThreeObject;
610
+ [key: string]: any;
611
+ };
612
+ explode(c: VehicleContext, options?: ExplodeOptions): number | false;
613
+ blastDamage(c: VehicleContext, amount: number): 'fire' | 'explosion' | null;
614
+ roll(c: VehicleContext, side?: number): boolean;
615
+ applyArmor(c: VehicleContext): void;
616
+ spawn: Builder;
617
+ burst: Builder;
618
+ addEmitter: Builder;
619
+ readonly geo: Record<string, Builder>;
620
+ readonly materials: Record<string, any>;
621
+ [builder: string]: any;
622
+ }
623
+
624
+ /**
625
+ * Creates a vehicle kit bound to a three.js namespace and a locale.
626
+ * The returned object is the public API; every call creates an independent kit (its own registry, caches and configuration).
627
+ */
628
+ declare function createVehicleKit(options: VehicleKitOptions): VehicleKit;
629
+
630
+ /** Build states: new English name -> original seed text. */
631
+ declare const LEGACY_STATES: Record<string, string>;
632
+ /** Salts mixed into the seed of each phase of `applyZones`. */
633
+ declare const SEED_SALTS: {
634
+ rust: string;
635
+ scenario: string;
636
+ settle: string;
637
+ rollover: string;
638
+ };
639
+ /** Auto-derived zone ids: new id -> original id. Ids that did not change are not listed. */
640
+ declare const LEGACY_ZONE_IDS: Record<string, string>;
641
+ /**
642
+ * Lets a content pack add its own legacy seeds: `zones` maps a new zone id to the original id and `glassLabels` maps the key of a
643
+ * glass part to its original label. The tables are shared by every kit of the process; an id keeps one meaning, so a different
644
+ * text for an id that is already known is an error.
645
+ */
646
+ declare function registerLegacySeeds(tables: {
647
+ zones?: Record<string, string>;
648
+ glassLabels?: Record<string, string>;
649
+ }): void;
650
+ /** The text a zone contributes to its seed: an explicit `seedId`, the legacy id, or the id itself. */
651
+ declare function legacyZoneId(z: {
652
+ id: string;
653
+ seedId?: string;
654
+ }): string;
655
+ /**
656
+ * Original zone id of a glass pane. `key` is the part key (null for free-text labels), `label` the current label,
657
+ * `side` -1/1 for panes made by `sideWindows`, `appended` 'left'/'right' when the zone added a side word itself and
658
+ * `fallback` the new id, used when the label was free text (then the id never changed).
659
+ */
660
+ declare function legacyGlassId(key: string | null, label: string, side: number, appended: string | null, fallback: string): string;
661
+ /** Original id of a light zone: `farol_e`, `lanterna_c`, `farol_d_2`... */
662
+ declare function legacyLightId(kind: string, side: string, index: number): string;
663
+
664
+ /** Pure helpers shared by every module. They never touch three.js. */
665
+ /** Deterministic hash of three numbers to [0, 1). */
666
+ declare function hash(a: number, b: number, c: number): number;
667
+ declare function clamp(v: number, a: number, b: number): number;
668
+ /** Smoothstep on [0, 1]. */
669
+ declare function smooth(t: number): number;
670
+ /** Mulberry32 pseudo random generator. The same seed always gives the same sequence. */
671
+ declare function rng(seed: number): () => number;
672
+ /** FNV-1a hash of a string, used to derive seeds from vehicle keys and zone ids. */
673
+ declare function strHash(s: string): number;
674
+
675
+ /**
676
+ * Part and joint model of a vehicle for the destruction contract: every damage zone becomes a part with a material, the mechanical parts the
677
+ * zones do not cover (battery, alternator, gearbox, brakes, steering, shock absorbers, tow hitch, tyres, mirrors, pillars...) are added from the
678
+ * vehicle meta, and the joints (hinge, bolt, weld, glue, clip) say how each one is held.
679
+ *
680
+ * Everything here is pure data derived from the built vehicle: no meshes are created or touched.
681
+ */
682
+
683
+ /** What a part is, which decides its material, its joint and what happens when it comes off. */
684
+ type PartRole = 'frame' | 'panel' | 'fender' | 'door' | 'hood' | 'lid' | 'roof' | 'bumper' | 'glass' | 'light' | 'rim' | 'tyre' | 'mirror' | 'pillar' | 'engine' | 'radiator' | 'fuel_tank' | 'oil_pan' | 'battery' | 'alternator' | 'gearbox' | 'brakes' | 'steering' | 'shocks' | 'hitch' | 'other';
685
+ /** An axis-aligned box in `c.vehicle` coordinates (+x front, +y up, +z right). */
686
+ interface LocalBox {
687
+ center: Vec3;
688
+ size: Vec3;
689
+ }
690
+ interface PartDef {
691
+ id: string;
692
+ role: PartRole;
693
+ /** Display name from the locale. */
694
+ name: string;
695
+ material: MaterialId;
696
+ box: LocalBox;
697
+ mass: number;
698
+ /** Energy in joules that wrecks the part. */
699
+ hp: number;
700
+ /** The damage zone this part is, when it is one. */
701
+ zoneId?: string;
702
+ /** Fluid held, in litres. */
703
+ contains?: {
704
+ fluid: string;
705
+ liters: number;
706
+ pressurized?: boolean;
707
+ };
708
+ explodes?: {
709
+ energy: number;
710
+ radius: number;
711
+ atC: number;
712
+ };
713
+ /** Temperature in Celsius at which the part catches fire (none: it does not burn). */
714
+ ignitionC?: number;
715
+ /** Parts that can be seen coming off the vehicle (the others are logical: they keep state and effects only). */
716
+ visual: boolean;
717
+ /** The part is one of the new mechanical parts (the ones the damage zones do not cover). */
718
+ mechanical: boolean;
719
+ tags: string[];
720
+ }
721
+ interface JointDef {
722
+ id: string;
723
+ a: string;
724
+ b: string;
725
+ kind: JointKind;
726
+ strength: number;
727
+ tools: ToolKind[];
728
+ seconds: number;
729
+ }
730
+ interface VehicleModel {
731
+ parts: PartDef[];
732
+ joints: JointDef[];
733
+ /** The part every other part hangs from. */
734
+ hub: string;
735
+ hitch: boolean;
736
+ }
737
+ interface ModelOptions {
738
+ /** Fit a tow hitch. Default: the spec flag `hitch`, else a seeded choice by vehicle kind. */
739
+ hitch?: boolean;
740
+ }
741
+ /** Joint kinds as the vehicle uses them: strength in joules of wear, the tools that undo them and the seconds of work. */
742
+ declare const JOINT_RULES: Record<'hinge' | 'bolt' | 'weld' | 'glue' | 'clip', {
743
+ strength: number;
744
+ tools: ToolKind[];
745
+ seconds: number;
746
+ }>;
747
+ /** Builds the part and joint model of a built vehicle. */
748
+ declare function buildVehicleModel(kit: VehicleKit, c: VehicleContext, options?: ModelOptions): VehicleModel;
749
+
750
+ /**
751
+ * `createVehicleDestructible`: a vehicle that follows the destruction contract of `@adatechnology/game-contracts` and brings its own rules.
752
+ * Every damage zone and mechanical part is a part with a material, hits become events (dent, hole, crack, fracture, detach, leak, ignite,
753
+ * melt, explode), joints come apart by wear, by a wrench or by breaking, and the hidden mechanics change how the vehicle drives.
754
+ *
755
+ * It depends on the contracts only (types) and on the kit it is given: not on the default destruction world.
756
+ */
757
+
758
+ interface VehicleDestructibleOptions {
759
+ /** Object id the host gives (`DestructibleImpl.id`). Default: the vehicle key. */
760
+ id?: string;
761
+ /** Display name. Default: the vehicle name. */
762
+ name?: string;
763
+ /** Object whose space `describe()` answers in (the wrapper the host placed the vehicle in). Default: `c.root`. */
764
+ frame?: any;
765
+ /** Tow hitch: the option wins over the spec flag, the spec flag over the seeded choice. */
766
+ hitch?: boolean;
767
+ /** Do not create or move any mesh (logic only, for servers and tests that need no scene). */
768
+ headless?: boolean;
769
+ /** Extra seed for the choices that are random in the real world (which way a broken steering pulls). */
770
+ seed?: number;
771
+ }
772
+ /** What the vehicle can do now, from the state of its hidden mechanics. */
773
+ interface VehicleStatus {
774
+ /** Battery, alternator, engine and fuel are in order. */
775
+ canStart: boolean;
776
+ /** Headlights and taillights are powered (battery and alternator in order). */
777
+ lightsOn: boolean;
778
+ /** Engine runs and the gearbox transmits. */
779
+ canDrive: boolean;
780
+ /** 1 is normal; worn or missing brakes make the stopping distance this many times longer. */
781
+ brakeFactor: number;
782
+ /** -1..1: the sideways pull of a damaged steering or flat tyres (negative is left). */
783
+ steerPull: number;
784
+ flatTyres: string[];
785
+ detached: string[];
786
+ leaking: string[];
787
+ burning: string[];
788
+ exploded: boolean;
789
+ fuelLiters: number;
790
+ }
791
+ interface VehicleDestructible extends DestructibleImpl {
792
+ readonly vehicle: VehicleContext;
793
+ readonly model: VehicleModel;
794
+ /** Display name of a part (from the kit locale). */
795
+ partName(partId: string): string;
796
+ status(): VehicleStatus;
797
+ /** Open and close clips for the doors, the hood and the trunk lid the vehicle has. */
798
+ animations(): AnimationClipSpec[];
799
+ /** World position of a part's centre. */
800
+ partWorldCenter(partId: string): Vec3;
801
+ /** Rolls the vehicle over (the roof, the glass and the fluids are hurt when it lands). */
802
+ rollover(side?: number): void;
803
+ /** Part ids that are no longer attached to the main body. */
804
+ detachedParts(): string[];
805
+ }
806
+ declare function createVehicleDestructible(kit: VehicleKit, vehicleCtx: VehicleContext, options?: VehicleDestructibleOptions): VehicleDestructible;
807
+
808
+ interface VehicleItemOptions {
809
+ state?: BuildState;
810
+ }
811
+ interface VehicleItem {
812
+ /** Add this to the scene: origin at the centre of the footprint on the floor, front facing +z. */
813
+ root: any;
814
+ /** The built vehicle inside it. */
815
+ vehicle: VehicleContext;
816
+ }
817
+ /**
818
+ * Builds vehicle `key` as an item for a viewer that expects the origin at the centre of the footprint on the floor and the front facing +z
819
+ * (the test room). The vehicle itself keeps the kit axes (+x front) inside a turned, centred group. Pass `root` as `frame` to
820
+ * `createVehicleDestructible` so `describe()` answers in the item's space.
821
+ */
822
+ declare function buildVehicleItem(kit: VehicleKit, key: string, options?: VehicleItemOptions): VehicleItem;
823
+
824
+ export { type Band, type BandId, type BandIndex, type BandOverride, type BuildFunction, type BuildState, type DamageMapOptions, type DamageZone, type ExplodeOptions, type FlagEffect, type FluidDefinition, type ImpactOptions, JOINT_RULES, type JointDef, type KitConfiguration, type KitInternals, type KitTexts, LEGACY_STATES, LEGACY_ZONE_IDS, type LocalBox, type LocaleStrings, type OverallHealth, type PartDef, type PartLabel, type PartRole, type PartialLocaleStrings, type Plugin, type ResolvedConfiguration, SEED_SALTS, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SplatOptions, type ThreeObject, type ThreeVector, type Translate, type UiHelpers, type VehicleContext, type VehicleDestructible, type VehicleDestructibleOptions, type VehicleItem, type VehicleItemOptions, type VehicleKit, type VehicleKitOptions, type VehicleMeta, type VehicleModel, type VehiclePart, type VehicleSpec, type VehicleStatus, type ZoneDamageEntry, type ZoneEffect, type ZoneState, buildVehicleItem, buildVehicleModel, clamp, createTranslate, createVehicleDestructible, createVehicleKit, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, registerLegacySeeds, registerLocale, resolveStrings, rng, smooth, strHash };