Exemple #1
0
        public bool Handle()
        {
            PhotonView photonView = PhotonView.Find(viewID);

            if (photonView == null)
            {
                return(true);
            }
            if ((photonView.Group != 0) && !PhotonNetwork.networkingPeer.allowedReceivingGroups.Contains(photonView.Group))
            {
                return(true);
            }
            System.Type[] callParameterTypes = new System.Type[0];
            if (parameters.Length > 0)
            {
                callParameterTypes = new System.Type[parameters.Length];
                int index = 0;
                for (int i = 0; i < parameters.Length; i++)
                {
                    object obj2 = parameters[i];
                    if (obj2 == null)
                    {
                        callParameterTypes[index] = null;
                    }
                    else
                    {
                        callParameterTypes[index] = obj2.GetType();
                    }
                    index++;
                }
            }
            int num7 = 0;
            int num8 = 0;

            foreach (MonoBehaviour behaviour in photonView.GetComponents <MonoBehaviour>())
            {
                if (behaviour == null)
                {
                    Debug.LogError("ERROR You have missing MonoBehaviours on your gameobjects!");
                }
                else
                {
                    System.Type       key  = behaviour.GetType();
                    List <MethodInfo> list = null;
                    if (PhotonNetwork.networkingPeer.monoRPCMethodsCache.ContainsKey(key))
                    {
                        list = PhotonNetwork.networkingPeer.monoRPCMethodsCache[key];
                    }
                    if (list == null)
                    {
                        List <MethodInfo> methods = SupportClass.GetMethods(key, typeof(UnityEngine.RPC));
                        PhotonNetwork.networkingPeer.monoRPCMethodsCache[key] = methods;
                        list = methods;
                    }
                    if (list != null)
                    {
                        for (int j = 0; j < list.Count; j++)
                        {
                            MethodInfo info = list[j];
                            if (info.Name == name)
                            {
                                num8++;
                                ParameterInfo[] methodParameters = info.GetParameters();
                                if (methodParameters.Length == callParameterTypes.Length)
                                {
                                    if (PhotonNetwork.networkingPeer.CheckTypeMatch(methodParameters, callParameterTypes))
                                    {
                                        num7++;
                                        object obj3 = info.Invoke(behaviour, parameters);
                                        if (info.ReturnType == typeof(IEnumerator))
                                        {
                                            behaviour.StartCoroutine((IEnumerator)obj3);
                                        }
                                    }
                                    return(true);
                                }
                                else if ((methodParameters.Length - 1) == callParameterTypes.Length)
                                {
                                    if (PhotonNetwork.networkingPeer.CheckTypeMatch(methodParameters, callParameterTypes) && (methodParameters[methodParameters.Length - 1].ParameterType == typeof(PhotonMessageInfo)))
                                    {
                                        num7++;
                                        object[] array = new object[parameters.Length + 1];
                                        parameters.CopyTo(array, 0);
                                        array[array.Length - 1] = new PhotonMessageInfo(sender, sTime, photonView);
                                        object obj4 = info.Invoke(behaviour, array);
                                        if (info.ReturnType == typeof(IEnumerator))
                                        {
                                            behaviour.StartCoroutine((IEnumerator)obj4);
                                        }
                                    }
                                    return(true);
                                }
                                else if ((methodParameters.Length == 1) && methodParameters[0].ParameterType.IsArray)
                                {
                                    num7++;
                                    object[] objArray5 = new object[] { parameters };
                                    object   obj5      = info.Invoke(behaviour, objArray5);
                                    if (info.ReturnType == typeof(IEnumerator))
                                    {
                                        behaviour.StartCoroutine((IEnumerator)obj5);
                                    }
                                    return(true);
                                }
                                return(false);
                            }
                            //Log.AddLineRaw("Unknown RPC: " + name + " by ID " + sender.ID);
                        }
                    }
                }
            }
            return(true);
        }