Class AttributeSetInstance
- Namespace
- ElectricDrill.SoapRpgFramework.Attributes
- Assembly
- com.electricdrill.soap-rpg-framework.Runtime.dll
Represents a runtime instance of an AttributeSet with actual values for each attribute. Provides methods to manipulate and access attribute values during gameplay.
public class AttributeSetInstance : IValueContainer<Attribute>
- Inheritance
-
objectAttributeSetInstance
- Implements
Constructors
AttributeSetInstance(AttributeSet)
Initializes a new instance of AttributeSetInstance based on an AttributeSet. All attributes are initialized with a value of 0.
public AttributeSetInstance(AttributeSet attrSet)
Parameters
attrSetAttributeSetThe AttributeSet to base this instance on
Properties
Attributes
Gets the internal dictionary containing all attribute-value pairs.
public Dictionary<Attribute, long> Attributes { get; }
Property Value
- Dictionary<Attribute, long>
this[Attribute]
Gets or sets the value of an attribute using indexer syntax.
public long this[Attribute attribute] { get; set; }
Parameters
attributeAttributeThe attribute to access
Property Value
- long
The current value when getting, or sets the value when setting
Methods
AddValue(Attribute, long)
Adds a value to the specified attribute. If the attribute doesn't exist, it will be created.
public void AddValue(Attribute attribute, long value)
Parameters
attributeAttributeThe attribute to modify
valuelongThe value to add. Can be negative to decrease the value.
Clone()
Creates a deep copy of this AttributeSetInstance.
public AttributeSetInstance Clone()
Returns
- AttributeSetInstance
A new AttributeSetInstance with the same attribute values
Contains(Attribute)
Checks whether the specified attribute is contained in this instance.
public bool Contains(Attribute stat)
Parameters
statAttributeThe attribute to check for
Returns
- bool
True if the attribute exists, false otherwise
Get(Attribute)
Gets the current value of the specified attribute.
public long Get(Attribute attribute)
Parameters
attributeAttributeThe attribute to retrieve
Returns
- long
The current value of the attribute
GetAsPercentage(Attribute)
Gets the value of an attribute as a percentage.
public Percentage GetAsPercentage(Attribute stat)
Parameters
statAttributeThe attribute to convert to percentage
Returns
- Percentage
A Percentage representation of the attribute value
GetEnumerator()
Returns an enumerator that iterates through the attribute-value pairs.
public IEnumerator<KeyValuePair<Attribute, long>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<Attribute, long>>
An enumerator for the attribute-value pairs
Operators
operator +(AttributeSetInstance, AttributeSetInstance)
Adds two AttributeSetInstance objects together, combining their attribute values.
public static AttributeSetInstance operator +(AttributeSetInstance a, AttributeSetInstance b)
Parameters
aAttributeSetInstanceThe first AttributeSetInstance
bAttributeSetInstanceThe second AttributeSetInstance
Returns
- AttributeSetInstance
A new AttributeSetInstance with combined values
explicit operator AttributeSetInstance(SerializableDictionary<Attribute, long>)
Explicitly converts a SerializableDictionary to an AttributeSetInstance.
public static explicit operator AttributeSetInstance(SerializableDictionary<Attribute, long> dictionary)
Parameters
dictionarySerializableDictionary<Attribute, long>The dictionary to convert
Returns
- AttributeSetInstance
A new AttributeSetInstance based on the dictionary