Class CharacterResourceAttribute
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
characterAttributeControllerICharacterAttributeControllertemplateIDintThe template ID for this resource attribute.
initialValueintThe initial base value.
currentValuefloatThe starting current value.
modifierintThe initial modifier value.
Properties
CurrentValue
Gets the current value of the resource.
public float CurrentValue { get; }
Property Value
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
valuefloatAmount 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
amountfloatAmount 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
amountfloatAmount 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
attributeCharacterAttributeThe 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
ToString()
Returns a string representation of the resource attribute (e.g., "Health: 50/100").
public override string ToString()