Class StatusModifier<T>

A status modifier holds a list of modifiers for some properties. It takes a reducer function that runs whenever this list changes (this is where you can calculate & apply changes).

Ex: In a movement status modifier you might have a property blockSprint and in your reducer if any modifier has blockSprint=true you would call SetSprintBlocked. This way you could have multiple sources blocking sprint without overwriting eachother.

Type Parameters

  • T extends StatusModifierEntry

Methods

  • Adds a modifier (this will run the reducer).

    Parameters

    • modifier: T

    Returns {
        Destroy: (() => boolean);
    }

    A Destroy function to remove the modifier. This can be passed to a Bin.

    • Destroy: (() => boolean)
        • (): boolean
        • Returns boolean

  • Clears all modifiers (this will run the reducer).

    Returns void

  • Returns all active modifiers.

    Returns Set<T>

  • Removes a modfier. If it existed (and was removed) this will run the reducer. Returns true if the modifier was removed.

    Parameters

    • modifier: T

    Returns boolean

  • Overwrites the existing reducer and immediately runs the new reducer.

    Parameters

    • reduce: ((modifiers, statusModifier) => void)
        • (modifiers, statusModifier): void
        • Parameters

          Returns void

    Returns void

  • Can be used to manually rerun modifiers. Usually this will run when a modifier is added or removed.

    Returns void