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,38 +1,27 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Content.Shared.Database;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.StationEvents.Events;
|
||||
|
||||
/// <summary>
|
||||
/// An abstract entity system inherited by all station events for their behavior.
|
||||
/// </summary>
|
||||
public abstract partial class StationEventSystem<T> : GameRuleSystem<T> where T : IComponent
|
||||
public abstract class StationEventSystem<T> : GameRuleSystem<T> where T : IComponent
|
||||
{
|
||||
[Dependency] protected readonly IAdminLogManager AdminLogManager = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] protected readonly IMapManager MapManager = default!;
|
||||
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
|
||||
[Dependency] protected readonly ChatSystem ChatSystem = default!;
|
||||
[Dependency] protected readonly SharedAudioSystem Audio = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] protected readonly StationSystem StationSystem = default!;
|
||||
|
||||
protected ISawmill Sawmill = default!;
|
||||
@@ -60,7 +49,7 @@ public abstract partial class StationEventSystem<T> : GameRuleSystem<T> where T
|
||||
}
|
||||
|
||||
Audio.PlayGlobal(stationEvent.StartAudio, Filter.Broadcast(), true);
|
||||
stationEvent.StartTime = _timing.CurTime + stationEvent.StartDelay;
|
||||
stationEvent.StartTime = Timing.CurTime + stationEvent.StartDelay;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -79,7 +68,7 @@ public abstract partial class StationEventSystem<T> : GameRuleSystem<T> where T
|
||||
? stationEvent.Duration
|
||||
: TimeSpan.FromSeconds(RobustRandom.NextDouble(stationEvent.Duration.Value.TotalSeconds,
|
||||
stationEvent.MaxDuration.Value.TotalSeconds));
|
||||
stationEvent.EndTime = _timing.CurTime + duration;
|
||||
stationEvent.EndTime = Timing.CurTime + duration;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,11 +105,11 @@ public abstract partial class StationEventSystem<T> : GameRuleSystem<T> where T
|
||||
if (!GameTicker.IsGameRuleAdded(uid, ruleData))
|
||||
continue;
|
||||
|
||||
if (!GameTicker.IsGameRuleActive(uid, ruleData) && _timing.CurTime >= stationEvent.StartTime)
|
||||
if (!GameTicker.IsGameRuleActive(uid, ruleData) && Timing.CurTime >= stationEvent.StartTime)
|
||||
{
|
||||
GameTicker.StartGameRule(uid, ruleData);
|
||||
}
|
||||
else if (stationEvent.EndTime != null && _timing.CurTime >= stationEvent.EndTime && GameTicker.IsGameRuleActive(uid, ruleData))
|
||||
else if (stationEvent.EndTime != null && Timing.CurTime >= stationEvent.EndTime && GameTicker.IsGameRuleActive(uid, ruleData))
|
||||
{
|
||||
GameTicker.EndGameRule(uid, ruleData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user