示例#1
0
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
            //var actorId = ctx.GetArgument<PhotonPlayer>(0); // ?
            var actorId = ctx.GetArgument <Photon.Realtime.Player>(0); // ?

            return(ctx.Source?.Equals(actorId) ?? false);
        }
示例#2
0
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
            int id      = ctx.GetArgument <int>(0);
            int actorID = ctx.GetArgument <int>(1);

            return(true);
        }
示例#3
0
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
//TODO: Validate this should happen.
            InstanceTracker.NewInstance();

            return(true);
        }
示例#4
0
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
            Vector3    point      = ctx.GetArgument <Vector3>(0);
            Quaternion quaternion = ctx.GetArgument <Quaternion>(1);

            return(true);
        }
示例#5
0
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
            var src     = ctx.Source;
            var actorId = ctx.GetArgument <int>(0);

            return((src == null || src.IsMasterClient) && actorId == 999 ||
                   src?.ActorNumber == actorId);
        }
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
            int    amount           = ctx.GetArgument <int>(0);
            string argumentTypeName = ctx.GetArgument <string>(1);

            Enum.TryParse <EvidenceTypeEnum>(argumentTypeName.Replace(' ', '_'), out var evidenceType);

            return(true);
        }
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
            var ghost = PhasmaticMod.GhostAI;

            if (ghost == null)
            {
                return(false);
            }

            return(ctx.Source?.IsMasterClient ?? true);
        }
示例#8
0
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
            //if (!PhasmaticMod.GameController.allPlayersAreConnected) return false;
            if (!PhasmaticMod.GameController.दतऩटऩणणचझढत)
            {
                return(false);
            }

            var ghost = PhasmaticMod.GhostAI;

            if (ghost != null)
            {
                return(false);
            }

            return(ctx.Source?.IsMasterClient ?? true);
        }
示例#9
0
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
            bool isOn = ctx.GetArgument <bool>(0);

            return(true);
        }
示例#10
0
 protected override bool ValidateInternal(ref RpcExecutionContext ctx)
 => ctx.Source?.IsMasterClient ?? true;
 protected override bool ValidateInternal(ref RpcExecutionContext ctx)
 {
     return(true);
 }
示例#12
0
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
            float timer = ctx.GetArgument <float>(0);

            return(true);
        }
示例#13
0
        protected override bool ValidateInternal(ref RpcExecutionContext ctx)
        {
            int newIndex = ctx.GetArgument <int>(0);

            return(true);
        }
示例#14
0
        public static bool PrefixExecuteRpc(object __instance,
                                            ref Hashtable rpcData,
                                            ref int senderID,
                                            ref object ___keyByteZero,
                                            ref object ___keyByteThree,
                                            ref object ___keyByteFour,
                                            ref object ___keyByteFive)
        {
            Photon.Realtime.Player?sender = null;
            try {
                sender = PhotonNetwork.CurrentRoom.GetPlayer(senderID);
            }
            catch {
                // can't find sender
            }

            var viewId = (int)rpcData[___keyByteZero];

            PhotonView?view = null;

            try {
                view = PhotonView.Find(viewId);
            }
            catch {
                // can't find view
            }

            var viewDesc = view == null
        ? "Invalid View #{viewId}"
        : $"{view.gameObject.name} #{viewId} (owned by {view.OwnerActorNr})";

            var senderDesc = $"{sender?.NickName ?? "Invalid Player"} #{senderID} STEAM:{sender?.UserId}";

            string rpcName;

            if (!rpcData.ContainsKey(___keyByteFive))
            {
                rpcName = (string)rpcData[___keyByteThree];
            }
            else
            {
                int rpcIndex = (byte)rpcData[___keyByteFive];
                if (rpcIndex > PhotonNetwork.PhotonServerSettings.RpcList.Count - 1)
                {
                    Instance.LogError($"Invalid RPC #{rpcIndex} from {senderDesc} on {viewDesc}");
                    return(true);
                }

                rpcName = PhotonNetwork.PhotonServerSettings.RpcList[rpcIndex];
            }

            var rpcArgs = (object[])rpcData[___keyByteFour];

            var rpcArgsDesc = string.Join(", ", rpcArgs.Select(a => a.ToString()));

            Instance.Log($"Photon RPC {rpcName} from {senderDesc}: {rpcArgsDesc}");

            MethodInfo?method = null;

            if (view != null)
            {
                var rpcMonoBehaviors = PhotonViewRpcMonoBehaviorsGetter(view);
                if (!PhotonNetwork.UseRpcMonoBehaviourCache && rpcMonoBehaviors == null)
                {
                    view.RefreshRpcMonoBehaviourCache();
                    rpcMonoBehaviors = PhotonViewRpcMonoBehaviorsGetter(view);
                }

                foreach (var behavior in rpcMonoBehaviors)
                {
                    var type = behavior.GetType();
                    method = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                             .FirstOrDefault(mi => mi.Name == rpcName && mi.GetCustomAttribute <PunRPC>() != null);
                }
            }

            var context = new RpcExecutionContext(view, sender, rpcName, method, rpcArgs);

            // will probably need to organize by view type then by name later since rpcs can have same names
            if (RpcValidatorsByRpcName.TryGetValue(rpcName, out var validator))
            {
                if (view == null)
                {
                    Instance.LogError($"No View to match against validators");
                    if (validator.View == null)
                    {
                        if (!validator.Validate(ref context))
                        {
                            Instance.LogError($"RPC Validation failed!");
                            // can return false to ignore RPC
                            return(false);
                        }
                    }
                }
                else
                {
                    /*
                     * var comp = view.ObservedComponents
                     * .FirstOrDefault(c => validator.View.IsInstanceOfType(c));
                     * if (comp == null)
                     * Instance.LogError($"No matching component on view for {validator.GetType().Name}");
                     * else {
                     * Instance.LogError($"Matched component on view for {validator.GetType().Name}");
                     * }
                     */

                    if (!validator.Validate(ref context))
                    {
                        Instance.LogError($"RPC Validation failed!");
                        // can return false to ignore RPC
                        return(false);
                    }
                }
            }

            return(true);
        }