]> git.deb.at Git - rhonda/impostor.git/commitdiff
Send chat message to self by default
authorAeonLucid <aeonlucid@outlook.com>
Mon, 2 Nov 2020 18:55:05 +0000 (19:55 +0100)
committerAeonLucid <aeonlucid@outlook.com>
Mon, 2 Nov 2020 18:55:05 +0000 (19:55 +0100)
src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs
src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs

index f79fbf6e15f515bb50dfcdc0877a3d3ec994f666..cd031db0d192bf1348bc91c003b990c55630ec4e 100644 (file)
@@ -93,9 +93,12 @@ namespace Impostor.Api.Net.Inner.Objects
         ///     Visible to only the current.
         /// </summary>
         /// <param name="text">The message to send.</param>
-        /// <param name="player">The player that should receive this chat message.</param>
+        /// <param name="player">
+        ///     The player that should receive this chat message.
+        ///     When left as null, will send message to self.
+        /// </param>
         /// <returns>Task that must be awaited.</returns>
-        ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl player);
+        ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl? player = null);
 
         /// <summary>
         ///     Sets the current to infected (impostor) <see cref="IInnerPlayerControl"/>.
index d73d3247ca86ad8b225bbd064090df36ac43dcbb..78337b952a53d8687b58137032b8f11c352a8cfe 100644 (file)
@@ -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);