Skip to main content

PlayerCharacterStats.AddStatModifier

Declaration#

public virtual bool AddStatModifier(GDTKStatModifier modifier, IUniquelyIdentifiable source, StatSource other)

Parameters#

NameDescription
modifierModifier to add to the object
sourceObject adding this Stat Modifier
otherStats associated with the Source, only required if the Source is outside this object and values on that object are referenced by the Stat Modifier.

Description#

Adds a new Stat Modifier to the object.

Usage#

Example
using NullSave.GDTK.Stats;using UnityEngine;
public class Example : MonoBehaviour{
    public void ExampleMethod(PlayerCharacterStats source)    {        // Create a modifier that applies 1 time immediately        // Modifier changes the value of a Stat with the Id        // of 'HP' by adding 2        GDTKStatModifier modifier = new GDTKStatModifier();        modifier.target = ModifierTarget.Value;        modifier.applies = ModifierApplication.Immediately;        modifier.affectsStatId = "HP";        modifier.changeType = ModifierChangeType.Add;        modifier.value.valueExpression = "2";
        source.AddStatModifier(modifier);    }
}