Refactor antag rule code (#23445)

* Initial Pass, Rev, Thief

* Zombie initial pass

* Rebase, Traitor

* Nukeops, More overloads

* Revert RevolutionaryRuleComponent

* Use TryRoundStartAttempt, Rewrite nukie spawning

* Comments, Add task scheduler to GameRuleSystem

* Zombie initial testing done

* Sort methods, rework GameRuleTask

* Add CCVar, Initial testing continues

* Might as well get rid of the obsolete logging

* Oops, i dont know how to log apparently

* Suggested formatting fixes

* Suggested changes

* Fix merge issues

* Minor optimisation

* Allowed thief to choose other antags

* Review changes

* Spawn items on floor first, then inserting

* minor tweaks

* Shift as much as possible to ProtoId<>

* Remove unneeded

* Add exclusive antag attribute

* Fix merge issues

* Minor formatting fix

* Convert to struct

* Cleanup

* Review cleanup (need to test a lot)

* Some fixes, (mostly) tested

* oop

* Pass tests (for real)

---------

Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
This commit is contained in:
Rainfey
2024-02-29 06:25:10 +00:00
committed by GitHub
parent 3966a65c65
commit 4e6c59cfe5
53 changed files with 22454 additions and 22396 deletions

View File

@@ -3,6 +3,7 @@ using Content.Shared.Chat;
using Content.Shared.NukeOps;
using JetBrains.Annotations;
using Robust.Shared.Configuration;
using Robust.Shared.Timing;
namespace Content.Client.NukeOps;
@@ -10,6 +11,8 @@ namespace Content.Client.NukeOps;
public sealed class WarDeclaratorBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
[ViewVariables]
private WarDeclaratorWindow? _window;
@@ -20,7 +23,7 @@ public sealed class WarDeclaratorBoundUserInterface : BoundUserInterface
{
base.Open();
_window = new WarDeclaratorWindow();
_window = new WarDeclaratorWindow(_gameTiming, _localizationManager);
if (State != null)
UpdateState(State);
@@ -42,7 +45,8 @@ public sealed class WarDeclaratorBoundUserInterface : BoundUserInterface
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing) _window?.Dispose();
if (disposing)
_window?.Dispose();
}
private void OnWarDeclaratorActivated(string message)

View File

@@ -1,4 +1,5 @@
<DefaultWindow xmlns="https://spacestation14.io"
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{Loc 'war-declarator-ui-header'}">
<BoxContainer Orientation="Vertical" SeparationOverride="4" MinWidth="440">
@@ -7,12 +8,16 @@
MinHeight="200"
Access="Public" />
<Button Name="WarButton"
Text="{Loc 'war-declarator-ui-war-button'}"
Text="{Loc 'war-declarator-ui-try-war-button'}"
StyleClasses="Caution"
Access="Public"/>
<Label Name="StatusLabel"
Access="Public"/>
<Label Name="InfoLabel"
Access="Public"/>
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<Label Name="StatusLabel"
Align="Center"
Access="Public"/>
<Label Name="InfoLabel"
Align="Center"
Access="Public"/>
</BoxContainer>
</BoxContainer>
</DefaultWindow>
</controls:FancyWindow>

View File

@@ -1,8 +1,7 @@
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Shared.NukeOps;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -10,74 +9,83 @@ using Robust.Shared.Utility;
namespace Content.Client.NukeOps;
[GenerateTypedNameReferences]
public sealed partial class WarDeclaratorWindow : DefaultWindow
public sealed partial class WarDeclaratorWindow : FancyWindow
{
private readonly IGameTiming _gameTiming;
public event Action<string>? OnActivated;
private TimeSpan _endTime;
private TimeSpan _timeStamp;
private TimeSpan _shuttleDisabledTime;
private WarConditionStatus _status;
public WarDeclaratorWindow()
public WarDeclaratorWindow(IGameTiming gameTiming, ILocalizationManager localizationManager)
{
RobustXamlLoader.Load(this);
_gameTiming = IoCManager.Resolve<IGameTiming>();
_gameTiming = gameTiming;
WarButton.OnPressed += (_) => OnActivated?.Invoke(Rope.Collapse(MessageEdit.TextRope));
var loc = IoCManager.Resolve<ILocalizationManager>();
MessageEdit.Placeholder = new Rope.Leaf(loc.GetString("war-declarator-message-placeholder"));
MessageEdit.Placeholder = new Rope.Leaf(localizationManager.GetString("war-declarator-message-placeholder"));
}
protected override void Draw(DrawingHandleScreen handle)
protected override void FrameUpdate(FrameEventArgs args)
{
base.Draw(handle);
UpdateTimer();
}
public void UpdateState(WarDeclaratorBoundUserInterfaceState state)
{
WarButton.Disabled = state.Status != WarConditionStatus.YES_WAR;
if (state.Status == null)
return;
WarButton.Disabled = state.Status == WarConditionStatus.WarReady;
_timeStamp = state.Delay;
_endTime = state.EndTime;
_status = state.Status;
_shuttleDisabledTime = state.ShuttleDisabledTime;
_status = state.Status.Value;
switch(state.Status)
UpdateStatus(state.Status.Value);
}
private void UpdateStatus(WarConditionStatus status)
{
switch (status)
{
case WarConditionStatus.WAR_READY:
case WarConditionStatus.WarReady:
WarButton.Disabled = true;
StatusLabel.Text = Loc.GetString("war-declarator-boost-declared");
InfoLabel.Text = Loc.GetString("war-declarator-conditions-ready");
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateLow);
break;
case WarConditionStatus.WAR_DELAY:
StatusLabel.Text = Loc.GetString("war-declarator-boost-declared-delay");
UpdateTimer();
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateLow);
break;
case WarConditionStatus.YES_WAR:
case WarConditionStatus.YesWar:
WarButton.Text = Loc.GetString("war-declarator-ui-war-button");
StatusLabel.Text = Loc.GetString("war-declarator-boost-possible");
UpdateTimer();
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateGood);
break;
case WarConditionStatus.NO_WAR_SMALL_CREW:
case WarConditionStatus.NoWarSmallCrew:
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
InfoLabel.Text = Loc.GetString("war-declarator-conditions-small-crew", ("min", state.MinCrew));
InfoLabel.Text = Loc.GetString("war-declarator-conditions-small-crew");
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
break;
case WarConditionStatus.NO_WAR_SHUTTLE_DEPARTED:
case WarConditionStatus.NoWarShuttleDeparted:
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
InfoLabel.Text = Loc.GetString("war-declarator-conditions-left-outpost");
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
break;
case WarConditionStatus.NO_WAR_TIMEOUT:
case WarConditionStatus.NoWarTimeout:
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
InfoLabel.Text = Loc.GetString("war-declarator-conditions-time-out");
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
break;
case WarConditionStatus.NoWarUnknown:
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
InfoLabel.Text = Loc.GetString("war-declarator-conditions-unknown");
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
break;
default:
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
InfoLabel.Text = Loc.GetString("war-declarator-conditions-unknown");
@@ -86,43 +94,24 @@ public sealed partial class WarDeclaratorWindow : DefaultWindow
}
}
public void UpdateTimer()
private void UpdateTimer()
{
switch(_status)
{
case WarConditionStatus.YES_WAR:
var gameruleTime = _gameTiming.CurTime.Subtract(_timeStamp);
var timeLeft = _endTime.Subtract(gameruleTime);
case WarConditionStatus.YesWar:
var timeLeft = _endTime.Subtract(_gameTiming.CurTime);
if (timeLeft > TimeSpan.Zero)
{
InfoLabel.Text = Loc.GetString("war-declarator-boost-timer", ("minutes", timeLeft.Minutes), ("seconds", timeLeft.Seconds));
}
InfoLabel.Text = Loc.GetString("war-declarator-boost-timer", ("time", timeLeft.ToString("mm\\:ss")));
else
{
_status = WarConditionStatus.NO_WAR_TIMEOUT;
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
InfoLabel.Text = Loc.GetString("war-declarator-conditions-time-out");
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
WarButton.Disabled = true;
}
UpdateStatus(WarConditionStatus.NoWarTimeout);
break;
case WarConditionStatus.WAR_DELAY:
var timeAfterDeclaration = _gameTiming.CurTime.Subtract(_timeStamp);
var timeRemain = _endTime.Subtract(timeAfterDeclaration);
if (timeRemain > TimeSpan.Zero)
{
InfoLabel.Text = Loc.GetString("war-declarator-boost-timer", ("minutes", timeRemain.Minutes), ("seconds", timeRemain.Seconds));
}
case WarConditionStatus.WarReady:
var time = _shuttleDisabledTime.Subtract(_gameTiming.CurTime);
if (time > TimeSpan.Zero)
InfoLabel.Text = Loc.GetString("war-declarator-boost-timer", ("time", time.ToString("mm\\:ss")));
else
{
_status = WarConditionStatus.WAR_READY;
StatusLabel.Text = Loc.GetString("war-declarator-boost-declared");
InfoLabel.Text = Loc.GetString("war-declarator-conditions-ready");
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateLow);
WarButton.Disabled = true;
}
break;
default:
return;