/// 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"/>.
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;
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);