From: Minorusama Date: Tue, 23 Mar 2021 20:12:39 +0000 (+0100) Subject: Add IInnerPlayerControl#ExileAsync (#271) X-Git-Tag: v1.3.0~5 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=be332e21d11125b330dfdbb5a41b353b13290c99;p=rhonda%2Fimpostor.git Add IInnerPlayerControl#ExileAsync (#271) --- diff --git a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs index c0ecf85..0ee065a 100644 --- a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs +++ b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs @@ -98,5 +98,12 @@ namespace Impostor.Api.Net.Inner.Objects /// Thrown when target is dead. /// Task that must be awaited. ValueTask MurderPlayerAsync(IInnerPlayerControl target); + + /// + /// Exile the current player. This doesn't produce a body to be reported. + /// Visible to all players. + /// + /// Task that must be awaited. + ValueTask ExileAsync(); } } diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs index 07c2126..e55f079 100644 --- a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs +++ b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs @@ -106,5 +106,24 @@ namespace Impostor.Server.Net.Inner.Objects await _eventManager.CallAsync(new PlayerMurderEvent(_game, _game.GetClientPlayer(OwnerId), this, target)); } + + public async ValueTask ExileAsync() + { + if (PlayerInfo.IsDead) + { + throw new ImpostorProtocolException("Tried to exile a player, but target was not alive."); + } + + // Update player. + Die(DeathReason.Exile); + + // Send RPC. + using var writer = _game.StartRpc(NetId, RpcCalls.Exiled); + Rpc04Exiled.Serialize(writer); + await _game.FinishRpcAsync(writer); + + // Notify plugins. + await _eventManager.CallAsync(new PlayerExileEvent(_game, _game.GetClientPlayer(OwnerId), this)); + } } }