MCPcopy
hub / github.com/magcius/noclip.website / Initializer_TrailLengthRandom

Class Initializer_TrailLengthRandom

src/SourceEngine/ParticleSystem.ts:417–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417class Initializer_TrailLengthRandom extends ModuleBase {
418 private readonly min: number;
419 private readonly max: number;
420 private readonly randomExponent: number;
421
422 constructor(elem: DMX.DMXElement) {
423 super(elem);
424 this.min = getAttribValue(elem, `length_min`, DMX.DMXAttributeType.Float, 0.1);
425 this.max = getAttribValue(elem, `length_max`, DMX.DMXAttributeType.Float, 0.1);
426 this.randomExponent = getAttribValue(elem, `length_random_exponent`, DMX.DMXAttributeType.Float, 1.0);
427 }
428
429 public override streamWrite(): StreamMask {
430 return StreamMask.TrailLength;
431 }
432
433 public init(system: ParticleSystemInstance, p: number): void {
434 if (!system.hasStream(StreamMask.TrailLength))
435 return;
436
437 const trailLength = randRangeExp(system, this.min, this.max, this.randomExponent);
438
439 const data = system.particleDataF32;
440 data[system.getStreamOffs(StreamMask.TrailLength, p)] = trailLength;
441 }
442}
443
444class Initializer_PositionModifyOffsetRandom extends ModuleBase {
445 private readonly min: ReadonlyVec3;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected