This commit is contained in:
Rane
2022-02-17 21:43:24 -05:00
committed by GitHub
parent 94c56980cb
commit 8049a709e6
29 changed files with 323 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ using Content.Server.Atmos.Monitor.Components;
using Content.Server.Power.Components;
using Content.Shared.Atmos.Monitor;
using Content.Shared.Interaction;
using Content.Shared.Emag.Systems;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -16,6 +17,7 @@ namespace Content.Server.Atmos.Monitor.Systems
public override void Initialize()
{
SubscribeLocalEvent<FireAlarmComponent, InteractHandEvent>(OnInteractHand);
SubscribeLocalEvent<FireAlarmComponent, GotEmaggedEvent>(OnEmagged);
}
private void OnInteractHand(EntityUid uid, FireAlarmComponent component, InteractHandEvent args)
@@ -38,5 +40,18 @@ namespace Content.Server.Atmos.Monitor.Systems
}
}
}
private void OnEmagged(EntityUid uid, FireAlarmComponent component, GotEmaggedEvent args)
{
if (TryComp<AtmosMonitorComponent>(uid, out var atmosMonitor))
{
if (atmosMonitor?.MonitorFire == true)
{
atmosMonitor.MonitorFire = false;
_monitorSystem.Alert(uid, AtmosMonitorAlarmType.Emagged);
args.Handled = true;
}
}
}
}
}

View File

@@ -25,6 +25,7 @@ using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Chemistry.Components
{
@@ -45,7 +46,11 @@ namespace Content.Server.Chemistry.Components
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entities = default!;
[ViewVariables] [DataField("pack")] private string _packPrototypeId = "";
[ViewVariables] [DataField("pack", customTypeSerializer:typeof(PrototypeIdSerializer<ReagentDispenserInventoryPrototype>))] private string _packPrototypeId = "";
[ViewVariables] [DataField("emagPack", customTypeSerializer:typeof(PrototypeIdSerializer<ReagentDispenserInventoryPrototype>))] public string EmagPackPrototypeId = "";
public bool AlreadyEmagged = false;
[DataField("clickSound")]
private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
@@ -119,6 +124,24 @@ namespace Content.Server.Chemistry.Components
Inventory.Sort(_comparer);
}
public void AddFromPrototype(string pack)
{
if (string.IsNullOrEmpty(pack)) return;
if (!_prototypeManager.TryIndex(pack, out ReagentDispenserInventoryPrototype? packPrototype))
{
return;
}
foreach (var entry in packPrototype.Inventory)
{
Inventory.Add(new ReagentDispenserInventoryEntry(entry));
}
Inventory.Sort(_comparer);
}
private void OnPowerChanged(PowerChangedMessage e)
{
UpdateUserInterface();

View File

@@ -1,14 +1,17 @@
using Content.Server.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Emag.Systems;
using Content.Shared.Chemistry.Dispenser;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.EntitySystems
{
[UsedImplicitly]
public sealed class ReagentDispenserSystem : SharedReagentDispenserSystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
{
base.Initialize();
@@ -16,6 +19,17 @@ namespace Content.Server.Chemistry.EntitySystems
SubscribeLocalEvent<ReagentDispenserComponent, SolutionChangedEvent>((_, comp, _) => comp.UpdateUserInterface());
SubscribeLocalEvent<ReagentDispenserComponent, EntInsertedIntoContainerMessage>((_, comp, _) => comp.UpdateUserInterface());
SubscribeLocalEvent<ReagentDispenserComponent, EntRemovedFromContainerMessage>((_, comp, _) => comp.UpdateUserInterface());
SubscribeLocalEvent<ReagentDispenserComponent, GotEmaggedEvent>(OnEmagged);
}
private void OnEmagged(EntityUid uid, ReagentDispenserComponent comp, GotEmaggedEvent args)
{
if (!comp.AlreadyEmagged)
{
comp.AddFromPrototype(comp.EmagPackPrototypeId);
comp.AlreadyEmagged = true;
args.Handled = true;
}
}
}
}

View File

@@ -5,11 +5,13 @@ using Content.Server.Construction;
using Content.Server.Construction.Components;
using Content.Server.Tools;
using Content.Server.Tools.Components;
using Content.Server.Doors.Components;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Doors;
using Content.Shared.Doors.Components;
using Content.Shared.Doors.Systems;
using Content.Shared.Emag.Systems;
using Content.Shared.Interaction;
using Content.Shared.Tag;
using Robust.Shared.Audio;
@@ -39,6 +41,7 @@ public sealed class DoorSystem : SharedDoorSystem
SubscribeLocalEvent<DoorComponent, PryCancelledEvent>(OnPryCancelled);
SubscribeLocalEvent<DoorComponent, WeldFinishedEvent>(OnWeldFinished);
SubscribeLocalEvent<DoorComponent, WeldCancelledEvent>(OnWeldCancelled);
SubscribeLocalEvent<DoorComponent, GotEmaggedEvent>(OnEmagged);
}
protected override void OnInit(EntityUid uid, DoorComponent door, ComponentInit args)
@@ -303,6 +306,18 @@ public sealed class DoorSystem : SharedDoorSystem
if(!container.Insert(board))
Logger.Warning($"Couldn't insert board {ToPrettyString(board)} into door {ToPrettyString(uid)}!");
}
private void OnEmagged(EntityUid uid, DoorComponent door, GotEmaggedEvent args)
{
if(TryComp<AirlockComponent>(uid, out var airlockComponent))
{
if (door.State == DoorState.Closed)
{
StartOpening(uid);
airlockComponent?.SetBoltsWithAudio(!airlockComponent.IsBolted());
args.Handled = true;
}
}
}
}
public sealed class PryFinishedEvent : EntityEventArgs { }

View File

@@ -0,0 +1,32 @@
using Content.Shared.Emag.Components;
using Content.Shared.Emag.Systems;
namespace Content.Server.Emag
{
public sealed class EmagSystem : EntitySystem
{
public override void Update(float frameTime)
{
base.Update(frameTime);
foreach (var emag in EntityManager.EntityQuery<EmagComponent>())
{
if (emag.Charges == emag.MaxCharges)
{
emag.Accumulator = 0;
continue;
}
emag.Accumulator += frameTime;
if (emag.Accumulator < emag.RechargeTime)
{
continue;
}
emag.Accumulator -= emag.RechargeTime;
emag.Charges++;
}
}
}
}

View File

@@ -1,6 +1,8 @@
using Content.Server.Access.Components;
using Content.Server.Access.Systems;
using Content.Server.Storage.Components;
using Content.Shared.Emag.Systems;
using Content.Shared.Emag.Components;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Examine;
@@ -33,6 +35,7 @@ namespace Content.Server.Lock
SubscribeLocalEvent<LockComponent, ActivateInWorldEvent>(OnActivated);
SubscribeLocalEvent<LockComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<LockComponent, GetVerbsEvent<AlternativeVerb>>(AddToggleLockVerb);
SubscribeLocalEvent<LockComponent, GotEmaggedEvent>(OnEmagged);
}
private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args)
@@ -182,5 +185,23 @@ namespace Content.Server.Lock
// TODO VERB ICONS need padlock open/close icons.
args.Verbs.Add(verb);
}
private void OnEmagged(EntityUid uid, LockComponent component, GotEmaggedEvent args)
{
if (component.Locked == true)
{
if (component.UnlockSound != null)
{
SoundSystem.Play(Filter.Pvs(component.Owner), component.UnlockSound.GetSound(), component.Owner, AudioParams.Default.WithVolume(-5));
}
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComp))
{
appearanceComp.SetData(StorageVisuals.Locked, false);
}
EntityManager.RemoveComponent<LockComponent>(uid); //Literally destroys the lock as a tell it was emagged
args.Handled = true;
}
}
}
}

View File

@@ -29,6 +29,8 @@ public sealed class ApcComponent : BaseApcNetComponent
[ViewVariables]
public bool MainBreakerEnabled = true;
public bool Emagged = false;
public const float HighPowerThreshold = 0.9f;
public static TimeSpan VisualsChangeDelay = TimeSpan.FromSeconds(1);

View File

@@ -5,6 +5,7 @@ using Content.Server.Power.Pow3r;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.APC;
using Content.Shared.Emag.Systems;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -34,6 +35,7 @@ namespace Content.Server.Power.EntitySystems
SubscribeLocalEvent<ApcComponent, MapInitEvent>(OnApcInit);
SubscribeLocalEvent<ApcComponent, ChargeChangedEvent>(OnBatteryChargeChanged);
SubscribeLocalEvent<ApcComponent, ApcToggleMainBreakerMessage>(OnToggleMainBreaker);
SubscribeLocalEvent<ApcComponent, GotEmaggedEvent>(OnEmagged);
}
// Change the APC's state only when the battery state changes, or when it's first created.
@@ -68,6 +70,15 @@ namespace Content.Server.Power.EntitySystems
}
}
private void OnEmagged(EntityUid uid, ApcComponent comp, GotEmaggedEvent args)
{
if(!comp.Emagged)
{
comp.Emagged = true;
args.Handled = true;
}
}
public void UpdateApcState(EntityUid uid,
ApcComponent? apc=null,
BatteryComponent? battery=null)
@@ -115,6 +126,9 @@ namespace Content.Server.Power.EntitySystems
ApcComponent? apc=null,
BatteryComponent? battery=null)
{
if (apc != null && apc.Emagged)
return ApcChargeState.Emag;
if (!Resolve(uid, ref apc, ref battery))
return ApcChargeState.Lack;

View File

@@ -2,9 +2,11 @@ using Content.Server.Power.Components;
using Content.Server.Recycling.Components;
using Content.Shared.Body.Components;
using Content.Shared.Recycling;
using Content.Shared.Emag.Systems;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
namespace Content.Server.Recycling
{
@@ -14,6 +16,7 @@ namespace Content.Server.Recycling
{
base.Initialize();
SubscribeLocalEvent<RecyclerComponent, StartCollideEvent>(HandleCollide);
SubscribeLocalEvent<RecyclerComponent, GotEmaggedEvent>(OnEmagged);
}
private void HandleCollide(EntityUid uid, RecyclerComponent component, StartCollideEvent args)
@@ -53,5 +56,14 @@ namespace Content.Server.Recycling
appearance.SetData(RecyclerVisuals.Bloody, true);
}
}
private void OnEmagged(EntityUid uid, RecyclerComponent component, GotEmaggedEvent args)
{
if (component.Safe == true)
{
component.Safe = false;
args.Handled = true;
}
}
}
}