slimecing

a fighting game featuring slimes and swords
Log | Files | Refs | README

Trigger.cs (627B)


      1 using System;
      2 using UnityEngine;
      3 
      4 namespace Slimecing.Triggers
      5 {
      6     public abstract class Trigger : ScriptableObject
      7     {
      8         public TriggerState currentTriggerState { get; set; }
      9         
     10         public event Action<TriggerState> TriggerStateChange;
     11 
     12         public Trigger GetTrigger() => Instantiate(this);
     13         public abstract void EnableTrigger(GameObject target);
     14         public virtual T ReadCurrentValue<T>() => (T) Convert.ChangeType(currentTriggerState, typeof(T));
     15         protected void OnTriggerStateChange(TriggerState state)
     16         {
     17             TriggerStateChange?.Invoke(state);
     18         }
     19     }
     20 }