/// <summary> /// Adding a delegate for reacting to noise from current entity when the delegate is called /// </summary> /// <param name="method">Delegate</param> public void AddHearer(HearDelegate method) { if (!HearContains(method)) { _hearingDelegates += method; } }
/// <summary> /// Removing a delegate for reacting to noise from current entity when the delegate is called /// </summary> /// <param name="method"></param> public void RemoveHearer(HearDelegate method) { if (HearContains(method)) { _hearingDelegates -= method; } }
/// <summary> /// Shows whether given method contains in _hearingDelegates delegates /// </summary> /// <param name="method"></param> private bool HearContains(HearDelegate method) { if (_hearingDelegates != null) { System.Delegate[] list = _hearingDelegates.GetInvocationList(); foreach (System.Delegate deleg in list) { if ((System.Delegate)method == deleg) { return(true); } } return(false); } return(false); }