Runtime Value SO

This value system is borrowed from some well-known games such as World of Warcraft and Elden's Ring.

SoleValueRuntime

If you need to edit update rules or add rules you can do so in SoleValueRuntime.cs.

SoleValueRuntime.cs
/// <summary>
/// Updates the cached current value.
/// </summary>
private void UpdateCurrentValue()
{
    int baseCurrentValue = mBaseValue + mValueAdd.GetValue();
    int mul = mValuePercentAdd.GetValue() * mValuePercentMul.GetValue();
    mCurrentValue = (baseCurrentValue * mul) / 10000;
}

You can change the value at runtime by using the following four functions. You can also change the relationship between the current value and the maximum value here.

//Direct modification Examples include using props to recover, 
//enemies attacking themselves, skill attacks, etc.
public void ModifyValue(int _modValue, bool _isMaxValue = false)

//Reference modifications, e.g. equipment, special buffs
public ModifyReference ReferenceModifyValue(StatModifyType _modifyType, int _modValue)

//Remove Reference e.g. touching equipment, end of special buffs
public void RemoveModifyReference(ModifyReference _modifyReference)SoleObjectRuntimeValueSO

SoleObjectRuntimeValueSO

This script manages all runtime values.

If you have a lot of enemies, you don't want to create a lot of this ScriptableObject for that purpose. You can use

ScriptableObject.CreateInstance<SoleObjectRuntimeValueSO>();

There are also some APIs provided that may not be common that you can view directly in the code. All are commented.

Last updated