class ConditionHolder: Component

A container for Condition objects.

conditions: SparseArray

The list of conditions.

modifierMap: table<ConditionModifier, ConditionModifier[]>
__new(self: ConditionHolder)
add(self: ConditionHolder, condition: Condition): (handle: integer)

Adds a condition and its modifiers. Will remove other conditions of the same type if marked as a singleton.

remove(self: ConditionHolder, handle: integer)

Removes a condition using its handle.

removeIf(
    self: ConditionHolder,
    filter: fun(condition: Condition): boolean
): (self: ConditionHolder)

Removes conditions based on a filter.

Parameters:

filter (fun(condition: Condition): boolean) – Any conditions that return true will be removed.

each(
    self: ConditionHolder,
    func: fun(condition: Condition)
): (self: ConditionHolder)

Runs a function on each condition.

Parameters:

func (fun(condition: Condition)) – A function to apply to each condition.

getModifiers(self: ConditionHolder, prototype: <T>): <T>[]

Returns a list of modifiers of a given type.

get(self: ConditionHolder, handle: integer): Condition?

Returns a condition given a handle.

staticmethod getActorModifiers(actor: Entity, prototype: <T>): <T>[]

Helper method to retrieve an actor’s modifier of a given type.

Returns:

_1 (<T>[]) – A list of modifiers. Treat this as immutable.

pairs(self: ConditionHolder): fun(): integer, Condition

Iterator on each condition.