Table of Contents

Struct ActiveModifierList

Namespace
Core.Modifiers
Assembly
Core.dll

ENGINE: Pool-based list of active modifiers with add/remove/expire logic Pattern used by: EU4 (timed modifiers), CK3 (character effects), Stellaris (empire modifiers)

Design:

  • Fixed-size array (zero allocations)
  • Lazy deletion (mark as empty, compact on rebuild)
  • Efficient iteration (skip empty slots)
  • Track active count for quick checks

Performance: O(n) iteration where n = active modifiers (not max capacity)

public struct ActiveModifierList

Fields

DEFAULT_CAPACITY

public const int DEFAULT_CAPACITY = 64

Field Value

int

Properties

ActiveCount

Get count of active modifiers

public int ActiveCount { get; }

Property Value

int

HasAnyModifiers

Check if any modifiers are active

public bool HasAnyModifiers { get; }

Property Value

bool

Methods

Add(ModifierSource)

Add a new modifier to the list Returns false if capacity exceeded

public bool Add(ModifierSource source)

Parameters

source ModifierSource

Returns

bool

ApplyTo(ref ModifierSet)

Apply all active modifiers to a ModifierSet

public void ApplyTo(ref ModifierSet modifierSet)

Parameters

modifierSet ModifierSet

Clear()

Clear all modifiers

public void Clear()

CountBySource(SourceType, uint)

Count modifiers from a specific source

public int CountBySource(ModifierSource.SourceType sourceType, uint sourceId)

Parameters

sourceType ModifierSource.SourceType
sourceId uint

Returns

int

Create(int, Allocator)

Create a new active modifier list with specified capacity

public static ActiveModifierList Create(int capacity = 64, Allocator allocator = Allocator.Persistent)

Parameters

capacity int
allocator Allocator

Returns

ActiveModifierList

Dispose()

Dispose native collections

public void Dispose()

ExpireModifiers(int)

Expire temporary modifiers that have passed their expiration tick Returns count of modifiers expired

public int ExpireModifiers(int currentTick)

Parameters

currentTick int

Returns

int

ForEach(Action<ModifierSource>)

Iterate over all active modifiers (for debugging/tooltips)

public void ForEach(Action<ModifierSource> action)

Parameters

action Action<ModifierSource>

ForEachByModifierType(ushort, Action<ModifierSource>)

Iterate over modifiers of a specific modifier type

public void ForEachByModifierType(ushort modifierTypeId, Action<ModifierSource> action)

Parameters

modifierTypeId ushort
action Action<ModifierSource>

ForEachBySource(SourceType, uint, Action<ModifierSource>)

Iterate over modifiers from a specific source

public void ForEachBySource(ModifierSource.SourceType sourceType, uint sourceId, Action<ModifierSource> action)

Parameters

sourceType ModifierSource.SourceType
sourceId uint
action Action<ModifierSource>

RemoveBySource(SourceType, uint)

Remove modifiers from a specific source Returns count of modifiers removed

public int RemoveBySource(ModifierSource.SourceType sourceType, uint sourceId)

Parameters

sourceType ModifierSource.SourceType
sourceId uint

Returns

int

RemoveBySourceAndType(SourceType, uint, ushort)

Remove modifiers of a specific type from a specific source Returns count of modifiers removed

public int RemoveBySourceAndType(ModifierSource.SourceType sourceType, uint sourceId, ushort modifierTypeId)

Parameters

sourceType ModifierSource.SourceType
sourceId uint
modifierTypeId ushort

Returns

int