predict emag and make blessed record struct events (#13623)

This commit is contained in:
Nemanja
2023-01-21 10:12:45 -05:00
committed by GitHub
parent fec54b7cb2
commit d87d8f2886
17 changed files with 255 additions and 158 deletions

View File

@@ -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))
{

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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))
{

View File

@@ -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;
}
}
}

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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.
}
}
}

View File

@@ -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;