void ProcessClientRpc(HashSet <string> names, MethodDefinition md, CustomAttribute ca)
        {
            if (!RpcProcessor.ProcessMethodsValidateRpc(md, ca))
            {
                return;
            }

            if (names.Contains(md.Name))
            {
                Weaver.Error("Duplicate ClientRpc name [" + netBehaviourSubclass.FullName + ":" + md.Name + "]");
                return;
            }
            names.Add(md.Name);
            clientRpcs.Add(md);

            MethodDefinition rpcCallFunc = RpcProcessor.ProcessRpcCall(netBehaviourSubclass, md, ca);

            MethodDefinition rpcFunc = RpcProcessor.ProcessRpcInvoke(netBehaviourSubclass, md, rpcCallFunc);

            if (rpcFunc != null)
            {
                clientRpcInvocationFuncs.Add(rpcFunc);
            }

            if (rpcCallFunc != null)
            {
                clientRpcCallFuncs.Add(rpcCallFunc);
            }
        }
        void ProcessClientRpc(HashSet <string> names, MethodDefinition md, CustomAttribute clientRpcAttr)
        {
            if (md.IsAbstract)
            {
                Weaver.Error("Abstract ClientRpc are currently not supported, use virtual method instead", md);
                return;
            }

            if (!RpcProcessor.ProcessMethodsValidateRpc(md))
            {
                return;
            }

            if (names.Contains(md.Name))
            {
                Weaver.Error($"Duplicate ClientRpc name {md.Name}", md);
                return;
            }
            names.Add(md.Name);
            clientRpcs.Add(md);

            MethodDefinition rpcCallFunc = RpcProcessor.ProcessRpcCall(netBehaviourSubclass, md, clientRpcAttr);

            MethodDefinition rpcFunc = RpcProcessor.ProcessRpcInvoke(netBehaviourSubclass, md, rpcCallFunc);

            if (rpcFunc != null)
            {
                clientRpcInvocationFuncs.Add(rpcFunc);
            }
        }
Пример #3
0
        void ProcessClientRpc(HashSet <string> names, MethodDefinition md, CustomAttribute clientRpcAttr)
        {
            if (md.IsAbstract)
            {
                Weaver.Error("Abstract ClientRpc are currently not supported, use virtual method instead", md);
                return;
            }

            if (!ValidateRemoteCallAndParameters(md, RemoteCallType.ClientRpc))
            {
                return;
            }

            if (names.Contains(md.Name))
            {
                Weaver.Error($"Duplicate ClientRpc name {md.Name}", md);
                return;
            }

            bool excludeOwner = clientRpcAttr.GetField("excludeOwner", false);

            names.Add(md.Name);
            clientRpcs.Add(new ClientRpcResult
            {
                method       = md,
                excludeOwner = excludeOwner
            });

            MethodDefinition rpcCallFunc = RpcProcessor.ProcessRpcCall(netBehaviourSubclass, md, clientRpcAttr);

            // need null check here because ProcessRpcCall returns null if it can't write all the args
            if (rpcCallFunc == null)
            {
                return;
            }

            MethodDefinition rpcFunc = RpcProcessor.ProcessRpcInvoke(netBehaviourSubclass, md, rpcCallFunc);

            if (rpcFunc != null)
            {
                clientRpcInvocationFuncs.Add(rpcFunc);
            }
        }
Пример #4
0
        void ProcessClientRpc(HashSet <string> names, MethodDefinition md, CustomAttribute clientRpcAttr, ref bool WeavingFailed)
        {
            if (md.IsAbstract)
            {
                Log.Error("Abstract ClientRpc are currently not supported, use virtual method instead", md);
                WeavingFailed = true;
                return;
            }

            if (!ValidateRemoteCallAndParameters(md, RemoteCallType.ClientRpc, ref WeavingFailed))
            {
                return;
            }

            bool includeOwner = clientRpcAttr.GetField("includeOwner", true);

            names.Add(md.Name);
            clientRpcs.Add(new ClientRpcResult
            {
                method       = md,
                includeOwner = includeOwner
            });

            MethodDefinition rpcCallFunc = RpcProcessor.ProcessRpcCall(weaverTypes, writers, Log, netBehaviourSubclass, md, clientRpcAttr, ref WeavingFailed);

            // need null check here because ProcessRpcCall returns null if it can't write all the args
            if (rpcCallFunc == null)
            {
                return;
            }

            MethodDefinition rpcFunc = RpcProcessor.ProcessRpcInvoke(weaverTypes, writers, readers, Log, netBehaviourSubclass, md, rpcCallFunc, ref WeavingFailed);

            if (rpcFunc != null)
            {
                clientRpcInvocationFuncs.Add(rpcFunc);
            }
        }
Пример #5
0
        void ProcessMethods()
        {
            HashSet <string> names = new HashSet <string>();

            // find command and RPC functions
            foreach (MethodDefinition md in m_td.Methods)
            {
                Weaver.ResetRecursionCount();
                foreach (CustomAttribute ca in md.CustomAttributes)
                {
                    if (ca.AttributeType.FullName == Weaver.CommandType.FullName)
                    {
                        if (!CommandProcessor.ProcessMethodsValidateCommand(m_td, md, ca))
                        {
                            return;
                        }

                        if (names.Contains(md.Name))
                        {
                            Log.Error("Duplicate Command name [" + m_td.FullName + ":" + md.Name + "]");
                            Weaver.fail = true;
                            return;
                        }
                        names.Add(md.Name);
                        m_Cmds.Add(md);

                        MethodDefinition cmdFunc = CommandProcessor.ProcessCommandInvoke(m_td, md);
                        if (cmdFunc != null)
                        {
                            m_CmdInvocationFuncs.Add(cmdFunc);
                        }

                        MethodDefinition cmdCallFunc = CommandProcessor.ProcessCommandCall(m_td, md, ca);
                        if (cmdCallFunc != null)
                        {
                            m_CmdCallFuncs.Add(cmdCallFunc);
                            Weaver.lists.replaceMethods[md.FullName] = cmdCallFunc;
                        }
                        break;
                    }

                    if (ca.AttributeType.FullName == Weaver.TargetRpcType.FullName)
                    {
                        if (!TargetRpcProcessor.ProcessMethodsValidateTargetRpc(m_td, md, ca))
                        {
                            return;
                        }

                        if (names.Contains(md.Name))
                        {
                            Log.Error("Duplicate Target Rpc name [" + m_td.FullName + ":" + md.Name + "]");
                            Weaver.fail = true;
                            return;
                        }
                        names.Add(md.Name);
                        m_TargetRpcs.Add(md);

                        MethodDefinition rpcFunc = TargetRpcProcessor.ProcessTargetRpcInvoke(m_td, md);
                        if (rpcFunc != null)
                        {
                            m_TargetRpcInvocationFuncs.Add(rpcFunc);
                        }

                        MethodDefinition rpcCallFunc = TargetRpcProcessor.ProcessTargetRpcCall(m_td, md, ca);
                        if (rpcCallFunc != null)
                        {
                            m_TargetRpcCallFuncs.Add(rpcCallFunc);
                            Weaver.lists.replaceMethods[md.FullName] = rpcCallFunc;
                        }
                        break;
                    }

                    if (ca.AttributeType.FullName == Weaver.ClientRpcType.FullName)
                    {
                        if (!RpcProcessor.ProcessMethodsValidateRpc(m_td, md, ca))
                        {
                            return;
                        }

                        if (names.Contains(md.Name))
                        {
                            Log.Error("Duplicate ClientRpc name [" + m_td.FullName + ":" + md.Name + "]");
                            Weaver.fail = true;
                            return;
                        }
                        names.Add(md.Name);
                        m_Rpcs.Add(md);

                        MethodDefinition rpcFunc = RpcProcessor.ProcessRpcInvoke(m_td, md);
                        if (rpcFunc != null)
                        {
                            m_RpcInvocationFuncs.Add(rpcFunc);
                        }

                        MethodDefinition rpcCallFunc = RpcProcessor.ProcessRpcCall(m_td, md, ca);
                        if (rpcCallFunc != null)
                        {
                            m_RpcCallFuncs.Add(rpcCallFunc);
                            Weaver.lists.replaceMethods[md.FullName] = rpcCallFunc;
                        }
                        break;
                    }
                }
            }

            // cmds
            foreach (MethodDefinition md in m_CmdInvocationFuncs)
            {
                m_td.Methods.Add(md);
            }
            foreach (MethodDefinition md in m_CmdCallFuncs)
            {
                m_td.Methods.Add(md);
            }

            // rpcs
            foreach (MethodDefinition md in m_RpcInvocationFuncs)
            {
                m_td.Methods.Add(md);
            }
            foreach (MethodDefinition md in m_TargetRpcInvocationFuncs)
            {
                m_td.Methods.Add(md);
            }
            foreach (MethodDefinition md in m_RpcCallFuncs)
            {
                m_td.Methods.Add(md);
            }
            foreach (MethodDefinition md in m_TargetRpcCallFuncs)
            {
                m_td.Methods.Add(md);
            }
        }