1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-03 16:55:53 +00:00

Merge pull request #62805 from raulsntos/csharp-rpc

This commit is contained in:
Rémi Verschelde
2022-07-07 17:21:51 +02:00
committed by GitHub
7 changed files with 76 additions and 41 deletions

View File

@@ -0,0 +1,43 @@
using System;
namespace Godot
{
/// <summary>
/// Attribute that changes the RPC mode for the annotated <c>method</c> to the given <see cref="Mode"/>,
/// optionally specifying the <see cref="TransferMode"/> and <see cref="TransferChannel"/> (on supported peers).
/// See <see cref="RPCMode"/> and <see cref="TransferMode"/>. By default, methods are not exposed to networking
/// (and RPCs).
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class RPCAttribute : Attribute
{
/// <summary>
/// RPC mode for the annotated method.
/// </summary>
public RPCMode Mode { get; } = RPCMode.Disabled;
/// <summary>
/// If the method will also be called locally; otherwise, it is only called remotely.
/// </summary>
public bool CallLocal { get; set; } = false;
/// <summary>
/// Transfer mode for the annotated method.
/// </summary>
public TransferMode TransferMode { get; set; } = TransferMode.Reliable;
/// <summary>
/// Transfer channel for the annotated mode.
/// </summary>
public int TransferChannel { get; set; } = 0;
/// <summary>
/// Constructs a <see cref="RPCAttribute"/> instance.
/// </summary>
/// <param name="mode">The RPC mode to use.</param>
public RPCAttribute(RPCMode mode = RPCMode.Authority)
{
Mode = mode;
}
}
}

View File

@@ -1,16 +0,0 @@
using System;
namespace Godot
{
/// <summary>
/// Constructs a new AnyPeerAttribute instance. Members with the AnyPeerAttribute are given authority over their own player.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class AnyPeerAttribute : Attribute { }
/// <summary>
/// Constructs a new AuthorityAttribute instance. Members with the AuthorityAttribute are given authority over the game.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class AuthorityAttribute : Attribute { }
}

View File

@@ -18,7 +18,7 @@
<Compile Include="Core\Attributes\DisableGodotGeneratorsAttribute.cs" />
<Compile Include="Core\Attributes\ExportAttribute.cs" />
<Compile Include="Core\Attributes\GodotMethodAttribute.cs" />
<Compile Include="Core\Attributes\RPCAttributes.cs" />
<Compile Include="Core\Attributes\RPCAttribute.cs" />
<Compile Include="Core\Attributes\ScriptPathAttribute.cs" />
<Compile Include="Core\Attributes\SignalAttribute.cs" />
<Compile Include="Core\Attributes\ToolAttribute.cs" />