Emitters now give alerts if interfered with. (#39513)

* tesloose alert

* forgot to remove this when I removed naming the unlocker

* and these too...

* migrate to Entity<T> and clarify emitter lines

---------

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
This commit is contained in:
Super
2026-02-07 11:46:59 +00:00
committed by GitHub
parent 980cb75ef5
commit 993c316b6c
4 changed files with 61 additions and 0 deletions

View File

@@ -4,9 +4,14 @@ using Content.Server.Administration.Logs;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Projectiles;
using Content.Server.Pinpointer;
using Content.Server.Radio.EntitySystems;
using Content.Server.Weapons.Ranged.Systems;
using Content.Shared.Construction;
using Content.Shared.Database;
using Content.Shared.Destructible;
using Content.Shared.DeviceLinking.Events;
using Content.Shared.Emag.Systems;
using Content.Shared.Interaction;
using Content.Shared.Lock;
using Content.Shared.Popups;
@@ -33,6 +38,8 @@ namespace Content.Server.Singularity.EntitySystems
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly ProjectileSystem _projectile = default!;
[Dependency] private readonly GunSystem _gun = default!;
[Dependency] private readonly RadioSystem _radio = default!;
[Dependency] private readonly NavMapSystem _navMap = default!;
public override void Initialize()
{
@@ -43,6 +50,9 @@ namespace Content.Server.Singularity.EntitySystems
SubscribeLocalEvent<EmitterComponent, ActivateInWorldEvent>(OnActivate);
SubscribeLocalEvent<EmitterComponent, AnchorStateChangedEvent>(OnAnchorStateChanged);
SubscribeLocalEvent<EmitterComponent, SignalReceivedEvent>(OnSignalReceived);
SubscribeLocalEvent<EmitterComponent, DestructionAttemptEvent>(OnDestructionAttempted);
SubscribeLocalEvent<EmitterComponent, MachineDeconstructedEvent>(OnDeconstructed); // you shouldn't be able to deconstruct locked emitters but out of scope to fix
SubscribeLocalEvent<EmitterComponent, LockToggledEvent>(OnLockToggled);
}
private void OnAnchorStateChanged(EntityUid uid, EmitterComponent component, ref AnchorStateChangedEvent args)
@@ -164,6 +174,8 @@ namespace Content.Server.Singularity.EntitySystems
return;
}
AlertRadio((uid, component), "unpowered");
component.IsPowered = false;
// Must be set while emitter powered.
@@ -284,5 +296,38 @@ namespace Content.Server.Singularity.EntitySystems
component.BoltType = boltType;
}
}
private void OnDestructionAttempted(Entity<EmitterComponent> ent, ref DestructionAttemptEvent args)
{
// warn engineering their containment engine needs IMMEDIATE repairs
// this doesn't change much for natural loosing through emitter destruction given any meteor warning serves the same purpose
// can also be used to scare engineering though given it broadcasts its location you need a renamed station beacon to really scare them
AlertRadio(ent, "destroyed");
}
private void OnDeconstructed(Entity<EmitterComponent> ent, ref MachineDeconstructedEvent args)
{
// right now you don't even need to unlock the emitter to deconstruct it. that's almost certainly a bug but even without it it probably still needs an alert
AlertRadio(ent, "deconstructed");
}
private void AlertRadio(Entity<EmitterComponent> ent, string type)
{
if (!ent.Comp.AlertRadio || !ent.Comp.IsOn || !ent.Comp.IsPowered)
return; // APEs do not need to scream over engineering radio, and an emitter that is off is probably not going to be alerting radios
var message = Loc.GetString("emitter-" + type + "-broadcast",
("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString(ent.Owner)))
);
_radio.SendRadioMessage(ent.Owner, message, ent.Comp.RadioChannel, ent.Owner);
}
private void OnLockToggled(Entity<EmitterComponent> ent, ref LockToggledEvent args)
{
if (args.Locked)
return;
AlertRadio(ent, "unlocked");
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Threading;
using Content.Shared.DeviceLinking;
using Content.Shared.Radio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
@@ -96,6 +97,12 @@ public sealed partial class EmitterComponent : Component
/// </summary>
[DataField]
public Dictionary<ProtoId<SinkPortPrototype>, EntProtoId> SetTypePorts = new();
[DataField]
public ProtoId<RadioChannelPrototype> RadioChannel = "Engineering";
[DataField]
public bool AlertRadio = false; // is this emitter critical to the station to the point a radio channel should be alerted if anything happens to it (i.e. emitters near singularity/tesla containment)
}
[NetSerializable, Serializable]

View File

@@ -13,3 +13,8 @@ comp-emitter-not-anchored = The {$target} isn't anchored to the ground!
emitter-component-current-type = The current selected type is: [color=yellow]{$type}[/color].
emitter-component-type-set = Type set to: {$type}
emitter-destroyed-broadcast = A powered emitter {$location} has been destroyed.
emitter-deconstructed-broadcast = A powered {$location} has been deconstructed.
emitter-unlocked-broadcast = A powered {$location} has been unlocked.
emitter-unpowered-broadcast = A powered {$location} has lost power.

View File

@@ -36,6 +36,7 @@
visible: false
map: ["enum.LockVisualLayers.Lock"]
- type: Emitter
alertRadio: true
- type: Gun
showExamineText: false
fireRate: 10 #just has to be fast enough to keep up with upgrades
@@ -55,6 +56,9 @@
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: StructuralMetallicStrong
- type: ActiveRadio
channels:
- Engineering
- type: Destructible
thresholds:
- trigger: