Interface IBuffController
Interface for a character's buff controller, handling application, removal, and events for buffs and debuffs.
public interface IBuffController : ICharacterBehaviour
- Inherited Members
Fields
OnAddBuff
Static event triggered when a buff (positive effect) is added. Carries the owner.
public static Action<IBuffController, Buff> OnAddBuff
Field Value
OnAddDebuff
Static event triggered when a debuff (negative effect) is added. Carries the owner.
public static Action<IBuffController, Buff> OnAddDebuff
Field Value
OnBuffTick
Static event fired each tick for every active buff, providing the owning controller and the current network tick for UI duration-bar updates via RemainingSeconds(uint).
public static Action<IBuffController, Buff, uint> OnBuffTick
Field Value
Remarks
All five of these events carry their owner. They are static — one invocation list shared by every buff controller in the process — and they used to carry only the Buff, which has no owner either. The local player's buff and debuff strips subscribe to them, so every buff applied to every NPC, pet and other player in view was rendered onto the local player's own strips. The strips looked correct only because keying by template ID hid duplicates; a debuff landing on a mob genuinely appeared on the player.
Subscribers MUST compare the controller against the one they care about. There is no way to scope a static event at subscription time, so the filter has to be at the callback.
OnObservedBuffsChanged
Raised when this character's buff set changes on this peer — applied by its own simulation, or materialised from the server's message on a peer that only observes it. Subscribers read Buffs; there is no separate display list.
public static Action<IBuffController> OnObservedBuffsChanged
Field Value
OnRemoveBuff
Static event triggered when a buff (positive effect) is removed. Carries the owner.
public static Action<IBuffController, Buff> OnRemoveBuff
Field Value
OnRemoveDebuff
Static event triggered when a debuff (negative effect) is removed. Carries the owner.
public static Action<IBuffController, Buff> OnRemoveDebuff
Field Value
Properties
Buffs
Dictionary of all active buffs for the character, indexed by template ID.
SortedDictionary<int, Buff> Buffs { get; }
Property Value
OnBuffApplyTriggers
Triggers invoked when a buff or debuff is applied to this character. EventData: BuffEventData.
List<Trigger> OnBuffApplyTriggers { get; }
Property Value
OnBuffRemoveTriggers
Triggers invoked when a buff or debuff is removed from this character. EventData: BuffEventData.
List<Trigger> OnBuffRemoveTriggers { get; }
Property Value
Methods
Apply(BaseBuffTemplate, PredictionTick, ICharacter)
Applies a buff to the character by template, creating a new instance if needed and handling stacking.
void Apply(BaseBuffTemplate template, PredictionTick currentTick, ICharacter caster = null)
Parameters
templateBaseBuffTemplateThe buff template to apply.
currentTickPredictionTickThe replicate-domain tick at the moment of application.
casterICharacterThe character applying the buff, snapshotted so periodic effects have somebody to credit. May be null when the source has no initiator.
Apply(Buff, bool)
Applies a buff instance to the character if not already present, invoking appropriate events.
void Apply(Buff buff, bool suppressFX = false)
Parameters
ApplyAuthoritative(BaseBuffTemplate, uint, ICharacter)
Applies a buff from a server-authoritative context. Implementations should stamp the buff with their current replicate-domain tick when one is available.
void ApplyAuthoritative(BaseBuffTemplate template, uint serverTick, ICharacter caster = null)
Parameters
templateBaseBuffTemplateThe buff template to apply.
serverTickuintFallback authoritative tick used before any replicate tick exists.
casterICharacterThe character applying the buff, snapshotted so periodic effects have somebody to credit. May be null when the source has no initiator.
CreateReconcileSnapshot()
Creates a reconcile snapshot of all active buffs. Returns null when no buffs are active.
BuffReconcileEntry[] CreateReconcileSnapshot()
Returns
GetCurrentDomainTick()
Gets the current tick in the controller's replicate-domain. This is the reference tick used for all buff comparisons.
uint GetCurrentDomainTick()
Returns
- uint
The current replicate-domain tick.
Remove(int)
Removes a buff by template ID, invoking removal events and cleaning up.
void Remove(int buffID)
Parameters
buffIDintThe template ID of the buff to remove.
RemoveAll(bool, bool, bool)
Removes all non-permanent buffs from the character, optionally suppressing removal events.
void RemoveAll(bool ignoreInvokeRemove = false, bool includePermanent = false, bool preserveFX = false)
Parameters
ignoreInvokeRemoveboolIf true, does not invoke OnRemoveBuff/OnRemoveDebuff events.
includePermanentboolTrue to remove permanent buffs as well. Default false so gameplay dispels leave them alone; the lifecycle callers pass true, because a pooled object inheriting the previous occupant's permanent buff also inherits its attribute modifiers.
preserveFXboolTrue to leave buff effects showing. For a REFRESH — the spawn payload clears before it re-reads — where tearing effects down first makes every surviving buff's FX restart. Whatever is genuinely gone is despawned by the diff that follows.
RemoveRandom(DeterministicRNG, bool, bool)
Removes a random non-permanent buff or debuff, filtered by inclusion flags.
void RemoveRandom(DeterministicRNG rng, bool includeBuffs = false, bool includeDebuffs = false)
Parameters
rngDeterministicRNGThe deterministic random number generator to use.
includeBuffsboolWhether to include buffs in the selection.
includeDebuffsboolWhether to include debuffs in the selection.
ResolveAuthoritativeTick(uint)
Maps a raw authoritative tick to the controller's current replicate-domain tick when a replicate tick is available.
uint ResolveAuthoritativeTick(uint serverTick)
Parameters
serverTickuintFallback authoritative tick used before any replicate tick exists.
Returns
- uint
The effective tick to use for buff comparisons.
RestoreFromReconcile(BuffReconcileEntry[], uint)
Restores buff state from a reconcile snapshot.
void RestoreFromReconcile(BuffReconcileEntry[] entries, uint reconcileTick)
Parameters
entriesBuffReconcileEntry[]Authoritative buff snapshot.
reconcileTickuintReplicate tick associated with the reconcile snapshot.
Tick(uint)
Deterministic buff tick — evaluates expiry and tick conditions for all active buffs. Use this for CSP instead of relying on Unity's Update.
void Tick(uint currentTick)
Parameters
currentTickuintThe current network tick.