Beispiel #1
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);
            }
        }
Beispiel #2
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);
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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]);
        }