using System; using System.Collections.Generic; using NodeCanvas.Framework; using UnityEngine; using UnityEngine.UI; namespace Reset.Items{ public abstract class WeaponActor : MonoBehaviour{ public Dictionary weaponEvents = new Dictionary(); public Dictionary weaponVariables = new Dictionary(); public Weapon relatedWeapon; public GraphOwner relatedGraph; public GameObject relatedObject; // Recieve Weapon Catch signal from Animation public void WeaponCatch(){ relatedGraph.SendEvent("Weapon Catch"); } // Recieve Weapon Release signal from Animation public void WeaponRelease(){ relatedGraph.SendEvent("Weapon Release"); } public void RegisterWeaponEvent(string calledName, Action action){ weaponEvents.Add(calledName, action); } public void RegisterWeaponVariable(string variable, object value){ if (weaponVariables.ContainsKey(variable)) { weaponVariables[variable] = value; } else { weaponVariables.Add(variable, value); } } public object ReadWeaponVariable(string variable) where T : class{ return (T)weaponVariables[variable]; } public void DoWeaponEvent(string eventName){ if (weaponEvents.ContainsKey(eventName)) { weaponEvents[eventName].Invoke(); return; } Debug.LogError($"There is no event by name of {eventName} in {name}"); } } }