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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user