Пример #1
0
        public static bool TryRemoveGlobal(object obj)
        {
            var reciever = obj as IRecieve;

            if (reciever == null)
            {
                return(false);
            }
            var hasLocals = false;
            var all       = obj.GetType().GetInterfaces();

            foreach (var intType in all)
            {
                if (intType.IsGenericType && intType.GetGenericTypeDefinition() == typeof(IReceive <>))
                {
                    Default.Remove(reciever, intType.GetGenericArguments()[0]);
                }
                else if (!hasLocals && intType.IsGenericType &&
                         intType.GetGenericTypeDefinition() == typeof(IReceiveLocal <>))
                {
                    hasLocals = true;
                }
            }

            return(hasLocals);
        }
Пример #2
0
        public virtual void OnDisable()
        {
            if (Toolbox.isQuittingOrChangingScene() || !state.enabled)
            {
                return;
            }

            state.enabled = false;


            if (ProcessingSignals.TryRemoveGlobal(this))
            {
                signals?.Remove(this);
            }


            ProcessingUpdate.Default.Remove(this);

            HandleDisable();
        }
        public void Remove(object obj)
        {
            var reciever = obj as IRecieve;

            if (reciever == null)
            {
                return;
            }
            var all = obj.GetType().GetInterfaces();

            foreach (Type intType in all)
            {
                if (intType.IsGenericType && intType.GetGenericTypeDefinition() == typeof(IReceiveGlobal <>))
                {
                    Default.Remove(reciever, intType.GetGenericArguments()[0]);
                }
                else if (intType.IsGenericType && intType.GetGenericTypeDefinition() == typeof(IReceive <>))
                {
                    Remove(reciever, intType.GetGenericArguments()[0]);
                }
            }
        }
Пример #4
0
 public void SignalRemove <T>(IRecieve recieve)
 {
     signals.Remove <T>(recieve);
 }