Skip to content

Commit d8466b2

Browse files
Stop-Signssowelipililimute
authored andcommitted
Return of warops
1 parent 69a6bd4 commit d8466b2

File tree

7 files changed

+73
-4
lines changed

7 files changed

+73
-4
lines changed

Content.Server/GameTicking/Rules/Components/NukeopsRuleComponent.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Content.Server._DV.Antag; // DeltaV
12
using Content.Server.RoundEnd;
23
using Content.Shared.Dataset;
34
using Content.Shared.NPC.Prototypes;
@@ -8,7 +9,7 @@
89

910
namespace Content.Server.GameTicking.Rules.Components;
1011

11-
[RegisterComponent, Access(typeof(NukeopsRuleSystem))]
12+
[RegisterComponent, Access(typeof(NukeopsRuleSystem), typeof(NukieOperationSystem))] // DeltaV - Auto war declare
1213
public sealed partial class NukeopsRuleComponent : Component
1314
{
1415
/// <summary>

Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ public WarConditionStatus GetWarCondition(NukeopsRuleComponent nukieRule, WarCon
404404
return WarConditionStatus.YesWar;
405405
}
406406

407-
private void DistributeExtraTc(Entity<NukeopsRuleComponent> nukieRule)
407+
public void DistributeExtraTc(Entity<NukeopsRuleComponent> nukieRule) // DeltaV - Public so our war can work
408408
{
409409
var enumerator = EntityQueryEnumerator<StoreComponent>();
410410
while (enumerator.MoveNext(out var uid, out var component))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Content.Shared._DV.Antag;
2+
using Robust.Shared.Analyzers;
3+
4+
namespace Content.Server._DV.Antag;
5+
6+
[RegisterComponent, Access(typeof(NukieOperationSystem)), AutoGenerateComponentPause]
7+
public sealed partial class NukieAutoWarComponent : Component
8+
{
9+
/// <summary>
10+
/// Automatically calls war after set time.
11+
/// </summary>
12+
[DataField, AutoPausedField]
13+
public TimeSpan AutoWarCallTime;
14+
}

Content.Server/_DV/Antag/NukieOperationSystem.cs

+40-2
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,60 @@
11
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;
26
using Content.Server.Objectives;
37
using Content.Shared._DV.FeedbackOverwatch;
48
using Content.Shared.Mind;
59
using Content.Shared.Random.Helpers;
10+
using Robust.Shared.Audio;
611
using Robust.Shared.Prototypes;
712
using Robust.Shared.Random;
13+
using Robust.Shared.Timing;
814

915
namespace Content.Server._DV.Antag;
1016

1117
public sealed class NukieOperationSystem : EntitySystem
1218
{
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!;
1323
[Dependency] private readonly IRobustRandom _random = default!;
14-
[Dependency] private readonly SharedMindSystem _mind = default!;
24+
[Dependency] private readonly NukeopsRuleSystem _nukeops = default!;
1525
[Dependency] private readonly ObjectivesSystem _objectives = default!;
16-
[Dependency] private readonly IPrototypeManager _proto = default!;
1726
[Dependency] private readonly SharedFeedbackOverwatchSystem _feedback = default!;
27+
[Dependency] private readonly SharedMindSystem _mind = default!;
28+
1829
public override void Initialize()
1930
{
2031
base.Initialize();
2132

2233
SubscribeLocalEvent<NukieOperationComponent, AfterAntagEntitySelectedEvent>(OnAntagSelected);
2334
SubscribeLocalEvent<GetNukeCodePaperWriting>(OnNukeCodePaperWritingEvent);
2435
}
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+
}
2558

2659
private void OnAntagSelected(Entity<NukieOperationComponent> ent, ref AfterAntagEntitySelectedEvent args)
2760
{
@@ -54,6 +87,11 @@ private void OnAntagSelected(Entity<NukieOperationComponent> ent, ref AfterAntag
5487
if (objectiveProto.Id == "KidnapHeadsObjective")
5588
_feedback.SendPopupMind(mindId, "NukieHostageRoundStartPopup");
5689
}
90+
if (chosenOp.AutoWarAfter is { } duration)
91+
{
92+
var autoWar = EnsureComp<NukieAutoWarComponent>(ent);
93+
autoWar.AutoWarCallTime = _time.CurTime + duration;
94+
}
5795
}
5896

5997
private void OnNukeCodePaperWritingEvent(ref GetNukeCodePaperWriting ev)

Content.Shared/_DV/Antag/NukieOperationPrototype.cs

+6
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,10 @@ public sealed partial class NukieOperationPrototype : IPrototype
1717

1818
[DataField]
1919
public LocId? NukeCodePaperOverride;
20+
21+
/// <summary>
22+
/// If non-null, calls war after the given duration
23+
/// </summary>
24+
[DataField]
25+
public TimeSpan? AutoWarAfter;
2026
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Played when war is automatically called
2+
3+
nuke-ops-auto-war-message = Our intelligence indicates that a hostile boarding party is enroute to your location.

Resources/Prototypes/_DV/Objectives/nukies.yml

+7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44
id: NukieOperations
55
weights:
66
NukieOperationDestroyStation: 1
7+
NukieOperationDestroyStationWar: 1
78
# NukieOperationKidnapHeads: 1
89

910
- type: nukieOperation
1011
id: NukieOperationDestroyStation
1112
operationObjectives:
1213
- NukeStationObjective
1314

15+
- type: nukieOperation
16+
id: NukieOperationDestroyStationWar
17+
autoWarAfter: 120
18+
operationObjectives:
19+
- NukeStationObjective
20+
1421
- type: nukieOperation
1522
id: NukieOperationKidnapHeads
1623
operationObjectives:

0 commit comments

Comments
 (0)