Skip to content
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

Intercept rule #10

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Content.Server/AlertLevel/AlertLevelSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ private void OnPrototypeReload(PrototypesReloadedEventArgs args)
RaiseLocalEvent(new AlertLevelPrototypeReloadedEvent());
}

public string GetLevel(EntityUid station, AlertLevelComponent? alert = null)
{
if (!Resolve(station, ref alert))
{
return string.Empty;
}

return alert.CurrentLevel;
}

public float GetAlertLevelDelay(EntityUid station, AlertLevelComponent? alert = null)
{
if (!Resolve(station, ref alert))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Content.Server.StationEvents.Events;
using Content.Server.AlertLevel;
using Robust.Shared.Prototypes;

namespace Content.Server.StationEvents.Components;

[RegisterComponent, Access(typeof(CommunicationInterceptionRule))]
public sealed partial class CommunicationInterceptionRuleComponent : Component
{
/// <summary>
/// Alert level to set the station to when the event starts.
/// </summary>
[DataField]
public ProtoId<AlertLevelPrototype> AlertLevel = "yellow";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Server.GameTicking.Rules.Components;
using Content.Server.StationEvents.Components;
using Content.Server.AlertLevel;
using Content.Server.Chat.Systems;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;

namespace Content.Server.StationEvents.Events;

public sealed class CommunicationInterceptionRule : StationEventSystem<CommunicationInterceptionRuleComponent>
{
[Dependency] private readonly AlertLevelSystem _alertLevelSystem = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;

protected override void Started(EntityUid uid, CommunicationInterceptionRuleComponent component, GameRuleComponent gameRule,

Check failure on line 16 in Content.Server/StationEvents/Events/CommunicationInterceptionRule.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'GameRuleComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 16 in Content.Server/StationEvents/Events/CommunicationInterceptionRule.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'GameRuleComponent' could not be found (are you missing a using directive or an assembly reference?)
GameRuleStartedEvent args)

Check failure on line 17 in Content.Server/StationEvents/Events/CommunicationInterceptionRule.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'GameRuleStartedEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 17 in Content.Server/StationEvents/Events/CommunicationInterceptionRule.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'GameRuleStartedEvent' could not be found (are you missing a using directive or an assembly reference?)
{
base.Started(uid, component, gameRule, args);

if (!TryGetRandomStation(out var chosenStation))
return;

if (_alertLevelSystem.GetLevel(chosenStation.Value) != "green")
return;

_alertLevelSystem.SetLevel(chosenStation.Value, component.AlertLevel, true, true, true);
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString("station-event-communication-interception"), playSound: false, colorOverride: Color.Gold);
_audioSystem.PlayGlobal("/Audio/Announcements/intercept.ogg", Filter.Broadcast(), true);
}
}
5 changes: 5 additions & 0 deletions Resources/Audio/Announcements/attributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@
license: "CC-BY-SA-3.0"
copyright: "Paradise, volume and pitch changed, merged with redalert.ogg"
source: "https://github.com/ParadiseSS13/Paradise/blob/07b26ee6b4a11a0607986d322ee007020569feae/sound/effects/siren.ogg"

- files: ["intercept.ogg"]
license: "CC-BY-SA-3.0"
copyright: "Taken from tgstation"
source: "https://github.com/tgstation/tgstation/blob/95731342b97167d7883ff091d389f79c36442ee6/sound/ai/default/intercept.ogg"
Binary file added Resources/Audio/Announcements/intercept.ogg
Binary file not shown.
1 change: 1 addition & 0 deletions Resources/Locale/en-US/station-events/events/intercept.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
station-event-communication-interception = Attention! Enemy communication intercepted. Security level elevated.
10 changes: 10 additions & 0 deletions Resources/Prototypes/GameRules/events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,16 @@
minimumPlayers: 20
- type: ImmovableRodRule

- type: entity
id: CommunicationInterception
parent: BaseGameRule
noSpawn: true
components:
- type: StationEvent
weight: 10
earliestStart: 5
- type: CommunicationInterceptionRule

- type: entity
noSpawn: true
parent: BaseGameRule
Expand Down
Loading