@adatechnology/game-vfx 0.14.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/dist/index.d.ts +43 -2
- package/dist/index.global.js +86 -17
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +86 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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>>;
|
|
@@ -2394,4 +2435,4 @@ declare function resolveWaterShotProfile(profile: string | WaterShotProfile, tab
|
|
|
2394
2435
|
/** Changes a profile table without touching the kit's: `null` removes an entry, a partial entry is merged over the old one. */
|
|
2395
2436
|
declare function patchWaterShotProfiles(base: Readonly<Record<string, WaterShotProfile>>, changes: Readonly<Record<string, Partial<WaterShotProfile> | null>>): Record<string, WaterShotProfile>;
|
|
2396
2437
|
|
|
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 };
|
|
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 };
|
package/dist/index.global.js
CHANGED
|
@@ -73,6 +73,7 @@ var GameVfx = (() => {
|
|
|
73
73
|
createWorkshopBehaviors: () => createWorkshopBehaviors,
|
|
74
74
|
effectForEvent: () => effectForEvent,
|
|
75
75
|
estimateCost: () => estimateCost,
|
|
76
|
+
explosionEffectIds: () => explosionEffectIds,
|
|
76
77
|
hexToLinearRgb: () => hexToLinearRgb,
|
|
77
78
|
hexToRgb: () => hexToRgb,
|
|
78
79
|
inPuddle: () => inPuddle,
|
|
@@ -1135,6 +1136,9 @@ var GameVfx = (() => {
|
|
|
1135
1136
|
}
|
|
1136
1137
|
return result;
|
|
1137
1138
|
}
|
|
1139
|
+
function explosionEffectIds(explosions = EXPLOSIONS) {
|
|
1140
|
+
return Object.keys(explosions);
|
|
1141
|
+
}
|
|
1138
1142
|
|
|
1139
1143
|
// src/color.ts
|
|
1140
1144
|
var BYTE_MAX = 255;
|
|
@@ -1260,7 +1264,8 @@ var GameVfx = (() => {
|
|
|
1260
1264
|
trail: 0,
|
|
1261
1265
|
glow: null,
|
|
1262
1266
|
rng: placeholder,
|
|
1263
|
-
outColor: [0, 0, 0]
|
|
1267
|
+
outColor: [0, 0, 0],
|
|
1268
|
+
source: void 0
|
|
1264
1269
|
}),
|
|
1265
1270
|
freezeFollowingGlow
|
|
1266
1271
|
);
|
|
@@ -1366,7 +1371,8 @@ var GameVfx = (() => {
|
|
|
1366
1371
|
outY: 0,
|
|
1367
1372
|
outZ: 0,
|
|
1368
1373
|
outSize: 0,
|
|
1369
|
-
outIntensity: 0
|
|
1374
|
+
outIntensity: 0,
|
|
1375
|
+
source: void 0
|
|
1370
1376
|
}));
|
|
1371
1377
|
}
|
|
1372
1378
|
function spawnGlow(pool, init) {
|
|
@@ -1386,6 +1392,7 @@ var GameVfx = (() => {
|
|
|
1386
1392
|
glow.fx = init.fx ?? 0;
|
|
1387
1393
|
glow.fy = init.fy ?? 0;
|
|
1388
1394
|
glow.fz = init.fz ?? 0;
|
|
1395
|
+
glow.source = init.source;
|
|
1389
1396
|
return glow;
|
|
1390
1397
|
}
|
|
1391
1398
|
function ageOrKeep(glow, dt) {
|
|
@@ -1701,7 +1708,8 @@ var GameVfx = (() => {
|
|
|
1701
1708
|
rng: placeholder,
|
|
1702
1709
|
age: 0,
|
|
1703
1710
|
heat: 0,
|
|
1704
|
-
size: 0
|
|
1711
|
+
size: 0,
|
|
1712
|
+
source: void 0
|
|
1705
1713
|
}));
|
|
1706
1714
|
}
|
|
1707
1715
|
function spawnPuff(pool, random, init) {
|
|
@@ -1734,6 +1742,7 @@ var GameVfx = (() => {
|
|
|
1734
1742
|
puff3.age = 0;
|
|
1735
1743
|
puff3.heat = 0;
|
|
1736
1744
|
puff3.size = 0;
|
|
1745
|
+
puff3.source = init.source;
|
|
1737
1746
|
return puff3;
|
|
1738
1747
|
}
|
|
1739
1748
|
function ageOrKeep2(puff3, dt) {
|
|
@@ -1794,7 +1803,7 @@ var GameVfx = (() => {
|
|
|
1794
1803
|
var GROUND_LIFT = 0.02;
|
|
1795
1804
|
var BOUNCE_SLIDE = 0.55;
|
|
1796
1805
|
function createSparkPool(capacity) {
|
|
1797
|
-
return new OrderedPool(capacity, () => ({ x: 0, y: 0, z: 0, vx: 0, vy: 0, vz: 0, t: 0, life: 0.8, w: 0.04, st: 0.035, kind: 0, drag: 0.6, g: 9.8, bounce: 0.35, age: 0 }));
|
|
1806
|
+
return new OrderedPool(capacity, () => ({ x: 0, y: 0, z: 0, vx: 0, vy: 0, vz: 0, t: 0, life: 0.8, w: 0.04, st: 0.035, kind: 0, drag: 0.6, g: 9.8, bounce: 0.35, age: 0, source: void 0 }));
|
|
1798
1807
|
}
|
|
1799
1808
|
function spawnSpark(pool, init) {
|
|
1800
1809
|
const spark = pool.acquire();
|
|
@@ -1813,6 +1822,7 @@ var GameVfx = (() => {
|
|
|
1813
1822
|
spark.g = init.g ?? 9.8;
|
|
1814
1823
|
spark.bounce = init.bounce ?? 0.35;
|
|
1815
1824
|
spark.age = 0;
|
|
1825
|
+
spark.source = init.source;
|
|
1816
1826
|
return spark;
|
|
1817
1827
|
}
|
|
1818
1828
|
function ageOrKeep3(spark, dt) {
|
|
@@ -1848,22 +1858,26 @@ var GameVfx = (() => {
|
|
|
1848
1858
|
function addPuff(core, random, init) {
|
|
1849
1859
|
core.spawned.puffs++;
|
|
1850
1860
|
const puff3 = spawnPuff(core.puffs, random, init);
|
|
1861
|
+
puff3.source = init.source ?? core.source;
|
|
1851
1862
|
core.trace?.puff?.(puff3);
|
|
1852
1863
|
return puff3;
|
|
1853
1864
|
}
|
|
1854
1865
|
function addSpark(core, init) {
|
|
1855
1866
|
core.spawned.sparks++;
|
|
1856
1867
|
const spark = spawnSpark(core.sparks, init);
|
|
1868
|
+
spark.source = init.source ?? core.source;
|
|
1857
1869
|
core.trace?.spark?.(spark);
|
|
1858
1870
|
return spark;
|
|
1859
1871
|
}
|
|
1860
1872
|
function addGlow(core, init) {
|
|
1861
1873
|
const glow = spawnGlow(core.glows, init);
|
|
1874
|
+
glow.source = init.source ?? core.source;
|
|
1862
1875
|
core.trace?.glow?.(glow);
|
|
1863
1876
|
return glow;
|
|
1864
1877
|
}
|
|
1865
1878
|
function addChunk(core, random, init) {
|
|
1866
1879
|
const chunk = spawnChunk(core.chunks, random, init);
|
|
1880
|
+
chunk.source = core.source;
|
|
1867
1881
|
core.spawned.chunks++;
|
|
1868
1882
|
if (chunk.hot && core.layers.shrapnel) {
|
|
1869
1883
|
chunk.glow = addGlow(core, { follow: chunk, s: 0.35 + chunk.sx, i: 2.2, life: random.between(1, 2.2), color: HOT_GLOW_COLOR, curve: 1.5 });
|
|
@@ -1894,7 +1908,8 @@ var GameVfx = (() => {
|
|
|
1894
1908
|
fz: 0,
|
|
1895
1909
|
color: SMOKE_COLORS.black,
|
|
1896
1910
|
rng: placeholder,
|
|
1897
|
-
handle: 0
|
|
1911
|
+
handle: 0,
|
|
1912
|
+
source: void 0
|
|
1898
1913
|
}));
|
|
1899
1914
|
}
|
|
1900
1915
|
function spawnFire(pool, random, init, handle) {
|
|
@@ -1919,6 +1934,7 @@ var GameVfx = (() => {
|
|
|
1919
1934
|
fire.color = init.color ?? SMOKE_COLORS.black;
|
|
1920
1935
|
fire.rng = random;
|
|
1921
1936
|
fire.handle = handle;
|
|
1937
|
+
fire.source = init.source;
|
|
1922
1938
|
return fire;
|
|
1923
1939
|
}
|
|
1924
1940
|
function addFire(core, random, init, handle) {
|
|
@@ -1953,7 +1969,8 @@ var GameVfx = (() => {
|
|
|
1953
1969
|
buoy: 3.2,
|
|
1954
1970
|
color: fire.color,
|
|
1955
1971
|
kind: 0,
|
|
1956
|
-
wind: 0.4
|
|
1972
|
+
wind: 0.4,
|
|
1973
|
+
source: fire.source
|
|
1957
1974
|
});
|
|
1958
1975
|
}
|
|
1959
1976
|
}
|
|
@@ -1976,7 +1993,8 @@ var GameVfx = (() => {
|
|
|
1976
1993
|
drag: 0.6,
|
|
1977
1994
|
buoy: 0.55,
|
|
1978
1995
|
color: fire.color,
|
|
1979
|
-
kind: 0
|
|
1996
|
+
kind: 0,
|
|
1997
|
+
source: fire.source
|
|
1980
1998
|
});
|
|
1981
1999
|
}
|
|
1982
2000
|
}
|
|
@@ -1995,7 +2013,8 @@ var GameVfx = (() => {
|
|
|
1995
2013
|
st: 0.02,
|
|
1996
2014
|
kind: 4,
|
|
1997
2015
|
g: -0.6,
|
|
1998
|
-
drag: 1.2
|
|
2016
|
+
drag: 1.2,
|
|
2017
|
+
source: fire.source
|
|
1999
2018
|
});
|
|
2000
2019
|
}
|
|
2001
2020
|
function updateFires(core, dt) {
|
|
@@ -6100,10 +6119,11 @@ var GameVfx = (() => {
|
|
|
6100
6119
|
st: 0.05,
|
|
6101
6120
|
kind: 0,
|
|
6102
6121
|
g: 0,
|
|
6103
|
-
drag: 1
|
|
6122
|
+
drag: 1,
|
|
6123
|
+
source: chunk.source
|
|
6104
6124
|
});
|
|
6105
6125
|
if (random.next() < 0.25) {
|
|
6106
|
-
addPuff(core, random, { x: chunk.x, y: chunk.y, z: chunk.z, s0: 0.04, s1: 0.14 + chunk.sx * 0.3, sg: 0.15, life: random.between(1, 1.6), drag: 2, buoy: 0.6, color: SMOKE_COLORS.grey, kind: 0 });
|
|
6126
|
+
addPuff(core, random, { x: chunk.x, y: chunk.y, z: chunk.z, s0: 0.04, s1: 0.14 + chunk.sx * 0.3, sg: 0.15, life: random.between(1, 1.6), drag: 2, buoy: 0.6, color: SMOKE_COLORS.grey, kind: 0, source: chunk.source });
|
|
6107
6127
|
}
|
|
6108
6128
|
}
|
|
6109
6129
|
function updateChunks(core, dt) {
|
|
@@ -6163,10 +6183,11 @@ var GameVfx = (() => {
|
|
|
6163
6183
|
};
|
|
6164
6184
|
}
|
|
6165
6185
|
var SpriteKindPool = class {
|
|
6166
|
-
constructor(capacity, defs, owners) {
|
|
6186
|
+
constructor(capacity, defs, owners, sources = { ids: /* @__PURE__ */ new Map(), next: 0 }) {
|
|
6167
6187
|
__publicField(this, "capacity", capacity);
|
|
6168
6188
|
__publicField(this, "defs", defs);
|
|
6169
6189
|
__publicField(this, "owners", owners);
|
|
6190
|
+
__publicField(this, "sources", sources);
|
|
6170
6191
|
__publicField(this, "live", 0);
|
|
6171
6192
|
/** Records from the start the renderer draws (the highest live index + 1). */
|
|
6172
6193
|
__publicField(this, "drawCount", 0);
|
|
@@ -6186,6 +6207,7 @@ var GameVfx = (() => {
|
|
|
6186
6207
|
__publicField(this, "alphaMul");
|
|
6187
6208
|
__publicField(this, "tag");
|
|
6188
6209
|
__publicField(this, "owner");
|
|
6210
|
+
__publicField(this, "source");
|
|
6189
6211
|
__publicField(this, "colorHex");
|
|
6190
6212
|
__publicField(this, "rgbStart");
|
|
6191
6213
|
__publicField(this, "rgbEnd");
|
|
@@ -6207,6 +6229,7 @@ var GameVfx = (() => {
|
|
|
6207
6229
|
this.alphaMul = new Float32Array(n);
|
|
6208
6230
|
this.tag = new Int32Array(n);
|
|
6209
6231
|
this.owner = new Int32Array(n);
|
|
6232
|
+
this.source = new Int32Array(n);
|
|
6210
6233
|
this.colorHex = new Int32Array(n);
|
|
6211
6234
|
this.rgbStart = new Float32Array(n * 3);
|
|
6212
6235
|
this.rgbEnd = new Float32Array(n * 3);
|
|
@@ -6233,6 +6256,7 @@ var GameVfx = (() => {
|
|
|
6233
6256
|
this.alphaMul[i] = options?.alpha ?? 1;
|
|
6234
6257
|
this.tag[i] = options?.tag ?? 0;
|
|
6235
6258
|
this.owner[i] = options?.owner === void 0 ? -1 : this.ownerIndex(options.owner);
|
|
6259
|
+
this.source[i] = options?.source === void 0 ? -1 : this.sourceIndex(options.source);
|
|
6236
6260
|
this.colorHex[i] = options?.color ?? -1;
|
|
6237
6261
|
this.rgbStart.set(rgb(options?.color ?? def.c0), i * 3);
|
|
6238
6262
|
this.rgbEnd.set(rgb(options?.color ?? def.c1), i * 3);
|
|
@@ -6247,6 +6271,26 @@ var GameVfx = (() => {
|
|
|
6247
6271
|
if (index < 0) index = this.owners.push(name) - 1;
|
|
6248
6272
|
return index;
|
|
6249
6273
|
}
|
|
6274
|
+
sourceIndex(name) {
|
|
6275
|
+
let index = this.sources.ids.get(name);
|
|
6276
|
+
if (index === void 0) {
|
|
6277
|
+
index = this.sources.next++;
|
|
6278
|
+
this.sources.ids.set(name, index);
|
|
6279
|
+
}
|
|
6280
|
+
return index;
|
|
6281
|
+
}
|
|
6282
|
+
/** Kills the live sprites made for `source`; returns how many went. */
|
|
6283
|
+
clearSource(source) {
|
|
6284
|
+
const index = this.sources.ids.get(source);
|
|
6285
|
+
if (index === void 0) return 0;
|
|
6286
|
+
let killed = 0;
|
|
6287
|
+
for (let i = 0; i < this.high; i++) {
|
|
6288
|
+
if (!this.alive[i] || this.source[i] !== index) continue;
|
|
6289
|
+
this.kill(i);
|
|
6290
|
+
killed++;
|
|
6291
|
+
}
|
|
6292
|
+
return killed;
|
|
6293
|
+
}
|
|
6250
6294
|
kill(i) {
|
|
6251
6295
|
if (!this.alive[i]) return;
|
|
6252
6296
|
this.alive[i] = 0;
|
|
@@ -6706,14 +6750,15 @@ var GameVfx = (() => {
|
|
|
6706
6750
|
__publicField(this, "defs");
|
|
6707
6751
|
__publicField(this, "index", /* @__PURE__ */ new Map());
|
|
6708
6752
|
__publicField(this, "owners", []);
|
|
6753
|
+
__publicField(this, "sources", { ids: /* @__PURE__ */ new Map(), next: 0 });
|
|
6709
6754
|
__publicField(this, "listeners", /* @__PURE__ */ new Map());
|
|
6710
6755
|
const kinds = options.kinds ?? SPRITE_KINDS;
|
|
6711
6756
|
this.ids = Object.keys(kinds);
|
|
6712
6757
|
this.defs = this.ids.map((id) => kinds[id]);
|
|
6713
6758
|
this.ids.forEach((id, at3) => this.index.set(id, at3));
|
|
6714
6759
|
const additiveCapacity = Math.floor(options.capacity * 0.4);
|
|
6715
|
-
this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners);
|
|
6716
|
-
this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners);
|
|
6760
|
+
this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners, this.sources);
|
|
6761
|
+
this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners, this.sources);
|
|
6717
6762
|
this.random = spriteRandom(options.seed);
|
|
6718
6763
|
}
|
|
6719
6764
|
get capacity() {
|
|
@@ -6787,9 +6832,16 @@ var GameVfx = (() => {
|
|
|
6787
6832
|
if (this.additive.live > 0 || this.additive.drawCount > 0) this.additive.update(dt, host);
|
|
6788
6833
|
if (this.normal.live > 0 || this.normal.drawCount > 0) this.normal.update(dt, host);
|
|
6789
6834
|
}
|
|
6835
|
+
/** Kills the live sprites made for `source` (`SpriteSpawnOptions.source`); returns how many went. */
|
|
6836
|
+
clearSource(source) {
|
|
6837
|
+
const killed = this.additive.clearSource(source) + this.normal.clearSource(source);
|
|
6838
|
+
this.sources.ids.delete(source);
|
|
6839
|
+
return killed;
|
|
6840
|
+
}
|
|
6790
6841
|
clear() {
|
|
6791
6842
|
this.additive.clear();
|
|
6792
6843
|
this.normal.clear();
|
|
6844
|
+
this.sources.ids.clear();
|
|
6793
6845
|
}
|
|
6794
6846
|
};
|
|
6795
6847
|
|
|
@@ -7842,7 +7894,8 @@ var GameVfx = (() => {
|
|
|
7842
7894
|
groundAt,
|
|
7843
7895
|
...options.marklessAt ? { marklessAt: options.marklessAt } : {},
|
|
7844
7896
|
...options.cratersAt ? { cratersAt: options.cratersAt } : {},
|
|
7845
|
-
emit: (request) => options.onRequest?.(request)
|
|
7897
|
+
emit: (request) => options.onRequest?.(request),
|
|
7898
|
+
source: void 0
|
|
7846
7899
|
};
|
|
7847
7900
|
function definitionOf(id) {
|
|
7848
7901
|
return explosions[id] ?? explosions[aliases[id] ?? ""];
|
|
@@ -7853,7 +7906,13 @@ var GameVfx = (() => {
|
|
|
7853
7906
|
return streamFor(seed ?? Math.imul(handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
7854
7907
|
}
|
|
7855
7908
|
function detonate(def, point, call3) {
|
|
7856
|
-
|
|
7909
|
+
const outer = core.source;
|
|
7910
|
+
core.source = call3.source;
|
|
7911
|
+
try {
|
|
7912
|
+
composeExplosion(core, def, { x: point[0], y: point[1], z: point[2], direction: call3.direction, random: call3.random, handle: call3.handle });
|
|
7913
|
+
} finally {
|
|
7914
|
+
core.source = outer;
|
|
7915
|
+
}
|
|
7857
7916
|
}
|
|
7858
7917
|
let engine;
|
|
7859
7918
|
let player;
|
|
@@ -7894,8 +7953,9 @@ var GameVfx = (() => {
|
|
|
7894
7953
|
const handle = ++handles.next;
|
|
7895
7954
|
const direction = explosionOptions.direction && { x: explosionOptions.direction[0], y: explosionOptions.direction[1], z: explosionOptions.direction[2] };
|
|
7896
7955
|
const random = streamOf(explosionOptions.seed);
|
|
7897
|
-
|
|
7898
|
-
|
|
7956
|
+
const source = explosionOptions.source;
|
|
7957
|
+
if (explosionOptions.delay) core.schedule.at(core.clock.time + explosionOptions.delay, () => detonate(def, point, { direction, random, handle, source }));
|
|
7958
|
+
else detonate(def, point, { direction, random, handle, source });
|
|
7899
7959
|
return handle;
|
|
7900
7960
|
},
|
|
7901
7961
|
fire(fireOptions) {
|
|
@@ -7937,6 +7997,15 @@ var GameVfx = (() => {
|
|
|
7937
7997
|
const fires = core.fires;
|
|
7938
7998
|
for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
|
|
7939
7999
|
},
|
|
8000
|
+
clearSource(source) {
|
|
8001
|
+
const keep = (record, gone) => record.source !== gone;
|
|
8002
|
+
const drop = (pool) => {
|
|
8003
|
+
const before = pool.count;
|
|
8004
|
+
pool.compact(keep, source);
|
|
8005
|
+
return before - pool.count;
|
|
8006
|
+
};
|
|
8007
|
+
return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
|
|
8008
|
+
},
|
|
7940
8009
|
setLayer(layer, on) {
|
|
7941
8010
|
layers[layer] = on;
|
|
7942
8011
|
},
|