From fbe996b0c3548fc2a7decebb3a0498fcd510e74c Mon Sep 17 00:00:00 2001 From: AeonLucid Date: Mon, 2 Nov 2020 19:55:05 +0100 Subject: [PATCH] Send chat message to self by default --- src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs | 7 +++++-- .../Net/Inner/Objects/InnerPlayerControl.Api.cs | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs index f79fbf6..cd031db 100644 --- a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs +++ b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs @@ -93,9 +93,12 @@ namespace Impostor.Api.Net.Inner.Objects /// Visible to only the current. /// /// The message to send. - /// The player that should receive this chat message. + /// + /// The player that should receive this chat message. + /// When left as null, will send message to self. + /// /// Task that must be awaited. - ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl player); + ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl? player = null); /// /// Sets the current to infected (impostor) . diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs index d73d324..78337b9 100644 --- a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs +++ b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs @@ -1,6 +1,5 @@ using System.Threading.Tasks; using Impostor.Api.Innersloth.Customization; -using Impostor.Api.Net; using Impostor.Api.Net.Inner.Objects; using Impostor.Api.Net.Inner.Objects.Components; @@ -86,8 +85,13 @@ namespace Impostor.Server.Net.Inner.Objects await _game.FinishRpcAsync(writer); } - public async ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl player) + public async ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl? player = null) { + if (player == null) + { + player = this; + } + using var writer = _game.StartRpc(NetId, RpcCalls.SendChat); writer.Write(text); await _game.FinishRpcAsync(writer, player.OwnerId); -- 2.39.5