Table of Contents

Class SoSetScalingComponentBase<SetType, KeyType>

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

Abstract base class for scaling components that work with ScriptableObject-based sets.

public abstract class SoSetScalingComponentBase<SetType, KeyType> : ScalingComponentSO, ITaggable, IValueProvider<KeyType, double> where SetType : ScriptableObject

Type Parameters

SetType

The type of ScriptableObject set that contains the items used for defining the scaling value

KeyType

The type of items within the set that can be used to calculate the scaling value

Inheritance
object
SoSetScalingComponentBase<SetType, KeyType>
Implements
IValueProvider<KeyType, double>
Derived
Inherited Members

Fields

_set

[SerializeField]
protected SetType _set

Field Value

SetType

Properties

Set

The base set used for scaling calculations.

public SetType Set { get; }

Property Value

SetType

Methods

CalculateValue(EntityCore)

Calculates the final scaled value based on the entity's values and the configured scaling multipliers.

public override long CalculateValue(EntityCore entity)

Parameters

entity EntityCore

The entity to calculate the scaled value for

Returns

long

The calculated scaled value as a long integer

CalculateValueAt(EntityCore, int)

Calculates the final scaled value as it would be computed at the specified entity level. Allows consumers to snapshot scaled values at a level other than the entity's current one, which is useful for propagating per-level change events without mutating cached state.

public virtual long CalculateValueAt(EntityCore entity, int level)

Parameters

entity EntityCore

The entity to calculate the scaled value for

level int

The level at which to evaluate the scaling

Returns

long

The calculated scaled value as a long integer

Get(KeyType)

Gets the value associated with the specified key.

public virtual double Get(KeyType key)

Parameters

key KeyType

The key used to retrieve the value.

Returns

double

The value associated with the specified key.

GetEntitySet(EntityCore)

Gets the set associated with the specified entity. This method must be implemented by derived classes to define how to retrieve the entity's set.

protected abstract SetType GetEntitySet(EntityCore entity)

Parameters

entity EntityCore

The entity to get the set for

Returns

SetType

The set associated with the entity

GetEntityValue(EntityCore, KeyType)

Gets the current value of a specific key for the given entity. This method must be implemented by derived classes to define how to retrieve entity values.

protected abstract long GetEntityValue(EntityCore entity, KeyType key)

Parameters

entity EntityCore

The entity to get the value from

key KeyType

The specific key to get the value for

Returns

long

The current value of the specified key for the entity

GetEntityValueAt(EntityCore, KeyType, int)

Gets the value of a specific key at the given level. Defaults to the current value. Derived classes can override to return a value computed against a specific level, which is useful when producing per-level snapshots without touching runtime caches.

protected virtual long GetEntityValueAt(EntityCore entity, KeyType key, int level)

Parameters

entity EntityCore

The entity to get the value from

key KeyType

The specific key to get the value for

level int

The level at which to evaluate the value

Returns

long

The value of the specified key for the entity at the given level

GetSetItems()

Gets all items from the current set that can be used for scaling. This method must be implemented by derived classes to define which items are available for scaling.

protected abstract IEnumerable<KeyType> GetSetItems()

Returns

IEnumerable<KeyType>

An enumerable collection of all scalable items in the set

OnValidate()

Validates and refreshes the scaling attribute values based on the current set. Called automatically when the component is validated in the editor.

protected virtual void OnValidate()

ValidateEntitySet(EntityCore)

Validates that the entity's set is compatible with this scaling component's set. By default, requires exact equality. Derived classes can override for different validation logic. If the entity's set is null, logs a warning and skips validation.

protected virtual void ValidateEntitySet(EntityCore entity)

Parameters

entity EntityCore

The entity to validate

Events

OnValidated

Event invoked when this scaling component is validated in the editor (or when runtime mutations call OnValidate()). Consumers subscribe to rebuild caches or dependent indices without scanning every scaling SO on every access.

public event Action OnValidated

Event Type

Action