using System; using UnityEngine; using UnityEngine.Events; public class ReloadTigger : MonoBehaviour { public UnityEvent reloadDoneEvent; public UnityEvent outOfAmmoEvent; private void Start() { CharacterStatModifiers componentInParent = GetComponentInParent(); componentInParent.OnReloadDoneAction = (Action)Delegate.Combine(componentInParent.OnReloadDoneAction, new Action(OnReloadDone)); CharacterStatModifiers componentInParent2 = GetComponentInParent(); componentInParent2.OutOfAmmpAction = (Action)Delegate.Combine(componentInParent2.OutOfAmmpAction, new Action(OnOutOfAmmo)); } private void OnDestroy() { CharacterStatModifiers componentInParent = GetComponentInParent(); componentInParent.OnReloadDoneAction = (Action)Delegate.Remove(componentInParent.OnReloadDoneAction, new Action(OnReloadDone)); CharacterStatModifiers componentInParent2 = GetComponentInParent(); componentInParent2.OutOfAmmpAction = (Action)Delegate.Remove(componentInParent2.OutOfAmmpAction, new Action(OnOutOfAmmo)); } private void OnReloadDone(int bulletsReloaded) { reloadDoneEvent.Invoke(); } private void OnOutOfAmmo(int bulletsReloaded) { outOfAmmoEvent.Invoke(); } private void Update() { } }