@adatechnology/game-vfx 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,8 +69,12 @@ flash stays on the muzzle the view turns), and the smoke it throws stays in the
69
69
  `vfx.burst(kind, point, normal, count, speed?)` and `vfx.spawn(kind, point, velocity)` are the **sprite kinds** that destruction, fluids and weapons share
70
70
  (debris, sparks, ash, steam, drips, leaks...: `data/sprite-kinds.json`, `patchSpriteKinds`), with `onLand(owner, ...)` to hear where a drop touched the ground.
71
71
 
72
- `effectForEvent(event)` maps the destruction events to effects (`data/event-effects.json`): `spall` plays `impact_<material>`, the stages `stage_crack`,
73
- `breach_dust` and `collapse_dust`, `expose` `rebar_expose`, a fracture of glass `glass_burst`; `muzzle_*` and `casing_*` are the weapon slices. `GAME_EFFECTS`
72
+ `effectForEvent(event)` maps the destruction events to effects (`data/event-effects.json`): `spall` plays `impact_<material>`, the stages
73
+ `stage_crack_<family>`, `breach_dust_<family>` and `collapse_dust_<family>` (and a collapse `collapse_dust_<family>`), `expose` `rebar_expose` (concrete
74
+ chips and rust), a fracture of glass `glass_burst`; `muzzle_*` and `casing_*` are the weapon slices. The family is the `material` of the event
75
+ (`DEBRIS_EFFECT_FAMILIES`: `wood` splinters, `masonry` chips and dust, `glass` shards, `metal` sparks and no dust, `soft` flakes, `soil` clods and dust), and
76
+ the host draws them in the colour of the material that broke by passing `values: { debrisColor, dustColor }` to `play`. A stage with no family plays nothing.
77
+ `GAME_EFFECTS`
74
78
  is the recipes plus these, what a world plays by default. Texts of every recipe (name, cost, when, look, budget, network) are in `locales` (`en`, `pt-BR`).
75
79
 
76
80
  ## Vehicle effects
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];
@@ -615,6 +621,8 @@ interface Puff {
615
621
  age: number;
616
622
  heat: number;
617
623
  size: number;
624
+ /** The thing it was made for (a burning part's object): `VfxWorld.clearSource` takes it away when that thing leaves. */
625
+ source: string | undefined;
618
626
  }
619
627
 
620
628
  /** 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 +657,8 @@ interface Spark {
649
657
  g: number;
650
658
  bounce: number;
651
659
  age: number;
660
+ /** The thing it was made for (a burning part's object): `VfxWorld.clearSource` takes it away when that thing leaves. */
661
+ source: string | undefined;
652
662
  }
653
663
 
654
664
  interface Schedule {
@@ -731,6 +741,8 @@ interface VfxCore {
731
741
  /** Ground a blast opens a dirt crater in (`VfxOptions.cratersAt`). */
732
742
  cratersAt?: (x: number, z: number) => boolean;
733
743
  emit(request: VfxSideRequest): void;
744
+ /** The thing what is spawned now is made for (`ExplosionOptions.source` while it goes off): the records take it unless they name their own. */
745
+ source: string | undefined;
734
746
  }
735
747
 
736
748
  type Vec3Tuple = readonly [number, number, number];
@@ -1605,11 +1617,18 @@ interface SpriteSpawnOptions {
1605
1617
  tag?: number;
1606
1618
  /** Who hears the landing (see `VfxWorld.onLand`). */
1607
1619
  owner?: string;
1620
+ /** The thing the sprite was made for (a world object's id): `VfxWorld.clearSource` takes its sprites away when that thing leaves. */
1621
+ source?: string;
1608
1622
  /** Height the sprite stops or lands at, instead of the ground's under it (a splash on a table top). */
1609
1623
  floor?: number;
1610
1624
  /** Multiplier on the kind's upward acceleration (slow steam). */
1611
1625
  rise?: number;
1612
1626
  }
1627
+ /** 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. */
1628
+ interface SpriteSources {
1629
+ readonly ids: Map<string, number>;
1630
+ next: number;
1631
+ }
1613
1632
  interface KindPoolHost {
1614
1633
  groundAt(x: number, z: number): number;
1615
1634
  gravity: number;
@@ -1625,6 +1644,7 @@ declare class SpriteKindPool {
1625
1644
  readonly capacity: number;
1626
1645
  private readonly defs;
1627
1646
  private readonly owners;
1647
+ private readonly sources;
1628
1648
  live: number;
1629
1649
  /** Records from the start the renderer draws (the highest live index + 1). */
1630
1650
  drawCount: number;
@@ -1644,15 +1664,19 @@ declare class SpriteKindPool {
1644
1664
  private readonly alphaMul;
1645
1665
  private readonly tag;
1646
1666
  private readonly owner;
1667
+ private readonly source;
1647
1668
  private readonly colorHex;
1648
1669
  private readonly rgbStart;
1649
1670
  private readonly rgbEnd;
1650
1671
  private readonly bounced;
1651
1672
  private readonly floor;
1652
1673
  private readonly riseMul;
1653
- constructor(capacity: number, defs: readonly SpriteKindDef[], owners: string[]);
1674
+ constructor(capacity: number, defs: readonly SpriteKindDef[], owners: string[], sources?: SpriteSources);
1654
1675
  spawn(kind: number, p: readonly number[], v: readonly number[], random: () => number, options?: SpriteSpawnOptions): void;
1655
1676
  private ownerIndex;
1677
+ private sourceIndex;
1678
+ /** Kills the live sprites made for `source`; returns how many went. */
1679
+ clearSource(source: string): number;
1656
1680
  private kill;
1657
1681
  clear(): void;
1658
1682
  /** Shoves the live sprites within `radius` of a point away from it (a blast). */
@@ -1687,6 +1711,7 @@ declare class SpriteKindSystem {
1687
1711
  private readonly defs;
1688
1712
  private readonly index;
1689
1713
  private readonly owners;
1714
+ private readonly sources;
1690
1715
  private readonly listeners;
1691
1716
  constructor(options: SpriteKindSystemOptions);
1692
1717
  get capacity(): number;
@@ -1701,6 +1726,8 @@ declare class SpriteKindSystem {
1701
1726
  /** Blast wave: shoves the live sprites away from a point. */
1702
1727
  push(point: Vec3, radius: number, speed: number): void;
1703
1728
  update(dt: number): void;
1729
+ /** Kills the live sprites made for `source` (`SpriteSpawnOptions.source`); returns how many went. */
1730
+ clearSource(source: string): number;
1704
1731
  clear(): void;
1705
1732
  }
1706
1733
 
@@ -1746,6 +1773,8 @@ interface ExplosionOptions {
1746
1773
  readonly scale?: number;
1747
1774
  /** Seconds from now until it goes off (a chain). */
1748
1775
  readonly delay?: number;
1776
+ /** The thing that went off (a world object's id): what the blast throws goes with `clearSource`. */
1777
+ readonly source?: string;
1749
1778
  }
1750
1779
  interface FireOptions {
1751
1780
  readonly point: Vec3Like;
@@ -1763,6 +1792,8 @@ interface FireOptions {
1763
1792
  readonly follow?: Follow;
1764
1793
  readonly offset?: Vec3Like;
1765
1794
  readonly seed?: number;
1795
+ /** 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. */
1796
+ readonly source?: string;
1766
1797
  }
1767
1798
  /** The pools as the renderer reads them: live records, oldest first. */
1768
1799
  interface VfxPoolsView {
@@ -1815,6 +1846,11 @@ interface VfxWorld {
1815
1846
  /** The closed spaces declared now. */
1816
1847
  enclosures(): Enclosures;
1817
1848
  stop(handle: number): void;
1849
+ /**
1850
+ * The thing `source` names left the world for good: its fires go out, and every flame, smoke puff, ember and sprite made for it
1851
+ * (`FireOptions.source`, `SpriteSpawnOptions.source`) goes at once instead of living out its life. Returns how many records went.
1852
+ */
1853
+ clearSource(source: string): number;
1818
1854
  setLayer(layer: VfxLayer, on: boolean): void;
1819
1855
  layer(layer: VfxLayer): boolean;
1820
1856
  setCamera(position: Vec3Like): void;
@@ -1856,6 +1892,11 @@ declare const EXPLOSIONS: Readonly<Record<string, ExplosionDef>>;
1856
1892
  declare const EXPLOSION_ALIASES: Readonly<Record<string, string>>;
1857
1893
  /** 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
1894
  declare function patchExplosions(base: Readonly<Record<string, ExplosionDef>>, changes: Readonly<Record<string, Partial<ExplosionDef> | ExplosionDef | null>>): Record<string, ExplosionDef>;
1895
+ /**
1896
+ * 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
1897
+ * 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.
1898
+ */
1899
+ declare function explosionEffectIds(explosions?: Readonly<Record<string, ExplosionDef>>): string[];
1859
1900
 
1860
1901
  /** Every effect of the Workshop by id. A game adds, changes or removes entries with `patchEffects`. */
1861
1902
  declare const WORKSHOP_EFFECTS: Readonly<Record<string, EffectDef>>;
@@ -1870,6 +1911,18 @@ declare function patchEffects(base: Readonly<Record<string, EffectDef>>, changes
1870
1911
  */
1871
1912
  declare const EVENT_EFFECTS: readonly EffectDef[];
1872
1913
 
1914
+ /**
1915
+ * The families of material a destruction event plays its effect by (the `{material}` of the stage and collapse entries of `data/event-effects.json`): the
1916
+ * same names as `DebrisFamily` of `game-destruction`, kept as strings so this package does not depend on it.
1917
+ */
1918
+ declare const DEBRIS_EFFECT_FAMILIES: readonly ["wood", "masonry", "glass", "metal", "soft", "soil"];
1919
+ type DebrisEffectFamily = (typeof DEBRIS_EFFECT_FAMILIES)[number];
1920
+ /** The variables a host sets (`PlayOptions.values`) to draw the debris and the dust in the colour of the material that broke. */
1921
+ declare const DEBRIS_COLOR_VARIABLE = "debrisColor";
1922
+ declare const DUST_COLOR_VARIABLE = "dustColor";
1923
+ /** The stage, breach and collapse effects of every family, and the rebar laid bare. */
1924
+ declare const MATERIAL_EVENT_EFFECTS: readonly EffectDef[];
1925
+
1873
1926
  declare const VIEWMODEL_EFFECTS: readonly EffectDef[];
1874
1927
 
1875
1928
  /** What a game event looks like to the map: the kind of event and the little that picks its effect. */
@@ -1878,14 +1931,17 @@ interface GameEvent {
1878
1931
  readonly kind: string;
1879
1932
  /** The stage of a `stage` event (1, 2 or 3). */
1880
1933
  readonly stage?: number;
1881
- /** The material of a `spall` or `fracture` event. */
1934
+ /**
1935
+ * The material of a `spall` or `fracture` event; for a `stage`, `collapse` or `expose` event the family of the material that broke (`DEBRIS_EFFECT_FAMILIES`:
1936
+ * `wood`, `masonry`, `glass`, `metal`, `soft`, `soil`), so the stone dust of a breach is not raised by a wooden wall.
1937
+ */
1882
1938
  readonly material?: string;
1883
1939
  }
1884
1940
  type EventMap = Readonly<Record<string, string | Readonly<Record<string, string>>>>;
1885
1941
  declare const EVENT_EFFECTS_MAP: EventMap;
1886
1942
  /**
1887
1943
  * 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
1888
- * stage or material. A game passes its own map to add or change entries.
1944
+ * stage or material, and its value may use `{material}` too. A game passes its own map to add or change entries.
1889
1945
  */
1890
1946
  declare function effectForEvent(event: GameEvent, map?: EventMap): string | undefined;
1891
1947
 
@@ -2379,4 +2435,4 @@ declare function resolveWaterShotProfile(profile: string | WaterShotProfile, tab
2379
2435
  /** Changes a profile table without touching the kit's: `null` removes an entry, a partial entry is merged over the old one. */
2380
2436
  declare function patchWaterShotProfiles(base: Readonly<Record<string, WaterShotProfile>>, changes: Readonly<Record<string, Partial<WaterShotProfile> | null>>): Record<string, WaterShotProfile>;
2381
2437
 
2382
- 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, 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, 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 };
2438
+ 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, explosionEffectIds, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, patchWaterShotProfiles, planWaterBlast, planWaterShot, resolveStrings, resolveWaterBlast, resolveWaterShotProfile, slideAlong, streamFor, updateScreen, waterShotClassOf, workshopGround };