* inital * force them to WRITE * b * new system * aaaa * b * bbbb * translations * add tts support for evacuation reason * PaddedStool_Sprite&Prototype 8 colors of pudded stool. * PaddedStool_Crafting * ComfyChair_Sprites&Prototype * ComfyChair_Crafting * Sofa_Sprites&Prototype * Sofa_Crafting * Sofa_SpriteFix * Sofa_RemoveSomeSprites * Revert "Sofa_RemoveSomeSprites" This reverts commit b110e9bda9a75cf6337c4efacd4888967d0e1fe6. * Revert "Sofa_SpriteFix" This reverts commit bfa8a17c16c57d2f70d64eb8dd54ae94ac48b248. * Revert "Sofa_Crafting" This reverts commit 89daadcb1e9d45a84281a5fdf998ab6c6f6b0f9b. * Revert "Sofa_Sprites&Prototype" This reverts commit 73cd0be403e03b1852a4632e1b6a8ca7526c5622. * Revert "ComfyChair_Crafting" This reverts commit 940f9665dd998090b43bca596ef3800c0c6ba89b. * Revert "ComfyChair_Sprites&Prototype" This reverts commit 2c909de5d3e3f4ab5efa1cbef6b5feda32d05a80. * Revert "PaddedStool_Crafting" This reverts commit 82040ba82c0190f2a52614fd3573e77586d73802. * Revert "PaddedStool_Sprite&Prototype" This reverts commit c5241a03ffeccbb4a18ab0f108d05c4fe1e047ba. * Sprites&Meta * Crafting * Tweaks * PaddedStool_tweaks * Add Random Spawners * remove old colored chairs * Sprites&Meta * Changing prototypes * Adding to Theater vend * Sprite_Change * Sprite_Change * Prototype_Changes Is this exactly how it should be?... * add bouquet * Not very useful functionality has been removed * Update toys.yml * Now you need cloth to made bouquet * Update toys.yml * I hope. I done right * Update toys.yml * Update bouquet.yml * Update toys.yml * Update Resources/Prototypes/Recipes/Crafting/Graphs/toys.yml Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com> * add musician jumpskirt to loadouts * better bouquet * pAIs can now be inserted into plushies. * No more bad bleed * More Tourniquets, hopefully fixed YML check. * deals a bit of bloodloss * Reduce Stack Count. * fix tourniquet * add migrations for old chair types and add few new --------- Co-authored-by: Mr. 27 <koolthunder019@gmail.com> Co-authored-by: Арт <123451459+JustArt1m@users.noreply.github.com> Co-authored-by: Green resomi <135062489+Yeah-I-listening-Hollywood-undead@users.noreply.github.com> Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com> Co-authored-by: Moomoobeef <moomoobeef@protonmail.com> Co-authored-by: PoorMansDreams <andyroblox14@gmail.com>
489 lines
17 KiB
C#
489 lines
17 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.Screens.Components;
|
|
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.DeviceNetwork;
|
|
using Content.Shared.GameTicking;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Configuration;
|
|
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 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 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(5);
|
|
|
|
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()
|
|
{
|
|
AllEntityQuery<StationCentcommComponent>().MoveNext(out var centcomm);
|
|
|
|
return centcomm == null ? null : centcomm.MapEntity;
|
|
}
|
|
|
|
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",
|
|
string? reason = null)
|
|
{
|
|
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, reason);
|
|
}
|
|
|
|
public void RequestRoundEnd(
|
|
TimeSpan countdownTime,
|
|
EntityUid? requester = null,
|
|
bool checkCooldown = true,
|
|
string text = "round-end-system-shuttle-called-announcement",
|
|
string name = "Station",
|
|
string? reason = null)
|
|
{
|
|
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";
|
|
}
|
|
|
|
if (reason == null)
|
|
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString(text,
|
|
("time", time),
|
|
("units", Loc.GetString(units))),
|
|
name,
|
|
false,
|
|
null,
|
|
Color.Gold);
|
|
else
|
|
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString(text,
|
|
("time", time),
|
|
("units", Loc.GetString(units)),
|
|
("reason", reason)),
|
|
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 active clientside evac shuttle timers by zeroing the target time
|
|
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,
|
|
};
|
|
|
|
_deviceNetworkSystem.QueuePacket(shuttle.Value, null, payload, net.TransmitFrequency);
|
|
}
|
|
}
|
|
|
|
//WD-EDIT
|
|
private void SendRoundStatus(string status)
|
|
{
|
|
var utkaRoundStatusEvent = new UtkaRoundStatusEvent()
|
|
{
|
|
Message = status
|
|
};
|
|
|
|
_pandaWeb.SendBotPostMessage(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();
|
|
}
|
|
}
|
|
|
|
//WD start
|
|
public void DelayCursedShuttle(TimeSpan delay)
|
|
{
|
|
if (_gameTicker.RunLevel != GameRunLevel.InRound)
|
|
return;
|
|
|
|
if (_countdownTokenSource == null)
|
|
return;
|
|
|
|
var countdown = ExpectedCountdownEnd - _gameTiming.CurTime + delay;
|
|
ExpectedCountdownEnd = _gameTiming.CurTime + countdown;
|
|
|
|
_countdownTokenSource.Cancel();
|
|
_countdownTokenSource = new ();
|
|
|
|
if (countdown != null)
|
|
Timer.Spawn(countdown.Value, _shuttle.CallEmergencyShuttle, _countdownTokenSource.Token);
|
|
|
|
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString("round-end-system-shuttle-curse-delayed-announcement"),
|
|
Loc.GetString("Station"), colorOverride: Color.Gold);
|
|
}
|
|
|
|
public bool ShuttleCalled()
|
|
{
|
|
return ExpectedCountdownEnd != null;
|
|
}
|
|
//WD end
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|