Class SnapshotAttributeController
Lightweight read-only ICharacterAttributeController backed by frozen CharacterAttribute instances. Used by SnapshotCharacter to satisfy StatScaledValue and StatScaledFloatValue lookups for detached ability objects whose caster has disconnected.
Only TryGetAttribute(int, out CharacterAttribute) is functional. All mutating methods are no-ops.
public sealed class SnapshotAttributeController : ICharacterAttributeController, ICharacterBehaviour
- Inheritance
-
SnapshotAttributeController
- Implements
- Inherited Members
- Extension Methods
Constructors
SnapshotAttributeController(ICharacterAttributeController, ICharacter)
Creates a snapshot attribute controller by deep-copying the final values
from a live ICharacterAttributeController.
Each attribute is re-created with value = original.FinalValue and
modifier = 0 so that FinalValue returns
the same number as the original at the time of snapshotting.
public SnapshotAttributeController(ICharacterAttributeController live, ICharacter owner)
Parameters
liveICharacterAttributeControllerThe live attribute controller to snapshot.
ownerICharacterThe SnapshotCharacter that owns this controller.
Properties
Attributes
Dictionary of all non-resource character attributes, keyed by template ID.
public Dictionary<int, CharacterAttribute> Attributes { get; }
Property Value
Character
The character this behaviour is attached to.
public ICharacter Character { get; }
Property Value
Initialized
True if this behaviour has been initialized for its character.
public bool Initialized { get; }
Property Value
IsPropagating
True while the attribute graph is propagating value changes. Notifications are deferred until propagation completes.
public bool IsPropagating { get; }
Property Value
ResourceAttributes
Dictionary of all resource character attributes (e.g., health, mana), keyed by template ID.
public Dictionary<int, CharacterResourceAttribute> ResourceAttributes { get; }
Property Value
Methods
AddAttribute(CharacterAttribute)
Adds a new non-resource attribute instance to the controller.
public void AddAttribute(CharacterAttribute instance)
Parameters
instanceCharacterAttributeAttribute instance to add.
ApplyResourceState(CharacterAttributeResourceState)
Applies a resource state (health, mana, stamina, regen delta) to the controller.
public void ApplyResourceState(CharacterAttributeResourceState resourceState)
Parameters
resourceStateCharacterAttributeResourceStateResource state to apply.
BeginNotificationSuppression()
Begins a scope that suppresses all attribute update notifications while still allowing deterministic attribute/resource state mutations to run. Used by prediction replay so UI, ECA, and passive listeners do not observe intermediate resimulation states.
public void BeginNotificationSuppression()
BeginPropagation()
Begins a propagation batch. While active, EnqueueNotification(CharacterAttribute) collects changed attributes instead of firing events immediately. Must be paired with EndPropagation().
public void BeginPropagation()
ClearModifierSource(ModifierSource)
Releases one contributor from every attribute on the sheet.
public void ClearModifierSource(ModifierSource source)
Parameters
sourceModifierSourceThe contributor to release everywhere.
Remarks
For a source whose owner goes away without knowing which attributes it touched — see
Region, which releases its own contributions when a character leaves it.
EndNotificationSuppression()
Ends a notification-suppression scope and discards any queued updates without invoking OnAttributeUpdated listeners.
public void EndNotificationSuppression()
EndPropagation()
Ends a propagation batch. If this is the outermost batch (depth returns to zero), fires all deferred OnAttributeUpdated events.
public void EndPropagation()
EnqueueNotification(CharacterAttribute)
Enqueues an attribute for deferred notification during propagation. If not propagating, callers should invoke the event directly instead.
public void EnqueueNotification(CharacterAttribute attribute)
Parameters
attributeCharacterAttributeThe attribute to notify after propagation completes.
GetResourceState()
Gets the current resource state (health, mana, stamina, regen delta) for the controller.
public CharacterAttributeResourceState GetResourceState()
Returns
- CharacterAttributeResourceState
Current resource state struct.
InitializeOnce(ICharacter)
Initializes the behaviour with the specified character. Called once per behaviour instance.
public void InitializeOnce(ICharacter character)
Parameters
characterICharacterThe character to initialize for.
OnStartCharacter()
Called when the character starts on the client. Use for local client initialization.
public void OnStartCharacter()
OnStopCharacter()
Called when the character stops on the client. Use for local client cleanup.
public void OnStopCharacter()
Regenerate(uint)
Advances tick-driven regen for resource attributes (e.g., health, mana).
A pulse fires when tick % regenTickInterval == 0; an internal
monotonic guard prevents double-advancement under replay, resimulation,
or future-state execution.
public void Regenerate(uint tick)
Parameters
tickuintAuthoritative simulation tick for this replicate step.
SetAttribute(int, int, int?)
Sets the value and optional modifier of a non-resource attribute by template ID.
public void SetAttribute(int id, int value, int? modifier = null)
Parameters
idintTemplate ID of the attribute.
valueintNew value to set.
modifierint?Optional modifier value to set.
SetResourceAttribute(int, int, float, int?)
Sets the value, current value, and optional modifier of a resource attribute by template ID.
public void SetResourceAttribute(int id, int value, float currentValue, int? modifier = null)
Parameters
idintTemplate ID of the resource attribute.
valueintNew value to set.
currentValuefloatNew current value to set.
modifierint?Optional modifier value to set.
TryGetAttribute(CharacterAttributeTemplate, out CharacterAttribute)
Tries to get a non-resource attribute by template reference.
public bool TryGetAttribute(CharacterAttributeTemplate template, out CharacterAttribute attribute)
Parameters
templateCharacterAttributeTemplateAttribute template to look up.
attributeCharacterAttributeOut: found attribute instance.
Returns
- bool
True if found, false otherwise.
TryGetAttribute(int, out CharacterAttribute)
Tries to get a non-resource attribute by template ID.
public bool TryGetAttribute(int id, out CharacterAttribute attribute)
Parameters
idintTemplate ID to look up.
attributeCharacterAttributeOut: found attribute instance.
Returns
- bool
True if found, false otherwise.
TryGetHealthAttribute(out CharacterResourceAttribute)
Tries to get the health resource attribute for the character.
public bool TryGetHealthAttribute(out CharacterResourceAttribute health)
Parameters
healthCharacterResourceAttributeOut: found health resource attribute.
Returns
- bool
True if found, false otherwise.
TryGetManaAttribute(out CharacterResourceAttribute)
Tries to get the mana resource attribute for the character.
public bool TryGetManaAttribute(out CharacterResourceAttribute mana)
Parameters
manaCharacterResourceAttributeOut: found mana resource attribute.
Returns
- bool
True if found, false otherwise.
TryGetResourceAttribute(CharacterAttributeTemplate, out CharacterResourceAttribute)
Tries to get a resource attribute by template reference.
public bool TryGetResourceAttribute(CharacterAttributeTemplate template, out CharacterResourceAttribute attribute)
Parameters
templateCharacterAttributeTemplateResource attribute template to look up.
attributeCharacterResourceAttributeOut: found resource attribute instance.
Returns
- bool
True if found, false otherwise.
TryGetResourceAttribute(int, out CharacterResourceAttribute)
Tries to get a resource attribute by template ID.
public bool TryGetResourceAttribute(int id, out CharacterResourceAttribute attribute)
Parameters
idintTemplate ID to look up.
attributeCharacterResourceAttributeOut: found resource attribute instance.
Returns
- bool
True if found, false otherwise.
TryGetStaminaAttribute(out CharacterResourceAttribute)
Tries to get the stamina resource attribute for the character.
public bool TryGetStaminaAttribute(out CharacterResourceAttribute stamina)
Parameters
staminaCharacterResourceAttributeOut: found stamina resource attribute.
Returns
- bool
True if found, false otherwise.