-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graytide Virus Event #1293
Merged
VMSolidus
merged 5 commits into
Simple-Station:master
from
VMSolidus:Greytide-Virus-Event
Jan 2, 2025
Merged
Graytide Virus Event #1293
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fdfb1fd
Graytide Virus Event
VMSolidus b9f11df
Merge branch 'master' into Greytide-Virus-Event
sleepyyapril 6dfdaf4
Update AirlockVirusRuleComponent.cs
sleepyyapril 67ed36b
Merge branch 'master' into Greytide-Virus-Event
sleepyyapril 7fd866a
Eliminate the second loop
VMSolidus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
Content.Server/StationEvents/Components/AirlockVirusRuleComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Content.Server.StationEvents.Events; | ||
|
||
namespace Content.Server.StationEvents.Components; | ||
|
||
[RegisterComponent] | ||
public sealed partial class AirlockVirusRuleComponent : Component | ||
{ | ||
/// <summary> | ||
/// The minimum amount of time in seconds before each infected door is self-emagged. | ||
/// </summary> | ||
[DataField] | ||
public int MinimumTimeToEmag = 30; | ||
|
||
/// <summary> | ||
/// The maximum amount of time in seconds before each infected door is self-emagged. | ||
/// </summary> | ||
[DataField] | ||
public int MaximumTimeToEmag = 120; | ||
} |
4 changes: 4 additions & 0 deletions
4
Content.Server/StationEvents/Components/AirlockVirusTargetComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace Content.Server.StationEvents.Components; | ||
|
||
[RegisterComponent] | ||
public sealed partial class AirlockVirusTargetComponent : Component { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Content.Server.StationEvents.Components; | ||
using Content.Shared.GameTicking.Components; | ||
using JetBrains.Annotations; | ||
using Robust.Shared.Player; | ||
using Robust.Shared.Random; | ||
using Content.Server.Announcements.Systems; | ||
using Content.Server.GameTicking; | ||
using Content.Shared.Emag.Systems; | ||
using Robust.Shared.Timing; | ||
using Content.Server.Station.Components; | ||
using Content.Server.Station.Systems; | ||
|
||
namespace Content.Server.StationEvents.Events; | ||
|
||
[UsedImplicitly] | ||
public sealed class AirlockVirusRule : StationEventSystem<AirlockVirusRuleComponent> | ||
{ | ||
[Dependency] private readonly AnnouncerSystem _announcer = default!; | ||
[Dependency] private readonly GameTicker _gameTicker = default!; | ||
[Dependency] private readonly EmagSystem _emag = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly StationSystem _station = default!; | ||
|
||
protected override void Started(EntityUid uid, AirlockVirusRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) | ||
{ | ||
base.Started(uid, component, gameRule, args); | ||
|
||
var station = _gameTicker.GetSpawnableStations(); | ||
if (station is null) | ||
return; | ||
var stationGrids = new HashSet<EntityUid>(); | ||
foreach (var stations in station) | ||
{ | ||
if (TryComp<StationDataComponent>(stations, out var data) && _station.GetLargestGrid(data) is { } grid) | ||
stationGrids.Add(grid); | ||
} | ||
|
||
var query = EntityManager.EntityQueryEnumerator<AirlockVirusTargetComponent>(); | ||
List<EntityUid> airlocks = new(); | ||
while (query.MoveNext(out var airlockUid, out var _)) | ||
{ | ||
var parent = Transform(airlockUid).GridUid; | ||
if (parent is null | ||
|| !stationGrids.Contains(parent!.Value)) | ||
continue; | ||
|
||
airlocks.Add(airlockUid); | ||
} | ||
foreach (var target in airlocks) | ||
Timer.Spawn(TimeSpan.FromSeconds(_random.NextDouble(component.MinimumTimeToEmag, component.MaximumTimeToEmag)), () => | ||
_emag.DoEmagEffect(uid, target)); | ||
|
||
_announcer.SendAnnouncement( | ||
_announcer.GetAnnouncementId(args.RuleId), | ||
Filter.Broadcast(), | ||
"airlock-virus-event-announcement", | ||
null, | ||
Color.FromHex("#18abf5"), | ||
null, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
airlock-virus-event-announcement = We have detected a GR4YT1D3 virus in the station's systems. Engineering staff are to inspect all station equipment for malfunctions and affect repairs if necessary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can probably remove the whole
airlocks
list and do it inside thewhile
blockThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fatally allergic to while loops lmao. I'm horribly foreachpilled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're iterating over the airlocks twice basically. First time you're gathering them in
while
querry, next time you're applying effects to them. This is simply redundantThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh. Actually I see how you're right. gimme a few minutes to drop the PR I'm about to drop and I'll do this right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! There is now no longer a second loop. If an airlock passes the check, it targets that airlock with the emag timer.