+++ /dev/null
-using Impostor.Api.Net.Inner.Objects;
-
-namespace Impostor.Api.Events.Player
-{
- public interface IPlayerReportedBodyEvent : IPlayerEvent
- {
- /// <summary>
- /// Gets the player who's body got reported.
- /// </summary>
- IInnerPlayerControl? Body { get; }
- }
-}
--- /dev/null
+using Impostor.Api.Net.Inner.Objects;
+
+namespace Impostor.Api.Events.Player
+{
+ public interface IPlayerStartMeetingEvent : IPlayerEvent
+ {
+ /// <summary>
+ /// Gets the player who's body got reported. Is null when the meeting started by Emergency call button
+ /// </summary>
+ IInnerPlayerControl? Body { get; }
+ }
+}
}
[EventListener]
- public void OnPlayerReportedBodyEvent(IPlayerReportedBodyEvent e)
+ public void OnPlayerStartMeetingEvent(IPlayerStartMeetingEvent e)
{
- _logger.LogDebug("Player reported body");
+ _logger.LogDebug($"Player {e.PlayerControl.PlayerInfo.PlayerName} start meeting, reason: " + (e.Body==null ? "Emergency call button" : "Found the body of the player "+e.Body.PlayerInfo.PlayerName));
}
}
}
+++ /dev/null
-using Impostor.Api.Events.Player;
-using Impostor.Api.Games;
-using Impostor.Api.Net;
-using Impostor.Api.Net.Inner.Objects;
-
-namespace Impostor.Server.Events.Player
-{
- public class PlayerReportedBodyEvent : IPlayerReportedBodyEvent
- {
- public PlayerReportedBodyEvent(IGame game, IClientPlayer clientPlayer, IInnerPlayerControl playerControl, IInnerPlayerControl? body)
- {
- Game = game;
- ClientPlayer = clientPlayer;
- PlayerControl = playerControl;
- Body = body;
- }
-
- public IGame Game { get; }
-
- public IClientPlayer ClientPlayer { get; }
-
- public IInnerPlayerControl PlayerControl { get; }
-
- public IInnerPlayerControl? Body { get; }
- }
-}
--- /dev/null
+using Impostor.Api.Events.Player;
+using Impostor.Api.Games;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Inner.Objects;
+
+namespace Impostor.Server.Events.Player
+{
+ public class PlayerStartMeetingEvent : IPlayerStartMeetingEvent
+ {
+ public PlayerStartMeetingEvent(IGame game, IClientPlayer clientPlayer, IInnerPlayerControl playerControl, IInnerPlayerControl? body)
+ {
+ Game = game;
+ ClientPlayer = clientPlayer;
+ PlayerControl = playerControl;
+ Body = body;
+ }
+
+ public IGame Game { get; }
+
+ public IClientPlayer ClientPlayer { get; }
+
+ public IInnerPlayerControl PlayerControl { get; }
+
+ public IInnerPlayerControl? Body { get; }
+ }
+}
}
// TODO: (ANTICHEAT) Location check?
+ // only called by a non-host player on to start meeting
case RpcCalls.ReportDeadBody:
{
if (!sender.IsOwner(this))
throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.ReportDeadBody)} to a specific player instead of broadcast");
}
- // deadBodyPlayerId can be byte.MaxValue.
- // It happens when internally PlayerInfo is null.
- var deadBodyPlayerId = reader.ReadByte();
- var deadPlayer = deadBodyPlayerId != byte.MaxValue
- ? _game.GameNet.GameData.GetPlayerById(deadBodyPlayerId)?.Controller
- : null;
- if (deadBodyPlayerId == byte.MaxValue)
- {
- _logger.LogWarning("deadBodyPlayerId was byte.MaxValue");
- }
+ var deadBodyPlayerId = reader.ReadByte();
+ // deadBodyPlayerId == byte.MaxValue -- means emergency call by button
- await _eventManager.CallAsync(new PlayerReportedBodyEvent(_game, sender, this, deadPlayer));
break;
}
throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.StartMeeting)} to a specific player instead of broadcast");
}
- var playerId = reader.ReadByte();
- var player = _game.GameNet.GameData.GetPlayerById(playerId);
+ // deadBodyPlayerId == byte.MaxValue -- means emergency call by button
+ var deadBodyPlayerId = reader.ReadByte();
+ var deadPlayer = deadBodyPlayerId != byte.MaxValue
+ ? _game.GameNet.GameData.GetPlayerById(deadBodyPlayerId)?.Controller
+ : null;
- // Meeting started by "player", can also be null.
+ await _eventManager.CallAsync(new PlayerStartMeetingEvent(_game, _game.GetClientPlayer(this.OwnerId), this, deadPlayer));
break;
}