Skip to content

Commit

Permalink
more systems use AnnouncerSystem, update template
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Feb 18, 2024
1 parent d6aa388 commit 9bf9b0b
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void OnAnnouncementReceived(AnnouncementSendEvent ev)
if (!ev.Recipients.Contains(_player.LocalSession!.UserId))
return;

var resource = _cache.GetResource<AudioResource>(_announcer.GetAnnouncementPath(ev.AnnouncementId, ev.AnnouncerId)!);
var resource = _cache.GetResource<AudioResource>(_announcer.GetAnnouncementPath(ev.AnnouncementId, ev.AnnouncerId));
var source = _audioManager.CreateAudioSource(resource);

if (source != null)
Expand Down
16 changes: 4 additions & 12 deletions Content.Server/AlertLevel/AlertLevelSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Server.Chat.Systems;
using Content.Server.SimpleStation14.Announcements.Systems;
using Content.Server.Station.Systems;
using Content.Shared.CCVar;
using Robust.Shared.Audio;
Expand All @@ -16,6 +17,7 @@ public sealed class AlertLevelSystem : EntitySystem
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

// Until stations are a prototype, this is how it's going to have to be.
public const string DefaultAlertLevelSet = "stationAlerts";
Expand Down Expand Up @@ -162,24 +164,14 @@ public void SetLevel(EntityUid station, string level, bool playSound, bool annou
// The full announcement to be spat out into chat.
var announcementFull = Loc.GetString("alert-level-announcement", ("name", name), ("announcement", announcement));

var playDefault = false;
if (playSound)
{
if (detail.Sound != null)
{
var filter = _stationSystem.GetInOwningStation(station);
_audio.PlayGlobal(detail.Sound.GetSound(), filter, true, detail.Sound.Params);
}
else
{
playDefault = true;
}
_announcer.SendAnnouncementAudio($"alert{level.ToLower()}", _stationSystem.GetInOwningStation(station)); // Parkstation-RandomAnnouncers
}

if (announce)
{
_chatSystem.DispatchStationAnnouncement(station, announcementFull, playDefaultSound: playDefault,
colorOverride: detail.Color, sender: stationName);
_announcer.SendAnnouncementMessage($"alert{level.ToLower()}", announcementFull, colorOverride: detail.Color);
}

RaiseLocalEvent(new AlertLevelChangedEvent(station, level));
Expand Down
5 changes: 4 additions & 1 deletion Content.Server/Chat/Systems/AnnounceOnSpawnSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using Content.Server.Chat;
using Content.Server.SimpleStation14.Announcements.Systems;
using Robust.Shared.Player;

namespace Content.Server.Chat.Systems;

public sealed class AnnounceOnSpawnSystem : EntitySystem
{
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

public override void Initialize()
{
Expand All @@ -17,6 +20,6 @@ private void OnInit(EntityUid uid, AnnounceOnSpawnComponent comp, MapInitEvent a
{
var message = Loc.GetString(comp.Message);
var sender = comp.Sender != null ? Loc.GetString(comp.Sender) : "Central Command";
_chat.DispatchGlobalAnnouncement(message, sender, playSound: true, comp.Sound, comp.Color);
_announcer.SendAnnouncement("spawnannounce", Filter.Broadcast(), message, sender, comp.Color); // Parkstation-RandomAnnouncers
}
}
5 changes: 4 additions & 1 deletion Content.Server/Communications/CommsHackerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Content.Server.Chat.Systems;
using Content.Server.GameTicking;
using Content.Server.Ninja.Systems;
using Content.Server.SimpleStation14.Announcements.Systems;
using Content.Shared.Communications;
using Content.Shared.DoAfter;
using Content.Shared.Interaction;
using Content.Shared.Random;
using Content.Shared.Random.Helpers;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
Expand All @@ -21,6 +23,7 @@ public sealed class CommsHackerSystem : SharedCommsHackerSystem
// TODO: remove when generic check event is used
[Dependency] private readonly NinjaGlovesSystem _gloves = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -79,7 +82,7 @@ private void OnDoAfter(EntityUid uid, CommsHackerComponent comp, TerrorDoAfterEv
public void CallInThreat(NinjaHackingThreatPrototype ninjaHackingThreat)
{
_gameTicker.StartGameRule(ninjaHackingThreat.Rule, out _);
_chat.DispatchGlobalAnnouncement(Loc.GetString(ninjaHackingThreat.Announcement), playSound: true, colorOverride: Color.Red);
_announcer.SendAnnouncement("ninjahacking", Filter.Broadcast(), Loc.GetString(ninjaHackingThreat.Announcement), colorOverride: Color.Red); // Parkstation-RandomAnnouncers
}
}

Expand Down
5 changes: 3 additions & 2 deletions Content.Server/Dragon/DragonRiftSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager;
using System.Numerics;
using Content.Server.SimpleStation14.Announcements.Systems;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;

Expand All @@ -27,6 +28,7 @@ public sealed class DragonRiftSystem : EntitySystem
[Dependency] private readonly NavMapSystem _navMap = default!;
[Dependency] private readonly NPCSystem _npc = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -70,8 +72,7 @@ public override void Update(float frameTime)
Dirty(comp);

var location = xform.LocalPosition;
_chat.DispatchGlobalAnnouncement(Loc.GetString("carp-rift-warning", ("location", location)), playSound: false, colorOverride: Color.Red);
_audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true);
_announcer.SendAnnouncement("carprift", Filter.Broadcast(), Loc.GetString("carp-rift-warning", ("location", location)), colorOverride: Color.Red); // Parkstation-RandomAnnouncers
_navMap.SetBeaconEnabled(uid, true);
}

Expand Down
4 changes: 3 additions & 1 deletion Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Shuttles.Systems;
using Content.Server.SimpleStation14.Announcements.Systems;
using Content.Server.Spawners.Components;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
Expand Down Expand Up @@ -86,6 +87,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly WarDeclaratorSystem _warDeclarator = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;


[ValidatePrototypeId<CurrencyPrototype>]
Expand Down Expand Up @@ -211,7 +213,7 @@ public void DeclareWar(EntityUid opsUid, string msg, string title, SoundSpecifie

var nukieRule = comps.Value.Item1;
nukieRule.WarDeclaredTime = _gameTiming.CurTime;
_chat.DispatchGlobalAnnouncement(msg, title, announcementSound: announcementSound, colorOverride: colorOverride);
_announcer.SendAnnouncement("war", Filter.Broadcast(), msg, title, colorOverride); // Parkstation-RandomAnnouncers
DistributeExtraTC(nukieRule);
_warDeclarator.RefreshAllUI(comps.Value.Item1, comps.Value.Item2);
}
Expand Down
4 changes: 3 additions & 1 deletion Content.Server/GameTicking/Rules/ZombieRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Content.Server.Preferences.Managers;
using Content.Server.Roles;
using Content.Server.RoundEnd;
using Content.Server.SimpleStation14.Announcements.Systems;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.Zombies;
Expand Down Expand Up @@ -49,6 +50,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
[Dependency] private readonly SharedRoleSystem _roles = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -128,7 +130,7 @@ private void CheckRoundEnd()
comp.ShuttleCalled = true;
foreach (var station in _station.GetStations())
{
_chat.DispatchStationAnnouncement(station, Loc.GetString("zombie-shuttle-call"), colorOverride: Color.Crimson);
_announcer.SendAnnouncement("shuttlecalled", _station.GetInOwningStation(station), Loc.GetString("zombie-shuttle-call"), colorOverride: Color.Crimson); // Parkstation-RandomAnnouncers
}
_roundEnd.RequestRoundEnd(null, false);
}
Expand Down
5 changes: 4 additions & 1 deletion Content.Server/Nuke/NukeCodePaperSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using Content.Server.Chat.Systems;
using Content.Server.Fax;
using Content.Server.Paper;
using Content.Server.SimpleStation14.Announcements.Systems;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.Paper;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Utility;

Expand All @@ -17,6 +19,7 @@ public sealed class NukeCodePaperSystem : EntitySystem
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly PaperSystem _paper = default!;
[Dependency] private readonly FaxSystem _faxSystem = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -79,7 +82,7 @@ public bool SendNukeCodes(EntityUid station)
if (wasSent)
{
var msg = Loc.GetString("nuke-component-announcement-send-codes");
_chatSystem.DispatchStationAnnouncement(station, msg, colorOverride: Color.Red);
_announcer.SendAnnouncement("nukecodes", Filter.Broadcast(), msg, colorOverride: Color.Red); // Parkstation-AnnouncerSystem
}

return wasSent;
Expand Down
7 changes: 4 additions & 3 deletions Content.Server/Nuke/NukeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Server.Explosion.EntitySystems;
using Content.Server.Pinpointer;
using Content.Server.Popups;
using Content.Server.SimpleStation14.Announcements.Systems;
using Content.Server.Station.Systems;
using Content.Shared.Audio;
using Content.Shared.Containers.ItemSlots;
Expand Down Expand Up @@ -40,6 +41,7 @@ public sealed class NukeSystem : EntitySystem
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

/// <summary>
/// Used to calculate when the nuke song should start playing for maximum kino with the nuke sfx
Expand Down Expand Up @@ -455,7 +457,7 @@ public void ArmBomb(EntityUid uid, NukeComponent? component = null)
var announcement = Loc.GetString("nuke-component-announcement-armed",
("time", (int) component.RemainingTime), ("position", posText));
var sender = Loc.GetString("nuke-component-announcement-sender");
_chatSystem.DispatchStationAnnouncement(stationUid ?? uid, announcement, sender, false, null, Color.Red);
_announcer.SendAnnouncementMessage("nukearm", announcement, sender, Color.Red, stationUid ?? uid); // Parkstation-RandomAnnouncers

_sound.PlayGlobalOnStation(uid, _audio.GetSound(component.ArmSound));

Expand Down Expand Up @@ -493,7 +495,7 @@ public void DisarmBomb(EntityUid uid, NukeComponent? component = null)
// warn a crew
var announcement = Loc.GetString("nuke-component-announcement-unarmed");
var sender = Loc.GetString("nuke-component-announcement-sender");
_chatSystem.DispatchStationAnnouncement(uid, announcement, sender, false);
_announcer.SendAnnouncementMessage("nukedisarm", announcement, sender, station: stationUid ?? uid); // Parkstation-RandomAnnouncers

component.PlayedNukeSong = false;
_sound.PlayGlobalOnStation(uid, _audio.GetSound(component.DisarmSound));
Expand Down Expand Up @@ -604,4 +606,3 @@ public sealed class NukeDisarmSuccessEvent : EntityEventArgs
{

}

9 changes: 3 additions & 6 deletions Content.Server/PowerSink/PowerSinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Examine;
using Robust.Shared.Utility;
using Content.Server.Chat.Systems;
using Content.Server.SimpleStation14.Announcements.Systems;
using Content.Server.Station.Systems;
using Robust.Shared.Timing;
using Robust.Shared.Audio;
Expand Down Expand Up @@ -31,6 +32,7 @@ public sealed class PowerSinkSystem : EntitySystem
[Dependency] private readonly ExplosionSystem _explosionSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -133,12 +135,7 @@ private void NotifyStationOfImminentExplosion(EntityUid uid, PowerSinkComponent
if (station == null)
return;

_chat.DispatchStationAnnouncement(
station.Value,
Loc.GetString("powersink-immiment-explosion-announcement"),
playDefaultSound: true,
colorOverride: Color.Yellow
);
_announcer.SendAnnouncement("powersinkexplosion", _station.GetInOwningStation(station.Value), Loc.GetString("powersink-immiment-explosion-announcement"), colorOverride: Color.Yellow, station: station.Value); // Parkstation-RandomAnnouncers
}
}
}
7 changes: 5 additions & 2 deletions Content.Server/RoundEnd/RoundEndSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,12 @@ public void DoRoundEndBehavior(RoundEndBehavior behavior,
// Check is shuttle called or not. We should only dispatch announcement if it's already called
if (IsRoundEndRequested())
{
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString(textAnnounce),
_announcer.SendAnnouncement("shuttlecalled", // Parkstation-RandomAnnouncers
Filter.Broadcast(),
Loc.GetString(textAnnounce),
Loc.GetString(sender),
colorOverride: Color.Gold);
Color.Gold
);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public sealed class SharedAnnouncerSystem : EntitySystem
/// </summary>
/// <param name="announcementId">ID of the announcement from the announcer to get information for</param>
/// <param name="announcerId">ID of the announcer to use instead of the current one</param>
public string? GetAnnouncementPath(string announcementId, string announcerId)
public string GetAnnouncementPath(string announcementId, string announcerId)
{
if (!_proto.TryIndex<AnnouncerPrototype>(announcerId, out var announcer))
return null;
return "";

// Get the announcement data from the announcer
// Will be the fallback if the data for the announcementId is not found
Expand Down
15 changes: 12 additions & 3 deletions Resources/Prototypes/SimpleStation14/Announcers/template
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
id: Announcer # Localized as "announcer-<id>-name" in chat
basePath: /Audio/Codebase/Announcements/Announcer # Where to start looking for audio files
baseAudioParams: # Default audio parameters for all announcements, all options explained later
volume: -7 # if this example is really loud, lower it to match the others' volume
volume: -7 # If this announcer is really loud, lower it to match the others' volume
announcements: # List of all announcements this announcer has audio for, comment out unused ones - don't remove them
# Template
- id: template # Lowercase of the event ID, add "-complete" to the end for post-event announcements (endings)
ignoreBasePath: false # If true, it will ignore the basePath and use the path as is
path: template.ogg # Path to the file relative to basePath/, named with snake_case except for "-complete"
collection: AnnouncerTemplateAnnouncements # Collection of audios to randomly use for this, will ignore path if set - Ignores basePath automatically!
message: announcer-announcement-template # Localization key for the announcement message to use instead of the default one
message: announcer-announcement-template # Localization key for the announcement message to use instead of the default one - NOTE this does not pass through previous loc args yet
audioParams: # Overrides baseAudioParams entirely for this specific announcement, numbers are all floats
attenuation: LinearDistanceClamped # See AudioParams.cs for info - default is here
volume: 3 # We don't want announcement volumes to vary too much - default is here
pitch: 1 # Default is here
playOffsetSeconds: 0 # How many seconds into the audio to start from - default is here
Expand All @@ -36,6 +35,12 @@
path: spawn_announce.ogg
- id: war # Nuclear Operative declaration of war
path: war.ogg
- id: nukecodes # The station has been send nuclear activation codes
path: nuke_codes.ogg # Or command_report.ogg if you want
- id: nukearm # The nuke is active and ticking
path: nuke_arm.ogg
- id: nukedisarm # The nuke has been disarmed
path: nuke_disarm.ogg

# Alert levels
- id: alertgreen # Everything is fine
Expand All @@ -62,6 +67,8 @@
### Mid-Round Antagonists
- id: deathmatch # Everyone is going to kill each other
path: death_match.ogg
- id: powersinkexplosion # A power sink is about to overcharge and explode
path: powersink_explosion.ogg
### Events
- id: anomalyspawn # An anomaly has spawned in a random place
path: anomaly.ogg
Expand All @@ -77,6 +84,8 @@
path: clerical_error.ogg
- id: dragonspawn # A dragon has spawned in a random place
path: dragon_spawn.ogg
- id: carprift # A dragon's carp rift is active
path: carp_rift.ogg
- id: revenantspawn # A revenant has spawned (by a prober?)
path: revenant_spawn.ogg
- id: gasleak # A random gas is coming out of a random vent
Expand Down

0 comments on commit 9bf9b0b

Please sign in to comment.