namespace Impostor.Api.Net.Inner.Objects
{
- public interface IInnerPlayerControl
+ public interface IInnerPlayerControl : IInnerNetObject
{
/// <summary>
/// Gets the <see cref="IInnerPlayerInfo"/> of the <see cref="IInnerPlayerControl"/>.
/// 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>
/// <returns>Task that must be awaited.</returns>
- ValueTask SendChatToPlayerAsync(string text);
+ ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl player);
/// <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;
namespace Impostor.Server.Net.Inner.Objects
await _game.FinishRpcAsync(writer);
}
- public async ValueTask SendChatToPlayerAsync(string text)
+ public async ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl player)
{
using var writer = _game.StartRpc(NetId, RpcCalls.SendChat);
writer.Write(text);
-
- writer.EndMessage();
- writer.EndMessage();
-
- await _game.SendToAsync(writer, OwnerId);
+ await _game.FinishRpcAsync(writer, player.OwnerId);
}
public async ValueTask SetMurderedAsync()
return writer;
}
- internal ValueTask FinishRpcAsync(IMessageWriter writer)
+ internal ValueTask FinishRpcAsync(IMessageWriter writer, int? targetClientId = null)
{
writer.EndMessage();
writer.EndMessage();
- return SendToAllAsync(writer);
+ return targetClientId.HasValue
+ ? SendToAsync(writer, targetClientId.Value)
+ : SendToAllAsync(writer);
}
private void WriteRemovePlayerMessage(IMessageWriter message, bool clear, int playerId, DisconnectReason reason)
Message12WaitForHostS2C.Serialize(message, clear, Code, player.Client.Id);
}
}
-}
\ No newline at end of file
+}