From 8131358b719bb87a596ded2f9ed55295688210d9 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Thu, 7 Jul 2022 03:13:41 +0200 Subject: C#: New `RPCAttribute` Replace old RPC attributes with a new single `RPCAttribute` which works like the GDScript `@rpc` annotation. --- .../GodotSharp/Core/Attributes/RPCAttribute.cs | 43 ++++++++++++++++++++++ .../GodotSharp/Core/Attributes/RPCAttributes.cs | 16 -------- .../glue/GodotSharp/GodotSharp/GodotSharp.csproj | 2 +- 3 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttribute.cs delete mode 100644 modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs (limited to 'modules/mono/glue/GodotSharp') diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttribute.cs new file mode 100644 index 0000000000..0a1c8322d7 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttribute.cs @@ -0,0 +1,43 @@ +using System; + +namespace Godot +{ + /// + /// Attribute that changes the RPC mode for the annotated method to the given , + /// optionally specifying the and (on supported peers). + /// See and . By default, methods are not exposed to networking + /// (and RPCs). + /// + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public class RPCAttribute : Attribute + { + /// + /// RPC mode for the annotated method. + /// + public RPCMode Mode { get; } = RPCMode.Disabled; + + /// + /// If the method will also be called locally; otherwise, it is only called remotely. + /// + public bool CallLocal { get; set; } = false; + + /// + /// Transfer mode for the annotated method. + /// + public TransferMode TransferMode { get; set; } = TransferMode.Reliable; + + /// + /// Transfer channel for the annotated mode. + /// + public int TransferChannel { get; set; } = 0; + + /// + /// Constructs a instance. + /// + /// The RPC mode to use. + public RPCAttribute(RPCMode mode = RPCMode.Authority) + { + Mode = mode; + } + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs deleted file mode 100644 index f0d37c344d..0000000000 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Godot -{ - /// - /// Constructs a new AnyPeerAttribute instance. Members with the AnyPeerAttribute are given authority over their own player. - /// - [AttributeUsage(AttributeTargets.Method)] - public class AnyPeerAttribute : Attribute { } - - /// - /// Constructs a new AuthorityAttribute instance. Members with the AuthorityAttribute are given authority over the game. - /// - [AttributeUsage(AttributeTargets.Method)] - public class AuthorityAttribute : Attribute { } -} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj index 1fcfe74c86..e59f45bbf6 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj +++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj @@ -18,7 +18,7 @@ - + -- cgit v1.2.3