Class EntityAttributes
- Namespace
- ElectricDrill.SoapRpgFramework.Attributes
- Assembly
- com.electricdrill.soap-rpg-framework.Runtime.dll
Manages the attributes of an entity. This component calculates attribute values by combining base values, flat modifiers, percentage modifiers, and spent attribute points. It requires an ElectricDrill.SoapRpgFramework.Attributes.EntityAttributes.EntityCore component on the same GameObject.
[DisallowMultipleComponent]
[RequireComponent(typeof(EntityCore))]
public class EntityAttributes : MonoBehaviour, IHasAttributeSet, IValueProvider<Attribute, long>- Inheritance
- 
      objectEntityAttributes
- Implements
Properties
AttributeSet
Gets the AttributeSet used by this entity. The source of the attribute set depends on whether UseBaseAttributesFromClass is true. If true, it returns the attribute set from the EntityClass. Otherwise, it returns the ElectricDrill.SoapRpgFramework.Attributes.EntityAttributes._fixedBaseAttributeSet.
public virtual AttributeSet AttributeSet { get; }Property Value
AvailableAttributePoints
Gets the number of attribute points currently available to spend.
public int AvailableAttributePoints { get; }Property Value
- int
EntityClass
Gets the class for this entity. The class is used to determine base attributes when ElectricDrill.SoapRpgFramework.Attributes.EntityAttributes._useBaseAttributesFromClass is true.
public IClassSource EntityClass { get; }Property Value
FlatModifiers
Gets the instance of flat modifiers for the attributes. Flat modifiers are added directly to the base attribute values.
protected virtual AttributeSetInstance FlatModifiers { get; }Property Value
OnAttributeChanged
public AttributeChangedGameEvent OnAttributeChanged { get; }Property Value
PercentageModifiers
Gets the instance of percentage modifiers for the attributes. Percentage modifiers are applied after flat modifiers.
protected virtual AttributeSetInstance PercentageModifiers { get; }Property Value
TotalAttributePoints
Gets the total number of attribute points, including both available and spent points.
public int TotalAttributePoints { get; }Property Value
- int
UseBaseAttributesFromClass
Gets or sets whether to use base attributes from the entity's class. If true, base attributes are derived from the EntityClass. If false, fixed base attributes defined in this component are used.
public bool UseBaseAttributesFromClass { get; set; }Property Value
- bool
Methods
AddFlatModifier(Attribute, long)
Adds a flat modifier to an attribute.
public void AddFlatModifier(Attribute attribute, long value)Parameters
- attributeAttribute
- The attribute to modify. 
- valuelong
- The flat value to add. 
AddPercentageModifier(Attribute, Percentage)
Adds a percentage modifier to an attribute.
public void AddPercentageModifier(Attribute attribute, Percentage value)Parameters
- attributeAttribute
- The attribute to modify. 
- valuePercentage
- The percentage value to add. 
Get(Attribute)
Gets the final calculated value of a specific attribute. The final value includes base value, flat and percentage modifiers, and spent attribute points. The result is clamped to the attribute's min/max values.
public long Get(Attribute attribute)Parameters
- attributeAttribute
- The attribute to retrieve. 
Returns
- long
- The final value of the attribute if the component is enabled (clamped to min/max values); otherwise, 0 
GetAllSpentPoints()
Gets a dictionary containing the number of attribute points spent on each attribute.
public Dictionary<Attribute, int> GetAllSpentPoints()Returns
- Dictionary<Attribute, int>
- A dictionary where keys are attributes and values are the points spent on each attribute. 
GetBase(Attribute)
Gets the base value of an attribute at the entity's current level. Base attributes don't consider flat or percentage modifiers, nor spent attribute points.
public long GetBase(Attribute attribute)Parameters
- attributeAttribute
- The attribute to retrieve the base value for. 
Returns
- long
- The base value of the attribute (clamped to its min/max values) if enabled; otherwise, 0 
GetSpentOn(Attribute)
Gets the number of attribute points spent on a specific attribute.
public int GetSpentOn(Attribute attribute)Parameters
- attributeAttribute
- The attribute to check. 
Returns
- int
- The number of points spent on the attribute. 
RefundAllSpentPoints()
Refunds all spent attribute points, making them available to spend again.
public void RefundAllSpentPoints()RefundPointsForAttribute(Attribute)
Refunds all spent attribute points for a specific attribute, making them available to spend again.
public void RefundPointsForAttribute(Attribute attribute)Parameters
- attributeAttribute
- The attribute to refund points for. 
SetFixed(Attribute, long)
Sets a fixed base value for a specific attribute. This is only applicable when UseBaseAttributesFromClass is false.
public void SetFixed(Attribute attribute, long value)Parameters
- attributeAttribute
- The attribute to set. 
- valuelong
- The fixed base value to assign. 
SpendOn(Attribute, int)
Spends a certain amount of attribute points on a specific attribute.
public void SpendOn(Attribute attribute, int amount)Parameters
- attributeAttribute
- The attribute to increase. 
- amountint
- The number of points to spend.