Table of Contents

Class ScalingFormulaInstance

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

A per-entity runtime wrapper around a shared ScalingFormula asset.

Because ScalingFormula is a ScriptableObject, it is shared across all entities that reference it. Mutating temporary scaling components directly on the asset would therefore affect every entity that uses it. ScalingFormulaInstance solves this by keeping its own temporary component lists while delegating all computation to the underlying asset.

Each entity that needs per-entity runtime modifications (e.g. a buff that adds an extra scaling term) should create its own ScalingFormulaInstance from the shared ScalingFormula asset.

public class ScalingFormulaInstance : IScalingFormula
Inheritance
object
ScalingFormulaInstance
Implements

Examples

// At ability / buff initialisation:
var instance = new ScalingFormulaInstance(myScalingFormulaAsset);

// When a buff is applied to this specific entity:
instance.TmpSelfScalingComponents.Add(armorScalingComponent);

// When the buff expires:
instance.TmpSelfScalingComponents.Remove(armorScalingComponent);
// – or reset all temporaries at once:
instance.ResetTmpScalings();

Constructors

ScalingFormulaInstance(ScalingFormula)

public ScalingFormulaInstance(ScalingFormula formula)

Parameters

formula ScalingFormula

The shared ScalingFormula asset this instance wraps.

Properties

TmpSelfScalingComponents

Per-entity temporary scaling components applied to the "self" entity.

public List<ScalingComponent> TmpSelfScalingComponents { get; }

Property Value

List<ScalingComponent>

TmpTargetScalingComponents

Per-entity temporary scaling components applied to the "target" entity.

public List<ScalingComponent> TmpTargetScalingComponents { get; }

Property Value

List<ScalingComponent>

Methods

CalculateValue(EntityCore)

Calculates the final value using only the "self" entity. Assumes the formula has no target-scaling components and uses a fixed base value.

public long CalculateValue(EntityCore self)

Parameters

self EntityCore

Returns

long

CalculateValue(EntityCore, EntityCore)

Calculates the final value using both "self" and "target" entities. Assumes the formula uses a fixed base value.

public long CalculateValue(EntityCore self, EntityCore target)

Parameters

self EntityCore
target EntityCore

Returns

long

CalculateValue(EntityCore, EntityCore, int)

Calculates the final value using both "self" and "target" entities and a specific level for the base value. Assumes the formula uses a growth-based base value.

public long CalculateValue(EntityCore self, EntityCore target, int level)

Parameters

self EntityCore
target EntityCore
level int

Returns

long

CalculateValue(EntityCore, int)

Calculates the final value using only the "self" entity and a specific level for the base value. Assumes the formula has no target-scaling components and uses a growth-based base value.

public long CalculateValue(EntityCore self, int level)

Parameters

self EntityCore
level int

Returns

long

ResetTmpScalings()

Clears all per-entity temporary scaling components for both "self" and "target".

public void ResetTmpScalings()