Files
OldThink/Content.Server/RoundEnd/RoundEndSystem.cs
HitPanda 97a9c04d4e [Feat] Panda socket (#616)
* base server side

* token check & base command response

* panda base command response addition & some commands

* web event, rest of commands & events

* fix empty api

* [DRAFT] Panda HTTP server (#570)

* [Sponsor] Nairsark ghost (#492)

* [Sponsor] Trora ghost (#493)

* [Sponsor] Trora ghost

* ckey

* Vtergot fluff (#494)

* Твики (#491)

* Economy additions

* Tweak implant cooldowns

* Cult stuff

* Random appearance aspect nuke ops fix

* Auto shuttle enable on round end

* Holy water threshold

* Automatic changelog update

* [Sponsor] Geraldiy fluff (#496)

* [Fix] Reputation respawn hotfix (#497)

* Automatic changelog update

* Новые аспекты (#495)

* Add ReflectAspect

* Add SlipperyAspect

* Add TraitorRichAspect

* Add WhisperAspect

* Add DarknessAspect & StolenFloorAspect

* Add WindowLeakAspect

* Add CatEarsAspect

* Add NothingAspect

* Fix fast and furious clone

* Add SkeletonAspect

* Add cvar ceanup

* Automatic changelog update

* [Sponsor] Fluff knife cappy (#498)

* [Sponsor] Fluff KnifeCappy

* loadout

* Всякое (#501)

* eftpos form jurist

* ebal parameda

* Automatic changelog update

* [Sponsor] Zilendorie ghost upgrade (#502)

* Апдейт карт, станция прибытия (#503)

* Automatic changelog update

* Fix aspects (#500)

* Automatic changelog update

* Rules popup fix (#504)

* Defib fix (#499)

* Automatic changelog update

* Фикс флаффа (#507)

* Фикс прибытия (#509)

* Automatic changelog update

* Фиксы (#508)

* Fix cult blindfold

* Add stamina resistances

* Energy bolt is energy

* Laser shield is anti-laser

* Cult blindfold welding protection

* Eject id cards on deconstruct

* Wires panel power fix

* Add markings for species

* Ebow gaming

* feat: настенные консольки (#505)

* Automatic changelog update

* [Sponsor] Fluff Medicgaming (#510)

* Привязка банковского аккаунта (#506)

* Sustenance vend price fix

* Account link

* Automatic changelog update

* antag ban fix (#511)

* antag ban fix

* rename some shit

* Bugfixes (#512)

* Bullets go through open crates

* Bullets don't hit pulled dead bodies

* No glued cuffs

* Missed reflect aspect mark

* vehicles cannot be shot (#18910)

Co-authored-by: deltanedas <@deltanedas:kde.org>

* Cleanup

---------

Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>

* Automatic changelog update

* атмос гейминг indeed (#513)

* fix hypernob + plasma and trit fire

* add 11 new gas types

* actually fix hypernob

---------

Co-authored-by: halicopter <kirillhalic@gmail.com>

* Automatic changelog update

* [Sponsor] thechaotic fluff

* Revert "[Sponsor] thechaotic fluff"

This reverts commit d19c807751258f9cfb205db01b0e4617b638fe98.

* [Sponsor] Fluff updates (#518)

* warete update

* renosan & warete size

* [Sponsor] thechaotic fluff (#519)

(cherry picked from commit d19c807751258f9cfb205db01b0e4617b638fe98)

* fix tts sanitize (#517)

* Automatic changelog update

* [Fluff] ghost regari

* Buffs (#515)

* FIRE axe

* Bow pro

* Bang

* Meleeeee

* Disarm two-handed hard

* Automatic changelog update

* Игнор вайтлист требования ролей если стоит флаг TOOLS (#514)

* forAmins be like

* >вайтлист в девелопменте

* а описание кто напишет а

* Размеры попапов в чате (#525)

* попытка деконить магнит пока он активен гибает интернет приколистов (#524)

* Интернет прикол

* попап

* Prevent using cultist items & halberd (#523)

* Fix skeleton aspect (#522)

* Fix cult door (#521)

* Fix cult door

* Prevent emagging

* Walls and griders

* Fix

* Drone fix (#520)

* Drone fix

* RCD

* Automatic changelog update

* Смешное в конце раунда с аспектом (#516)

* Cats

* Fix

* Automatic changelog update

* Fix cult win conditions (#527)

* Runes stuff (#526)

* Blood boil 2.0

* Attach to grid

* No

* Automatic changelog update

* [Sponsor] thefrendlypsychopath ghost (#529)

* knifeCappy (#528)

Co-authored-by: Mona Hmiza <you@example.com>

* [Feat] TTS 8 new voices

* borg fix

* Automatic changelog update

* мапперы тестили

* fix void prototype

* [Fix] Cult chat fix (#536)

* ERT tweak (#530)

* tweak values

* tweak spawn logic

* Invisible rune (#531)

* Automatic changelog update

* [Sponsor] Oleg_Tinkoff fluff (#534)

* [Sponsor] Oleg_Tinkoff fluff

* name fix

* Small fixes (#537)

* No sleeping emotes

* Beakers & jugs in fridge

* Drone fix

* Fix teleport pulling

* Fix loc

* More fixes

* Fix ghost role

* Stuff

* Automatic changelog update

* Nerf grilles (#541)

* Nerf grilles

* tweak

* Bola fix (#540)

* Automatic changelog update

* Куча говна (#539)

* No Emp resistance (#538)

* No EMP resistance

* Cleanup

* Automatic changelog update

* mappews mapped some mowe~

* anothew update UwU

* [Sponsor] Geraldiy fluff 2 (#542)

* fix drydock

* Objective changes (#543)

* Automatic changelog update

* UwU spawnews are now fixed, hopefully~

* UwU tired of it alweady

* Automatic changelog update

* Респрайт капитанского лазера (#546)

* antique lasergun resprite lol

* лицуха

* Automatic changelog update

* Апдейт арахнидов (#544)

* Web underwear

* Fix layers

* Change melee sound

* Arachnid 2: Episode 2 (#19984)

* Shield

* minor sprite changes and buffs

* structure buff

* Crafting stuff

* tweaks

* 88-88

* Better web pocket sprites.

* yeah it's fine now.

* Fix

* Sprite tweaks

* This I guess

* Eye sprite

---------

Co-authored-by: PixelTK <85175107+PixelTheKermit@users.noreply.github.com>

* [Sponsor] Zilendorie fluff (#545)

* Automatic changelog update

* Fire buff (#549)

* EntityStorage deletion fix? (#548)

* strip fix (#21552) (#547)

Co-authored-by: PixelTK <85175107+PixelTheKermit@users.noreply.github.com>

* Automatic changelog update

* [Fluff] SSAO Ghost

* [Fluff] svinka ghost tweak

* [Fluff] Svinka Coat

* Meaty-Ore Idea (#550)

* qwe

* yeah

* Vtergot fluff fix (#552)

* наяриваем на лишние пиксели

* Чтобы мапперы не втыкали

* fix atmos (#551)

* fix atmos

* fixie

* Automatic changelog update

* Meow hotfix (#553)

* Many stuff (#555)

* Drone bucket

* Weird insuls

* Not too strong

* No cult door bolts

* Emergency shuttle after round end fix

* Fix spiders

* Automatic changelog update

* [FEAT] Всякие прикольные разности и вкусности (#554)

* feat: трикодер

* feat: принтер документов

* fix: текст фелинидов

* feat: возможность менять голос эмоутов

* feat: мяукаем при аспекте мяуканья

* feat: ПНВ

* fix: забирай свои метадаты

* fix: oopsies

* fix: линтер снова

* fix: пожалуйста линтер отстань

* Automatic changelog update

* Гарпии (#533)

* harpy initial

* fix and some locale

* ru locale

* actions refactor shit

* пофиксив гавпий~~~ пойду тестить~~

* hawpies are ready UwU

* cweanup OwO

* hawpies fixed a bit, still cant seawch them nya~

* hawpies can be stwipped now, fixie-dixie awwived~

* emotes fixie-dixied nya~

* говно

* говно говна линтер соси

* Automatic changelog update

* Revert "Гарпии (#533)" (#557)

This reverts commit e3f2166bf7cbd775278a396a3f8d8215a2d5c506.

* Doom fluff (#556)

* DOOMMAX fluff

* Detective meow

* Сеньёр помидор офицер

* RSI validator su4ka

* [Fluff] MR_Regari ghost tweak

* [Fluff] svinka ghost tweak

* [Fluff] Antohag gasmask fluff

* ГАРПИИ (#559)

* harpy initial

* fix and some locale

* ru locale

* actions refactor shit

* пофиксив гавпий~~~ пойду тестить~~

* hawpies are ready UwU

* cweanup OwO

* hawpies fixed a bit, still cant seawch them nya~

* hawpies can be stwipped now, fixie-dixie awwived~

* emotes fixie-dixied nya~

* говно

* говно говна линтер соси

* Automatic changelog update

* [Tweak] Бумажная работа и фикс крафта пнв. (#560)

* fix: персонал станции вспомнил как делать пнв

* tweak: блюспейс технологии убраны у принтера документов

* feat: заказ бумаги в карго

* feat: бумажная дверь

* Automatic changelog update

* doommaxx-fluff

nothing interesting

* fluff skufa (#562)

* [Sponsor] Fluff Forg (#567)

* [Sponsor] Fluff Forg

* fix size

* sound

* [Feat] TTS 15 new voices (#568)

* Automatic changelog update

* base server side

* token check & base command response

* panda base command response addition & some commands

* web event, rest of commands & events

* fix empty api

---------

Co-authored-by: Cinkafox <70429757+Cinkafox@users.noreply.github.com>
Co-authored-by: Aviu00 <93730715+Aviu00@users.noreply.github.com>
Co-authored-by: RavmorganButOnCocaine <valtos@nextmail.ru>
Co-authored-by: Kotovskiy <77529717+wCATw@users.noreply.github.com>
Co-authored-by: ThereDrD0 <88589686+ThereDrD0@users.noreply.github.com>
Co-authored-by: Remuchi <72476615+Remuchi@users.noreply.github.com>
Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: KurokoTurbo <92106367+melanoTurbo@users.noreply.github.com>
Co-authored-by: halicopter <kirillhalic@gmail.com>
Co-authored-by: rhailrake <49613070+rhailrake@users.noreply.github.com>
Co-authored-by: Subversionary <109166122+Subversionary@users.noreply.github.com>
Co-authored-by: RavMorgan <48182970+RavMorgan@users.noreply.github.com>
Co-authored-by: Mona Hmiza <you@example.com>
Co-authored-by: Valtos <valtos@spaces.ru>
Co-authored-by: REBOLUTION228-a11 <128076300+REBOLUTION228-a11@users.noreply.github.com>
Co-authored-by: PixelTK <85175107+PixelTheKermit@users.noreply.github.com>

* newtonsoft version change

* remove semaphore

* remove double dooc

* fix admin stealth

* cleanup

* remove utka sockets

---------

Co-authored-by: Cinkafox <70429757+Cinkafox@users.noreply.github.com>
Co-authored-by: Aviu00 <93730715+Aviu00@users.noreply.github.com>
Co-authored-by: RavmorganButOnCocaine <valtos@nextmail.ru>
Co-authored-by: Kotovskiy <77529717+wCATw@users.noreply.github.com>
Co-authored-by: ThereDrD0 <88589686+ThereDrD0@users.noreply.github.com>
Co-authored-by: Remuchi <72476615+Remuchi@users.noreply.github.com>
Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: KurokoTurbo <92106367+melanoTurbo@users.noreply.github.com>
Co-authored-by: halicopter <kirillhalic@gmail.com>
Co-authored-by: rhailrake <49613070+rhailrake@users.noreply.github.com>
Co-authored-by: Subversionary <109166122+Subversionary@users.noreply.github.com>
Co-authored-by: RavMorgan <48182970+RavMorgan@users.noreply.github.com>
Co-authored-by: Mona Hmiza <you@example.com>
Co-authored-by: Valtos <valtos@spaces.ru>
Co-authored-by: REBOLUTION228-a11 <128076300+REBOLUTION228-a11@users.noreply.github.com>
Co-authored-by: PixelTK <85175107+PixelTheKermit@users.noreply.github.com>
2024-01-26 10:44:21 +03:00

452 lines
16 KiB
C#

using System.Threading;
using Content.Server.Administration.Logs;
using Content.Server.AlertLevel;
using Content.Shared.CCVar;
using Content.Server.Chat.Managers;
using Content.Server.Chat.Systems;
using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Components;
using Content.Server.DeviceNetwork.Systems;
using Content.Server.GameTicking;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.White.PandaSocket.Main;
using Content.Shared.Database;
using Content.Shared.GameTicking;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Timer = Robust.Shared.Timing.Timer;
namespace Content.Server.RoundEnd
{
/// <summary>
/// Handles ending rounds normally and also via requesting it (e.g. via comms console)
/// If you request a round end then an escape shuttle will be used.
/// </summary>
public sealed class RoundEndSystem : EntitySystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
[Dependency] private readonly EmergencyShuttleSystem _shuttle = default!;
[Dependency] private readonly ShuttleTimerSystem _shuttleTimerSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
//WD-EDIT
[Dependency] private readonly PandaWebManager _pandaWeb = default!;
//WD-EDIT
public TimeSpan DefaultCooldownDuration { get; set; } = TimeSpan.FromSeconds(30);
/// <summary>
/// Countdown to use where there is no station alert countdown to be found.
/// </summary>
public TimeSpan DefaultCountdownDuration { get; set; } = TimeSpan.FromMinutes(10);
private CancellationTokenSource? _countdownTokenSource;
private CancellationTokenSource? _cooldownTokenSource;
public TimeSpan? LastCountdownStart { get; set; }
public TimeSpan? ExpectedCountdownEnd { get; set; }
public TimeSpan? ExpectedShuttleLength => ExpectedCountdownEnd - LastCountdownStart;
public TimeSpan? ShuttleTimeLeft => ExpectedCountdownEnd - _gameTiming.CurTime;
public TimeSpan AutoCallStartTime;
private bool _autoCalledBefore;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RoundRestartCleanupEvent>(_ => Reset());
SetAutoCallTime();
}
private void SetAutoCallTime()
{
AutoCallStartTime = _gameTiming.CurTime;
}
private void Reset()
{
if (_countdownTokenSource != null)
{
_countdownTokenSource.Cancel();
_countdownTokenSource = null;
}
if (_cooldownTokenSource != null)
{
_cooldownTokenSource.Cancel();
_cooldownTokenSource = null;
}
LastCountdownStart = null;
ExpectedCountdownEnd = null;
SetAutoCallTime();
_autoCalledBefore = false;
RaiseLocalEvent(RoundEndSystemChangedEvent.Default);
}
/// <summary>
/// Attempts to get the MapUid of the station using <see cref="StationSystem.GetLargestGrid"/>
/// </summary>
public EntityUid? GetStation()
{
AllEntityQuery<StationEmergencyShuttleComponent, StationDataComponent>()
.MoveNext(out _, out _, out var data);
if (data == null)
return null;
var targetGrid = _stationSystem.GetLargestGrid(data);
return targetGrid == null ? null : Transform(targetGrid.Value).MapUid;
}
/// <summary>
/// Attempts to get centcomm's MapUid
/// </summary>
public EntityUid? GetCentcomm()
{
return AllEntityQuery<StationCentcommComponent, TransformComponent>().MoveNext(out _, out var xform)
? xform.MapUid
: null;
}
public bool CanCallOrRecall()
{
return _cooldownTokenSource == null;
}
public bool IsRoundEndRequested()
{
return _countdownTokenSource != null;
}
public void RequestRoundEnd(
EntityUid? requester = null,
bool checkCooldown = true,
string text = "round-end-system-shuttle-called-announcement",
string name = "Station")
{
var duration = DefaultCountdownDuration;
if (requester != null)
{
var stationUid = _stationSystem.GetOwningStation(requester.Value);
if (TryComp<AlertLevelComponent>(stationUid, out var alertLevel))
{
duration = _protoManager
.Index<AlertLevelPrototype>(AlertLevelSystem.DefaultAlertLevelSet)
.Levels[alertLevel.CurrentLevel].ShuttleTime;
}
}
RequestRoundEnd(duration, requester, checkCooldown, text, name);
}
public void RequestRoundEnd(
TimeSpan countdownTime,
EntityUid? requester = null,
bool checkCooldown = true,
string text = "round-end-system-shuttle-called-announcement",
string name = "Station")
{
if (_gameTicker.RunLevel != GameRunLevel.InRound)
return;
if (checkCooldown && _cooldownTokenSource != null)
return;
if (_countdownTokenSource != null)
return;
_countdownTokenSource = new CancellationTokenSource();
if (requester != null)
{
_adminLogger.Add(LogType.ShuttleCalled, LogImpact.High,
$"Shuttle called by {ToPrettyString(requester.Value):user}");
}
else
{
_adminLogger.Add(LogType.ShuttleCalled, LogImpact.High, $"Shuttle called");
}
// I originally had these set up here but somehow time gets passed as 0 to Loc so IDEK.
int time;
string units;
if (countdownTime.TotalSeconds < 60)
{
time = countdownTime.Seconds;
units = "eta-units-seconds";
}
else
{
time = countdownTime.Minutes;
units = "eta-units-minutes";
}
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString(text,
("time", time),
("units", Loc.GetString(units))),
name,
false,
null,
Color.Gold);
_audio.PlayGlobal("/Audio/Announcements/shuttlecalled.ogg", Filter.Broadcast(), true);
LastCountdownStart = _gameTiming.CurTime;
ExpectedCountdownEnd = _gameTiming.CurTime + countdownTime;
Timer.Spawn(countdownTime, _shuttle.CallEmergencyShuttle, _countdownTokenSource.Token);
ActivateCooldown();
RaiseLocalEvent(RoundEndSystemChangedEvent.Default);
SendRoundStatus("shuttle_called");
var shuttle = _shuttle.GetShuttle();
if (shuttle != null && TryComp<DeviceNetworkComponent>(shuttle, out var net))
{
var payload = new NetworkPayload
{
[ShuttleTimerMasks.ShuttleMap] = shuttle,
[ShuttleTimerMasks.SourceMap] = GetCentcomm(),
[ShuttleTimerMasks.DestMap] = GetStation(),
[ShuttleTimerMasks.ShuttleTime] = countdownTime,
[ShuttleTimerMasks.SourceTime] = countdownTime +
TimeSpan.FromSeconds(_shuttle.TransitTime + _cfg.GetCVar(CCVars.EmergencyShuttleDockTime)),
[ShuttleTimerMasks.DestTime] = countdownTime,
};
_deviceNetworkSystem.QueuePacket(shuttle.Value, null, payload, net.TransmitFrequency);
}
}
public void CancelRoundEndCountdown(EntityUid? requester = null, bool checkCooldown = true)
{
if (_gameTicker.RunLevel != GameRunLevel.InRound)
return;
if (checkCooldown && _cooldownTokenSource != null)
return;
if (_countdownTokenSource == null)
return;
_countdownTokenSource.Cancel();
_countdownTokenSource = null;
if (requester != null)
{
_adminLogger.Add(LogType.ShuttleRecalled, LogImpact.High,
$"Shuttle recalled by {ToPrettyString(requester.Value):user}");
}
else
{
_adminLogger.Add(LogType.ShuttleRecalled, LogImpact.High, $"Shuttle recalled");
}
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString("round-end-system-shuttle-recalled-announcement"),
Loc.GetString("Station"), false, colorOverride: Color.Gold);
_audio.PlayGlobal("/Audio/Announcements/shuttlerecalled.ogg", Filter.Broadcast(), true);
LastCountdownStart = null;
ExpectedCountdownEnd = null;
ActivateCooldown();
RaiseLocalEvent(RoundEndSystemChangedEvent.Default);
//WD-EDIT
SendRoundStatus("shuttle_recalled");
//WD-EDIT
// remove all active shuttle timers
var zero = TimeSpan.Zero;
var shuttle = _shuttle.GetShuttle();
if (shuttle != null && TryComp<DeviceNetworkComponent>(shuttle, out var net))
{
var payload = new NetworkPayload
{
[ShuttleTimerMasks.ShuttleMap] = shuttle,
[ShuttleTimerMasks.SourceMap] = GetCentcomm(),
[ShuttleTimerMasks.DestMap] = GetStation(),
[ShuttleTimerMasks.ShuttleTime] = zero,
[ShuttleTimerMasks.SourceTime] = zero,
[ShuttleTimerMasks.DestTime] = zero,
[ShuttleTimerMasks.Text] = new[] { string.Empty, string.Empty }
};
_deviceNetworkSystem.QueuePacket(shuttle.Value, null, payload, net.TransmitFrequency);
}
}
//WD-EDIT
private void SendRoundStatus(string status)
{
var utkaRoundStatusEvent = new UtkaRoundStatusEvent()
{
Message = status
};
_pandaWeb.SendBotMessage(utkaRoundStatusEvent);
}
//WD-EDIT
public void EndRound(TimeSpan? countdownTime = null)
{
if (_gameTicker.RunLevel != GameRunLevel.InRound)
return;
LastCountdownStart = null;
ExpectedCountdownEnd = null;
RaiseLocalEvent(RoundEndSystemChangedEvent.Default);
_gameTicker.EndRound();
_countdownTokenSource?.Cancel();
_countdownTokenSource = new CancellationTokenSource();
countdownTime ??= TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.RoundRestartTime));
int time;
string unitsLocString;
if (countdownTime.Value.TotalSeconds < 60)
{
time = countdownTime.Value.Seconds;
unitsLocString = "eta-units-seconds";
}
else
{
time = countdownTime.Value.Minutes;
unitsLocString = "eta-units-minutes";
}
_chatManager.DispatchServerAnnouncement(
Loc.GetString(
"round-end-system-round-restart-eta-announcement",
("time", time),
("units", Loc.GetString(unitsLocString))));
Timer.Spawn(countdownTime.Value, AfterEndRoundRestart, _countdownTokenSource.Token);
}
/// <summary>
/// Starts a behavior to end the round
/// </summary>
/// <param name="behavior">The way in which the round will end</param>
/// <param name="time"></param>
/// <param name="sender"></param>
/// <param name="textCall"></param>
/// <param name="textAnnounce"></param>
public void DoRoundEndBehavior(
RoundEndBehavior behavior,
TimeSpan time,
string sender = "comms-console-announcement-title-centcom",
string textCall = "round-end-system-shuttle-called-announcement",
string textAnnounce = "round-end-system-shuttle-already-called-announcement")
{
switch (behavior)
{
case RoundEndBehavior.InstantEnd:
EndRound();
break;
case RoundEndBehavior.ShuttleCall:
// Check is shuttle called or not. We should only dispatch announcement if it's already called
if (IsRoundEndRequested())
{
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString(textAnnounce),
Loc.GetString(sender),
colorOverride: Color.Gold);
}
else
{
RequestRoundEnd(time, null, false, textCall,
Loc.GetString(sender));
}
break;
}
}
private void AfterEndRoundRestart()
{
if (_gameTicker.RunLevel != GameRunLevel.PostRound)
return;
Reset();
_gameTicker.RestartRound();
}
private void ActivateCooldown()
{
_cooldownTokenSource?.Cancel();
_cooldownTokenSource = new();
Timer.Spawn(DefaultCooldownDuration, () =>
{
_cooldownTokenSource.Cancel();
_cooldownTokenSource = null;
RaiseLocalEvent(RoundEndSystemChangedEvent.Default);
}, _cooldownTokenSource.Token);
}
public override void Update(float frameTime)
{
// Check if we should auto-call.
int mins = _autoCalledBefore
? _cfg.GetCVar(CCVars.EmergencyShuttleAutoCallExtensionTime)
: _cfg.GetCVar(CCVars.EmergencyShuttleAutoCallTime);
if (mins != 0 && _gameTiming.CurTime - AutoCallStartTime > TimeSpan.FromMinutes(mins))
{
if (!_shuttle.EmergencyShuttleArrived && ExpectedCountdownEnd is null)
{
RequestRoundEnd(null, false, "round-end-system-shuttle-auto-called-announcement");
_autoCalledBefore = true;
}
// Always reset auto-call in case of a recall.
SetAutoCallTime();
}
}
}
public sealed class RoundEndSystemChangedEvent : EntityEventArgs
{
public static RoundEndSystemChangedEvent Default { get; } = new();
}
public enum RoundEndBehavior : byte
{
/// <summary>
/// Instantly end round
/// </summary>
InstantEnd,
/// <summary>
/// Call shuttle with custom announcement
/// </summary>
ShuttleCall,
/// <summary>
/// Do nothing
/// </summary>
Nothing
}
}