mwg API
    Preparing search index...

    Class StatusVisuals

    Turns a set of active status-effect names into one additive colour on a sprite, so a game's own actors.applyStatusEffect handles - which know nothing about rendering - can drive what a character looks like without either side importing the other.

    Every active status composes over the additive channel (TintedSprite.colorAdd) rather than one winning by declaration order: poisoned-and-burning sums both colours (each channel clamped to 1, so an oversaturated combination clips rather than wrapping), instead of only the first-declared style showing. This class never touches the multiply tint, so a sprite's own identity tint (a team colour, say) rides underneath untouched - the composition this class's own earlier version could not do, because writing both halves of lerpTint per update meant the last status checked always overwrote whatever tint a caller had set. A one-shot flash (a damage hit, a heal glow) layers its own decaying contribution on top of whatever statuses are active, rather than needing a caller to juggle a separate colour write.

    target is any object shaped like TintedSprite's own colorAdd field - duck-typed the way Projectile takes a plain {x, y} rather than a real Pixi Sprite, so this is fully testable without Pixi and works on any sprite subclass that exposes the same field.

    import { StatusVisuals, TintedSprite, type Texture2D } from '@datamoc/mw_games/two-d/render';

    declare const ratTexture: Texture2D;
    const rat = new TintedSprite(ratTexture);
    rat.tint = 0x8080ff; // a team colour, untouched by anything below

    const visuals = new StatusVisuals(rat, {
    styles: {
    poisoned: { color: 0x00ff00, strength: 0.5 },
    burning: { color: 0xff6600, strength: 0.6, pulseRate: 2 },
    },
    });

    visuals.set('poisoned', true);
    visuals.set('burning', true);
    visuals.update(1 / 60); // both colours composed into rat.colorAdd; rat.tint is untouched
    console.log(visuals.has('poisoned')); // true

    visuals.flash(0xffffff, 0.8, 0.2); // a bright hit-flash, decaying over 0.2s
    visuals.update(1 / 60);

    visuals.set('poisoned', false);
    visuals.set('burning', false);
    visuals.update(1 / 60); // no status or flash left active: colorAdd back to 0
    Index
    • Layers a transient additive pulse on top of whatever statuses are active, linearly decaying strength to zero over duration seconds - a damage hit or a heal glow that needs no status of its own and no caller-managed timer.

      Parameters

      • color: number
      • strength: number
      • duration: number

      Returns void

    • marks kind active or inactive; a kind with no matching style is tracked but never shown

      Parameters

      • kind: string
      • active: boolean

      Returns void

    • advances any pulsing style and the flash decay, and repaints the sprite's additive channel

      Parameters

      • dt: number

      Returns void