@adatechnology/game-vfx 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.
- package/LICENSE +21 -0
- package/README.md +85 -2
- package/dist/index.d.ts +1703 -0
- package/dist/index.global.js +7985 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +7962 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1703 @@
|
|
|
1
|
+
type Rgb = readonly [number, number, number];
|
|
2
|
+
/** The channels of `0xRRGGBB` exactly as three.js r128 reads them (no colour-space conversion): the numbers the Lab's shaders and lights were tuned with. */
|
|
3
|
+
declare function hexToRgb(hex: number): Rgb;
|
|
4
|
+
/** `new Color(hex).convertSRGBToLinear()` of r128: the smoke, dust and fire colours the puff shader multiplies the light with. Converted once, at spawn. */
|
|
5
|
+
declare function hexToLinearRgb(hex: number): Rgb;
|
|
6
|
+
|
|
7
|
+
type Vec3Like = readonly [number, number, number];
|
|
8
|
+
/** The six layers of an explosion the viewer can turn off one by one (L478): flash and light, fire, shock wave, smoke and dust, shrapnel and debris, marks on the ground. */
|
|
9
|
+
type VfxLayer = 'flash' | 'fire' | 'shock' | 'smoke' | 'shrapnel' | 'mark';
|
|
10
|
+
declare const VFX_LAYERS: readonly VfxLayer[];
|
|
11
|
+
/** A chain of things that move: anything with a position, or a position. */
|
|
12
|
+
type Follow = {
|
|
13
|
+
readonly x: number;
|
|
14
|
+
readonly y: number;
|
|
15
|
+
readonly z: number;
|
|
16
|
+
} | {
|
|
17
|
+
readonly position: {
|
|
18
|
+
readonly x: number;
|
|
19
|
+
readonly y: number;
|
|
20
|
+
readonly z: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** A residual fire left behind by an explosion (L798 `residual`), or started by `world.fire`. */
|
|
24
|
+
interface FireSpec {
|
|
25
|
+
/** Offsets from the blast point. */
|
|
26
|
+
readonly dx?: number;
|
|
27
|
+
readonly dz?: number;
|
|
28
|
+
readonly radius: number;
|
|
29
|
+
readonly life: number;
|
|
30
|
+
readonly rate?: number;
|
|
31
|
+
readonly smoke?: number;
|
|
32
|
+
/** Grows from `startRadius` to `radius` over `grow` seconds. */
|
|
33
|
+
readonly startRadius?: number;
|
|
34
|
+
readonly grow?: number;
|
|
35
|
+
/** `0xRRGGBB` of the smoke the fire gives (default soot black). */
|
|
36
|
+
readonly smokeColor?: number;
|
|
37
|
+
}
|
|
38
|
+
interface MushroomSpec {
|
|
39
|
+
readonly height: number;
|
|
40
|
+
readonly radius: number;
|
|
41
|
+
readonly count: number;
|
|
42
|
+
readonly stem: number;
|
|
43
|
+
readonly life: number;
|
|
44
|
+
/** How fast the ring climbs towards `height` (the Lab's `rk`, default .55). */
|
|
45
|
+
readonly riseRate?: number;
|
|
46
|
+
readonly roll?: number;
|
|
47
|
+
readonly color?: number;
|
|
48
|
+
}
|
|
49
|
+
/** The Lab's explosion profile with English names; every number is the Lab's (`sources` lists the lines they come from). */
|
|
50
|
+
interface ExplosionDef {
|
|
51
|
+
readonly id: string;
|
|
52
|
+
/** Radius (m) inside which a body is torn apart, and the one inside which it is hurt. */
|
|
53
|
+
readonly lethal: number;
|
|
54
|
+
readonly injury: number;
|
|
55
|
+
/** Radius of the fireball (`vis`). */
|
|
56
|
+
readonly visualRadius: number;
|
|
57
|
+
readonly fireballs: number;
|
|
58
|
+
readonly fuel?: boolean;
|
|
59
|
+
readonly heat?: number;
|
|
60
|
+
readonly heatLifeScale?: number;
|
|
61
|
+
readonly smoke: {
|
|
62
|
+
readonly color: number;
|
|
63
|
+
readonly count: number;
|
|
64
|
+
readonly life: number;
|
|
65
|
+
readonly kind?: 0 | 3;
|
|
66
|
+
};
|
|
67
|
+
readonly dust: {
|
|
68
|
+
readonly color: number;
|
|
69
|
+
readonly count: number;
|
|
70
|
+
};
|
|
71
|
+
readonly shrapnel: {
|
|
72
|
+
readonly count: number;
|
|
73
|
+
readonly kind: 0 | 1 | 2 | 3 | 4;
|
|
74
|
+
readonly speed: number;
|
|
75
|
+
readonly width?: number;
|
|
76
|
+
readonly embers?: number;
|
|
77
|
+
};
|
|
78
|
+
readonly chunks: {
|
|
79
|
+
readonly count: number;
|
|
80
|
+
readonly colors: readonly number[];
|
|
81
|
+
readonly plate?: boolean;
|
|
82
|
+
readonly hot: number;
|
|
83
|
+
readonly speed?: number;
|
|
84
|
+
readonly size?: number;
|
|
85
|
+
};
|
|
86
|
+
readonly mark: {
|
|
87
|
+
readonly scorch?: number;
|
|
88
|
+
readonly crater?: number;
|
|
89
|
+
readonly dent?: number;
|
|
90
|
+
};
|
|
91
|
+
readonly flash: {
|
|
92
|
+
readonly light: number;
|
|
93
|
+
readonly life?: number;
|
|
94
|
+
readonly color?: number;
|
|
95
|
+
readonly intensity?: number;
|
|
96
|
+
readonly blinding?: boolean;
|
|
97
|
+
};
|
|
98
|
+
readonly shock?: false | {
|
|
99
|
+
readonly duration: number;
|
|
100
|
+
};
|
|
101
|
+
readonly shake: number;
|
|
102
|
+
readonly push: number;
|
|
103
|
+
readonly mushroom?: MushroomSpec;
|
|
104
|
+
readonly residualFires?: readonly FireSpec[];
|
|
105
|
+
/** Radius (m) in which characters catch fire. */
|
|
106
|
+
readonly ignite?: number;
|
|
107
|
+
/** The pieces that fly are hot (the characters' parts burn). */
|
|
108
|
+
readonly hotParts?: boolean;
|
|
109
|
+
readonly cone?: {
|
|
110
|
+
readonly angle: number;
|
|
111
|
+
readonly half: number;
|
|
112
|
+
readonly length: number;
|
|
113
|
+
};
|
|
114
|
+
readonly directionBias?: number;
|
|
115
|
+
readonly sources: readonly string[];
|
|
116
|
+
}
|
|
117
|
+
/** What a host does with what an effect cannot do by itself (break the windows, hurt the characters, dig the ground). */
|
|
118
|
+
type VfxSideRequest = {
|
|
119
|
+
readonly type: 'crater';
|
|
120
|
+
readonly x: number;
|
|
121
|
+
readonly z: number;
|
|
122
|
+
readonly radius: number;
|
|
123
|
+
readonly depth: number;
|
|
124
|
+
} | {
|
|
125
|
+
readonly type: 'ignite';
|
|
126
|
+
readonly point: Vec3Like;
|
|
127
|
+
readonly radius: number;
|
|
128
|
+
} | {
|
|
129
|
+
readonly type: 'blast_front';
|
|
130
|
+
readonly explosion: string;
|
|
131
|
+
readonly point: Vec3Like;
|
|
132
|
+
/** Where the glass breaks, damage and push reach: the Lab's `min(injury, 20) * .85`. */
|
|
133
|
+
readonly glassRadius: number;
|
|
134
|
+
/** Metres per second the front travels (the speed of sound): the host delays what it breaks by `distance / speed`. */
|
|
135
|
+
readonly speed: number;
|
|
136
|
+
readonly lethal: number;
|
|
137
|
+
readonly injury: number;
|
|
138
|
+
readonly push: number;
|
|
139
|
+
readonly hotParts: boolean;
|
|
140
|
+
readonly blinding: boolean;
|
|
141
|
+
readonly cone?: {
|
|
142
|
+
readonly angle: number;
|
|
143
|
+
readonly half: number;
|
|
144
|
+
readonly length: number;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
interface VfxProfile {
|
|
148
|
+
readonly puffs: number;
|
|
149
|
+
readonly sparks: number;
|
|
150
|
+
readonly glows: number;
|
|
151
|
+
readonly chunks: number;
|
|
152
|
+
readonly sprites: {
|
|
153
|
+
readonly add: number;
|
|
154
|
+
readonly normal: number;
|
|
155
|
+
};
|
|
156
|
+
readonly streaks: number;
|
|
157
|
+
readonly debris: number;
|
|
158
|
+
}
|
|
159
|
+
type VfxProfileName = 'low' | 'medium' | 'high';
|
|
160
|
+
interface LodBands {
|
|
161
|
+
/** Distances (m) at which the scale drops. */
|
|
162
|
+
readonly edges: readonly [number, number, number];
|
|
163
|
+
/** The scale in each of the four bands. */
|
|
164
|
+
readonly scales: readonly [number, number, number, number];
|
|
165
|
+
/** How many visual radii are taken off the distance: a big blast stays detailed farther away. */
|
|
166
|
+
readonly radiusFactor: number;
|
|
167
|
+
}
|
|
168
|
+
interface AreaCap {
|
|
169
|
+
readonly radius: number;
|
|
170
|
+
readonly window: number;
|
|
171
|
+
readonly count: number;
|
|
172
|
+
readonly excessScale: number;
|
|
173
|
+
}
|
|
174
|
+
interface ScreenState {
|
|
175
|
+
/** Camera shake amplitude (the Lab's `shakeAmp`). */
|
|
176
|
+
shake: number;
|
|
177
|
+
/** White flash of the Lab, 0..1, and how fast it fades. */
|
|
178
|
+
flash: number;
|
|
179
|
+
flashDecay: number;
|
|
180
|
+
white: number;
|
|
181
|
+
red: number;
|
|
182
|
+
directionLeft: number;
|
|
183
|
+
directionRight: number;
|
|
184
|
+
chroma: number;
|
|
185
|
+
desat: number;
|
|
186
|
+
gas: number;
|
|
187
|
+
beat: number;
|
|
188
|
+
}
|
|
189
|
+
interface VfxStats {
|
|
190
|
+
readonly puffs: number;
|
|
191
|
+
readonly sparks: number;
|
|
192
|
+
readonly glows: number;
|
|
193
|
+
readonly chunks: number;
|
|
194
|
+
readonly fires: number;
|
|
195
|
+
readonly shocks: number;
|
|
196
|
+
readonly rings: number;
|
|
197
|
+
/** Blast lights and fire lights that are lit. */
|
|
198
|
+
readonly blastLights: number;
|
|
199
|
+
readonly fireLights: number;
|
|
200
|
+
/** What the last explosion made: puffs, sparks, chunks, lights. */
|
|
201
|
+
readonly lastBlast: {
|
|
202
|
+
readonly puffs: number;
|
|
203
|
+
readonly sparks: number;
|
|
204
|
+
readonly chunks: number;
|
|
205
|
+
readonly lights: number;
|
|
206
|
+
};
|
|
207
|
+
/** The scale the last explosion was made at (LOD times the area cap). */
|
|
208
|
+
readonly lod: number;
|
|
209
|
+
/** Seconds since the last explosion, or `-1` before the first. */
|
|
210
|
+
readonly blastTime: number;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** The game's cap (G68194-68202): from the 7th explosion within 40 m in 4 s, the extra ones are made at 0.3. */
|
|
214
|
+
declare const AREA_CAP_GAME: AreaCap;
|
|
215
|
+
interface AreaCapTracker {
|
|
216
|
+
/** Registers an explosion at (`x`, `z`) at `time` seconds and answers the scale it gets: 1, or the cap's `excessScale` when `count` or more are already recent in the area. */
|
|
217
|
+
register(time: number, x: number, z: number): number;
|
|
218
|
+
clear(): void;
|
|
219
|
+
}
|
|
220
|
+
declare function createAreaCap(cap: AreaCap): AreaCapTracker;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* A pool that keeps its live records in the order they were added, reuses dead records instead of allocating, and compacts in place. When it is full
|
|
224
|
+
* the oldest record goes (the Lab's `P.shift()`); a pool may choose which one instead (the chunks drop a resting one first).
|
|
225
|
+
*/
|
|
226
|
+
declare class OrderedPool<T extends object> {
|
|
227
|
+
readonly capacity: number;
|
|
228
|
+
private readonly create;
|
|
229
|
+
private readonly release?;
|
|
230
|
+
/** The live records, oldest first. */
|
|
231
|
+
readonly items: T[];
|
|
232
|
+
private readonly spare;
|
|
233
|
+
constructor(capacity: number, create: () => T, release?: ((item: T) => void) | undefined);
|
|
234
|
+
get count(): number;
|
|
235
|
+
/** A record to fill in. At capacity the record `victim` picks (default: the oldest) is dropped and reused. */
|
|
236
|
+
acquire(victim?: (items: readonly T[]) => number): T;
|
|
237
|
+
removeAt(index: number): void;
|
|
238
|
+
/** Keeps the records `keep` accepts, in the same order, without allocating. `context` goes to `keep` so no closure is needed per frame. */
|
|
239
|
+
compact<TContext>(keep: (item: T, context: TContext) => boolean, context: TContext): void;
|
|
240
|
+
clear(): void;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
interface MutableVec3 {
|
|
244
|
+
x: number;
|
|
245
|
+
y: number;
|
|
246
|
+
z: number;
|
|
247
|
+
}
|
|
248
|
+
/** A seeded stream of numbers in [0, 1). The Lab's generator and the Fluid Standard's are both here, behind the same three calls. */
|
|
249
|
+
interface RandomStream {
|
|
250
|
+
/** The next number (the Lab's `rnd`). */
|
|
251
|
+
next(): number;
|
|
252
|
+
/** The Lab's `rr(min, max)`: one draw, scaled. */
|
|
253
|
+
between(min: number, max: number): number;
|
|
254
|
+
/** The Lab's `rdir`: a random unit vector, two draws (`u`, then the angle), written into `out`. */
|
|
255
|
+
direction(out: MutableVec3): MutableVec3;
|
|
256
|
+
readonly state: number;
|
|
257
|
+
}
|
|
258
|
+
/** Park-Miller 16807 (the Lab's L16-18). A seed in 1..2147483646 is used as is, so a stream replays the page's. */
|
|
259
|
+
declare function lehmer(seed: number): RandomStream;
|
|
260
|
+
/** The Fluid Standard's generator (F17-18): a 32-bit linear congruential one. */
|
|
261
|
+
declare function lcg(seed: number): RandomStream;
|
|
262
|
+
/** The stream of one event: the same event seed draws the same effect on every machine, whatever else is playing (`randomMode: 'per_event'`). */
|
|
263
|
+
declare function streamFor(eventSeed: number): RandomStream;
|
|
264
|
+
|
|
265
|
+
/** A lingering fire (L424-442): it grows, gives flames that cool into smoke, and fades out. */
|
|
266
|
+
interface Fire {
|
|
267
|
+
x: number;
|
|
268
|
+
y: number;
|
|
269
|
+
z: number;
|
|
270
|
+
r: number;
|
|
271
|
+
r0: number;
|
|
272
|
+
grow: number;
|
|
273
|
+
life: number;
|
|
274
|
+
t: number;
|
|
275
|
+
rate: number;
|
|
276
|
+
acc: number;
|
|
277
|
+
smoke: number;
|
|
278
|
+
smokeAcc: number;
|
|
279
|
+
fade: number;
|
|
280
|
+
follow: Follow | null;
|
|
281
|
+
fx: number;
|
|
282
|
+
fy: number;
|
|
283
|
+
fz: number;
|
|
284
|
+
color: Rgb;
|
|
285
|
+
rng: RandomStream;
|
|
286
|
+
handle: number;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
interface GroundFieldOptions {
|
|
290
|
+
/** Side of the deformable patch in metres (the Lab's 60). */
|
|
291
|
+
readonly size?: number;
|
|
292
|
+
/** Cells per side (the Lab's 180: 33 cm cells). */
|
|
293
|
+
readonly segments?: number;
|
|
294
|
+
}
|
|
295
|
+
/** The deformable ground the Lab's craters dig into (L60-83): a height field, in float32 like the page, centred on the origin. */
|
|
296
|
+
interface GroundField {
|
|
297
|
+
readonly size: number;
|
|
298
|
+
readonly segments: number;
|
|
299
|
+
/** Vertices per side. */
|
|
300
|
+
readonly stride: number;
|
|
301
|
+
readonly cellSize: number;
|
|
302
|
+
/** World coordinate of the first row and column. */
|
|
303
|
+
readonly origin: number;
|
|
304
|
+
readonly heights: Float32Array;
|
|
305
|
+
/** Goes up on every dent or reset: a renderer redraws its mesh when it changes. */
|
|
306
|
+
readonly version: number;
|
|
307
|
+
heightAt(x: number, z: number): number;
|
|
308
|
+
/** A bowl with an uneven floor and a raised rim, drawing from `random` like the Lab's `dent`. */
|
|
309
|
+
dent(random: RandomStream, x: number, z: number, radius: number, depth: number): void;
|
|
310
|
+
reset(): void;
|
|
311
|
+
}
|
|
312
|
+
declare function createGroundField(options?: GroundFieldOptions): GroundField;
|
|
313
|
+
|
|
314
|
+
/** One of the 4 blast lights (L349-365). */
|
|
315
|
+
interface BlastLight {
|
|
316
|
+
x: number;
|
|
317
|
+
y: number;
|
|
318
|
+
z: number;
|
|
319
|
+
distance: number;
|
|
320
|
+
peak: number;
|
|
321
|
+
life: number;
|
|
322
|
+
t: number;
|
|
323
|
+
color: Rgb;
|
|
324
|
+
/** The level before the flash layer is applied. */
|
|
325
|
+
level: number;
|
|
326
|
+
intensity: number;
|
|
327
|
+
}
|
|
328
|
+
/** One of the 2 fire lights: they go to the two largest fires. */
|
|
329
|
+
interface FireLight {
|
|
330
|
+
x: number;
|
|
331
|
+
y: number;
|
|
332
|
+
z: number;
|
|
333
|
+
distance: number;
|
|
334
|
+
intensity: number;
|
|
335
|
+
}
|
|
336
|
+
/** The glow the puff shader reads (`uGlowPos`, `uGlowCol`, `uGlowI`): where the brightest light is, in linear colour. */
|
|
337
|
+
interface LightGlow {
|
|
338
|
+
x: number;
|
|
339
|
+
y: number;
|
|
340
|
+
z: number;
|
|
341
|
+
color: [number, number, number];
|
|
342
|
+
intensity: number;
|
|
343
|
+
}
|
|
344
|
+
interface LightPool {
|
|
345
|
+
readonly blast: BlastLight[];
|
|
346
|
+
readonly fire: FireLight[];
|
|
347
|
+
readonly glow: LightGlow;
|
|
348
|
+
/** Which blast light the next explosion takes (the Lab's `xlIdx`). */
|
|
349
|
+
cursor: number;
|
|
350
|
+
}
|
|
351
|
+
interface BlastLightSpec {
|
|
352
|
+
readonly x: number;
|
|
353
|
+
readonly y: number;
|
|
354
|
+
readonly z: number;
|
|
355
|
+
readonly peak: number;
|
|
356
|
+
readonly distance: number;
|
|
357
|
+
readonly life: number;
|
|
358
|
+
readonly color: number;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** What an explosion leaves on the ground, as data: the renderer builds the meshes (L443-476). */
|
|
362
|
+
interface ScorchMark {
|
|
363
|
+
readonly kind: 'scorch';
|
|
364
|
+
readonly x: number;
|
|
365
|
+
readonly z: number;
|
|
366
|
+
readonly radius: number;
|
|
367
|
+
/** Which of the three scorch textures. */
|
|
368
|
+
readonly variant: number;
|
|
369
|
+
readonly lift: number;
|
|
370
|
+
readonly rotation: number;
|
|
371
|
+
}
|
|
372
|
+
interface DirtMark {
|
|
373
|
+
readonly kind: 'dirt';
|
|
374
|
+
readonly x: number;
|
|
375
|
+
readonly z: number;
|
|
376
|
+
readonly radius: number;
|
|
377
|
+
readonly lift: number;
|
|
378
|
+
readonly rotation: number;
|
|
379
|
+
}
|
|
380
|
+
/** A piece of broken asphalt on the rim of a crater. */
|
|
381
|
+
interface RockMark {
|
|
382
|
+
readonly kind: 'rock';
|
|
383
|
+
readonly x: number;
|
|
384
|
+
readonly y: number;
|
|
385
|
+
readonly z: number;
|
|
386
|
+
readonly scale: readonly [number, number, number];
|
|
387
|
+
readonly rotation: readonly [number, number, number];
|
|
388
|
+
readonly plate: boolean;
|
|
389
|
+
readonly color: number;
|
|
390
|
+
}
|
|
391
|
+
interface BloodMark {
|
|
392
|
+
readonly kind: 'blood';
|
|
393
|
+
readonly x: number;
|
|
394
|
+
readonly y: number;
|
|
395
|
+
readonly z: number;
|
|
396
|
+
readonly scaleX: number;
|
|
397
|
+
readonly scaleZ: number;
|
|
398
|
+
readonly rotation: number;
|
|
399
|
+
}
|
|
400
|
+
type Mark = ScorchMark | DirtMark | RockMark | BloodMark;
|
|
401
|
+
type MarkEvent = {
|
|
402
|
+
readonly type: 'add';
|
|
403
|
+
readonly mark: Mark;
|
|
404
|
+
} | {
|
|
405
|
+
readonly type: 'clear';
|
|
406
|
+
};
|
|
407
|
+
interface MarkStore {
|
|
408
|
+
readonly entries: Mark[];
|
|
409
|
+
/** Goes up on every mark added or cleared. */
|
|
410
|
+
readonly version: number;
|
|
411
|
+
readonly bloodCount: number;
|
|
412
|
+
/** The counter that lifts each decal a hair higher than the last (the Lab's `decalY`). */
|
|
413
|
+
lift: number;
|
|
414
|
+
add(mark: Mark): void;
|
|
415
|
+
clear(): void;
|
|
416
|
+
/** Tells a renderer the moment a mark is made (the ground it conforms to is the ground of that moment) or taken away. */
|
|
417
|
+
subscribe(listener: (event: MarkEvent) => void): () => void;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** The position a glow follows (a chunk, or anything with `x`, `y`, `z`). */
|
|
421
|
+
interface FollowPoint {
|
|
422
|
+
readonly x: number;
|
|
423
|
+
readonly y: number;
|
|
424
|
+
readonly z: number;
|
|
425
|
+
}
|
|
426
|
+
/** An additive halo (L294-318). The last block is what the renderer reads after `update`: where it is, how big and how bright. */
|
|
427
|
+
interface Glow {
|
|
428
|
+
x: number;
|
|
429
|
+
y: number;
|
|
430
|
+
z: number;
|
|
431
|
+
s: number;
|
|
432
|
+
s1: number | null;
|
|
433
|
+
i: number;
|
|
434
|
+
t: number;
|
|
435
|
+
life: number;
|
|
436
|
+
color: Rgb;
|
|
437
|
+
curve: number;
|
|
438
|
+
flick: boolean;
|
|
439
|
+
follow: FollowPoint | null;
|
|
440
|
+
fx: number;
|
|
441
|
+
fy: number;
|
|
442
|
+
fz: number;
|
|
443
|
+
outX: number;
|
|
444
|
+
outY: number;
|
|
445
|
+
outZ: number;
|
|
446
|
+
outSize: number;
|
|
447
|
+
outIntensity: number;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** Debris with embers (L366-400). The last block is what the renderer reads: the colour already blended towards the glow of a hot piece. */
|
|
451
|
+
interface Chunk {
|
|
452
|
+
x: number;
|
|
453
|
+
y: number;
|
|
454
|
+
z: number;
|
|
455
|
+
vx: number;
|
|
456
|
+
vy: number;
|
|
457
|
+
vz: number;
|
|
458
|
+
rx: number;
|
|
459
|
+
ry: number;
|
|
460
|
+
rz: number;
|
|
461
|
+
ax: number;
|
|
462
|
+
ay: number;
|
|
463
|
+
az: number;
|
|
464
|
+
sx: number;
|
|
465
|
+
sy: number;
|
|
466
|
+
sz: number;
|
|
467
|
+
color: Rgb;
|
|
468
|
+
plate: boolean;
|
|
469
|
+
hot: boolean;
|
|
470
|
+
rest: boolean;
|
|
471
|
+
blood: boolean;
|
|
472
|
+
splat: boolean;
|
|
473
|
+
t: number;
|
|
474
|
+
trail: number;
|
|
475
|
+
glow: Glow | null;
|
|
476
|
+
rng: RandomStream;
|
|
477
|
+
outColor: [number, number, number];
|
|
478
|
+
}
|
|
479
|
+
/** `_hotCol` (L399-400): the colour of a hot piece, blended towards the glow while it is young. */
|
|
480
|
+
declare function colorOfChunk(chunk: Chunk): readonly [number, number, number];
|
|
481
|
+
|
|
482
|
+
/** The ring a mushroom cloud's puffs travel on (L722-735). */
|
|
483
|
+
interface Ring {
|
|
484
|
+
x: number;
|
|
485
|
+
z: number;
|
|
486
|
+
y0: number;
|
|
487
|
+
rise: number;
|
|
488
|
+
rk: number;
|
|
489
|
+
R0: number;
|
|
490
|
+
R1: number;
|
|
491
|
+
r: number;
|
|
492
|
+
roll: number;
|
|
493
|
+
t: number;
|
|
494
|
+
life: number;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Fire, smoke, dust, blood and gas (L193-238). `kind`: 0 fire that turns into smoke, 1 dust, 2 blood, 3 gas or white powder smoke, 4 bile.
|
|
498
|
+
* The last block is what the renderer reads after `update`.
|
|
499
|
+
*/
|
|
500
|
+
interface Puff {
|
|
501
|
+
x: number;
|
|
502
|
+
y: number;
|
|
503
|
+
z: number;
|
|
504
|
+
vx: number;
|
|
505
|
+
vy: number;
|
|
506
|
+
vz: number;
|
|
507
|
+
s0: number;
|
|
508
|
+
s1: number;
|
|
509
|
+
sg: number;
|
|
510
|
+
gk: number;
|
|
511
|
+
life: number;
|
|
512
|
+
t: number;
|
|
513
|
+
h0: number;
|
|
514
|
+
hl: number;
|
|
515
|
+
drag: number;
|
|
516
|
+
buoy: number;
|
|
517
|
+
grav: number;
|
|
518
|
+
kind: number;
|
|
519
|
+
seed: number;
|
|
520
|
+
wind: number;
|
|
521
|
+
color: Rgb;
|
|
522
|
+
ring: Ring | null;
|
|
523
|
+
ph: number;
|
|
524
|
+
th: number;
|
|
525
|
+
rng: RandomStream;
|
|
526
|
+
age: number;
|
|
527
|
+
heat: number;
|
|
528
|
+
size: number;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** A shock wave: an air shell that grows to the lethal radius in 120 ms, and a dust ring on the ground (L319-348). The last block is what the renderer reads. */
|
|
532
|
+
interface Shock {
|
|
533
|
+
x: number;
|
|
534
|
+
y: number;
|
|
535
|
+
z: number;
|
|
536
|
+
Rs: number;
|
|
537
|
+
Rg: number;
|
|
538
|
+
t: number;
|
|
539
|
+
dur: number;
|
|
540
|
+
shellScale: number;
|
|
541
|
+
shellAlpha: number;
|
|
542
|
+
ringScale: number;
|
|
543
|
+
ringAlpha: number;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/** Shrapnel, sparks and embers, stretched along their velocity by the shader (L239-293). `kind`: 0 hot fragment, 1 steel ball, 2 white spark, 3 glass, 4 slow ember. */
|
|
547
|
+
interface Spark {
|
|
548
|
+
x: number;
|
|
549
|
+
y: number;
|
|
550
|
+
z: number;
|
|
551
|
+
vx: number;
|
|
552
|
+
vy: number;
|
|
553
|
+
vz: number;
|
|
554
|
+
t: number;
|
|
555
|
+
life: number;
|
|
556
|
+
w: number;
|
|
557
|
+
st: number;
|
|
558
|
+
kind: number;
|
|
559
|
+
drag: number;
|
|
560
|
+
g: number;
|
|
561
|
+
bounce: number;
|
|
562
|
+
age: number;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
interface Schedule {
|
|
566
|
+
/** Runs `action` once `now` reaches `time`. */
|
|
567
|
+
at(time: number, action: () => void): void;
|
|
568
|
+
/** Runs what is due at `now`, from the last one added to the first (the Lab's L1085 and the Workshop's W1280 walk the list backwards, and so does this). */
|
|
569
|
+
update(now: number): void;
|
|
570
|
+
clear(): void;
|
|
571
|
+
readonly pending: number;
|
|
572
|
+
}
|
|
573
|
+
declare function createSchedule(): Schedule;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* A listener on everything an effect spawns, in the order it spawns it. It exists for the goldens (the Lab page records the same calls) and for
|
|
577
|
+
* tools; nothing reads it in normal play. A record is only valid during the call: copy what you need.
|
|
578
|
+
*/
|
|
579
|
+
interface VfxTrace {
|
|
580
|
+
puff?(puff: Readonly<Puff>): void;
|
|
581
|
+
spark?(spark: Readonly<Spark>): void;
|
|
582
|
+
glow?(glow: Readonly<Glow>): void;
|
|
583
|
+
chunk?(chunk: Readonly<Chunk>): void;
|
|
584
|
+
fire?(fire: Readonly<Fire>): void;
|
|
585
|
+
shock?(spec: {
|
|
586
|
+
x: number;
|
|
587
|
+
y: number;
|
|
588
|
+
z: number;
|
|
589
|
+
shellRadius: number;
|
|
590
|
+
groundRadius: number;
|
|
591
|
+
duration: number;
|
|
592
|
+
}): void;
|
|
593
|
+
light?(spec: Readonly<BlastLightSpec>): void;
|
|
594
|
+
scorch?(x: number, z: number, radius: number): void;
|
|
595
|
+
crater?(x: number, z: number, radius: number, depth: number): void;
|
|
596
|
+
mushroom?(x: number, y: number, z: number, spec: Readonly<MushroomSpec>): void;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
type RandomMode = 'per_event' | 'shared';
|
|
600
|
+
/** What every part of the effects reads and writes: the pools, lights, screen, marks, clock and the few settings. Internal; the host sees `VfxWorld`. */
|
|
601
|
+
interface VfxCore {
|
|
602
|
+
readonly profile: VfxProfile;
|
|
603
|
+
readonly puffs: OrderedPool<Puff>;
|
|
604
|
+
readonly sparks: OrderedPool<Spark>;
|
|
605
|
+
readonly glows: OrderedPool<Glow>;
|
|
606
|
+
readonly chunks: OrderedPool<Chunk>;
|
|
607
|
+
readonly fires: OrderedPool<Fire>;
|
|
608
|
+
readonly shocks: OrderedPool<Shock>;
|
|
609
|
+
readonly rings: OrderedPool<Ring>;
|
|
610
|
+
readonly lights: LightPool;
|
|
611
|
+
readonly marks: MarkStore;
|
|
612
|
+
readonly screen: ScreenState;
|
|
613
|
+
readonly layers: Record<VfxLayer, boolean>;
|
|
614
|
+
readonly schedule: Schedule;
|
|
615
|
+
readonly wind: MutableVec3;
|
|
616
|
+
readonly camera: MutableVec3;
|
|
617
|
+
readonly ground: GroundField | undefined;
|
|
618
|
+
readonly bands: LodBands;
|
|
619
|
+
readonly areaCap: AreaCapTracker | undefined;
|
|
620
|
+
readonly randomMode: RandomMode;
|
|
621
|
+
/** The stream every explosion draws from in `shared` mode, and what spawns outside an event use. */
|
|
622
|
+
readonly sharedRandom: RandomStream;
|
|
623
|
+
readonly reducedMotion: boolean;
|
|
624
|
+
readonly gravity: number;
|
|
625
|
+
readonly trace: VfxTrace | undefined;
|
|
626
|
+
/** What the last explosion made: puffs, sparks, chunks, lights (the Lab's `evCount`). */
|
|
627
|
+
readonly spawned: {
|
|
628
|
+
puffs: number;
|
|
629
|
+
sparks: number;
|
|
630
|
+
chunks: number;
|
|
631
|
+
lights: number;
|
|
632
|
+
};
|
|
633
|
+
readonly clock: {
|
|
634
|
+
time: number;
|
|
635
|
+
lastBlast: number;
|
|
636
|
+
lod: number;
|
|
637
|
+
forcedLod: number | null;
|
|
638
|
+
};
|
|
639
|
+
groundAt(x: number, z: number): number;
|
|
640
|
+
emit(request: VfxSideRequest): void;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
type Vec3Tuple = readonly [number, number, number];
|
|
644
|
+
type SpriteRange = number | readonly [number, number];
|
|
645
|
+
/**
|
|
646
|
+
* What the Workshop's particle systems take (W179-220). The keys are the page's own (`sp` speed, `fi` fade-in, `gnd` ground mode, `ds` decal size) and
|
|
647
|
+
* their order in a recipe is the order the page wrote them: the golden compares the options as text.
|
|
648
|
+
*/
|
|
649
|
+
interface SpriteSpawn {
|
|
650
|
+
readonly p: Vec3Tuple;
|
|
651
|
+
readonly r?: number;
|
|
652
|
+
readonly flat?: boolean;
|
|
653
|
+
readonly box?: Vec3Tuple;
|
|
654
|
+
readonly dir?: Vec3Tuple;
|
|
655
|
+
readonly cone?: number;
|
|
656
|
+
readonly sp?: SpriteRange;
|
|
657
|
+
readonly v?: Vec3Tuple;
|
|
658
|
+
readonly life?: SpriteRange;
|
|
659
|
+
readonly size?: SpriteRange;
|
|
660
|
+
readonly grow?: number;
|
|
661
|
+
readonly c0?: number;
|
|
662
|
+
readonly c1?: number;
|
|
663
|
+
readonly a?: number;
|
|
664
|
+
readonly g?: number;
|
|
665
|
+
readonly drag?: number;
|
|
666
|
+
readonly fi?: number;
|
|
667
|
+
/** 0 flies free, 1 dies at the ground, 2 bounces, 3 leaves a blood decal. */
|
|
668
|
+
readonly gnd?: 0 | 1 | 2 | 3;
|
|
669
|
+
readonly ds?: SpriteRange;
|
|
670
|
+
readonly len?: number;
|
|
671
|
+
}
|
|
672
|
+
interface DebrisSpawn {
|
|
673
|
+
readonly p: Vec3Tuple;
|
|
674
|
+
readonly dir?: Vec3Tuple;
|
|
675
|
+
readonly cone?: number;
|
|
676
|
+
readonly sp?: SpriteRange;
|
|
677
|
+
readonly v?: Vec3Tuple;
|
|
678
|
+
readonly size?: Vec3Tuple | readonly [SpriteRange, SpriteRange, SpriteRange];
|
|
679
|
+
readonly k?: SpriteRange;
|
|
680
|
+
readonly box?: Vec3Tuple;
|
|
681
|
+
readonly c?: number;
|
|
682
|
+
readonly spin?: number;
|
|
683
|
+
readonly life?: number;
|
|
684
|
+
readonly bounce?: number;
|
|
685
|
+
}
|
|
686
|
+
interface DecalOptions {
|
|
687
|
+
readonly n?: Vec3Tuple;
|
|
688
|
+
readonly grow?: number;
|
|
689
|
+
readonly life?: number;
|
|
690
|
+
readonly delay?: number;
|
|
691
|
+
readonly ar?: number;
|
|
692
|
+
readonly dark?: number;
|
|
693
|
+
readonly dry?: number;
|
|
694
|
+
readonly dryAt?: number;
|
|
695
|
+
readonly dryT?: number;
|
|
696
|
+
readonly fluid?: 'blood' | 'oil' | 'fuel' | 'bile' | 'water';
|
|
697
|
+
}
|
|
698
|
+
type SpriteSystem = 'add' | 'normal' | 'streak';
|
|
699
|
+
type TraceKind = 'add' | 'normal' | 'streak' | 'debris' | 'decal' | 'ring' | 'flash';
|
|
700
|
+
/** Hears each spawn in call order with the arguments the page's function got; the Workshop golden records the same calls. */
|
|
701
|
+
type WorkshopTrace = (kind: TraceKind, args: readonly unknown[]) => void;
|
|
702
|
+
interface WorkshopContext {
|
|
703
|
+
/** Swapped while an effect with a seed of its own runs, so a LAN client draws the same numbers. */
|
|
704
|
+
random: RandomStream;
|
|
705
|
+
readonly groundAt: (x: number, z: number) => number;
|
|
706
|
+
readonly quality: {
|
|
707
|
+
level: number;
|
|
708
|
+
mult: number;
|
|
709
|
+
};
|
|
710
|
+
readonly trace: WorkshopTrace | undefined;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
interface DebrisPiece {
|
|
714
|
+
on: boolean;
|
|
715
|
+
x: number;
|
|
716
|
+
y: number;
|
|
717
|
+
z: number;
|
|
718
|
+
vx: number;
|
|
719
|
+
vy: number;
|
|
720
|
+
vz: number;
|
|
721
|
+
sx: number;
|
|
722
|
+
sy: number;
|
|
723
|
+
sz: number;
|
|
724
|
+
rx: number;
|
|
725
|
+
ry: number;
|
|
726
|
+
rz: number;
|
|
727
|
+
ax: number;
|
|
728
|
+
ay: number;
|
|
729
|
+
az: number;
|
|
730
|
+
life: number;
|
|
731
|
+
bounce: number;
|
|
732
|
+
rest: boolean;
|
|
733
|
+
color: number;
|
|
734
|
+
}
|
|
735
|
+
/** The Workshop's physics debris (W248-263): 500 boxes in a ring buffer, the newest overwriting the oldest, that tumble, bounce, settle on a face and shrink away. */
|
|
736
|
+
declare class DebrisPool {
|
|
737
|
+
private readonly context;
|
|
738
|
+
readonly pieces: DebrisPiece[];
|
|
739
|
+
count: number;
|
|
740
|
+
private next;
|
|
741
|
+
private readonly direction;
|
|
742
|
+
constructor(context: WorkshopContext);
|
|
743
|
+
spawn(options: DebrisSpawn): void;
|
|
744
|
+
clear(): void;
|
|
745
|
+
update(dt: number): void;
|
|
746
|
+
/** Scale at the end of its life, 1 until the last half second (the renderer's `sh`). */
|
|
747
|
+
static fade(piece: DebrisPiece): number;
|
|
748
|
+
private move;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
interface Decal {
|
|
752
|
+
on: boolean;
|
|
753
|
+
x: number;
|
|
754
|
+
y: number;
|
|
755
|
+
z: number;
|
|
756
|
+
sx: number;
|
|
757
|
+
sy: number;
|
|
758
|
+
t: number;
|
|
759
|
+
life: number;
|
|
760
|
+
grow: number;
|
|
761
|
+
color: number;
|
|
762
|
+
/** Where the surface faces, and the colour a fluid dries to (`-1`: it does not dry). */
|
|
763
|
+
normal: Vec3Tuple;
|
|
764
|
+
fluid: DecalOptions['fluid'] | undefined;
|
|
765
|
+
dryColor: number;
|
|
766
|
+
dryAt: number;
|
|
767
|
+
dryTime: number;
|
|
768
|
+
}
|
|
769
|
+
/** The Workshop's decals (W265-306): 400 marks on the ground in a ring buffer. Wet ones spread and evaporate (fuel, water), the rest last their life. */
|
|
770
|
+
declare class DecalPool {
|
|
771
|
+
private readonly context;
|
|
772
|
+
readonly decals: Decal[];
|
|
773
|
+
count: number;
|
|
774
|
+
private next;
|
|
775
|
+
constructor(context: WorkshopContext);
|
|
776
|
+
add(x: number, y: number, z: number, size: number, color: number, options?: DecalOptions): void;
|
|
777
|
+
clear(): void;
|
|
778
|
+
update(dt: number): void;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
interface DecalFromSprite {
|
|
782
|
+
(x: number, y: number, z: number, size: number, color: number, options: {
|
|
783
|
+
readonly grow: number;
|
|
784
|
+
readonly fluid: 'blood';
|
|
785
|
+
}): void;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* The Workshop's `PSys` (W179-220): a pool of sprites in typed arrays, as the page keeps them. A dead record is replaced by the last one, so the order
|
|
789
|
+
* in the arrays is the page's, and the golden hashes the arrays as they are. Additive and normal-blend systems are two instances.
|
|
790
|
+
*/
|
|
791
|
+
declare class SpritePool {
|
|
792
|
+
readonly capacity: number;
|
|
793
|
+
private readonly context;
|
|
794
|
+
count: number;
|
|
795
|
+
readonly position: Float32Array;
|
|
796
|
+
readonly velocity: Float32Array;
|
|
797
|
+
readonly colorStart: Float32Array;
|
|
798
|
+
readonly colorEnd: Float32Array;
|
|
799
|
+
readonly life: Float32Array;
|
|
800
|
+
readonly maxLife: Float32Array;
|
|
801
|
+
readonly startSize: Float32Array;
|
|
802
|
+
readonly growth: Float32Array;
|
|
803
|
+
readonly startAlpha: Float32Array;
|
|
804
|
+
readonly gravity: Float32Array;
|
|
805
|
+
readonly drag: Float32Array;
|
|
806
|
+
readonly fadeIn: Float32Array;
|
|
807
|
+
readonly groundMode: Uint8Array;
|
|
808
|
+
readonly decalSize: Float32Array;
|
|
809
|
+
/** Written by `update`: what the renderer draws. */
|
|
810
|
+
readonly color: Float32Array;
|
|
811
|
+
readonly size: Float32Array;
|
|
812
|
+
readonly alpha: Float32Array;
|
|
813
|
+
private readonly vectorArrays;
|
|
814
|
+
private readonly scalarArrays;
|
|
815
|
+
private readonly direction;
|
|
816
|
+
private readonly unit;
|
|
817
|
+
constructor(capacity: number, context: WorkshopContext);
|
|
818
|
+
spawn(options: SpriteSpawn): void;
|
|
819
|
+
kill(index: number): void;
|
|
820
|
+
clear(): void;
|
|
821
|
+
update(dt: number, leaveDecal: DecalFromSprite): void;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/** The Workshop's `Streaks` (W223-245): short lines that follow their own velocity (sparks, tracers, rain-like glints). Same swap-with-last pool as `SpritePool`. */
|
|
825
|
+
declare class StreakPool {
|
|
826
|
+
readonly capacity: number;
|
|
827
|
+
private readonly context;
|
|
828
|
+
count: number;
|
|
829
|
+
readonly point: Float32Array;
|
|
830
|
+
readonly velocity: Float32Array;
|
|
831
|
+
readonly colorStart: Float32Array;
|
|
832
|
+
readonly colorEnd: Float32Array;
|
|
833
|
+
readonly life: Float32Array;
|
|
834
|
+
readonly maxLife: Float32Array;
|
|
835
|
+
readonly length: Float32Array;
|
|
836
|
+
readonly gravity: Float32Array;
|
|
837
|
+
readonly drag: Float32Array;
|
|
838
|
+
readonly groundMode: Uint8Array;
|
|
839
|
+
readonly startAlpha: Float32Array;
|
|
840
|
+
/** Two end points and two colours per line: what the renderer draws. */
|
|
841
|
+
readonly segment: Float32Array;
|
|
842
|
+
readonly segmentColor: Float32Array;
|
|
843
|
+
private readonly vectorArrays;
|
|
844
|
+
private readonly scalarArrays;
|
|
845
|
+
private readonly direction;
|
|
846
|
+
constructor(capacity: number, context: WorkshopContext);
|
|
847
|
+
spawn(options: SpriteSpawn): void;
|
|
848
|
+
kill(index: number): void;
|
|
849
|
+
clear(): void;
|
|
850
|
+
update(dt: number): void;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
interface WaveRing {
|
|
854
|
+
on: boolean;
|
|
855
|
+
point: Vec3Tuple;
|
|
856
|
+
from: number;
|
|
857
|
+
to: number;
|
|
858
|
+
t: number;
|
|
859
|
+
duration: number;
|
|
860
|
+
color: number;
|
|
861
|
+
normal: Vec3Tuple;
|
|
862
|
+
hold: number;
|
|
863
|
+
}
|
|
864
|
+
/** The Workshop's expanding rings on the ground (W308-315): 120 in a ring buffer. A ring with `hold` stays at that brightness until cleared. */
|
|
865
|
+
declare class WaveRingPool {
|
|
866
|
+
readonly rings: WaveRing[];
|
|
867
|
+
count: number;
|
|
868
|
+
private next;
|
|
869
|
+
add(point: Vec3Tuple, from: number, to: number, duration: number, color: number, normal?: Vec3Tuple, hold?: number): void;
|
|
870
|
+
clear(): void;
|
|
871
|
+
update(dt: number): void;
|
|
872
|
+
}
|
|
873
|
+
interface FlashLight {
|
|
874
|
+
x: number;
|
|
875
|
+
y: number;
|
|
876
|
+
z: number;
|
|
877
|
+
color: number;
|
|
878
|
+
distance: number;
|
|
879
|
+
peak: number;
|
|
880
|
+
duration: number;
|
|
881
|
+
t: number;
|
|
882
|
+
intensity: number;
|
|
883
|
+
}
|
|
884
|
+
interface FireLightSlot {
|
|
885
|
+
x: number;
|
|
886
|
+
y: number;
|
|
887
|
+
z: number;
|
|
888
|
+
intensity: number;
|
|
889
|
+
}
|
|
890
|
+
/** The four short flashes of the Workshop (W333-337), taken in turn, and its two fire lights. */
|
|
891
|
+
declare class FlashLightPool {
|
|
892
|
+
private readonly context;
|
|
893
|
+
readonly lights: FlashLight[];
|
|
894
|
+
readonly fire: FireLightSlot[];
|
|
895
|
+
private next;
|
|
896
|
+
constructor(context: WorkshopContext);
|
|
897
|
+
get lit(): number;
|
|
898
|
+
flash(point: Vec3Tuple, color: number, intensity: number, duration: number, distance?: number, force?: boolean | 'boom'): void;
|
|
899
|
+
clear(): void;
|
|
900
|
+
update(dt: number): void;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/** Water or blood on the camera lens: a soft blob that fades and runs down (W351-352). */
|
|
904
|
+
interface LensBlob {
|
|
905
|
+
x: number;
|
|
906
|
+
y: number;
|
|
907
|
+
radius: number;
|
|
908
|
+
color: string;
|
|
909
|
+
alpha: number;
|
|
910
|
+
fall: number;
|
|
911
|
+
}
|
|
912
|
+
/** The page's `P0` (W347, W1277): what an effect asks of the post-process for this frame only; it is emptied before every frame's tick. */
|
|
913
|
+
interface PostProcess {
|
|
914
|
+
desat?: number;
|
|
915
|
+
tunnel?: number;
|
|
916
|
+
blur?: number;
|
|
917
|
+
cold?: number;
|
|
918
|
+
chroma?: number;
|
|
919
|
+
hue?: number;
|
|
920
|
+
red?: number;
|
|
921
|
+
tintAlpha?: number;
|
|
922
|
+
tintColor?: string;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Where an effect is put when it is played at a point instead of on the Workshop's set: what the recipe wrote at `anchor` lands at `origin`, turned
|
|
926
|
+
* about the vertical axis by `yaw`. Positions are moved and turned, directions and velocities only turned.
|
|
927
|
+
*/
|
|
928
|
+
interface Placement {
|
|
929
|
+
readonly origin: Vec3Tuple;
|
|
930
|
+
readonly anchor: Vec3Tuple;
|
|
931
|
+
readonly yaw: number;
|
|
932
|
+
}
|
|
933
|
+
interface WorkshopOptions {
|
|
934
|
+
readonly random: RandomStream;
|
|
935
|
+
readonly profile?: VfxProfile;
|
|
936
|
+
readonly groundAt?: (x: number, z: number) => number;
|
|
937
|
+
readonly trace?: WorkshopTrace;
|
|
938
|
+
}
|
|
939
|
+
/** The default ground of the Workshop scene: a raised kerb 12 cm high between z -4.5 and -2.9 (W29). */
|
|
940
|
+
declare function workshopGround(x: number, z: number): number;
|
|
941
|
+
/**
|
|
942
|
+
* Everything the Workshop's recipes spawn into and the loop that ages it (W168-371, W1285-1287): sprites, streaks, debris, decals, rings, lights, the
|
|
943
|
+
* screen state and the lens blobs, plus the quality level that thins what a recipe asks for and the accumulators that turn a rate into spawns.
|
|
944
|
+
*/
|
|
945
|
+
declare class WorkshopEngine {
|
|
946
|
+
readonly context: WorkshopContext;
|
|
947
|
+
readonly add: SpritePool;
|
|
948
|
+
readonly normal: SpritePool;
|
|
949
|
+
readonly streaks: StreakPool;
|
|
950
|
+
readonly debris: DebrisPool;
|
|
951
|
+
readonly decals: DecalPool;
|
|
952
|
+
readonly rings: WaveRingPool;
|
|
953
|
+
readonly lights: FlashLightPool;
|
|
954
|
+
readonly screen: ScreenState;
|
|
955
|
+
readonly lens: LensBlob[];
|
|
956
|
+
post: PostProcess;
|
|
957
|
+
/** Set by whoever runs an effect for the time it runs; `undefined` leaves every number as the recipe wrote it. */
|
|
958
|
+
placement: Placement | undefined;
|
|
959
|
+
private readonly accumulators;
|
|
960
|
+
constructor(options: WorkshopOptions);
|
|
961
|
+
get random(): RandomStream;
|
|
962
|
+
get quality(): number;
|
|
963
|
+
setQuality(level: number): void;
|
|
964
|
+
/** `n` (W340): a count thinned by the quality level, never to zero when something was asked. */
|
|
965
|
+
scaled(count: number): number;
|
|
966
|
+
/** A point of the recipe's space in the world (`undefined` placement: as is). */
|
|
967
|
+
place(point: Vec3Tuple): Vec3Tuple;
|
|
968
|
+
/** A direction or velocity of the recipe's space in the world. */
|
|
969
|
+
turn(vector: Vec3Tuple): Vec3Tuple;
|
|
970
|
+
private placed;
|
|
971
|
+
spawn(system: SpriteSystem, recipe: SpriteSpawn): void;
|
|
972
|
+
burst(system: SpriteSystem, count: number, options: SpriteSpawn): void;
|
|
973
|
+
/** `emit` (W343-345): `rate` per second, thinned by the quality, carried over between frames under `key`. `options` is read again for every particle. */
|
|
974
|
+
emit(key: string, system: SpriteSystem, rate: number, dt: number, options: () => SpriteSpawn): void;
|
|
975
|
+
debrisPiece(recipe: DebrisSpawn): void;
|
|
976
|
+
decal(recipe: readonly [number, number, number, number, number, DecalOptions?]): void;
|
|
977
|
+
ring(recipe: readonly [Vec3Tuple, number, number, number, number, Vec3Tuple?, number?]): void;
|
|
978
|
+
flash(recipe: readonly [Vec3Tuple, number, number, number, number?, (boolean | 'boom')?]): void;
|
|
979
|
+
/** `fireLight` (W400): sways with the clock and flickers with one draw. */
|
|
980
|
+
fireLight(slot: 0 | 1, recipe: Vec3Tuple, intensity: number, time: number): void;
|
|
981
|
+
lensBlob(x: number, y: number, radius: number, color: string, alpha: number): void;
|
|
982
|
+
/** The order of the page's loop (W1285-1287): the sprites, streaks, debris, decals, rings and lights, then the screen and its lens. */
|
|
983
|
+
update(dt: number): void;
|
|
984
|
+
clear(): void;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/** What an effect step may hold: literals, or computed fields (`Expr`) resolved when the step runs. Typed loosely on purpose, it is data. */
|
|
988
|
+
type Computed = unknown;
|
|
989
|
+
interface EffectParams {
|
|
990
|
+
readonly id: string;
|
|
991
|
+
readonly options: readonly string[];
|
|
992
|
+
readonly default: number;
|
|
993
|
+
}
|
|
994
|
+
interface EffectBudget {
|
|
995
|
+
readonly particles?: number;
|
|
996
|
+
readonly debris?: number;
|
|
997
|
+
readonly decals?: number;
|
|
998
|
+
readonly lights?: number;
|
|
999
|
+
}
|
|
1000
|
+
type ScreenKey = 'shake' | 'white' | 'red' | 'dirL' | 'dirR' | 'chroma' | 'desat' | 'gas' | 'beat';
|
|
1001
|
+
type EffectStep = {
|
|
1002
|
+
readonly op: 'burst';
|
|
1003
|
+
readonly system: 'add' | 'normal' | 'streak';
|
|
1004
|
+
readonly count: Computed;
|
|
1005
|
+
readonly spawn: Computed;
|
|
1006
|
+
} | {
|
|
1007
|
+
readonly op: 'spawn';
|
|
1008
|
+
readonly system: 'add' | 'normal' | 'streak';
|
|
1009
|
+
readonly spawn: Computed;
|
|
1010
|
+
} | {
|
|
1011
|
+
readonly op: 'emit';
|
|
1012
|
+
readonly key: string;
|
|
1013
|
+
readonly system: 'add' | 'normal' | 'streak';
|
|
1014
|
+
readonly rate: Computed;
|
|
1015
|
+
readonly spawn: Computed;
|
|
1016
|
+
} | {
|
|
1017
|
+
readonly op: 'debris';
|
|
1018
|
+
readonly spawn: Computed;
|
|
1019
|
+
} | {
|
|
1020
|
+
readonly op: 'decal' | 'ring' | 'flash' | 'lens';
|
|
1021
|
+
readonly args: readonly Computed[];
|
|
1022
|
+
} | {
|
|
1023
|
+
readonly op: 'screen';
|
|
1024
|
+
readonly add?: Readonly<Partial<Record<ScreenKey, Computed>>>;
|
|
1025
|
+
readonly set?: Readonly<Partial<Record<ScreenKey, Computed>>>;
|
|
1026
|
+
readonly max?: Readonly<Partial<Record<ScreenKey, Computed>>>;
|
|
1027
|
+
} | {
|
|
1028
|
+
readonly op: 'fire_light';
|
|
1029
|
+
readonly slot: 0 | 1;
|
|
1030
|
+
readonly point: Computed;
|
|
1031
|
+
readonly intensity: Computed;
|
|
1032
|
+
readonly time: Computed;
|
|
1033
|
+
} | {
|
|
1034
|
+
readonly op: 'fire_light_off';
|
|
1035
|
+
readonly slot: 0 | 1;
|
|
1036
|
+
} | {
|
|
1037
|
+
readonly op: 'cue';
|
|
1038
|
+
readonly cue: string;
|
|
1039
|
+
readonly args?: Computed;
|
|
1040
|
+
readonly draws?: number;
|
|
1041
|
+
} | {
|
|
1042
|
+
readonly op: 'call';
|
|
1043
|
+
readonly macro: string;
|
|
1044
|
+
readonly args: readonly Computed[];
|
|
1045
|
+
} | {
|
|
1046
|
+
readonly op: 'at';
|
|
1047
|
+
readonly time: Computed;
|
|
1048
|
+
readonly steps: readonly EffectStep[];
|
|
1049
|
+
} | {
|
|
1050
|
+
readonly op: 'when';
|
|
1051
|
+
readonly if: Computed;
|
|
1052
|
+
readonly steps: readonly EffectStep[];
|
|
1053
|
+
readonly otherwise?: readonly EffectStep[];
|
|
1054
|
+
} | {
|
|
1055
|
+
readonly op: 'repeat';
|
|
1056
|
+
readonly count: Computed;
|
|
1057
|
+
readonly steps: readonly EffectStep[];
|
|
1058
|
+
} | {
|
|
1059
|
+
readonly op: 'set';
|
|
1060
|
+
readonly name: string;
|
|
1061
|
+
readonly value: Computed;
|
|
1062
|
+
} | {
|
|
1063
|
+
readonly op: 'append';
|
|
1064
|
+
readonly name: string;
|
|
1065
|
+
readonly value: Computed;
|
|
1066
|
+
} | {
|
|
1067
|
+
readonly op: 'camera';
|
|
1068
|
+
readonly eye: Computed;
|
|
1069
|
+
readonly target: Computed; /** Puts the camera there at once instead of gliding. */
|
|
1070
|
+
readonly instant?: boolean;
|
|
1071
|
+
} | {
|
|
1072
|
+
readonly op: 'post';
|
|
1073
|
+
readonly values: Readonly<Record<string, Computed>>;
|
|
1074
|
+
} | {
|
|
1075
|
+
readonly op: 'behavior';
|
|
1076
|
+
readonly id: string;
|
|
1077
|
+
readonly action: string;
|
|
1078
|
+
readonly args?: Computed;
|
|
1079
|
+
};
|
|
1080
|
+
/**
|
|
1081
|
+
* One entry of the Workshop (W449-1244) as data. `setup` and `timeline` run when the effect starts (the page's `setup` and `run`, in that order), `tick`
|
|
1082
|
+
* every frame. A step that draws random numbers draws them in the order the page did, which the Workshop golden checks.
|
|
1083
|
+
*/
|
|
1084
|
+
interface EffectDef {
|
|
1085
|
+
readonly id: string;
|
|
1086
|
+
/** The id the Workshop page gave it (`sangue`): the goldens and the inventory find the effect by it. */
|
|
1087
|
+
readonly pageId: string;
|
|
1088
|
+
readonly team: 'creatures' | 'weapons' | 'world' | 'destruction' | 'vehicles' | 'screen';
|
|
1089
|
+
readonly params?: EffectParams;
|
|
1090
|
+
readonly budget: EffectBudget;
|
|
1091
|
+
/** Seconds of the page's loop; `0` runs until stopped. */
|
|
1092
|
+
readonly loop?: number;
|
|
1093
|
+
readonly view?: {
|
|
1094
|
+
readonly eye: Vec3Tuple;
|
|
1095
|
+
readonly target: Vec3Tuple;
|
|
1096
|
+
};
|
|
1097
|
+
/**
|
|
1098
|
+
* Where the recipe puts the thing the effect is about (the hit, the muzzle, the pool) and which way it points, in the recipe's own space: `play` puts
|
|
1099
|
+
* `anchor` at the point it is given and turns `heading` toward its `direction`. Both optional: a recipe written around the origin needs neither.
|
|
1100
|
+
*/
|
|
1101
|
+
readonly anchor?: Vec3Tuple;
|
|
1102
|
+
readonly heading?: Vec3Tuple;
|
|
1103
|
+
/** The Lab profile that replaced this Workshop entry in the game (W406: `lab: 1`). */
|
|
1104
|
+
readonly lab?: string;
|
|
1105
|
+
/** The props this effect keeps (a car, walkers, a bottle in flight), by behaviour id. */
|
|
1106
|
+
readonly props?: readonly string[];
|
|
1107
|
+
readonly setup?: readonly EffectStep[];
|
|
1108
|
+
readonly timeline: readonly EffectStep[];
|
|
1109
|
+
readonly tick?: readonly EffectStep[];
|
|
1110
|
+
}
|
|
1111
|
+
/** Something an effect asks of its owner: move a prop, play a sound. */
|
|
1112
|
+
interface CueRequest {
|
|
1113
|
+
readonly cue: string;
|
|
1114
|
+
readonly args: unknown;
|
|
1115
|
+
readonly time: number;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/** What an effect reads off the view: where it is and which way the camera's own axes point. The Workshop's bench also moves it (`camera` steps). */
|
|
1119
|
+
interface EffectView {
|
|
1120
|
+
readonly position: Vec3Tuple;
|
|
1121
|
+
forward(local: readonly number[]): Vec3Tuple;
|
|
1122
|
+
goTo?(eye: Vec3Tuple, target: Vec3Tuple): void;
|
|
1123
|
+
place?(eye: Vec3Tuple, target: Vec3Tuple): void;
|
|
1124
|
+
}
|
|
1125
|
+
interface InstanceDeps {
|
|
1126
|
+
readonly engine: WorkshopEngine;
|
|
1127
|
+
readonly view: EffectView;
|
|
1128
|
+
/** The prop models the recipe can call, by id (see `Behavior`). */
|
|
1129
|
+
readonly behavior: (id: string) => Behavior;
|
|
1130
|
+
/** Every behaviour made so far, to age them every frame. */
|
|
1131
|
+
readonly behaviors: () => Iterable<Behavior>;
|
|
1132
|
+
readonly onCue?: (cue: CueRequest) => void;
|
|
1133
|
+
}
|
|
1134
|
+
/** Where and how a played effect sits in the world. */
|
|
1135
|
+
interface InstanceSetup {
|
|
1136
|
+
readonly placement?: Placement;
|
|
1137
|
+
/** Which way the effect points in the world (`direction` in a recipe). */
|
|
1138
|
+
readonly direction?: Vec3Tuple;
|
|
1139
|
+
/** The surface it hit (`normal` in a recipe). */
|
|
1140
|
+
readonly normal?: Vec3Tuple;
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* One run of one effect (W1259-1295): `begin` runs the recipe's `setup` and `timeline`, `step` runs the timers that came due (from the last added to the
|
|
1144
|
+
* first) and the `tick`, once per frame. Step by step it draws random numbers where the page did and in the same order.
|
|
1145
|
+
*/
|
|
1146
|
+
declare class EffectInstance {
|
|
1147
|
+
private readonly deps;
|
|
1148
|
+
readonly variables: Map<string, unknown>;
|
|
1149
|
+
def: EffectDef | undefined;
|
|
1150
|
+
param: number;
|
|
1151
|
+
/** True until the first run of a chosen effect is over: a repeat of the loop is not fresh (`f.fresh`). */
|
|
1152
|
+
fresh: boolean;
|
|
1153
|
+
time: number;
|
|
1154
|
+
/** Seconds since the effect was chosen: unlike `time`, a restart of the loop does not reset it (`el`). */
|
|
1155
|
+
elapsed: number;
|
|
1156
|
+
setup: InstanceSetup;
|
|
1157
|
+
private dt;
|
|
1158
|
+
private index;
|
|
1159
|
+
private readonly schedule;
|
|
1160
|
+
private readonly host;
|
|
1161
|
+
private readonly context;
|
|
1162
|
+
constructor(deps: InstanceDeps);
|
|
1163
|
+
/** The effect starts (`select` + `startLoop`): the recipe's `setup` and `timeline` run now. */
|
|
1164
|
+
begin(def: EffectDef, param: number | undefined, setup?: InstanceSetup): void;
|
|
1165
|
+
/** The loop starts over (`startLoop`): timers, variables and props go back to the start. */
|
|
1166
|
+
restart(): void;
|
|
1167
|
+
/** The effect's part of one frame: the timers due, then the tick, then the props. The pools are aged by whoever owns the engine. */
|
|
1168
|
+
step(dt: number): void;
|
|
1169
|
+
/** True once a looping effect has run its seconds, or a one-shot has nothing left to fire. */
|
|
1170
|
+
get finished(): boolean;
|
|
1171
|
+
/** The recipe's own camera shake on top of the screen's (`panico` trembles the aim). */
|
|
1172
|
+
get tremor(): number;
|
|
1173
|
+
private within;
|
|
1174
|
+
private value;
|
|
1175
|
+
execute(steps: readonly EffectStep[]): void;
|
|
1176
|
+
private run;
|
|
1177
|
+
private moveView;
|
|
1178
|
+
private changeScreen;
|
|
1179
|
+
private cue;
|
|
1180
|
+
private scheduleSteps;
|
|
1181
|
+
private repeat;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/** What a prop model may read and write: the engine, the camera, the effect's variables and its clock. */
|
|
1185
|
+
interface BehaviorHost {
|
|
1186
|
+
readonly engine: WorkshopEngine;
|
|
1187
|
+
readonly camera: EffectView;
|
|
1188
|
+
readonly variables: Map<string, unknown>;
|
|
1189
|
+
readonly param: number;
|
|
1190
|
+
/** Seconds since the effect started. */
|
|
1191
|
+
readonly time: number;
|
|
1192
|
+
/** Schedules `action` at `seconds` after the start (the page's `at`). */
|
|
1193
|
+
after(seconds: number, action: () => void): void;
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* A prop the page animates by hand (a walking zombie, a car, a bottle in flight): the part of that motion a spawn position or a random draw depends on,
|
|
1197
|
+
* ported as a small deterministic model. A recipe calls it with `{ op: 'behavior', id, action }`; it is reset when an effect starts and updated every
|
|
1198
|
+
* frame after the effect's own tick (`updateZombie` runs there in the page's loop).
|
|
1199
|
+
*/
|
|
1200
|
+
interface Behavior {
|
|
1201
|
+
reset(host: BehaviorHost): void;
|
|
1202
|
+
act(host: BehaviorHost, action: string, args: unknown): void;
|
|
1203
|
+
/** Reads something off the prop (`{ $: 'query', a: [id, name, ...] }` in a recipe). */
|
|
1204
|
+
query(host: BehaviorHost, name: string, args: readonly unknown[]): unknown;
|
|
1205
|
+
update(host: BehaviorHost, dt: number, elapsed: number): void;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
interface PlayOptions {
|
|
1209
|
+
/** Which way the effect points in the world (the muzzle's barrel, the spray of a jet). */
|
|
1210
|
+
readonly direction?: Vec3Tuple;
|
|
1211
|
+
/** The surface it hit. */
|
|
1212
|
+
readonly normal?: Vec3Tuple;
|
|
1213
|
+
/** Repeats the same visual: a LAN client draws the same numbers from the same seed. */
|
|
1214
|
+
readonly seed?: number;
|
|
1215
|
+
/** The recipe's parameter (age, material, weapon...). */
|
|
1216
|
+
readonly param?: number | string;
|
|
1217
|
+
/** Moves with a thing: the effect sits at its position plus the point it was played at. */
|
|
1218
|
+
readonly follow?: Follow;
|
|
1219
|
+
/** Stops after this many seconds (default: the recipe's loop). */
|
|
1220
|
+
readonly seconds?: number;
|
|
1221
|
+
}
|
|
1222
|
+
interface EffectPlayerOptions {
|
|
1223
|
+
readonly engine: WorkshopEngine;
|
|
1224
|
+
readonly effects: Readonly<Record<string, EffectDef>>;
|
|
1225
|
+
readonly behaviors?: Readonly<Record<string, () => Behavior>>;
|
|
1226
|
+
/** Where the viewer is, for the recipes that read it. */
|
|
1227
|
+
readonly view: EffectView;
|
|
1228
|
+
/** A stream for a seed (default `lehmer`). */
|
|
1229
|
+
readonly streamFor?: (seed: number) => RandomStream;
|
|
1230
|
+
readonly maxInstances?: number;
|
|
1231
|
+
readonly onCue?: (cue: CueRequest) => void;
|
|
1232
|
+
}
|
|
1233
|
+
interface EffectPlayer {
|
|
1234
|
+
/** Plays `id` at `point`; `null` when no recipe has that id or the cap of live effects is reached. Returns a handle for `stop`. */
|
|
1235
|
+
play(id: string, point: Vec3Tuple, options?: PlayOptions): number | null;
|
|
1236
|
+
stop(handle: number): void;
|
|
1237
|
+
/** Runs the timers and ticks of every live effect (the engine's pools are aged by its owner). */
|
|
1238
|
+
update(dt: number): void;
|
|
1239
|
+
clear(): void;
|
|
1240
|
+
readonly active: number;
|
|
1241
|
+
has(id: string): boolean;
|
|
1242
|
+
ids(): readonly string[];
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Plays the Workshop's recipes anywhere in the world, many at once, each with its own clock, variables and props, a place and a way it faces. They all
|
|
1246
|
+
* spawn into the one engine, so the pools stay shared and bounded. This is what `VfxWorld.play` and the host's `EffectSink` use.
|
|
1247
|
+
*/
|
|
1248
|
+
declare function createEffectPlayer(options: EffectPlayerOptions): EffectPlayer;
|
|
1249
|
+
|
|
1250
|
+
/** The kinds of sprite the game's pools make: debris, sparks, smoke, steam, drips... (the destruction renderer's old `ParticleKind`). */
|
|
1251
|
+
type SpriteKind = 'fire' | 'smoke' | 'sparks' | 'dust' | 'shards' | 'splinters' | 'chips' | 'fibers' | 'leaves' | 'drips' | 'ash' | 'steam' | 'flash' | 'foam';
|
|
1252
|
+
/** What happens to a sprite that reaches the ground. */
|
|
1253
|
+
type SpriteGround = 'none' | 'bounce' | 'stop' | 'land';
|
|
1254
|
+
interface SpriteKindDef {
|
|
1255
|
+
readonly id: SpriteKind;
|
|
1256
|
+
readonly additive: boolean;
|
|
1257
|
+
/** Life range in seconds. */
|
|
1258
|
+
readonly life: readonly [number, number];
|
|
1259
|
+
/** Start size range in metres (billboard diameter). */
|
|
1260
|
+
readonly size: readonly [number, number];
|
|
1261
|
+
/** Size multiplier reached at the end of the life. */
|
|
1262
|
+
readonly grow: number;
|
|
1263
|
+
/** Gravity multiplier (1 = full gravity). */
|
|
1264
|
+
readonly gravity: number;
|
|
1265
|
+
/** Constant upward acceleration in m/s² (heat, steam). */
|
|
1266
|
+
readonly rise: number;
|
|
1267
|
+
/** Velocity damping per second. */
|
|
1268
|
+
readonly drag: number;
|
|
1269
|
+
/** `0xRRGGBB` at the start and at the end of the life. */
|
|
1270
|
+
readonly c0: number;
|
|
1271
|
+
readonly c1: number;
|
|
1272
|
+
readonly alpha: number;
|
|
1273
|
+
/** Fraction of the life spent fading in. */
|
|
1274
|
+
readonly fadeIn: number;
|
|
1275
|
+
/** How much of the emission direction follows the surface normal (1) versus a random direction (0). */
|
|
1276
|
+
readonly cone: number;
|
|
1277
|
+
readonly ground: SpriteGround;
|
|
1278
|
+
readonly flutter?: number;
|
|
1279
|
+
readonly flicker?: number;
|
|
1280
|
+
}
|
|
1281
|
+
declare const SPRITE_KINDS: Readonly<Record<SpriteKind, SpriteKindDef>>;
|
|
1282
|
+
/** A copy of the kinds with some changed (a partial replaces the fields it names), added or removed (`null`); a game tunes its sprites without touching the core. */
|
|
1283
|
+
declare function patchSpriteKinds(base: Readonly<Record<string, SpriteKindDef>>, changes: Readonly<Record<string, Partial<SpriteKindDef> | SpriteKindDef | null>>): Record<string, SpriteKindDef>;
|
|
1284
|
+
|
|
1285
|
+
/** Per-spawn overrides. */
|
|
1286
|
+
interface SpriteSpawnOptions {
|
|
1287
|
+
/** `0xRRGGBB`: replaces the kind's colour ramp. */
|
|
1288
|
+
color?: number;
|
|
1289
|
+
/** Multiplier on the start size. */
|
|
1290
|
+
size?: number;
|
|
1291
|
+
/** Multiplier on the life. */
|
|
1292
|
+
life?: number;
|
|
1293
|
+
/** Multiplier on the peak alpha. */
|
|
1294
|
+
alpha?: number;
|
|
1295
|
+
/** Non-zero: a `land` sprite (a drip) that reaches the ground calls the owner's `onLand` with this tag. */
|
|
1296
|
+
tag?: number;
|
|
1297
|
+
/** Who hears the landing (see `VfxWorld.onLand`). */
|
|
1298
|
+
owner?: string;
|
|
1299
|
+
/** Height the sprite stops or lands at, instead of the ground's under it (a splash on a table top). */
|
|
1300
|
+
floor?: number;
|
|
1301
|
+
/** Multiplier on the kind's upward acceleration (slow steam). */
|
|
1302
|
+
rise?: number;
|
|
1303
|
+
}
|
|
1304
|
+
interface KindPoolHost {
|
|
1305
|
+
groundAt(x: number, z: number): number;
|
|
1306
|
+
gravity: number;
|
|
1307
|
+
land(owner: string, x: number, y: number, z: number, color: number, tag: number): void;
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* One fixed-size ring of sprites of the game's kinds, in typed arrays a renderer draws as points: `position`, `color`, `alpha` and `size` are what it
|
|
1311
|
+
* reads, `drawCount` how many records from the start. Additive and normal blending are two instances.
|
|
1312
|
+
*/
|
|
1313
|
+
declare class SpriteKindPool {
|
|
1314
|
+
readonly capacity: number;
|
|
1315
|
+
private readonly defs;
|
|
1316
|
+
private readonly owners;
|
|
1317
|
+
live: number;
|
|
1318
|
+
/** Records from the start the renderer draws (the highest live index + 1). */
|
|
1319
|
+
drawCount: number;
|
|
1320
|
+
readonly position: Float32Array;
|
|
1321
|
+
readonly color: Float32Array;
|
|
1322
|
+
readonly alpha: Float32Array;
|
|
1323
|
+
readonly size: Float32Array;
|
|
1324
|
+
private next;
|
|
1325
|
+
private high;
|
|
1326
|
+
private readonly velocity;
|
|
1327
|
+
private readonly age;
|
|
1328
|
+
private readonly life;
|
|
1329
|
+
private readonly size0;
|
|
1330
|
+
private readonly alive;
|
|
1331
|
+
private readonly kind;
|
|
1332
|
+
private readonly seed;
|
|
1333
|
+
private readonly alphaMul;
|
|
1334
|
+
private readonly tag;
|
|
1335
|
+
private readonly owner;
|
|
1336
|
+
private readonly colorHex;
|
|
1337
|
+
private readonly rgbStart;
|
|
1338
|
+
private readonly rgbEnd;
|
|
1339
|
+
private readonly bounced;
|
|
1340
|
+
private readonly floor;
|
|
1341
|
+
private readonly riseMul;
|
|
1342
|
+
constructor(capacity: number, defs: readonly SpriteKindDef[], owners: string[]);
|
|
1343
|
+
spawn(kind: number, p: readonly number[], v: readonly number[], random: () => number, options?: SpriteSpawnOptions): void;
|
|
1344
|
+
private ownerIndex;
|
|
1345
|
+
private kill;
|
|
1346
|
+
clear(): void;
|
|
1347
|
+
/** Shoves the live sprites within `radius` of a point away from it (a blast). */
|
|
1348
|
+
push(cx: number, cy: number, cz: number, radius: number, speed: number): void;
|
|
1349
|
+
update(dt: number, host: KindPoolHost): void;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
type Vec3 = readonly [number, number, number];
|
|
1353
|
+
interface SpriteKindSystemOptions {
|
|
1354
|
+
/** Most live sprites at once (additive takes 40 %, normal the rest). */
|
|
1355
|
+
readonly capacity: number;
|
|
1356
|
+
/** Count multiplier for bursts (0.6 on low quality). */
|
|
1357
|
+
readonly density: number;
|
|
1358
|
+
readonly seed: number;
|
|
1359
|
+
readonly groundAt: (x: number, z: number) => number;
|
|
1360
|
+
readonly gravity: number;
|
|
1361
|
+
readonly kinds?: Readonly<Record<string, SpriteKindDef>>;
|
|
1362
|
+
}
|
|
1363
|
+
type LandListener = (x: number, y: number, z: number, color: number, tag: number) => void;
|
|
1364
|
+
/**
|
|
1365
|
+
* The game's sprites of fixed kinds (debris, sparks, smoke, steam, drips...), burst or spawned one by one: two pooled rings, additive and normal, that
|
|
1366
|
+
* a renderer draws as points. This is the destruction renderer's old particle system with the maths unchanged and the drawing taken out.
|
|
1367
|
+
*/
|
|
1368
|
+
declare class SpriteKindSystem {
|
|
1369
|
+
private readonly options;
|
|
1370
|
+
readonly additive: SpriteKindPool;
|
|
1371
|
+
readonly normal: SpriteKindPool;
|
|
1372
|
+
private readonly random;
|
|
1373
|
+
private readonly ids;
|
|
1374
|
+
private readonly defs;
|
|
1375
|
+
private readonly index;
|
|
1376
|
+
private readonly owners;
|
|
1377
|
+
private readonly listeners;
|
|
1378
|
+
constructor(options: SpriteKindSystemOptions);
|
|
1379
|
+
get capacity(): number;
|
|
1380
|
+
get live(): number;
|
|
1381
|
+
/** Hears the landing of the drips of `owner` (the ones spawned with `{ owner, tag }`). Returns the function that stops listening. */
|
|
1382
|
+
onLand(owner: string, listener: LandListener): () => void;
|
|
1383
|
+
private kindOf;
|
|
1384
|
+
/** One sprite with an explicit velocity. */
|
|
1385
|
+
spawn(kind: SpriteKind | string, point: Vec3, velocity: Vec3, options?: SpriteSpawnOptions): void;
|
|
1386
|
+
/** `count` sprites leaving `point` around `normal` at about `speed` m/s. */
|
|
1387
|
+
burst(kind: SpriteKind | string, point: Vec3, normal: Vec3, count: number, speed?: number, options?: SpriteSpawnOptions): void;
|
|
1388
|
+
/** Blast wave: shoves the live sprites away from a point. */
|
|
1389
|
+
push(point: Vec3, radius: number, speed: number): void;
|
|
1390
|
+
update(dt: number): void;
|
|
1391
|
+
clear(): void;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
interface VfxOptions {
|
|
1395
|
+
readonly seed?: number;
|
|
1396
|
+
/** `per_event` (default): every explosion draws from a stream of its own seed, so a LAN client repeats it from a few bytes. `shared`: one stream for everything, like the Lab page (the goldens). */
|
|
1397
|
+
readonly randomMode?: RandomMode;
|
|
1398
|
+
readonly profile?: VfxProfileName | VfxProfile;
|
|
1399
|
+
readonly lod?: LodBands;
|
|
1400
|
+
/** The cap on explosions in one area; `false` turns it off. Default the game's: 6 in 4 s within 40 m, the extra ones at 0.3. */
|
|
1401
|
+
readonly areaCap?: AreaCap | false;
|
|
1402
|
+
/** Height of the ground for what bounces. Default: the `ground` field, else flat at 0. */
|
|
1403
|
+
readonly groundAt?: (x: number, z: number) => number;
|
|
1404
|
+
/** A deformable ground the craters dig into (see `createGroundField`). */
|
|
1405
|
+
readonly ground?: GroundField;
|
|
1406
|
+
readonly wind?: Vec3Like;
|
|
1407
|
+
readonly gravity?: number;
|
|
1408
|
+
/** The catalogue by id (default the Lab's 16 and `generic`); build another with `patchExplosions(EXPLOSIONS, ...)`. */
|
|
1409
|
+
readonly explosions?: Readonly<Record<string, ExplosionDef>>;
|
|
1410
|
+
readonly aliases?: Readonly<Record<string, string>>;
|
|
1411
|
+
/** The Workshop's recipes by id for `play` (default `GAME_EFFECTS`; build another with `patchEffects`). */
|
|
1412
|
+
readonly effects?: Readonly<Record<string, EffectDef>>;
|
|
1413
|
+
/** The sprites of fixed kinds (`burst`, `spawn`): pool size and count multiplier (default 2500 and 1; a `low` profile halves the pool and uses 0.6) and the kinds by id. */
|
|
1414
|
+
readonly sprites?: {
|
|
1415
|
+
readonly capacity?: number;
|
|
1416
|
+
readonly density?: number;
|
|
1417
|
+
readonly kinds?: Readonly<Record<string, SpriteKindDef>>;
|
|
1418
|
+
};
|
|
1419
|
+
readonly reducedMotion?: boolean;
|
|
1420
|
+
/** Hears everything that spawns, in order (the goldens use it). */
|
|
1421
|
+
readonly trace?: VfxTrace;
|
|
1422
|
+
readonly onRequest?: (request: VfxSideRequest) => void;
|
|
1423
|
+
}
|
|
1424
|
+
interface ExplosionOptions {
|
|
1425
|
+
readonly direction?: Vec3Like;
|
|
1426
|
+
/** Repeats the same visual: used in `per_event` mode. */
|
|
1427
|
+
readonly seed?: number;
|
|
1428
|
+
/** Multiplies the size of the effect (radius, marks, mushroom, fires). */
|
|
1429
|
+
readonly scale?: number;
|
|
1430
|
+
/** Seconds from now until it goes off (a chain). */
|
|
1431
|
+
readonly delay?: number;
|
|
1432
|
+
}
|
|
1433
|
+
interface FireOptions {
|
|
1434
|
+
readonly point: Vec3Like;
|
|
1435
|
+
readonly radius: number;
|
|
1436
|
+
readonly life: number;
|
|
1437
|
+
/** Flames per second per square-ish metre (the Lab's `rate`, default 22) and smoke puffs (default .6). */
|
|
1438
|
+
readonly rate?: number;
|
|
1439
|
+
readonly smoke?: number;
|
|
1440
|
+
/** Grows from `startRadius` to `radius` over `grow` seconds. */
|
|
1441
|
+
readonly startRadius?: number;
|
|
1442
|
+
readonly grow?: number;
|
|
1443
|
+
/** `0xRRGGBB` of the smoke (default soot black). */
|
|
1444
|
+
readonly smokeColor?: number;
|
|
1445
|
+
/** Moves with a thing (a burning part): the fire sits at its position plus `offset`. */
|
|
1446
|
+
readonly follow?: Follow;
|
|
1447
|
+
readonly offset?: Vec3Like;
|
|
1448
|
+
readonly seed?: number;
|
|
1449
|
+
}
|
|
1450
|
+
/** The pools as the renderer reads them: live records, oldest first. */
|
|
1451
|
+
interface VfxPoolsView {
|
|
1452
|
+
readonly puffs: OrderedPool<Puff>;
|
|
1453
|
+
readonly sparks: OrderedPool<Spark>;
|
|
1454
|
+
readonly glows: OrderedPool<Glow>;
|
|
1455
|
+
readonly chunks: OrderedPool<Chunk>;
|
|
1456
|
+
readonly shocks: OrderedPool<Shock>;
|
|
1457
|
+
readonly rings: OrderedPool<Ring>;
|
|
1458
|
+
readonly lights: LightPool;
|
|
1459
|
+
readonly marks: MarkStore;
|
|
1460
|
+
readonly ground: GroundField | undefined;
|
|
1461
|
+
}
|
|
1462
|
+
interface VfxWorld {
|
|
1463
|
+
/** Sets off an explosion of the catalogue by id (an explosive id or an alias); `null` when the id is unknown. */
|
|
1464
|
+
explosion(id: string, point: Vec3Like, options?: ExplosionOptions): number | null;
|
|
1465
|
+
/** A lingering area fire (a molotov's pool, a burning part). Returns a handle for `stop`. */
|
|
1466
|
+
fire(options: FireOptions): number;
|
|
1467
|
+
/**
|
|
1468
|
+
* Plays a recipe of the Workshop (a blood hit, a muzzle flash, a collapse) at `point`, facing `options.direction`, into the world's Workshop pools
|
|
1469
|
+
* (`workshop()`); `null` when the id is unknown. Returns a handle for `stop`.
|
|
1470
|
+
*/
|
|
1471
|
+
play(id: string, point: Vec3Like, options?: PlayOptions): number | null;
|
|
1472
|
+
/** The Workshop's pools (sprites, streaks, debris, decals, rings, lights, screen): what the renderer draws for `play`. Made on first use. */
|
|
1473
|
+
workshop(): WorkshopEngine;
|
|
1474
|
+
/** The Workshop engine if something already made it (`play`, `workshop()`); never creates it. */
|
|
1475
|
+
peekWorkshop(): WorkshopEngine | undefined;
|
|
1476
|
+
/** The ids `play` accepts. */
|
|
1477
|
+
effectIds(): readonly string[];
|
|
1478
|
+
/** `count` sprites of a kind leaving `point` around `normal` at about `speed` m/s (debris, sparks, smoke, steam, drips...). */
|
|
1479
|
+
burst(kind: SpriteKind | string, point: Vec3Like, normal: Vec3Like, count: number, speed?: number, options?: SpriteSpawnOptions): void;
|
|
1480
|
+
/** One sprite of a kind with an explicit velocity. */
|
|
1481
|
+
spawn(kind: SpriteKind | string, point: Vec3Like, velocity: Vec3Like, options?: SpriteSpawnOptions): void;
|
|
1482
|
+
/** Hears where the sprites of `owner` that land (drips spawned with `{ owner, tag }`) touch the ground. Returns the function that stops listening. */
|
|
1483
|
+
onLand(owner: string, listener: LandListener): () => void;
|
|
1484
|
+
/** The sprite pools as the renderer reads them. */
|
|
1485
|
+
sprites(): SpriteKindSystem;
|
|
1486
|
+
/** Pushes the smoke and dust within `radius` of `point` outwards, as fast as `speed` at the centre. */
|
|
1487
|
+
push(point: Vec3Like, radius: number, speed: number): void;
|
|
1488
|
+
stop(handle: number): void;
|
|
1489
|
+
setLayer(layer: VfxLayer, on: boolean): void;
|
|
1490
|
+
layer(layer: VfxLayer): boolean;
|
|
1491
|
+
setCamera(position: Vec3Like): void;
|
|
1492
|
+
/** Forces the scale of every explosion from now on (`null`: back to the distance bands and the cap). */
|
|
1493
|
+
forceLod(scale: number | null): void;
|
|
1494
|
+
update(dt: number): void;
|
|
1495
|
+
screen(): Readonly<ScreenState>;
|
|
1496
|
+
stats(): VfxStats;
|
|
1497
|
+
pools(): VfxPoolsView;
|
|
1498
|
+
/** The live lingering fires, oldest first. */
|
|
1499
|
+
fires(): readonly Fire[];
|
|
1500
|
+
/** Hears every mark the moment it is made, and when they are cleared. Returns the function that stops listening. */
|
|
1501
|
+
onMarks(listener: (event: MarkEvent) => void): () => void;
|
|
1502
|
+
/** Seconds the world has run since it was created or cleared. */
|
|
1503
|
+
time(): number;
|
|
1504
|
+
/** The state of the shared stream (`randomMode: 'shared'`): what a golden compares after a run. */
|
|
1505
|
+
randomState(): number;
|
|
1506
|
+
/** Takes everything away (pools, marks, ground, timers, lights, screen) and restarts the clock. */
|
|
1507
|
+
clear(): void;
|
|
1508
|
+
/** The catalogue ids `explosion` accepts, aliases included. */
|
|
1509
|
+
catalog(): readonly string[];
|
|
1510
|
+
}
|
|
1511
|
+
declare function createVfx(options?: VfxOptions): VfxWorld;
|
|
1512
|
+
|
|
1513
|
+
/**
|
|
1514
|
+
* The 16 profiles of the Explosion Lab (`PROF`, L795-812) keyed by the id of the explosive in `game-weapons` (`m67`, `molotov`, `pipe_bomb`,
|
|
1515
|
+
* `propane_p13`, `dynamite`, `c4`, `claymore`, `flashbang`, `m79_40mm`, `m72_66mm`, `at4_84mm`, `pg7v`, `fuel_barrel`, `car_fuel_tank`, `fuel_pump`,
|
|
1516
|
+
* `fuel_station_tank`), plus `generic` (the M67 for a part with no explosive id: scale it by `injury / 15`). Each one lists the Lab lines it comes from.
|
|
1517
|
+
*/
|
|
1518
|
+
declare const EXPLOSIONS: Readonly<Record<string, ExplosionDef>>;
|
|
1519
|
+
/** Explosives with no profile of their own: the Carl Gustaf blasts like the AT4, the VOG-25 like the M79. */
|
|
1520
|
+
declare const EXPLOSION_ALIASES: Readonly<Record<string, string>>;
|
|
1521
|
+
/** A copy of a catalogue with some profiles changed (a partial replaces the fields it names) or removed (`null`); a game adds, tunes or drops effects without touching the core. */
|
|
1522
|
+
declare function patchExplosions(base: Readonly<Record<string, ExplosionDef>>, changes: Readonly<Record<string, Partial<ExplosionDef> | ExplosionDef | null>>): Record<string, ExplosionDef>;
|
|
1523
|
+
|
|
1524
|
+
/** Every effect of the Workshop by id. A game adds, changes or removes entries with `patchEffects`. */
|
|
1525
|
+
declare const WORKSHOP_EFFECTS: Readonly<Record<string, EffectDef>>;
|
|
1526
|
+
/** The Workshop's recipes plus the one-shot effects the destruction events play (`event-effects.json`): what a world plays by default. */
|
|
1527
|
+
declare const GAME_EFFECTS: Readonly<Record<string, EffectDef>>;
|
|
1528
|
+
/** A copy of the recipes with some changed (a partial replaces the fields it names), added or removed (`null`); a game tunes the Workshop's effects without touching the core. */
|
|
1529
|
+
declare function patchEffects(base: Readonly<Record<string, EffectDef>>, changes: Readonly<Record<string, Partial<EffectDef> | EffectDef | null>>): Record<string, EffectDef>;
|
|
1530
|
+
|
|
1531
|
+
/**
|
|
1532
|
+
* The effects the destruction events play, as slices of the Workshop's recipes: the same bursts, with the recipe's own numbers, centred on the point the event
|
|
1533
|
+
* happens (`data/event-effects.json` says which event plays which). They are not Workshop pages, so they have no golden of their own; each cites the lines it was cut from.
|
|
1534
|
+
*/
|
|
1535
|
+
declare const EVENT_EFFECTS: readonly EffectDef[];
|
|
1536
|
+
|
|
1537
|
+
/** What a game event looks like to the map: the kind of event and the little that picks its effect. */
|
|
1538
|
+
interface GameEvent {
|
|
1539
|
+
/** `spall`, `stage`, `expose`, `collapse`, `explode`, `fracture`... (strings, so there is no compile dependency on the destruction package). */
|
|
1540
|
+
readonly kind: string;
|
|
1541
|
+
/** The stage of a `stage` event (1, 2 or 3). */
|
|
1542
|
+
readonly stage?: number;
|
|
1543
|
+
/** The material of a `spall` or `fracture` event. */
|
|
1544
|
+
readonly material?: string;
|
|
1545
|
+
}
|
|
1546
|
+
type EventMap = Readonly<Record<string, string | Readonly<Record<string, string>>>>;
|
|
1547
|
+
declare const EVENT_EFFECTS_MAP: EventMap;
|
|
1548
|
+
/**
|
|
1549
|
+
* The effect id that plays for an event (`undefined` when the map has none). A string entry may use `{material}`; an object entry is chosen by the event's
|
|
1550
|
+
* stage or material. A game passes its own map to add or change entries.
|
|
1551
|
+
*/
|
|
1552
|
+
declare function effectForEvent(event: GameEvent, map?: EventMap): string | undefined;
|
|
1553
|
+
|
|
1554
|
+
/** Locales shipped with the package. Unknown locales fall back to `en`. */
|
|
1555
|
+
type VfxLocale = 'en' | 'pt-BR';
|
|
1556
|
+
/** The texts of one Workshop effect: its card in the list and its sheet (when, how it looks, what it costs, what goes over the network). */
|
|
1557
|
+
interface EffectTexts {
|
|
1558
|
+
readonly name: string;
|
|
1559
|
+
readonly short: string;
|
|
1560
|
+
/** The cost shown on the card, and what comes with it. */
|
|
1561
|
+
readonly cost: string;
|
|
1562
|
+
readonly costNote: string;
|
|
1563
|
+
/** The label of the effect's parameter, when it has one. */
|
|
1564
|
+
readonly paramLabel?: string;
|
|
1565
|
+
readonly when: string;
|
|
1566
|
+
readonly look: string;
|
|
1567
|
+
readonly budget: string;
|
|
1568
|
+
readonly network: string;
|
|
1569
|
+
}
|
|
1570
|
+
/** The words around the sheet (`renderSheet`, W1266). */
|
|
1571
|
+
interface SheetLabels {
|
|
1572
|
+
readonly when: string;
|
|
1573
|
+
readonly look: string;
|
|
1574
|
+
readonly budget: string;
|
|
1575
|
+
readonly network: string;
|
|
1576
|
+
readonly quality: string;
|
|
1577
|
+
readonly replay: string;
|
|
1578
|
+
readonly auto: string;
|
|
1579
|
+
}
|
|
1580
|
+
interface VfxStrings {
|
|
1581
|
+
readonly effects: Readonly<Record<string, EffectTexts>>;
|
|
1582
|
+
readonly sheet: SheetLabels;
|
|
1583
|
+
readonly groups: Readonly<Record<string, string>>;
|
|
1584
|
+
}
|
|
1585
|
+
declare const locales: Record<VfxLocale, VfxStrings>;
|
|
1586
|
+
declare const resolveStrings: (locale: string | undefined) => VfxStrings;
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* The Workshop's view (W1259-1262): it glides to each effect's `view` (`camTo`) in about 0.7 s and persists between effects, so an effect that reads the
|
|
1590
|
+
* camera (a ring that faces the viewer, a mist at the lens) sees where the previous one left it.
|
|
1591
|
+
*/
|
|
1592
|
+
declare class EffectCamera {
|
|
1593
|
+
position: Vec3Tuple;
|
|
1594
|
+
target: Vec3Tuple;
|
|
1595
|
+
private animation;
|
|
1596
|
+
goTo(eye: Vec3Tuple, target: Vec3Tuple): void;
|
|
1597
|
+
place(eye: Vec3Tuple, target: Vec3Tuple): void;
|
|
1598
|
+
hold(): void;
|
|
1599
|
+
update(dt: number): void;
|
|
1600
|
+
/** A direction given in the camera's own axes, in world axes. */
|
|
1601
|
+
forward(local: readonly number[]): Vec3Tuple;
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
interface EffectRunnerOptions {
|
|
1605
|
+
readonly engine: WorkshopEngine;
|
|
1606
|
+
readonly effects: Readonly<Record<string, EffectDef>>;
|
|
1607
|
+
readonly behaviors?: Readonly<Record<string, Behavior>>;
|
|
1608
|
+
readonly onCue?: (cue: CueRequest) => void;
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* The Workshop's one-effect-at-a-time view (W1253-1295): choosing an effect clears the set and runs it; each frame fires the timers due, runs the tick, ages
|
|
1612
|
+
* the pools, glides the camera and draws the camera shake. This is what the bench shows and what the golden replays; `createEffectPlayer` plays many at once.
|
|
1613
|
+
*/
|
|
1614
|
+
declare class EffectRunner {
|
|
1615
|
+
private readonly options;
|
|
1616
|
+
readonly camera: EffectCamera;
|
|
1617
|
+
readonly instance: EffectInstance;
|
|
1618
|
+
/** The camera shake of the last frame, three draws per frame as in the page. */
|
|
1619
|
+
shake: Vec3Tuple;
|
|
1620
|
+
constructor(options: EffectRunnerOptions);
|
|
1621
|
+
get current(): EffectDef | undefined;
|
|
1622
|
+
get variables(): Map<string, unknown>;
|
|
1623
|
+
get param(): number;
|
|
1624
|
+
get fresh(): boolean;
|
|
1625
|
+
get time(): number;
|
|
1626
|
+
/** Seconds since the effect was chosen: unlike `time`, a restart of the loop does not reset it (`el`). */
|
|
1627
|
+
get elapsed(): number;
|
|
1628
|
+
get random(): RandomStream;
|
|
1629
|
+
/** `select` + `startLoop` (W1253-1257): clears everything, then runs the effect's setup and timeline. */
|
|
1630
|
+
start(id: string, param?: number): boolean;
|
|
1631
|
+
/** `startLoop` again: the same effect from its start (the replay button and the end of the loop). */
|
|
1632
|
+
restart(): void;
|
|
1633
|
+
/** One frame of the page (W1280-1295). */
|
|
1634
|
+
update(dt: number): void;
|
|
1635
|
+
execute(steps: readonly EffectStep[]): void;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
/** How to build each prop the Workshop animates by hand, by id (see `Behavior`). A game adds its own the same way. */
|
|
1639
|
+
declare const WORKSHOP_BEHAVIORS: Readonly<Record<string, () => Behavior>>;
|
|
1640
|
+
/** A fresh set of the props the Workshop animates by hand, by id; one per runner, since they keep state. */
|
|
1641
|
+
declare function createWorkshopBehaviors(factories?: Readonly<Record<string, () => Behavior>>): Record<string, Behavior>;
|
|
1642
|
+
|
|
1643
|
+
/** Where and how one explosion goes off. */
|
|
1644
|
+
interface ExplosionCall {
|
|
1645
|
+
readonly x: number;
|
|
1646
|
+
readonly y: number;
|
|
1647
|
+
readonly z: number;
|
|
1648
|
+
/** Where it is aimed (a rocket's direction, a charge's face). */
|
|
1649
|
+
readonly direction?: MutableVec3;
|
|
1650
|
+
/** The stream the whole effect draws from: the world's in `shared` mode, the event's own in `per_event`. */
|
|
1651
|
+
readonly random: RandomStream;
|
|
1652
|
+
readonly handle: number;
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* The Lab's layer compositor (`blast`, L642-714), layer by layer in the Lab's order and drawing from the stream in the Lab's order: flash, fireball,
|
|
1656
|
+
* its own smoke, shock wave, dust, shrapnel, debris, then marks, mushroom and lingering fires, and last what the host does (glass, characters).
|
|
1657
|
+
*/
|
|
1658
|
+
declare function composeExplosion(core: VfxCore, def: ExplosionDef, call: ExplosionCall): number;
|
|
1659
|
+
|
|
1660
|
+
/** The game's bands: distance minus the visual radius, 15 / 40 / 80 m, scales 1 / .5 / .2 / .1 (G68203, the Workshop's quality bands). The default. */
|
|
1661
|
+
declare const LOD_GAME: LodBands;
|
|
1662
|
+
/** The Lab's own bands (L481): distance minus three visual radii, 20 / 45 / 85 m, scales 1 / .5 / .2 / .08. Used on the bench and in the goldens. */
|
|
1663
|
+
declare const LOD_LAB: LodBands;
|
|
1664
|
+
/** The scale of an effect `distance` metres from the camera, for an effect whose fireball has `visualRadius`. */
|
|
1665
|
+
declare function lodScale(bands: LodBands, distance: number, visualRadius: number): number;
|
|
1666
|
+
|
|
1667
|
+
/**
|
|
1668
|
+
* The pool sizes of the three profiles. `high` is the bench and the goldens (the Lab's caps L131/240/295/367 and the Workshop's W221), `medium` the
|
|
1669
|
+
* game's default (G67747/67762), `low` close to the game's own budgets (G68074, G68108).
|
|
1670
|
+
*/
|
|
1671
|
+
declare const PROFILES: Readonly<Record<VfxProfileName, VfxProfile>>;
|
|
1672
|
+
/** The Lab's per-event meters (L1043-1044): 400 GPU particles, 40 physics debris, and 4 + 2 lights. */
|
|
1673
|
+
declare const EVENT_BUDGET: {
|
|
1674
|
+
readonly particles: 400;
|
|
1675
|
+
readonly debris: 40;
|
|
1676
|
+
readonly blastLights: 4;
|
|
1677
|
+
readonly fireLights: 2;
|
|
1678
|
+
};
|
|
1679
|
+
/** Particles an explosion makes on the GPU, the number of the Lab's effect sheet (L1033): fireballs, smoke, dust, shrapnel, the mushroom and the embers. */
|
|
1680
|
+
declare function estimateCost(def: ExplosionDef): number;
|
|
1681
|
+
|
|
1682
|
+
declare function createScreenState(): ScreenState;
|
|
1683
|
+
/**
|
|
1684
|
+
* The decays of the Lab (L1087, L1092: flash by its own rate, shake by 5 per second) and the Workshop (W354-355: white, red, the two sides, chroma,
|
|
1685
|
+
* desaturation, gas and the heartbeat), with the same constants.
|
|
1686
|
+
*/
|
|
1687
|
+
declare function updateScreen(state: ScreenState, dt: number): void;
|
|
1688
|
+
|
|
1689
|
+
/** The Lab's smoke colours (L211-214), converted to linear once. Colours of an explosion in data are `0xRRGGBB` and go through `hexToLinearRgb` the same way. */
|
|
1690
|
+
declare const SMOKE_COLORS: {
|
|
1691
|
+
readonly grey: Rgb;
|
|
1692
|
+
readonly dark: Rgb;
|
|
1693
|
+
readonly black: Rgb;
|
|
1694
|
+
readonly brown: Rgb;
|
|
1695
|
+
readonly dust: Rgb;
|
|
1696
|
+
readonly concrete: Rgb;
|
|
1697
|
+
readonly white: Rgb;
|
|
1698
|
+
readonly blood: Rgb;
|
|
1699
|
+
readonly bile: Rgb;
|
|
1700
|
+
readonly gas: Rgb;
|
|
1701
|
+
};
|
|
1702
|
+
|
|
1703
|
+
export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, type Chunk, type CueRequest, type DebrisSpawn, type Decal, type DecalOptions, type DirtMark, EVENT_BUDGET, EVENT_EFFECTS, EVENT_EFFECTS_MAP, EXPLOSIONS, EXPLOSION_ALIASES, EffectCamera, type EffectDef, EffectInstance, type EffectPlayer, type EffectPlayerOptions, EffectRunner, type EffectRunnerOptions, type EffectStep, type EffectTexts, type EffectView, type ExplosionCall, type ExplosionDef, type ExplosionOptions, type Fire, type FireLight, type FireOptions, type FireSpec, type Follow, GAME_EFFECTS, type GameEvent, type Glow, type GroundField, type GroundFieldOptions, type InstanceDeps, type InstanceSetup, type KindPoolHost, LOD_GAME, LOD_LAB, type LandListener, type LensBlob, type LightGlow, type LightPool, type LodBands, type Mark, type MarkEvent, type MarkStore, type MushroomSpec, type MutableVec3, OrderedPool, PROFILES, type Placement, type PlayOptions, type PostProcess, type Puff, type RandomStream, type Rgb, type Ring, type RockMark, SMOKE_COLORS, SPRITE_KINDS, type Schedule, type ScorchMark, type ScreenState, type SheetLabels, type Shock, type Spark, type SpriteGround, type SpriteKind, type SpriteKindDef, SpriteKindPool, SpriteKindSystem, type SpriteKindSystemOptions, type SpriteSpawn, type SpriteSpawnOptions, type SpriteSystem, VFX_LAYERS, type Vec3Like, type Vec3Tuple, type VfxLayer, type VfxLocale, type VfxOptions, type VfxPoolsView, type VfxProfile, type VfxProfileName, type VfxSideRequest, type VfxStats, type VfxStrings, type VfxTrace, type VfxWorld, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWorkshopBehaviors, effectForEvent, estimateCost, hexToLinearRgb, hexToRgb, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, resolveStrings, streamFor, updateScreen, workshopGround };
|