predict emag and make blessed record struct events (#13623)
This commit is contained in:
@@ -74,7 +74,7 @@ public sealed class FireAlarmSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, FireAlarmComponent component, GotEmaggedEvent args)
|
||||
private void OnEmagged(EntityUid uid, FireAlarmComponent component, ref GotEmaggedEvent args)
|
||||
{
|
||||
if (TryComp<AtmosAlarmableComponent>(uid, out var alarmable))
|
||||
{
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Content.Server.Bed
|
||||
UpdateMetabolisms(uid, component, args.Powered);
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, StasisBedComponent component, GotEmaggedEvent args)
|
||||
private void OnEmagged(EntityUid uid, StasisBedComponent component, ref GotEmaggedEvent args)
|
||||
{
|
||||
// Repeatable
|
||||
// Reset any metabolisms first so they receive the multiplier correctly
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
return inventory;
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, ReagentDispenserComponent reagentDispenser, GotEmaggedEvent args)
|
||||
private void OnEmagged(EntityUid uid, ReagentDispenserComponent reagentDispenser, ref GotEmaggedEvent args)
|
||||
{
|
||||
if (!reagentDispenser.IsEmagged)
|
||||
{
|
||||
|
||||
@@ -267,7 +267,7 @@ public sealed class DoorSystem : SharedDoorSystem
|
||||
if (Tags.HasTag(otherUid, "DoorBumpOpener"))
|
||||
TryOpen(uid, door, otherUid);
|
||||
}
|
||||
private void OnEmagged(EntityUid uid, DoorComponent door, GotEmaggedEvent args)
|
||||
private void OnEmagged(EntityUid uid, DoorComponent door, ref GotEmaggedEvent args)
|
||||
{
|
||||
if(TryComp<AirlockComponent>(uid, out var airlockComponent))
|
||||
{
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Emag
|
||||
{
|
||||
public sealed class EmagSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<EmagComponent, AfterInteractEvent>(OnAfterInteract);
|
||||
}
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAfterInteract(EntityUid uid, EmagComponent component, AfterInteractEvent args)
|
||||
{
|
||||
if (!args.CanReach || args.Target == null)
|
||||
return;
|
||||
|
||||
if (_tagSystem.HasTag(args.Target.Value, "EmagImmune"))
|
||||
return;
|
||||
|
||||
if (component.Charges <= 0)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("emag-no-charges"), args.User, args.User);
|
||||
return;
|
||||
}
|
||||
|
||||
var handled = DoEmag(args.Target, args.User);
|
||||
if (handled)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("emag-success", ("target", Identity.Entity(args.Target.Value, EntityManager))), args.User,
|
||||
args.User, PopupType.Medium);
|
||||
_adminLogger.Add(LogType.Emag, LogImpact.High, $"{ToPrettyString(args.User):player} emagged {ToPrettyString(args.Target.Value):target}");
|
||||
component.Charges--;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DoEmag(EntityUid? target, EntityUid? user)
|
||||
{
|
||||
if (target == null || user == null)
|
||||
return false;
|
||||
|
||||
var emaggedEvent = new GotEmaggedEvent(user.Value);
|
||||
RaiseLocalEvent(target.Value, emaggedEvent, false);
|
||||
return emaggedEvent.Handled;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -226,7 +226,7 @@ public sealed class FaxSystem : EntitySystem
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, FaxMachineComponent component, GotEmaggedEvent args)
|
||||
private void OnEmagged(EntityUid uid, FaxMachineComponent component, ref GotEmaggedEvent args)
|
||||
{
|
||||
if (component.Emagged)
|
||||
return;
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace Content.Server.Lock
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, LockComponent component, GotEmaggedEvent args)
|
||||
private void OnEmagged(EntityUid uid, LockComponent component, ref GotEmaggedEvent args)
|
||||
{
|
||||
if (component.Locked)
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
SoundSystem.Play(apc.OnReceiveMessageSound.GetSound(), Filter.Pvs(uid), uid, AudioParams.Default.WithVolume(-2f));
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, ApcComponent comp, GotEmaggedEvent args)
|
||||
private void OnEmagged(EntityUid uid, ApcComponent comp, ref GotEmaggedEvent args)
|
||||
{
|
||||
if(!comp.Emagged)
|
||||
{
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace Content.Server.Recycling
|
||||
QueueDel(component.Owner);
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, RecyclerComponent component, GotEmaggedEvent args)
|
||||
private void OnEmagged(EntityUid uid, RecyclerComponent component, ref GotEmaggedEvent args)
|
||||
{
|
||||
if (!component.Safe) return;
|
||||
component.Safe = false;
|
||||
|
||||
@@ -5,7 +5,6 @@ using Content.Shared.Revenant;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Map;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Light.Components;
|
||||
using Content.Server.Ghost;
|
||||
@@ -18,12 +17,10 @@ using Content.Server.Disease.Components;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using System.Linq;
|
||||
using Content.Server.Beam;
|
||||
using Content.Server.Emag;
|
||||
using Content.Server.Humanoid;
|
||||
using Content.Server.Maps;
|
||||
using Content.Server.Revenant.Components;
|
||||
using Content.Server.Store.Components;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Mobs;
|
||||
@@ -339,7 +336,7 @@ public sealed partial class RevenantSystem
|
||||
|
||||
foreach (var ent in _lookup.GetEntitiesInRange(uid, component.MalfunctionRadius))
|
||||
{
|
||||
_emag.DoEmag(ent, ent); //it emags itself. spooky.
|
||||
_emag.DoEmagEffect(ent, ent); //it emags itself. spooky.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Content.Server.VendingMachines
|
||||
TryUpdateVisualState(uid, vendComponent);
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, VendingMachineComponent component, GotEmaggedEvent args)
|
||||
private void OnEmagged(EntityUid uid, VendingMachineComponent component, ref GotEmaggedEvent args)
|
||||
{
|
||||
if (component.Emagged || component.EmaggedInventory.Count == 0 )
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user