CustomEffect
Abstract Scriptable Object
Description
Custom Effects are a way to add additional functionality to each StatusEffectData. Truthfully anything can be done with them as they are just an inheritable abstract class with a coroutine, allowing for unlimited functionality. It is highly recommended to take a look at the samples for an idea of how to use them.
Abstract Methods
Effect
A Coroutine that is started when the StatusEffect begins.
EffectEnd
A method that is invoked when the StatusEffect is stopped.
Example
using System.Collections;
using UnityEngine;
// Use StatusEffects.Custom namespace for organization.
namespace StatusEffects.Custom
{
// Setup scriptable object in create menu.
[CreateAssetMenu(fileName = "Poison Effect", menuName = "Custom Effects/Poison", order = 1)]
public class PoisonEffect : CustomEffect
{
// Unique value for this effect example
public float intervalSeconds = 1f;
public override IEnumerator Effect<T>(T monoBehaviour, StatusEffect statusEffect)
{
// Use your own character/entity class for this
Entity entity = monoBehaviour.GetComponent<Entity>();
for (; ; )
{
// Use your own TakeDamage() logic. This will
// occur every interval until the effect ends.
entity.TakeDamage(statusEffect.data.baseValue);
yield return new WaitForSeconds(intervalSeconds);
}
}
public override void EffectEnd<T>(T monoBehaviour, StatusEffect statusEffect) { }
}
}
Last updated