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); } }
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); } }