Illegal
How do I use Illegal
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: NetworkingPeer.cs
Copy
2835 internal void RPC(PhotonView view, string methodName, PhotonPlayer player, bool encrypt, params object[] parameters)
2836 {
2837 if (this.blockSendingGroups.Contains(view.group))
2838 {
2839 return; // Block sending on this group
2840 }
2841
2842 if (view.viewID < 1) //TODO: check why 0 should be illegal
2843 {
2844 Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name);
2845 }
2846
2847 if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
2848 {
2849 Debug.Log("Sending RPC \"" + methodName + "\" to player[" + player + "]");
2850 }
2851
2852
2853 //ts: changed RPCs to a one-level hashtable as described in internal.txt
2854 Hashtable rpcEvent = new Hashtable();
2855 rpcEvent[(byte)0] = (int)view.viewID; // LIMITS PHOTONVIEWS&PLAYERS
2856 if (view.prefix > 0)
2857 {
2858 rpcEvent[(byte)1] = (short)view.prefix;
2859 }
2860 rpcEvent[(byte)2] = this.ServerTimeInMilliSeconds;
2861
2862 // send name or shortcut (if available)
2863 int shortcut = 0;
2864 if (rpcShortcuts.TryGetValue(methodName, out shortcut))
2865 {
2866 rpcEvent[(byte)5] = (byte)shortcut; // LIMITS RPC COUNT
2867 }
2868 else
2869 {
2870 rpcEvent[(byte)3] = methodName;
2871 }
2872
2873 if (parameters != null && parameters.Length > 0)
2874 {
2875 rpcEvent[(byte) 4] = (object[]) parameters;
2876 }
2877
2878 if (this.mLocalActor == player)
2879 {
2880 this.ExecuteRPC(rpcEvent, player);
2881 }
2882 else
2883 {
2884 RaiseEventOptions options = new RaiseEventOptions() { TargetActors = new int[] { player.ID }, Encrypt = encrypt };
2885 this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
2886 }
2887 }
File name: NetworkingPeer.cs
Copy
2890 /// (byte)0 -> (int) ViewId (combined from actorNr and actor-unique-id)
2891 /// (byte)1 -> (short) prefix (level)
2895 /// (byte)5 -> (byte) method shortcut (alternative to name)
2899 internal void RPC(PhotonView view, string methodName, PhotonTargets target, bool encrypt, params object[] parameters)
2900 {
2901 if (this.blockSendingGroups.Contains(view.group))
2902 {
2903 return; // Block sending on this group
2904 }
2905
2906 if (view.viewID < 1)
2907 {
2908 Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name);
2909 }
2910
2911 if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
2912 Debug.Log("Sending RPC \"" + methodName + "\" to " + target);
2913
2914
2915 //ts: changed RPCs to a one-level hashtable as described in internal.txt
2916 Hashtable rpcEvent = new Hashtable();
2917 rpcEvent[(byte)0] = (int)view.viewID; // LIMITS NETWORKVIEWS&PLAYERS
2918 if (view.prefix > 0)
2919 {
2920 rpcEvent[(byte)1] = (short)view.prefix;
2921 }
2922 rpcEvent[(byte)2] = this.ServerTimeInMilliSeconds;
2923
2924
2925 // send name or shortcut (if available)
2926 int shortcut = 0;
2927 if (rpcShortcuts.TryGetValue(methodName, out shortcut))
2928 {
2929 rpcEvent[(byte)5] = (byte)shortcut; // LIMITS RPC COUNT
2930 }
2931 else
2932 {
2933 rpcEvent[(byte)3] = methodName;
2934 }
2935
2936 if (parameters != null && parameters.Length > 0)
2937 {
2938 rpcEvent[(byte)4] = (object[])parameters;
2939 }
2940
2941 // Check scoping
2942 if (target == PhotonTargets.All)
2943 {
2944 RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Encrypt = encrypt };
2945 this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
2946
2947 // Execute local
2948 this.ExecuteRPC(rpcEvent, this.mLocalActor);
2949 }
2950 else if (target == PhotonTargets.Others)
2951 {
2952 RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Encrypt = encrypt };
2953 this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
2954 }
2955 else if (target == PhotonTargets.AllBuffered)
2956 {
2957 RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache, Encrypt = encrypt };
2958 this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
2959
2960 // Execute local
2961 this.ExecuteRPC(rpcEvent, this.mLocalActor);
2962 }
2963 else if (target == PhotonTargets.OthersBuffered)
2964 {
2965 RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache, Encrypt = encrypt };
2966 this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
2967 }
2968 else if (target == PhotonTargets.MasterClient)
2969 {
2970 if (this.mMasterClient == this.mLocalActor)
2971 {
2972 this.ExecuteRPC(rpcEvent, this.mLocalActor);
2973 }
2974 else
2975 {
2976 RaiseEventOptions options = new RaiseEventOptions() { Receivers = ReceiverGroup.MasterClient, Encrypt = encrypt };
2977 this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
2978 }
2979 }
2980 else if (target == PhotonTargets.AllViaServer)
2981 {
2982 RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Receivers = ReceiverGroup.All, Encrypt = encrypt };
2983 this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
2984 if (PhotonNetwork.offlineMode)
2985 {
2986 this.ExecuteRPC(rpcEvent, this.mLocalActor);
2987 }
2988 }
2989 else if (target == PhotonTargets.AllBufferedViaServer)
2990 {
2991 RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Receivers = ReceiverGroup.All, CachingOption = EventCaching.AddToRoomCache, Encrypt = encrypt };
2992 this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
2993 if (PhotonNetwork.offlineMode)
2994 {
2995 this.ExecuteRPC(rpcEvent, this.mLocalActor);
2996 }
2997 }
2998 else
2999 {
3000 Debug.LogError("Unsupported target enum: " + target);
3001 }
3002 }
File name: NetworkingPeer.cs
Copy
3005 public void SetReceivingEnabled(int group, bool enabled)
3006 {
3007 if (group <= 0)
3008 {
3009 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled was called with an illegal group number: " + group + ". The group number should be at least 1.");
3010 return;
3011 }
3012
3013 if (enabled)
3014 {
3015 if (!this.allowedReceivingGroups.Contains(group))
3016 {
3017 this.allowedReceivingGroups.Add(group);
3018 byte[] groups = new byte[1] { (byte)group };
3019 this.OpChangeGroups(null, groups);
3020 }
3021 }
3022 else
3023 {
3024 if (this.allowedReceivingGroups.Contains(group))
3025 {
3026 this.allowedReceivingGroups.Remove(group);
3027 byte[] groups = new byte[1] { (byte)group };
3028 this.OpChangeGroups(groups, null);
3029 }
3030 }
3031 }
File name: NetworkingPeer.cs
Copy
3034 public void SetReceivingEnabled(int[] enableGroups, int[] disableGroups)
3035 {
3036 List
3037 List
3038
3039 if (enableGroups != null)
3040 {
3041 for (int index = 0; index < enableGroups.Length; index++)
3042 {
3043 int i = enableGroups[index];
3044 if (i <= 0)
3045 {
3046 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled was called with an illegal group number: " + i + ". The group number should be at least 1.");
3047 continue;
3048 }
3049 if (!this.allowedReceivingGroups.Contains(i))
3050 {
3051 this.allowedReceivingGroups.Add(i);
3052 enableList.Add((byte)i);
3053 }
3054 }
3055 }
3056 if (disableGroups != null)
3057 {
3058 for (int index = 0; index < disableGroups.Length; index++)
3059 {
3060 int i = disableGroups[index];
3061 if (i <= 0)
3062 {
3063 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled was called with an illegal group number: " + i + ". The group number should be at least 1.");
3064 continue;
3065 }
3066 if (enableList.Contains((byte)i))
3067 {
3068 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled disableGroups contains a group that is also in the enableGroups: " + i + ".");
3069 continue;
3070 }
3071 if (this.allowedReceivingGroups.Contains(i))
3072 {
3073 this.allowedReceivingGroups.Remove(i);
3074 disableList.Add((byte)i);
3075 }
3076 }
3077 }
3078
3079 this.OpChangeGroups(disableList.Count > 0 ? disableList.ToArray() : null, enableList.Count > 0 ? enableList.ToArray() : null); //Passing a 0 sized array != passing null
3080 }
Illegal 104 lượt xem
Gõ tìm kiếm nhanh...