Fix using RPC attribute without ctor usage

This commit is contained in:
Wojtek Figat
2023-02-10 11:02:06 +01:00
parent 07892ccf18
commit 07ca64c8a0

View File

@@ -1244,15 +1244,16 @@ namespace Flax.Build.Plugins
var methodRPC = new MethodRPC();
methodRPC.Type = type;
methodRPC.Method = method;
methodRPC.IsServer = (bool)attribute.GetFieldValue("Server", false);
methodRPC.IsClient = (bool)attribute.GetFieldValue("Client", false);
methodRPC.Channel = (int)attribute.GetFieldValue("Channel", 4); // int as NetworkChannelType (default is ReliableOrdered=4)
methodRPC.Channel = 4; // int as NetworkChannelType (default is ReliableOrdered=4)
if (attribute.HasConstructorArguments && attribute.ConstructorArguments.Count >= 3)
{
methodRPC.IsServer = (bool)attribute.ConstructorArguments[0].Value;
methodRPC.IsClient = (bool)attribute.ConstructorArguments[1].Value;
methodRPC.Channel = (int)attribute.ConstructorArguments[2].Value;
}
methodRPC.IsServer = (bool)attribute.GetFieldValue("Server", methodRPC.IsServer);
methodRPC.IsClient = (bool)attribute.GetFieldValue("Client", methodRPC.IsClient);
methodRPC.Channel = (int)attribute.GetFieldValue("Channel", methodRPC.Channel);
if (methodRPC.IsServer && methodRPC.IsClient)
{
MonoCecil.CompilationError($"Network RPC {method.Name} in {type.FullName} cannot be both Server and Client.", method);