Table of Contents

Class CharacterResourceAttribute

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Represents a character resource attribute (e.g., health, mana, stamina) that can be consumed or regenerated. Extends CharacterAttribute to add current value tracking and resource-specific logic.

public class CharacterResourceAttribute : CharacterAttribute
Inheritance
CharacterResourceAttribute
Inherited Members

Constructors

CharacterResourceAttribute(ICharacterAttributeController, int, int, float, int)

Constructs a new CharacterResourceAttribute with the given template ID, initial value, current value, and modifier.

public CharacterResourceAttribute(ICharacterAttributeController characterAttributeController, int templateID, int initialValue, float currentValue, int modifier)

Parameters

characterAttributeController ICharacterAttributeController
templateID int

The template ID for this resource attribute.

initialValue int

The initial base value.

currentValue float

The starting current value.

modifier int

The initial modifier value.

Properties

CurrentValue

Gets the current value of the resource.

public float CurrentValue { get; }

Property Value

float

Methods

AddToCurrentValue(float)

Adds the specified value to the current resource value, clamping to the maximum (FinalValue). Triggers attribute update if the value changes.

public void AddToCurrentValue(float value)

Parameters

value float

Amount to add to the current value.

Consume(float)

Consumes the specified amount from the current resource value, clamping to zero. Triggers attribute update event.

public void Consume(float amount)

Parameters

amount float

Amount to consume.

Gain(float)

Gains the specified amount to the current resource value, clamping to the maximum (FinalValue). Triggers attribute update event.

public void Gain(float amount)

Parameters

amount float

Amount to gain.

Internal_OnAttributeChanged(CharacterAttribute)

Called when the attribute is updated. Invokes base logic and event notification.

protected override void Internal_OnAttributeChanged(CharacterAttribute attribute)

Parameters

attribute CharacterAttribute

The attribute that was changed.

SetCurrentValue(float, bool)

Sets the current resource value directly. Optionally triggers attribute update.

public void SetCurrentValue(float value, bool updateInternal = true)

Parameters

value float

The new current value.

updateInternal bool

If true, triggers attribute update event.

ToString()

Returns a string representation of the resource attribute (e.g., "Health: 50/100").

public override string ToString()

Returns

string