@adatechnology/game-vfx 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -284,6 +284,8 @@ interface Fire {
284
284
  color: Rgb;
285
285
  rng: RandomStream;
286
286
  handle: number;
287
+ /** The thing that burns (`FireOptions.source`): the fire and what it gave off go with `VfxWorld.clearSource`. */
288
+ source: string | undefined;
287
289
  }
288
290
 
289
291
  interface GroundFieldOptions {
@@ -461,6 +463,8 @@ interface Glow {
461
463
  outZ: number;
462
464
  outSize: number;
463
465
  outIntensity: number;
466
+ /** The thing it was made for: `VfxWorld.clearSource` takes it away when that thing leaves. */
467
+ source: string | undefined;
464
468
  }
465
469
 
466
470
  /** Debris with embers (L366-400). The last block is what the renderer reads: the colour already blended towards the glow of a hot piece. */
@@ -491,6 +495,8 @@ interface Chunk {
491
495
  glow: Glow | null;
492
496
  rng: RandomStream;
493
497
  outColor: [number, number, number];
498
+ /** The thing it was made for: `VfxWorld.clearSource` takes it away when that thing leaves. */
499
+ source: string | undefined;
494
500
  }
495
501
  /** `_hotCol` (L399-400): the colour of a hot piece, blended towards the glow while it is young. */
496
502
  declare function colorOfChunk(chunk: Chunk): readonly [number, number, number];
@@ -534,8 +540,20 @@ interface Confiner {
534
540
  * walls (a puff is a ball, not a point: its middle stops before its edge goes through the glass).
535
541
  */
536
542
  confine(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, pad: number, dt: number): boolean;
543
+ /** `confine` with the step in an object the caller reuses: eight numbers passed to a call are boxed on the heap, one object is not. `move` is only read during the call: it is not kept. */
544
+ confineMove(move: ConfineMove, dt: number): boolean;
537
545
  readonly out: ConfineResult;
538
546
  }
547
+ /** One particle's step for {@link Confiner.confineMove}: from `(x0, y0, z0)` to `(x1, y1, z1)`, kept `pad` metres off the walls. */
548
+ interface ConfineMove {
549
+ x0: number;
550
+ y0: number;
551
+ z0: number;
552
+ x1: number;
553
+ y1: number;
554
+ z1: number;
555
+ pad: number;
556
+ }
539
557
  /**
540
558
  * The closed spaces of a world by id. Each step of a carried particle that would cross a wall is tested: through an opening it passes (a hole only at
541
559
  * its rate), through a closed wall only at the leak; otherwise it stays on its side, put back on the wall and sliding along it.
@@ -548,6 +566,8 @@ declare class Enclosures implements Confiner {
548
566
  private readonly l0;
549
567
  private readonly l1;
550
568
  private readonly q;
569
+ private readonly h;
570
+ private readonly move;
551
571
  constructor(seed?: number);
552
572
  get empty(): boolean;
553
573
  get size(): number;
@@ -564,7 +584,14 @@ declare class Enclosures implements Confiner {
564
584
  /** The opening the wall point `q` (local) is in lets it through now. */
565
585
  private through;
566
586
  confine(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, pad: number, dt: number): boolean;
587
+ confineMove(move: ConfineMove, dt: number): boolean;
567
588
  }
589
+ /** {@link slideAlong} written back into the particle's own velocity, nothing allocated. */
590
+ declare function slideInto(out: ConfineResult, velocity: {
591
+ vx: number;
592
+ vy: number;
593
+ vz: number;
594
+ }): void;
568
595
  /** Takes the part of a velocity that runs into the wall away (what is left slides along it). */
569
596
  declare function slideAlong(out: ConfineResult, vx: number, vy: number, vz: number): [number, number, number];
570
597
 
@@ -615,6 +642,8 @@ interface Puff {
615
642
  age: number;
616
643
  heat: number;
617
644
  size: number;
645
+ /** The thing it was made for (a burning part's object): `VfxWorld.clearSource` takes it away when that thing leaves. */
646
+ source: string | undefined;
618
647
  }
619
648
 
620
649
  /** 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. */
@@ -649,6 +678,8 @@ interface Spark {
649
678
  g: number;
650
679
  bounce: number;
651
680
  age: number;
681
+ /** The thing it was made for (a burning part's object): `VfxWorld.clearSource` takes it away when that thing leaves. */
682
+ source: string | undefined;
652
683
  }
653
684
 
654
685
  interface Schedule {
@@ -731,6 +762,8 @@ interface VfxCore {
731
762
  /** Ground a blast opens a dirt crater in (`VfxOptions.cratersAt`). */
732
763
  cratersAt?: (x: number, z: number) => boolean;
733
764
  emit(request: VfxSideRequest): void;
765
+ /** The thing what is spawned now is made for (`ExplosionOptions.source` while it goes off): the records take it unless they name their own. */
766
+ source: string | undefined;
734
767
  }
735
768
 
736
769
  type Vec3Tuple = readonly [number, number, number];
@@ -1605,11 +1638,18 @@ interface SpriteSpawnOptions {
1605
1638
  tag?: number;
1606
1639
  /** Who hears the landing (see `VfxWorld.onLand`). */
1607
1640
  owner?: string;
1641
+ /** The thing the sprite was made for (a world object's id): `VfxWorld.clearSource` takes its sprites away when that thing leaves. */
1642
+ source?: string;
1608
1643
  /** Height the sprite stops or lands at, instead of the ground's under it (a splash on a table top). */
1609
1644
  floor?: number;
1610
1645
  /** Multiplier on the kind's upward acceleration (slow steam). */
1611
1646
  rise?: number;
1612
1647
  }
1648
+ /** The sources the pools of one system share: a name keeps its number until `SpriteKindSystem.clearSource` forgets it, and a number is never given twice. */
1649
+ interface SpriteSources {
1650
+ readonly ids: Map<string, number>;
1651
+ next: number;
1652
+ }
1613
1653
  interface KindPoolHost {
1614
1654
  groundAt(x: number, z: number): number;
1615
1655
  gravity: number;
@@ -1625,6 +1665,7 @@ declare class SpriteKindPool {
1625
1665
  readonly capacity: number;
1626
1666
  private readonly defs;
1627
1667
  private readonly owners;
1668
+ private readonly sources;
1628
1669
  live: number;
1629
1670
  /** Records from the start the renderer draws (the highest live index + 1). */
1630
1671
  drawCount: number;
@@ -1644,15 +1685,19 @@ declare class SpriteKindPool {
1644
1685
  private readonly alphaMul;
1645
1686
  private readonly tag;
1646
1687
  private readonly owner;
1688
+ private readonly source;
1647
1689
  private readonly colorHex;
1648
1690
  private readonly rgbStart;
1649
1691
  private readonly rgbEnd;
1650
1692
  private readonly bounced;
1651
1693
  private readonly floor;
1652
1694
  private readonly riseMul;
1653
- constructor(capacity: number, defs: readonly SpriteKindDef[], owners: string[]);
1695
+ constructor(capacity: number, defs: readonly SpriteKindDef[], owners: string[], sources?: SpriteSources);
1654
1696
  spawn(kind: number, p: readonly number[], v: readonly number[], random: () => number, options?: SpriteSpawnOptions): void;
1655
1697
  private ownerIndex;
1698
+ private sourceIndex;
1699
+ /** Kills the live sprites made for `source`; returns how many went. */
1700
+ clearSource(source: string): number;
1656
1701
  private kill;
1657
1702
  clear(): void;
1658
1703
  /** Shoves the live sprites within `radius` of a point away from it (a blast). */
@@ -1687,6 +1732,7 @@ declare class SpriteKindSystem {
1687
1732
  private readonly defs;
1688
1733
  private readonly index;
1689
1734
  private readonly owners;
1735
+ private readonly sources;
1690
1736
  private readonly listeners;
1691
1737
  constructor(options: SpriteKindSystemOptions);
1692
1738
  get capacity(): number;
@@ -1701,6 +1747,8 @@ declare class SpriteKindSystem {
1701
1747
  /** Blast wave: shoves the live sprites away from a point. */
1702
1748
  push(point: Vec3, radius: number, speed: number): void;
1703
1749
  update(dt: number): void;
1750
+ /** Kills the live sprites made for `source` (`SpriteSpawnOptions.source`); returns how many went. */
1751
+ clearSource(source: string): number;
1704
1752
  clear(): void;
1705
1753
  }
1706
1754
 
@@ -1746,6 +1794,8 @@ interface ExplosionOptions {
1746
1794
  readonly scale?: number;
1747
1795
  /** Seconds from now until it goes off (a chain). */
1748
1796
  readonly delay?: number;
1797
+ /** The thing that went off (a world object's id): what the blast throws goes with `clearSource`. */
1798
+ readonly source?: string;
1749
1799
  }
1750
1800
  interface FireOptions {
1751
1801
  readonly point: Vec3Like;
@@ -1763,6 +1813,8 @@ interface FireOptions {
1763
1813
  readonly follow?: Follow;
1764
1814
  readonly offset?: Vec3Like;
1765
1815
  readonly seed?: number;
1816
+ /** The thing that burns (a world object's id): `clearSource` puts the fire out and takes away the flames, smoke and embers it gave off. */
1817
+ readonly source?: string;
1766
1818
  }
1767
1819
  /** The pools as the renderer reads them: live records, oldest first. */
1768
1820
  interface VfxPoolsView {
@@ -1815,6 +1867,11 @@ interface VfxWorld {
1815
1867
  /** The closed spaces declared now. */
1816
1868
  enclosures(): Enclosures;
1817
1869
  stop(handle: number): void;
1870
+ /**
1871
+ * The thing `source` names left the world for good: its fires go out, and every flame, smoke puff, ember and sprite made for it
1872
+ * (`FireOptions.source`, `SpriteSpawnOptions.source`) goes at once instead of living out its life. Returns how many records went.
1873
+ */
1874
+ clearSource(source: string): number;
1818
1875
  setLayer(layer: VfxLayer, on: boolean): void;
1819
1876
  layer(layer: VfxLayer): boolean;
1820
1877
  setCamera(position: Vec3Like): void;
@@ -1856,6 +1913,11 @@ declare const EXPLOSIONS: Readonly<Record<string, ExplosionDef>>;
1856
1913
  declare const EXPLOSION_ALIASES: Readonly<Record<string, string>>;
1857
1914
  /** 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. */
1858
1915
  declare function patchExplosions(base: Readonly<Record<string, ExplosionDef>>, changes: Readonly<Record<string, Partial<ExplosionDef> | ExplosionDef | null>>): Record<string, ExplosionDef>;
1916
+ /**
1917
+ * Every explosion a catalogue can play, by id (each profile once; an alias plays its profile): what a host warms at load, so that no explosive's first
1918
+ * blast links its programs or uploads its buffers in play. Derived from the catalogue, so an explosive added to it is warmed with no list to update.
1919
+ */
1920
+ declare function explosionEffectIds(explosions?: Readonly<Record<string, ExplosionDef>>): string[];
1859
1921
 
1860
1922
  /** Every effect of the Workshop by id. A game adds, changes or removes entries with `patchEffects`. */
1861
1923
  declare const WORKSHOP_EFFECTS: Readonly<Record<string, EffectDef>>;
@@ -1879,6 +1941,12 @@ type DebrisEffectFamily = (typeof DEBRIS_EFFECT_FAMILIES)[number];
1879
1941
  /** The variables a host sets (`PlayOptions.values`) to draw the debris and the dust in the colour of the material that broke. */
1880
1942
  declare const DEBRIS_COLOR_VARIABLE = "debrisColor";
1881
1943
  declare const DUST_COLOR_VARIABLE = "dustColor";
1944
+ /**
1945
+ * Set (to 1) by a host that draws the pieces of what broke itself (the destruction renderer: its fragments and the loose parts in physics): the breach and
1946
+ * collapse effects then raise only their dust, without the stand-in blocks they throw for a scene that has none, which would lie beside the real pieces
1947
+ * at a size and shape the material does not break into.
1948
+ */
1949
+ declare const PIECES_DRAWN_VARIABLE = "piecesDrawn";
1882
1950
  /** The stage, breach and collapse effects of every family, and the rebar laid bare. */
1883
1951
  declare const MATERIAL_EVENT_EFFECTS: readonly EffectDef[];
1884
1952
 
@@ -2394,4 +2462,4 @@ declare function resolveWaterShotProfile(profile: string | WaterShotProfile, tab
2394
2462
  /** Changes a profile table without touching the kit's: `null` removes an entry, a partial entry is merged over the old one. */
2395
2463
  declare function patchWaterShotProfiles(base: Readonly<Record<string, WaterShotProfile>>, changes: Readonly<Record<string, Partial<WaterShotProfile> | null>>): Record<string, WaterShotProfile>;
2396
2464
 
2397
- export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, type Carrier, type Chunk, type ConfineResult, type Confiner, type CueRequest, DEBRIS_COLOR_VARIABLE, DEBRIS_EFFECT_FAMILIES, DUST_COLOR_VARIABLE, type DebrisEffectFamily, 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 EffectTrack, type EffectView, Enclosures, 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, MATERIAL_EVENT_EFFECTS, type Mark, type MarkEvent, type MarkStore, type MeshParticle, MeshPool, type MeshShape, type MeshSpawn, type MushroomSpec, type MutableVec3, OrderedPool, PROFILES, type Placement, type PlayOptions, type PostProcess, type Puddle, type Puff, type Quaternion, RAIN_CAPACITY, RainField, type RandomStream, type Rgb, type Ring, type RockMark, SCRAPE_LIMIT, SMOKE_COLORS, SPRITE_KINDS, type Schedule, type ScorchMark, type ScrapeMark, 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, VIEWMODEL_EFFECTS, type Vec3Like, type Vec3Tuple, type VfxEnclosure, type VfxEnclosureBox, type VfxLayer, type VfxLocale, type VfxOptions, type VfxPoolsView, type VfxProfile, type VfxProfileName, type VfxSideRequest, type VfxStats, type VfxStrings, type VfxTrace, type VfxWorld, WATER_BLASTS, WATER_BLAST_KINDS, WATER_LIMITS, WATER_SHOT_BY_CALIBER, WATER_SHOT_PROFILES, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, WORKSHOP_PUDDLES, type WaterBlastCharge, type WaterBlastKind, type WaterBlastKindId, type WaterBlastParams, type WaterBlastPlan, type WaterBubble, type WaterColumn, type WaterDrop, type WaterEffects, type WaterEffectsLimits, type WaterEffectsOptions, type WaterEffectsStats, type WaterFoam, type WaterMist, type WaterRing, type WaterRound, type WaterShotClass, type WaterShotParams, type WaterShotPlan, type WaterShotProfile, type WaterVec3, type WaterWave, type WaterWaveSample, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWaterEffects, createWorkshopBehaviors, effectForEvent, estimateCost, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, patchWaterShotProfiles, planWaterBlast, planWaterShot, resolveStrings, resolveWaterBlast, resolveWaterShotProfile, slideAlong, streamFor, updateScreen, waterShotClassOf, workshopGround };
2465
+ export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, type Carrier, type Chunk, type ConfineMove, type ConfineResult, type Confiner, type CueRequest, DEBRIS_COLOR_VARIABLE, DEBRIS_EFFECT_FAMILIES, DUST_COLOR_VARIABLE, type DebrisEffectFamily, 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 EffectTrack, type EffectView, Enclosures, 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, MATERIAL_EVENT_EFFECTS, type Mark, type MarkEvent, type MarkStore, type MeshParticle, MeshPool, type MeshShape, type MeshSpawn, type MushroomSpec, type MutableVec3, OrderedPool, PIECES_DRAWN_VARIABLE, PROFILES, type Placement, type PlayOptions, type PostProcess, type Puddle, type Puff, type Quaternion, RAIN_CAPACITY, RainField, type RandomStream, type Rgb, type Ring, type RockMark, SCRAPE_LIMIT, SMOKE_COLORS, SPRITE_KINDS, type Schedule, type ScorchMark, type ScrapeMark, 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, VIEWMODEL_EFFECTS, type Vec3Like, type Vec3Tuple, type VfxEnclosure, type VfxEnclosureBox, type VfxLayer, type VfxLocale, type VfxOptions, type VfxPoolsView, type VfxProfile, type VfxProfileName, type VfxSideRequest, type VfxStats, type VfxStrings, type VfxTrace, type VfxWorld, WATER_BLASTS, WATER_BLAST_KINDS, WATER_LIMITS, WATER_SHOT_BY_CALIBER, WATER_SHOT_PROFILES, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, WORKSHOP_PUDDLES, type WaterBlastCharge, type WaterBlastKind, type WaterBlastKindId, type WaterBlastParams, type WaterBlastPlan, type WaterBubble, type WaterColumn, type WaterDrop, type WaterEffects, type WaterEffectsLimits, type WaterEffectsOptions, type WaterEffectsStats, type WaterFoam, type WaterMist, type WaterRing, type WaterRound, type WaterShotClass, type WaterShotParams, type WaterShotPlan, type WaterShotProfile, type WaterVec3, type WaterWave, type WaterWaveSample, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWaterEffects, createWorkshopBehaviors, effectForEvent, estimateCost, explosionEffectIds, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, patchWaterShotProfiles, planWaterBlast, planWaterShot, resolveStrings, resolveWaterBlast, resolveWaterShotProfile, slideAlong, slideInto, streamFor, updateScreen, waterShotClassOf, workshopGround };