Пример #1
0
            public ScopeEvents(BaseScope scope)
            {
                this.scope = scope;

                signals = new List <SignalEvent>(100);
                events  = new List <ScopeEvent>(10);
            }
Пример #2
0
        public static void AddOutgoingSignal(BaseScope scope, Type outgoingScopeType, NetworkReader reader)
        {
            // read useless data
            reader.ReadInt32();

            int signalType = reader.ReadInt32();

            MethodInfo method = outgoingScopeType.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public).FirstOrDefault(m => m.Name.GetHashCode() == signalType);

            if (method == null)
            {
                Debug.Log("Could not find method with sigType " + signalType);
            }

            ScopeEvents ev = GetOrCreateScopeEvent(scope);

            SignalEvent sigEvent = ev.AddSignalEvent(method, reader, false);

            reader.SeekZero();

            if (OnSignalEvent != null)
            {
                OnSignalEvent(scope, sigEvent);
            }
        }
Пример #3
0
            public ScopeEvent(Type eventType, BaseScope scope1, BaseScope scope2)
            {
                type = eventType;

                this.scope1 = scope1;
                this.scope2 = scope2;

                receiveTime = DateTime.Now;
            }
Пример #4
0
        public static void AddScopeEvent(BaseScope scope, BaseScope otherScope, ScopeEvent.Type scopeEv)
        {
            ScopeEvents ev = GetOrCreateScopeEvent(scope);

            ScopeEvent scopeEvent = ev.AddScopeEvent(scopeEv, scope, otherScope);

            if (OnScopeEvent != null)
            {
                OnScopeEvent(scope, otherScope, scopeEvent);
            }
        }
Пример #5
0
            public Log(BaseScope scope, ScopeDebugger.SignalEvent sigEv)
            {
                name       = sigEv.method.Name;
                parameters = sigEv.parameters;

                if (sigEv.isOutgoing)
                {
                    color = Color.green;
                }
                else
                {
                    color = Color.cyan;
                }
            }
Пример #6
0
            public Log(BaseScope scope, BaseScope otherScope, ScopeDebugger.ScopeEvent scopeEv)
            {
                name = scopeEv.type.ToString() + " Scope";

                color = Color.white;
                if (scopeEv.type == ScopeDebugger.ScopeEvent.Type.Switch)
                {
                    parameters = new string[] { scope.GetType().Name, otherScope.GetType().Name }
                }
                ;
                else
                {
                    parameters = new string[] { scope.GetType().Name }
                };
            }
        }
Пример #7
0
        public static void AddIncomingSignal(BaseScope scope, NetworkReader reader)
        {
            int signalType = reader.ReadInt32();

            MethodInfo method = scope.GetType().GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public).FirstOrDefault(m => m.Name.GetHashCode() == signalType);

            ScopeEvents ev = GetOrCreateScopeEvent(scope);

            SignalEvent sigEvent = ev.AddSignalEvent(method, reader, false);

            reader.SeekZero();

            if (OnSignalEvent != null)
            {
                OnSignalEvent(scope, sigEvent);
            }
        }
Пример #8
0
        private static ScopeEvents GetOrCreateScopeEvent(BaseScope scope)
        {
            if (scopeEventsList == null)
            {
                scopeEventsList = new List <ScopeEvents>();
            }

            // find event
            int scopeEventIndex = scopeEventsList.FindIndex(s => s.scope == scope);

            // create and add if not found
            if (scopeEventIndex == -1)
            {
                ScopeEvents ev = new ScopeEvents(scope);
                scopeEventsList.Add(ev);
                return(ev);
            }

            return(scopeEventsList[scopeEventIndex]);
        }
Пример #9
0
 public ScopeEvent AddScopeEvent(ScopeEvent.Type eventType, BaseScope scope1, BaseScope scope2)
 {
     events.Add(new ScopeEvent(eventType, scope1, scope2));
     return(events[events.Count - 1]);
 }
Пример #10
0
        void ScopeDebugger_OnScopeEvent(BaseScope scope, BaseScope otherScope, ScopeDebugger.ScopeEvent scopeEvent)
        {
            logs.Add(new Log(scope, otherScope, scopeEvent));

            Repaint();
        }
Пример #11
0
        void ScopeDebugger_OnSignalEvent(BaseScope scope, ScopeDebugger.SignalEvent signalEvent)
        {
            logs.Add(new Log(scope, signalEvent));

            Repaint();
        }