Table of Contents

Class SnapshotAttributeController

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

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

live ICharacterAttributeController

The live attribute controller to snapshot.

owner ICharacter

The 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

Dictionary<int, CharacterAttribute>

Character

The character this behaviour is attached to.

public ICharacter Character { get; }

Property Value

ICharacter

Initialized

True if this behaviour has been initialized for its character.

public bool Initialized { get; }

Property Value

bool

IsPropagating

True while the attribute graph is propagating value changes. Notifications are deferred until propagation completes.

public bool IsPropagating { get; }

Property Value

bool

ResourceAttributes

Dictionary of all resource character attributes (e.g., health, mana), keyed by template ID.

public Dictionary<int, CharacterResourceAttribute> ResourceAttributes { get; }

Property Value

Dictionary<int, CharacterResourceAttribute>

Methods

AddAttribute(CharacterAttribute)

Adds a new non-resource attribute instance to the controller.

public void AddAttribute(CharacterAttribute instance)

Parameters

instance CharacterAttribute

Attribute instance to add.

ApplyResourceState(CharacterAttributeResourceState)

Applies a resource state (health, mana, stamina, regen delta) to the controller.

public void ApplyResourceState(CharacterAttributeResourceState resourceState)

Parameters

resourceState CharacterAttributeResourceState

Resource 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

source ModifierSource

The 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

attribute CharacterAttribute

The 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

character ICharacter

The 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

tick uint

Authoritative 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

id int

Template ID of the attribute.

value int

New value to set.

modifier int?

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

id int

Template ID of the resource attribute.

value int

New value to set.

currentValue float

New current value to set.

modifier int?

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

template CharacterAttributeTemplate

Attribute template to look up.

attribute CharacterAttribute

Out: 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

id int

Template ID to look up.

attribute CharacterAttribute

Out: 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

health CharacterResourceAttribute

Out: 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

mana CharacterResourceAttribute

Out: 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

template CharacterAttributeTemplate

Resource attribute template to look up.

attribute CharacterResourceAttribute

Out: 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

id int

Template ID to look up.

attribute CharacterResourceAttribute

Out: 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

stamina CharacterResourceAttribute

Out: found stamina resource attribute.

Returns

bool

True if found, false otherwise.