Table of Contents

Class StatSetInstance

Namespace
ElectricDrill.AstraRpgFramework.Stats
Assembly
com.electricdrill.astra-rpg-framework.Runtime.dll

Represents an instance of a StatSet with actual values for each stat. Implements IEnumerable and IStatContainer to provide collection functionality.

public class StatSetInstance : IValueContainer<StatSO>
Inheritance
object
StatSetInstance
Implements

Constructors

StatSetInstance(StatSetSO)

Initializes a new StatSetInstance based on the provided StatSet. All stats from the StatSet are initialized with a value of 0.

public StatSetInstance(StatSetSO statSet)

Parameters

statSet StatSetSO

The StatSet to base this instance on.

Properties

this[StatSO]

Gets or sets the value of the specified stat using indexer syntax.

public long this[StatSO stat] { get; set; }

Parameters

stat StatSO

The stat to get or set.

Property Value

long

The current value of the stat.

Methods

AddValue(StatSO, long)

Adds value to the specified stat. If the stat doesn't exist, it will be created with the specified value. Use negative values to subtract from the stat.

public void AddValue(StatSO stat, long value)

Parameters

stat StatSO

The stat to modify.

value long

The value to add (can be negative).

Clone()

Creates a deep copy of this StatSetInstance.

public StatSetInstance Clone()

Returns

StatSetInstance

A new StatSetInstance with the same stats and values.

Contains(StatSO)

Determines whether this instance contains the specified stat.

public bool Contains(StatSO stat)

Parameters

stat StatSO

The stat to check for.

Returns

bool

true if the instance contains the stat; otherwise, false.

Get(StatSO)

Gets the current value of the specified stat.

public long Get(StatSO stat)

Parameters

stat StatSO

The stat to retrieve.

Returns

long

The current value of the stat.

GetAsPercentage(StatSO)

Gets the value of the specified stat as a Percentage.

public Percentage GetAsPercentage(StatSO stat)

Parameters

stat StatSO

The stat to get as a percentage.

Returns

Percentage

The stat value wrapped in a Percentage object.

GetEnumerator()

Struct-typed enumerator so foreach resolves to the underlying dictionary's struct enumerator without boxing. The System.Collections.Generic.IEnumerable<T> implementations below are preserved for LINQ/interface consumers and remain boxing for those paths.

public Dictionary<StatSO, long>.Enumerator GetEnumerator()

Returns

Dictionary<StatSO, long>.Enumerator

TryGet(StatSO, out long)

Tries to get the current value of the specified stat.

public bool TryGet(StatSO stat, out long value)

Parameters

stat StatSO

The stat to query.

value long

The stat value if present; otherwise, 0.

Returns

bool

True if the stat exists in this instance; otherwise, false.

Operators

operator +(StatSetInstance, StatSetInstance)

Adds the values of corresponding stats from two StatSetInstances. All stats present in the first instance must also be present in the second instance.

public static StatSetInstance operator +(StatSetInstance a, StatSetInstance b)

Parameters

a StatSetInstance

The first StatSetInstance.

b StatSetInstance

The second StatSetInstance.

Returns

StatSetInstance

A new StatSetInstance with the sum of corresponding stat values.

Exceptions

KeyNotFoundException

Thrown when a stat from instance 'a' is not found in instance 'b'.