Add admin logs for shuttle call/recall

This commit is contained in:
DrSmugleaf
2021-11-22 21:31:50 +01:00
parent 37e7da0e42
commit af6353da46
5 changed files with 36 additions and 11 deletions

View File

@@ -1,8 +1,11 @@
using System;
using System.Threading;
using Content.Server.Administration.Logs;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
using Content.Shared.Administration.Logs;
using Content.Shared.GameTicking;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -18,6 +21,8 @@ namespace Content.Server.RoundEnd
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly AdminLogSystem _adminLog = default!;
public const float RestartRoundTime = 20f;
private CancellationTokenSource _roundEndCancellationTokenSource = new();
@@ -74,12 +79,12 @@ namespace Content.Server.RoundEnd
Timer.Spawn(CallCooldown, () => OnCallCooldownEnded?.Invoke(), _callCooldownEndedTokenSource.Token);
}
public void RequestRoundEnd(bool checkCooldown = true)
public void RequestRoundEnd(IEntity? requester = null, bool checkCooldown = true)
{
RequestRoundEnd(RoundEndCountdownTime, checkCooldown);
RequestRoundEnd(RoundEndCountdownTime, requester, checkCooldown);
}
public void RequestRoundEnd(TimeSpan countdownTime, bool checkCooldown = true)
public void RequestRoundEnd(TimeSpan countdownTime, IEntity? requester = null, bool checkCooldown = true)
{
if (IsRoundEndCountdownStarted)
return;
@@ -89,6 +94,15 @@ namespace Content.Server.RoundEnd
return;
}
if (requester != null)
{
_adminLog.Add(LogType.ShuttleCalled, LogImpact.High, $"Shuttle called by {requester}");
}
else
{
_adminLog.Add(LogType.ShuttleCalled, LogImpact.High, $"Shuttle called");
}
IsRoundEndCountdownStarted = true;
_chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", countdownTime.Minutes)), Loc.GetString("Station"));
@@ -103,7 +117,7 @@ namespace Content.Server.RoundEnd
OnRoundEndCountdownStarted?.Invoke();
}
public void CancelRoundEndCountdown( bool checkCooldown = true)
public void CancelRoundEndCountdown(IEntity? requester = null, bool checkCooldown = true)
{
if (!IsRoundEndCountdownStarted)
return;
@@ -113,6 +127,15 @@ namespace Content.Server.RoundEnd
return;
}
if (requester != null)
{
_adminLog.Add(LogType.ShuttleRecalled, LogImpact.High, $"Shuttle recalled by {requester}");
}
else
{
_adminLog.Add(LogType.ShuttleRecalled, LogImpact.High, $"Shuttle recalled");
}
IsRoundEndCountdownStarted = false;
_chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-recalled-announcement"), Loc.GetString("Station"));