|
1 | 1 | using Content.Server.Antag;
|
| 2 | +using Content.Server.Chat.Systems; |
| 3 | +using Content.Server.GameTicking; |
| 4 | +using Content.Server.GameTicking.Rules; |
| 5 | +using Content.Server.GameTicking.Rules.Components; |
2 | 6 | using Content.Server.Objectives;
|
3 | 7 | using Content.Shared._DV.FeedbackOverwatch;
|
4 | 8 | using Content.Shared.Mind;
|
5 | 9 | using Content.Shared.Random.Helpers;
|
| 10 | +using Robust.Shared.Audio; |
6 | 11 | using Robust.Shared.Prototypes;
|
7 | 12 | using Robust.Shared.Random;
|
| 13 | +using Robust.Shared.Timing; |
8 | 14 |
|
9 | 15 | namespace Content.Server._DV.Antag;
|
10 | 16 |
|
11 | 17 | public sealed class NukieOperationSystem : EntitySystem
|
12 | 18 | {
|
| 19 | + [Dependency] private readonly ChatSystem _chat = default!; |
| 20 | + [Dependency] private readonly GameTicker _ticker = default!; |
| 21 | + [Dependency] private readonly IGameTiming _time = default!; |
| 22 | + [Dependency] private readonly IPrototypeManager _proto = default!; |
13 | 23 | [Dependency] private readonly IRobustRandom _random = default!;
|
14 |
| - [Dependency] private readonly SharedMindSystem _mind = default!; |
| 24 | + [Dependency] private readonly NukeopsRuleSystem _nukeops = default!; |
15 | 25 | [Dependency] private readonly ObjectivesSystem _objectives = default!;
|
16 |
| - [Dependency] private readonly IPrototypeManager _proto = default!; |
17 | 26 | [Dependency] private readonly SharedFeedbackOverwatchSystem _feedback = default!;
|
| 27 | + [Dependency] private readonly SharedMindSystem _mind = default!; |
| 28 | + |
18 | 29 | public override void Initialize()
|
19 | 30 | {
|
20 | 31 | base.Initialize();
|
21 | 32 |
|
22 | 33 | SubscribeLocalEvent<NukieOperationComponent, AfterAntagEntitySelectedEvent>(OnAntagSelected);
|
23 | 34 | SubscribeLocalEvent<GetNukeCodePaperWriting>(OnNukeCodePaperWritingEvent);
|
24 | 35 | }
|
| 36 | + /// <summary> |
| 37 | + /// This runs the automatic war declaration, distributes TC, and makes sure it only happens when it's not hostage ops. |
| 38 | + /// </summary> |
| 39 | + public override void Update(float frameTime) |
| 40 | + { |
| 41 | + base.Update(frameTime); |
| 42 | + |
| 43 | + var query = EntityQueryEnumerator<NukieAutoWarComponent>(); |
| 44 | + while (query.MoveNext(out var uid, out var comp)) |
| 45 | + { |
| 46 | + if (_time.CurTime < comp.AutoWarCallTime) |
| 47 | + continue; |
| 48 | + |
| 49 | + RemCompDeferred<NukieAutoWarComponent>(uid); |
| 50 | + var nukeops = Comp<NukeopsRuleComponent>(uid); |
| 51 | + nukeops.WarDeclaredTime = _time.CurTime; |
| 52 | + _nukeops.DistributeExtraTc((uid, nukeops)); |
| 53 | + _chat.DispatchGlobalAnnouncement(Loc.GetString("nuke-ops-auto-war-message"), |
| 54 | + Loc.GetString("chat-manager-sender-announcement"), |
| 55 | + true, new SoundPathSpecifier("/Audio/Announcements/war.ogg"), Color.DarkRed); |
| 56 | + } |
| 57 | + } |
25 | 58 |
|
26 | 59 | private void OnAntagSelected(Entity<NukieOperationComponent> ent, ref AfterAntagEntitySelectedEvent args)
|
27 | 60 | {
|
@@ -54,6 +87,11 @@ private void OnAntagSelected(Entity<NukieOperationComponent> ent, ref AfterAntag
|
54 | 87 | if (objectiveProto.Id == "KidnapHeadsObjective")
|
55 | 88 | _feedback.SendPopupMind(mindId, "NukieHostageRoundStartPopup");
|
56 | 89 | }
|
| 90 | + if (chosenOp.AutoWarAfter is { } duration) |
| 91 | + { |
| 92 | + var autoWar = EnsureComp<NukieAutoWarComponent>(ent); |
| 93 | + autoWar.AutoWarCallTime = _time.CurTime + duration; |
| 94 | + } |
57 | 95 | }
|
58 | 96 |
|
59 | 97 | private void OnNukeCodePaperWritingEvent(ref GetNukeCodePaperWriting ev)
|
|
0 commit comments