@adatechnology/game-vfx 0.10.1 → 0.12.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 +3 -1
- package/dist/index.d.ts +74 -7
- package/dist/index.global.js +121 -15
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +121 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,7 +62,9 @@ material, a place and a turn inside a group, a scale ramp, growth, drag, gravity
|
|
|
62
62
|
the order of the gallery's `Particles`. `play` can also take the thing's whole turn (`orientation`, a unit quaternion, pitch and roll included, instead of the turn
|
|
63
63
|
about the vertical axis `direction` gives) and named numbers (`values`, read with `variable(name)`). `VIEWMODEL_EFFECTS` use all three: the first-person muzzle flash
|
|
64
64
|
(`viewmodel_muzzle_flash`: an open cone, four small cones and a core for 55 ms, a light that holds, six spheres of smoke), `weapon_smoke_puff`, `launcher_backblast` and
|
|
65
|
-
`flame_jet`, written in the weapon's own axes (x along the barrel) with the Arsenal gallery's numbers and the order it drew them in.
|
|
65
|
+
`flame_jet`, written in the weapon's own axes (x along the barrel) with the Arsenal gallery's numbers and the order it drew them in. With `track` (a function
|
|
66
|
+
answering where the thing is now, asked every frame) an effect rides on the thing it belongs to: its grouped pieces and its light keep their place on it (a muzzle
|
|
67
|
+
flash stays on the muzzle the view turns), and the smoke it throws stays in the air; `world.follow()` puts them where the thing is after the frame moved it.
|
|
66
68
|
|
|
67
69
|
`vfx.burst(kind, point, normal, count, speed?)` and `vfx.spawn(kind, point, velocity)` are the **sprite kinds** that destruction, fluids and weapons share
|
|
68
70
|
(debris, sparks, ash, steam, drips, leaks...: `data/sprite-kinds.json`, `patchSpriteKinds`), with `onLand(owner, ...)` to hear where a drop touched the ground.
|
package/dist/index.d.ts
CHANGED
|
@@ -397,7 +397,20 @@ interface BloodMark {
|
|
|
397
397
|
readonly scaleZ: number;
|
|
398
398
|
readonly rotation: number;
|
|
399
399
|
}
|
|
400
|
-
|
|
400
|
+
/** A scratch a dragged piece leaves on the floor (`VfxWorld.scrape`): a thin strip along the drag, lighter or darker than the floor. */
|
|
401
|
+
interface ScrapeMark {
|
|
402
|
+
readonly kind: 'scrape';
|
|
403
|
+
/** Middle of the strip, on the floor. */
|
|
404
|
+
readonly x: number;
|
|
405
|
+
readonly y: number;
|
|
406
|
+
readonly z: number;
|
|
407
|
+
readonly length: number;
|
|
408
|
+
readonly width: number;
|
|
409
|
+
/** Turn of the strip about the vertical: 0 runs along +x. */
|
|
410
|
+
readonly rotation: number;
|
|
411
|
+
readonly color: number;
|
|
412
|
+
}
|
|
413
|
+
type Mark = ScorchMark | DirtMark | RockMark | BloodMark | ScrapeMark;
|
|
401
414
|
type MarkEvent = {
|
|
402
415
|
readonly type: 'add';
|
|
403
416
|
readonly mark: Mark;
|
|
@@ -409,6 +422,7 @@ interface MarkStore {
|
|
|
409
422
|
/** Goes up on every mark added or cleared. */
|
|
410
423
|
readonly version: number;
|
|
411
424
|
readonly bloodCount: number;
|
|
425
|
+
readonly scrapeCount: number;
|
|
412
426
|
/** The counter that lifts each decal a hair higher than the last (the Lab's `decalY`). */
|
|
413
427
|
lift: number;
|
|
414
428
|
add(mark: Mark): void;
|
|
@@ -416,6 +430,8 @@ interface MarkStore {
|
|
|
416
430
|
/** Tells a renderer the moment a mark is made (the ground it conforms to is the ground of that moment) or taken away. */
|
|
417
431
|
subscribe(listener: (event: MarkEvent) => void): () => void;
|
|
418
432
|
}
|
|
433
|
+
/** Scratches kept on the floor; past it the oldest goes, so dragging furniture all day costs no more than this. */
|
|
434
|
+
declare const SCRAPE_LIMIT = 400;
|
|
419
435
|
|
|
420
436
|
/** The position a glow follows (a chunk, or anything with `x`, `y`, `z`). */
|
|
421
437
|
interface FollowPoint {
|
|
@@ -835,6 +851,22 @@ interface WorkshopContext {
|
|
|
835
851
|
readonly confiner?: Confiner;
|
|
836
852
|
}
|
|
837
853
|
|
|
854
|
+
/** A unit quaternion `[x, y, z, w]`. */
|
|
855
|
+
type Quaternion = readonly [number, number, number, number];
|
|
856
|
+
/**
|
|
857
|
+
* The live pose of the thing an effect belongs to (the muzzle of a gun in the hands), moved by whoever plays the effect while it lives: the pieces drawn in
|
|
858
|
+
* its own axes (the cones of a muzzle flash) and its lights ride on it, and what is thrown free (smoke) stays in the world.
|
|
859
|
+
*/
|
|
860
|
+
interface Carrier {
|
|
861
|
+
origin: Vec3Tuple;
|
|
862
|
+
orientation: Quaternion | undefined;
|
|
863
|
+
}
|
|
864
|
+
/** What a piece keeps to ride on a carrier: the carrier and where the piece sits in the recipe's space (from the recipe's anchor). */
|
|
865
|
+
interface Carried {
|
|
866
|
+
readonly carrier: Carrier;
|
|
867
|
+
readonly local: Vec3Tuple;
|
|
868
|
+
}
|
|
869
|
+
|
|
838
870
|
interface DebrisPiece {
|
|
839
871
|
on: boolean;
|
|
840
872
|
x: number;
|
|
@@ -950,8 +982,6 @@ declare class RainField {
|
|
|
950
982
|
private set;
|
|
951
983
|
}
|
|
952
984
|
|
|
953
|
-
/** A unit quaternion `[x, y, z, w]`. */
|
|
954
|
-
type Quaternion = readonly [number, number, number, number];
|
|
955
985
|
/** One solid particle as the pool keeps it; a renderer draws it from these fields and never changes them. */
|
|
956
986
|
interface MeshParticle {
|
|
957
987
|
/** Grows by one for every particle ever spawned: a renderer knows a new one by it. */
|
|
@@ -968,7 +998,7 @@ interface MeshParticle {
|
|
|
968
998
|
x: number;
|
|
969
999
|
y: number;
|
|
970
1000
|
z: number;
|
|
971
|
-
|
|
1001
|
+
frame: Quaternion;
|
|
972
1002
|
readonly at: Vec3Tuple;
|
|
973
1003
|
rx: number;
|
|
974
1004
|
ry: number;
|
|
@@ -987,6 +1017,10 @@ interface MeshParticle {
|
|
|
987
1017
|
readonly ramp: readonly [number, number] | undefined;
|
|
988
1018
|
readonly fade: boolean;
|
|
989
1019
|
readonly startOpacity: number;
|
|
1020
|
+
/** A piece of a group that rides on the effect's carrier (a muzzle flash on the gun in the hands): its own roll in the group, and how far it moved from its place on the carrier. */
|
|
1021
|
+
readonly carried: Carried | undefined;
|
|
1022
|
+
readonly roll: Quaternion | undefined;
|
|
1023
|
+
readonly drift: [number, number, number];
|
|
990
1024
|
}
|
|
991
1025
|
/**
|
|
992
1026
|
* The solids of the Workshop's recipes: the gallery's `Particles` (thrown with a velocity and a spin, slowed, lifted by a negative gravity, grown and faded) without
|
|
@@ -998,9 +1032,15 @@ declare class MeshPool {
|
|
|
998
1032
|
private serial;
|
|
999
1033
|
constructor(capacity?: number);
|
|
1000
1034
|
get count(): number;
|
|
1001
|
-
spawn(options: MeshSpawn, frame?: Quaternion): MeshParticle;
|
|
1035
|
+
spawn(options: MeshSpawn, frame?: Quaternion, carried?: Carried): MeshParticle;
|
|
1002
1036
|
update(dt: number): void;
|
|
1003
1037
|
clear(): void;
|
|
1038
|
+
/** Puts every carried piece where its carrier is now (after the frame moved the thing it belongs to). */
|
|
1039
|
+
follow(): void;
|
|
1040
|
+
/** A carried piece: how far its own velocity took it, then its place on the carrier. */
|
|
1041
|
+
private ride;
|
|
1042
|
+
/** A carried piece's place on the carrier now plus its drift, turned with the carrier. */
|
|
1043
|
+
private place;
|
|
1004
1044
|
}
|
|
1005
1045
|
|
|
1006
1046
|
interface DecalFromSprite {
|
|
@@ -1109,6 +1149,8 @@ interface FlashLight {
|
|
|
1109
1149
|
intensity: number;
|
|
1110
1150
|
/** Holds `peak` until `duration` is over. */
|
|
1111
1151
|
steady: boolean;
|
|
1152
|
+
/** Rides on the effect's carrier while it burns (a muzzle flash on the gun in the hands). */
|
|
1153
|
+
carried?: Carried | undefined;
|
|
1112
1154
|
}
|
|
1113
1155
|
interface FireLightSlot {
|
|
1114
1156
|
x: number;
|
|
@@ -1124,8 +1166,10 @@ declare class FlashLightPool {
|
|
|
1124
1166
|
private next;
|
|
1125
1167
|
constructor(context: WorkshopContext);
|
|
1126
1168
|
get lit(): number;
|
|
1127
|
-
flash(point: Vec3Tuple, color: number, intensity: number, duration: number, distance?: number, force?: boolean | 'boom', steady?: boolean):
|
|
1169
|
+
flash(point: Vec3Tuple, color: number, intensity: number, duration: number, distance?: number, force?: boolean | 'boom', steady?: boolean): FlashLight | undefined;
|
|
1128
1170
|
clear(): void;
|
|
1171
|
+
/** Puts every carried light that burns where its carrier is now. */
|
|
1172
|
+
follow(): void;
|
|
1129
1173
|
update(dt: number): void;
|
|
1130
1174
|
}
|
|
1131
1175
|
|
|
@@ -1160,6 +1204,8 @@ interface Placement {
|
|
|
1160
1204
|
readonly anchor: Vec3Tuple;
|
|
1161
1205
|
readonly yaw: number;
|
|
1162
1206
|
readonly orientation?: Quaternion;
|
|
1207
|
+
/** The live pose the effect rides on while it lives (`origin` and `orientation` move with it): its grouped pieces and its lights follow it. */
|
|
1208
|
+
readonly carrier?: Carrier;
|
|
1163
1209
|
}
|
|
1164
1210
|
interface WorkshopOptions {
|
|
1165
1211
|
readonly random: RandomStream;
|
|
@@ -1200,6 +1246,8 @@ declare class WorkshopEngine {
|
|
|
1200
1246
|
scaled(count: number): number;
|
|
1201
1247
|
/** A point of the recipe's space in the world (`undefined` placement: as is). */
|
|
1202
1248
|
place(point: Vec3Tuple): Vec3Tuple;
|
|
1249
|
+
/** A point of the recipe's space from the anchor, turned by the placement's yaw when it has no orientation (the carrier turns the rest). */
|
|
1250
|
+
private local;
|
|
1203
1251
|
/** A direction or velocity of the recipe's space in the world. */
|
|
1204
1252
|
turn(vector: Vec3Tuple): Vec3Tuple;
|
|
1205
1253
|
private placed;
|
|
@@ -1448,6 +1496,11 @@ interface Behavior {
|
|
|
1448
1496
|
update(host: BehaviorHost, dt: number, elapsed: number): void;
|
|
1449
1497
|
}
|
|
1450
1498
|
|
|
1499
|
+
/** Where the thing an effect belongs to is now (a muzzle), asked every frame the effect lives; `null` leaves the effect where it was last put. */
|
|
1500
|
+
type EffectTrack = () => {
|
|
1501
|
+
readonly point: Vec3Tuple;
|
|
1502
|
+
readonly orientation?: readonly [number, number, number, number];
|
|
1503
|
+
} | null;
|
|
1451
1504
|
interface PlayOptions {
|
|
1452
1505
|
/** Which way the effect points in the world (the muzzle's barrel, the spray of a jet). */
|
|
1453
1506
|
readonly direction?: Vec3Tuple;
|
|
@@ -1463,6 +1516,11 @@ interface PlayOptions {
|
|
|
1463
1516
|
readonly values?: Readonly<Record<string, number>>;
|
|
1464
1517
|
/** Moves with a thing: the effect sits at its position plus the point it was played at. */
|
|
1465
1518
|
readonly follow?: Follow;
|
|
1519
|
+
/**
|
|
1520
|
+
* Rides on the thing it belongs to while it lives (the muzzle of a gun in the hands, which the view turns and the kick moves): the effect's grouped pieces (the
|
|
1521
|
+
* flash's cones) and its lights keep their place on it, and what it throws free (smoke) is thrown from where the thing is and stays in the world.
|
|
1522
|
+
*/
|
|
1523
|
+
readonly track?: EffectTrack;
|
|
1466
1524
|
/** Stops after this many seconds (default: the recipe's loop). */
|
|
1467
1525
|
readonly seconds?: number;
|
|
1468
1526
|
}
|
|
@@ -1483,6 +1541,8 @@ interface EffectPlayer {
|
|
|
1483
1541
|
stop(handle: number): void;
|
|
1484
1542
|
/** Runs the timers and ticks of every live effect (the engine's pools are aged by its owner). */
|
|
1485
1543
|
update(dt: number): void;
|
|
1544
|
+
/** Moves the carrier of every tracked effect to where its thing is now (after the frame moved it); the engine's `follow` then puts the carried pieces there. True when one is live. */
|
|
1545
|
+
retrack(): boolean;
|
|
1486
1546
|
clear(): void;
|
|
1487
1547
|
readonly active: number;
|
|
1488
1548
|
has(id: string): boolean;
|
|
@@ -1726,6 +1786,11 @@ interface VfxWorld {
|
|
|
1726
1786
|
* (`workshop()`); `null` when the id is unknown. Returns a handle for `stop`.
|
|
1727
1787
|
*/
|
|
1728
1788
|
play(id: string, point: Vec3Like, options?: PlayOptions): number | null;
|
|
1789
|
+
/**
|
|
1790
|
+
* Puts what rides on a thing (an effect played with `track`: a muzzle flash) where the thing is now. `update` does it as it steps; call this too after the frame moved
|
|
1791
|
+
* the things (the gun posed, the view turned) and before drawing, so the flash is drawn on the muzzle of this frame and not of the last. True when something rides.
|
|
1792
|
+
*/
|
|
1793
|
+
follow(): boolean;
|
|
1729
1794
|
/** The Workshop's pools (sprites, streaks, debris, decals, rings, lights, screen): what the renderer draws for `play`. Made on first use. */
|
|
1730
1795
|
workshop(): WorkshopEngine;
|
|
1731
1796
|
/** The Workshop engine if something already made it (`play`, `workshop()`); never creates it. */
|
|
@@ -1768,6 +1833,8 @@ interface VfxWorld {
|
|
|
1768
1833
|
fires(): readonly Fire[];
|
|
1769
1834
|
/** Hears every mark the moment it is made, and when they are cleared. Returns the function that stops listening. */
|
|
1770
1835
|
onMarks(listener: (event: MarkEvent) => void): () => void;
|
|
1836
|
+
/** Scratches the floor where a piece was dragged (`ScrapeMark`): it stays, the oldest going past `SCRAPE_LIMIT`. */
|
|
1837
|
+
scrape(mark: Omit<ScrapeMark, 'kind'>): void;
|
|
1771
1838
|
/** Seconds the world has run since it was created or cleared. */
|
|
1772
1839
|
time(): number;
|
|
1773
1840
|
/** The state of the shared stream (`randomMode: 'shared'`): what a golden compares after a run. */
|
|
@@ -1971,4 +2038,4 @@ declare const SMOKE_COLORS: {
|
|
|
1971
2038
|
readonly gas: Rgb;
|
|
1972
2039
|
};
|
|
1973
2040
|
|
|
1974
|
-
export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, 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 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, 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, 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, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, WORKSHOP_PUDDLES, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWorkshopBehaviors, effectForEvent, estimateCost, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, resolveStrings, slideAlong, streamFor, updateScreen, workshopGround };
|
|
2041
|
+
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, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, WORKSHOP_PUDDLES, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWorkshopBehaviors, effectForEvent, estimateCost, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, resolveStrings, slideAlong, streamFor, updateScreen, workshopGround };
|
package/dist/index.global.js
CHANGED
|
@@ -41,6 +41,7 @@ var GameVfx = (() => {
|
|
|
41
41
|
PROFILES: () => PROFILES,
|
|
42
42
|
RAIN_CAPACITY: () => RAIN_CAPACITY,
|
|
43
43
|
RainField: () => RainField,
|
|
44
|
+
SCRAPE_LIMIT: () => SCRAPE_LIMIT,
|
|
44
45
|
SMOKE_COLORS: () => SMOKE_COLORS,
|
|
45
46
|
SPRITE_KINDS: () => SPRITE_KINDS,
|
|
46
47
|
SpriteKindPool: () => SpriteKindPool,
|
|
@@ -5241,9 +5242,17 @@ var GameVfx = (() => {
|
|
|
5241
5242
|
});
|
|
5242
5243
|
}
|
|
5243
5244
|
function placementOf(entry) {
|
|
5245
|
+
const carrier = entry.carrier;
|
|
5246
|
+
if (carrier) return { origin: carrier.origin, anchor: entry.anchor, yaw: entry.yaw, carrier, ...carrier.orientation ? { orientation: carrier.orientation } : {} };
|
|
5244
5247
|
const origin = entry.follow ? [entry.origin[0] + positionOf2(entry.follow)[0], entry.origin[1] + positionOf2(entry.follow)[1], entry.origin[2] + positionOf2(entry.follow)[2]] : entry.origin;
|
|
5245
5248
|
return { origin, anchor: entry.anchor, yaw: entry.yaw, ...entry.orientation ? { orientation: entry.orientation } : {} };
|
|
5246
5249
|
}
|
|
5250
|
+
function moveCarrier(entry) {
|
|
5251
|
+
const pose = entry.track?.();
|
|
5252
|
+
if (!pose || !entry.carrier) return;
|
|
5253
|
+
entry.carrier.origin = [pose.point[0], pose.point[1], pose.point[2]];
|
|
5254
|
+
if (pose.orientation) entry.carrier.orientation = pose.orientation;
|
|
5255
|
+
}
|
|
5247
5256
|
function drawing(entry, action) {
|
|
5248
5257
|
const context = engine.context;
|
|
5249
5258
|
const shared = context.random;
|
|
@@ -5269,7 +5278,9 @@ var GameVfx = (() => {
|
|
|
5269
5278
|
anchor: def.anchor ?? ORIGIN5,
|
|
5270
5279
|
yaw: yawOf(heading, playOptions.direction),
|
|
5271
5280
|
orientation: playOptions.orientation,
|
|
5272
|
-
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS)
|
|
5281
|
+
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS),
|
|
5282
|
+
track: playOptions.track,
|
|
5283
|
+
carrier: playOptions.track ? { origin: point, orientation: playOptions.orientation } : void 0
|
|
5273
5284
|
};
|
|
5274
5285
|
playing.push(entry);
|
|
5275
5286
|
drawing(
|
|
@@ -5291,11 +5302,21 @@ var GameVfx = (() => {
|
|
|
5291
5302
|
for (let index = playing.length - 1; index >= 0; index--) {
|
|
5292
5303
|
const entry = playing[index];
|
|
5293
5304
|
const instance = entry.instance;
|
|
5305
|
+
moveCarrier(entry);
|
|
5294
5306
|
instance.setup = { ...instance.setup, placement: placementOf(entry) };
|
|
5295
5307
|
drawing(entry, () => instance.step(dt));
|
|
5296
5308
|
if (instance.time >= entry.seconds) playing.splice(index, 1);
|
|
5297
5309
|
}
|
|
5298
5310
|
},
|
|
5311
|
+
retrack() {
|
|
5312
|
+
let tracked = false;
|
|
5313
|
+
for (const entry of playing) {
|
|
5314
|
+
if (!entry.carrier) continue;
|
|
5315
|
+
moveCarrier(entry);
|
|
5316
|
+
tracked = true;
|
|
5317
|
+
}
|
|
5318
|
+
return tracked;
|
|
5319
|
+
},
|
|
5299
5320
|
clear() {
|
|
5300
5321
|
playing.length = 0;
|
|
5301
5322
|
},
|
|
@@ -5411,12 +5432,14 @@ var GameVfx = (() => {
|
|
|
5411
5432
|
|
|
5412
5433
|
// src/marks.ts
|
|
5413
5434
|
var BLOOD_LIMIT = 450;
|
|
5435
|
+
var SCRAPE_LIMIT = 400;
|
|
5414
5436
|
var SCORCH_VARIANTS = 3;
|
|
5415
5437
|
var RIM_COLORS = [2829359, 3815478];
|
|
5416
5438
|
function createMarkStore() {
|
|
5417
5439
|
const entries = [];
|
|
5418
5440
|
let version = 0;
|
|
5419
5441
|
let bloodCount = 0;
|
|
5442
|
+
let scrapeCount = 0;
|
|
5420
5443
|
const listeners = /* @__PURE__ */ new Set();
|
|
5421
5444
|
return {
|
|
5422
5445
|
entries,
|
|
@@ -5426,16 +5449,25 @@ var GameVfx = (() => {
|
|
|
5426
5449
|
get bloodCount() {
|
|
5427
5450
|
return bloodCount;
|
|
5428
5451
|
},
|
|
5452
|
+
get scrapeCount() {
|
|
5453
|
+
return scrapeCount;
|
|
5454
|
+
},
|
|
5429
5455
|
lift: 0,
|
|
5430
5456
|
add(mark) {
|
|
5457
|
+
if (mark.kind === "scrape" && scrapeCount >= SCRAPE_LIMIT) {
|
|
5458
|
+
entries.splice(entries.findIndex((m) => m.kind === "scrape"), 1);
|
|
5459
|
+
scrapeCount--;
|
|
5460
|
+
}
|
|
5431
5461
|
entries.push(mark);
|
|
5432
5462
|
if (mark.kind === "blood") bloodCount++;
|
|
5463
|
+
if (mark.kind === "scrape") scrapeCount++;
|
|
5433
5464
|
version++;
|
|
5434
5465
|
for (const listener of listeners) listener({ type: "add", mark });
|
|
5435
5466
|
},
|
|
5436
5467
|
clear() {
|
|
5437
5468
|
entries.length = 0;
|
|
5438
5469
|
bloodCount = 0;
|
|
5470
|
+
scrapeCount = 0;
|
|
5439
5471
|
this.lift = 0;
|
|
5440
5472
|
version++;
|
|
5441
5473
|
for (const listener of listeners) listener({ type: "clear" });
|
|
@@ -5495,6 +5527,9 @@ var GameVfx = (() => {
|
|
|
5495
5527
|
const scaleZ = spec.radius * random.between(1.2, 2);
|
|
5496
5528
|
store.add({ kind: "blood", x: spec.x, y, z: spec.z, scaleX, scaleZ, rotation: random.next() * 6 });
|
|
5497
5529
|
}
|
|
5530
|
+
function addScrape(store, spec) {
|
|
5531
|
+
store.add({ kind: "scrape", ...spec, y: spec.y + 2e-3 + nextLift(store) * 2e-4 });
|
|
5532
|
+
}
|
|
5498
5533
|
|
|
5499
5534
|
// src/pools/rings.ts
|
|
5500
5535
|
function createRingPool(capacity) {
|
|
@@ -6934,6 +6969,21 @@ var GameVfx = (() => {
|
|
|
6934
6969
|
}
|
|
6935
6970
|
};
|
|
6936
6971
|
|
|
6972
|
+
// src/workshop/carrier.ts
|
|
6973
|
+
function rotate(q, v) {
|
|
6974
|
+
const [qx, qy, qz, qw] = q;
|
|
6975
|
+
const ix = qw * v[0] + qy * v[2] - qz * v[1];
|
|
6976
|
+
const iy = qw * v[1] + qz * v[0] - qx * v[2];
|
|
6977
|
+
const iz = qw * v[2] + qx * v[1] - qy * v[0];
|
|
6978
|
+
const iw = -qx * v[0] - qy * v[1] - qz * v[2];
|
|
6979
|
+
return [ix * qw + iw * -qx + iy * -qz - iz * -qy, iy * qw + iw * -qy + iz * -qx - ix * -qz, iz * qw + iw * -qz + ix * -qy - iy * -qx];
|
|
6980
|
+
}
|
|
6981
|
+
function carriedPoint(carried) {
|
|
6982
|
+
const { carrier, local: local2 } = carried;
|
|
6983
|
+
const turned = carrier.orientation ? rotate(carrier.orientation, local2) : local2;
|
|
6984
|
+
return [carrier.origin[0] + turned[0], carrier.origin[1] + turned[1], carrier.origin[2] + turned[2]];
|
|
6985
|
+
}
|
|
6986
|
+
|
|
6937
6987
|
// src/workshop/meshes.ts
|
|
6938
6988
|
var CAPACITY3 = 400;
|
|
6939
6989
|
var IDENTITY = [0, 0, 0, 1];
|
|
@@ -6952,7 +7002,7 @@ var GameVfx = (() => {
|
|
|
6952
7002
|
get count() {
|
|
6953
7003
|
return this.particles.length;
|
|
6954
7004
|
}
|
|
6955
|
-
spawn(options, frame = IDENTITY) {
|
|
7005
|
+
spawn(options, frame = IDENTITY, carried) {
|
|
6956
7006
|
const velocity = options.v ?? [0, 0, 0];
|
|
6957
7007
|
const world = options.wv ?? [0, 0, 0];
|
|
6958
7008
|
const particle = {
|
|
@@ -6969,6 +7019,9 @@ var GameVfx = (() => {
|
|
|
6969
7019
|
y: options.p[1],
|
|
6970
7020
|
z: options.p[2],
|
|
6971
7021
|
frame: options.roll ? multiply(frame, aboutX(options.roll)) : frame,
|
|
7022
|
+
roll: options.roll ? aboutX(options.roll) : void 0,
|
|
7023
|
+
carried,
|
|
7024
|
+
drift: [0, 0, 0],
|
|
6972
7025
|
at: options.at ?? [0, 0, 0],
|
|
6973
7026
|
rx: options.rot?.[0] ?? 0,
|
|
6974
7027
|
ry: options.rot?.[1] ?? 0,
|
|
@@ -7009,9 +7062,12 @@ var GameVfx = (() => {
|
|
|
7009
7062
|
particle.vy *= keep;
|
|
7010
7063
|
particle.vz *= keep;
|
|
7011
7064
|
}
|
|
7012
|
-
particle.
|
|
7013
|
-
|
|
7014
|
-
|
|
7065
|
+
if (particle.carried) this.ride(particle, dt);
|
|
7066
|
+
else {
|
|
7067
|
+
particle.x += particle.vx * dt;
|
|
7068
|
+
particle.y += particle.vy * dt;
|
|
7069
|
+
particle.z += particle.vz * dt;
|
|
7070
|
+
}
|
|
7015
7071
|
particle.rx += particle.spin[0] * dt;
|
|
7016
7072
|
particle.ry += particle.spin[1] * dt;
|
|
7017
7073
|
particle.rz += particle.spin[2] * dt;
|
|
@@ -7022,6 +7078,30 @@ var GameVfx = (() => {
|
|
|
7022
7078
|
clear() {
|
|
7023
7079
|
this.particles.length = 0;
|
|
7024
7080
|
}
|
|
7081
|
+
/** Puts every carried piece where its carrier is now (after the frame moved the thing it belongs to). */
|
|
7082
|
+
follow() {
|
|
7083
|
+
for (const particle of this.particles) if (particle.carried) this.place(particle);
|
|
7084
|
+
}
|
|
7085
|
+
/** A carried piece: how far its own velocity took it, then its place on the carrier. */
|
|
7086
|
+
ride(particle, dt) {
|
|
7087
|
+
const drift = particle.drift;
|
|
7088
|
+
drift[0] += particle.vx * dt;
|
|
7089
|
+
drift[1] += particle.vy * dt;
|
|
7090
|
+
drift[2] += particle.vz * dt;
|
|
7091
|
+
this.place(particle);
|
|
7092
|
+
}
|
|
7093
|
+
/** A carried piece's place on the carrier now plus its drift, turned with the carrier. */
|
|
7094
|
+
place(particle) {
|
|
7095
|
+
const carried = particle.carried;
|
|
7096
|
+
if (!carried) return;
|
|
7097
|
+
const drift = particle.drift;
|
|
7098
|
+
const [x, y, z] = carriedPoint(carried);
|
|
7099
|
+
particle.x = x + drift[0];
|
|
7100
|
+
particle.y = y + drift[1];
|
|
7101
|
+
particle.z = z + drift[2];
|
|
7102
|
+
const turn = carried.carrier.orientation;
|
|
7103
|
+
if (turn) particle.frame = particle.roll ? multiply(turn, particle.roll) : turn;
|
|
7104
|
+
}
|
|
7025
7105
|
};
|
|
7026
7106
|
|
|
7027
7107
|
// src/workshop/sprites.ts
|
|
@@ -7390,8 +7470,8 @@ var GameVfx = (() => {
|
|
|
7390
7470
|
}
|
|
7391
7471
|
flash(point, color, intensity, duration, distance, force, steady) {
|
|
7392
7472
|
const { level } = this.context.quality;
|
|
7393
|
-
if (level >= 1 && !force) return;
|
|
7394
|
-
if (level >= 2 && force !== "boom") return;
|
|
7473
|
+
if (level >= 1 && !force) return void 0;
|
|
7474
|
+
if (level >= 2 && force !== "boom") return void 0;
|
|
7395
7475
|
const light = this.lights[this.next++ % LIGHT_CAPACITY];
|
|
7396
7476
|
light.x = point[0];
|
|
7397
7477
|
light.y = point[1];
|
|
@@ -7403,17 +7483,24 @@ var GameVfx = (() => {
|
|
|
7403
7483
|
light.t = 0;
|
|
7404
7484
|
light.steady = steady === true;
|
|
7405
7485
|
light.intensity = intensity;
|
|
7486
|
+
light.carried = void 0;
|
|
7487
|
+
return light;
|
|
7406
7488
|
}
|
|
7407
7489
|
clear() {
|
|
7408
7490
|
for (const light of this.lights) light.intensity = 0;
|
|
7409
7491
|
for (const light of this.fire) light.intensity = 0;
|
|
7410
7492
|
}
|
|
7493
|
+
/** Puts every carried light that burns where its carrier is now. */
|
|
7494
|
+
follow() {
|
|
7495
|
+
for (const light of this.lights) if (light.intensity > 0 && light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
|
|
7496
|
+
}
|
|
7411
7497
|
update(dt) {
|
|
7412
7498
|
for (const light of this.lights) {
|
|
7413
7499
|
if (light.intensity <= 0) continue;
|
|
7414
7500
|
light.t += dt;
|
|
7415
7501
|
const age = light.t / light.duration;
|
|
7416
7502
|
light.intensity = age >= 1 ? 0 : light.steady ? light.peak : light.peak * (1 - age) * (1 - age);
|
|
7503
|
+
if (light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
|
|
7417
7504
|
}
|
|
7418
7505
|
}
|
|
7419
7506
|
};
|
|
@@ -7423,7 +7510,7 @@ var GameVfx = (() => {
|
|
|
7423
7510
|
var FIRE_FLICKER_SWAY = 0.25;
|
|
7424
7511
|
var FIRE_FLICKER_JITTER = 0.08;
|
|
7425
7512
|
var LENS_FADE = 0.16;
|
|
7426
|
-
function
|
|
7513
|
+
function rotate2(q, v) {
|
|
7427
7514
|
const [qx, qy, qz, qw] = q;
|
|
7428
7515
|
const ix = qw * v[0] + qy * v[2] - qz * v[1];
|
|
7429
7516
|
const iy = qw * v[1] + qz * v[0] - qx * v[2];
|
|
@@ -7481,7 +7568,7 @@ var GameVfx = (() => {
|
|
|
7481
7568
|
if (!placement) return point;
|
|
7482
7569
|
const { anchor, origin, yaw, orientation } = placement;
|
|
7483
7570
|
if (orientation) {
|
|
7484
|
-
const turned =
|
|
7571
|
+
const turned = rotate2(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
|
|
7485
7572
|
return [origin[0] + turned[0], origin[1] + turned[1], origin[2] + turned[2]];
|
|
7486
7573
|
}
|
|
7487
7574
|
const x = point[0] - anchor[0];
|
|
@@ -7490,11 +7577,20 @@ var GameVfx = (() => {
|
|
|
7490
7577
|
const sin2 = Math.sin(yaw);
|
|
7491
7578
|
return [origin[0] + cos2 * x + sin2 * z, origin[1] + point[1] - anchor[1], origin[2] - sin2 * x + cos2 * z];
|
|
7492
7579
|
}
|
|
7580
|
+
/** A point of the recipe's space from the anchor, turned by the placement's yaw when it has no orientation (the carrier turns the rest). */
|
|
7581
|
+
local(point) {
|
|
7582
|
+
const placement = this.placement;
|
|
7583
|
+
if (!placement) return point;
|
|
7584
|
+
const offset = [point[0] - placement.anchor[0], point[1] - placement.anchor[1], point[2] - placement.anchor[2]];
|
|
7585
|
+
if (placement.carrier?.orientation) return offset;
|
|
7586
|
+
const turned = this.place(point);
|
|
7587
|
+
return [turned[0] - placement.origin[0], turned[1] - placement.origin[1], turned[2] - placement.origin[2]];
|
|
7588
|
+
}
|
|
7493
7589
|
/** A direction or velocity of the recipe's space in the world. */
|
|
7494
7590
|
turn(vector2) {
|
|
7495
7591
|
const placement = this.placement;
|
|
7496
7592
|
if (!placement) return vector2;
|
|
7497
|
-
if (placement.orientation) return
|
|
7593
|
+
if (placement.orientation) return rotate2(placement.orientation, vector2);
|
|
7498
7594
|
const cos2 = Math.cos(placement.yaw);
|
|
7499
7595
|
const sin2 = Math.sin(placement.yaw);
|
|
7500
7596
|
return [cos2 * vector2[0] + sin2 * vector2[2], vector2[1], -sin2 * vector2[0] + cos2 * vector2[2]];
|
|
@@ -7529,7 +7625,8 @@ var GameVfx = (() => {
|
|
|
7529
7625
|
const options = placement ? { ...recipe, p: this.place(recipe.p), ...recipe.v ? { v: this.turn(recipe.v) } : {} } : recipe;
|
|
7530
7626
|
this.context.trace?.("mesh", [options]);
|
|
7531
7627
|
const grouped = recipe.at !== void 0 || recipe.roll !== void 0;
|
|
7532
|
-
|
|
7628
|
+
const carried = placement?.carrier && grouped ? { carrier: placement.carrier, local: this.local(recipe.p) } : void 0;
|
|
7629
|
+
return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0, carried);
|
|
7533
7630
|
}
|
|
7534
7631
|
debrisPiece(recipe) {
|
|
7535
7632
|
const options = this.placed(recipe);
|
|
@@ -7553,9 +7650,11 @@ var GameVfx = (() => {
|
|
|
7553
7650
|
}
|
|
7554
7651
|
/** `steady` (a seventh number): the light holds its intensity for its duration and goes out, where the Workshop's fades with the square of its age. */
|
|
7555
7652
|
flash(recipe) {
|
|
7556
|
-
const
|
|
7653
|
+
const placement = this.placement;
|
|
7654
|
+
const args = placement ? [this.place(recipe[0]), recipe[1], recipe[2], recipe[3], recipe[4], recipe[5], recipe[6]] : recipe;
|
|
7557
7655
|
this.context.trace?.("flash", args.slice(0, 6));
|
|
7558
|
-
this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
7656
|
+
const light = this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
7657
|
+
if (light && placement?.carrier) light.carried = { carrier: placement.carrier, local: this.local(recipe[0]) };
|
|
7559
7658
|
}
|
|
7560
7659
|
/** `fireLight` (W400): sways with the clock and flickers with one draw. */
|
|
7561
7660
|
fireLight(slot, recipe, intensity, time) {
|
|
@@ -7718,6 +7817,12 @@ var GameVfx = (() => {
|
|
|
7718
7817
|
const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
7719
7818
|
return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
|
|
7720
7819
|
},
|
|
7820
|
+
follow() {
|
|
7821
|
+
if (!engine || !player?.retrack()) return false;
|
|
7822
|
+
engine.meshes.follow();
|
|
7823
|
+
engine.lights.follow();
|
|
7824
|
+
return true;
|
|
7825
|
+
},
|
|
7721
7826
|
burst: (kind, point, normal, count, speed, spriteOptions) => spriteSystem.burst(kind, point, normal, count, speed, spriteOptions),
|
|
7722
7827
|
spawn: (kind, point, velocity, spriteOptions) => spriteSystem.spawn(kind, point, velocity, spriteOptions),
|
|
7723
7828
|
onLand: (owner, listener) => spriteSystem.onLand(owner, listener),
|
|
@@ -7843,6 +7948,7 @@ var GameVfx = (() => {
|
|
|
7843
7948
|
}),
|
|
7844
7949
|
fires: () => core.fires.items,
|
|
7845
7950
|
onMarks: (listener) => core.marks.subscribe(listener),
|
|
7951
|
+
scrape: (mark) => addScrape(core.marks, mark),
|
|
7846
7952
|
time: () => core.clock.time,
|
|
7847
7953
|
randomState: () => sharedRandom.state,
|
|
7848
7954
|
clear() {
|
|
@@ -8723,7 +8829,7 @@ var GameVfx = (() => {
|
|
|
8723
8829
|
function mix(from, to, amount) {
|
|
8724
8830
|
return [from[0] + (to[0] - from[0]) * amount, from[1] + (to[1] - from[1]) * amount, from[2] + (to[2] - from[2]) * amount];
|
|
8725
8831
|
}
|
|
8726
|
-
function
|
|
8832
|
+
function rotate3(local2, x, y, z, w) {
|
|
8727
8833
|
const [vx2, vy2, vz2] = local2;
|
|
8728
8834
|
const ix = w * vx2 + y * vz2 - z * vy2;
|
|
8729
8835
|
const iy = w * vy2 + z * vx2 - x * vz2;
|
|
@@ -8781,7 +8887,7 @@ var GameVfx = (() => {
|
|
|
8781
8887
|
/** A direction given in the camera's own axes, in world axes. */
|
|
8782
8888
|
forward(local2) {
|
|
8783
8889
|
const [x, y, z, w] = lookAtQuaternion(this.position, this.target);
|
|
8784
|
-
return
|
|
8890
|
+
return rotate3(local2, x, y, z, w);
|
|
8785
8891
|
}
|
|
8786
8892
|
};
|
|
8787
8893
|
|