using System; using System.Collections.Generic; using UnityEngine; namespace BitStrap { public class SafeAction { private List actions = new List(); public void Register(Action a) { if (!actions.Contains(a)) { actions.Add(a); } } public void Unregister(Action a) { actions.Remove(a); } public void Call() { for (int i = 0; i < actions.Count; i++) { try { if (actions[i] != null) { actions[i](); } } catch (Exception exception) { Debug.LogException(exception); } } } } public class SafeAction { private List> actions = new List>(); public void Register(Action a) { if (!actions.Contains(a)) { actions.Add(a); } } public void Unregister(Action a) { actions.Remove(a); } public void Call(T p1) { for (int i = 0; i < actions.Count; i++) { try { if (actions[i] != null) { actions[i](p1); } } catch (Exception exception) { Debug.LogException(exception); } } } } public class SafeAction { private List> actions = new List>(); public void Register(Action a) { if (!actions.Contains(a)) { actions.Add(a); } } public void Unregister(Action a) { actions.Remove(a); } public void Call(T1 p1, T2 p2) { for (int i = 0; i < actions.Count; i++) { try { if (actions[i] != null) { actions[i](p1, p2); } } catch (Exception exception) { Debug.LogException(exception); } } } } }