Predict EMP Examine (#39419)
* another one bites the dust * Update Content.Shared/Emp/SharedEmpSystem.cs --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -2,8 +2,6 @@ using Content.Server.Power.EntitySystems;
|
|||||||
using Content.Server.Radio;
|
using Content.Server.Radio;
|
||||||
using Content.Server.SurveillanceCamera;
|
using Content.Server.SurveillanceCamera;
|
||||||
using Content.Shared.Emp;
|
using Content.Shared.Emp;
|
||||||
using Content.Shared.Examine;
|
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
namespace Content.Server.Emp;
|
namespace Content.Server.Emp;
|
||||||
@@ -11,14 +9,12 @@ namespace Content.Server.Emp;
|
|||||||
public sealed class EmpSystem : SharedEmpSystem
|
public sealed class EmpSystem : SharedEmpSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||||
[Dependency] private readonly TransformSystem _transform = default!;
|
|
||||||
|
|
||||||
public const string EmpPulseEffectPrototype = "EffectEmpPulse";
|
public const string EmpPulseEffectPrototype = "EffectEmpPulse";
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<EmpDisabledComponent, ExaminedEvent>(OnExamine);
|
|
||||||
|
|
||||||
SubscribeLocalEvent<EmpDisabledComponent, RadioSendAttemptEvent>(OnRadioSendAttempt);
|
SubscribeLocalEvent<EmpDisabledComponent, RadioSendAttemptEvent>(OnRadioSendAttempt);
|
||||||
SubscribeLocalEvent<EmpDisabledComponent, RadioReceiveAttemptEvent>(OnRadioReceiveAttempt);
|
SubscribeLocalEvent<EmpDisabledComponent, RadioReceiveAttemptEvent>(OnRadioReceiveAttempt);
|
||||||
@@ -77,15 +73,15 @@ public sealed class EmpSystem : SharedEmpSystem
|
|||||||
{
|
{
|
||||||
var ev = new EmpPulseEvent(energyConsumption, false, false, TimeSpan.FromSeconds(duration));
|
var ev = new EmpPulseEvent(energyConsumption, false, false, TimeSpan.FromSeconds(duration));
|
||||||
RaiseLocalEvent(uid, ref ev);
|
RaiseLocalEvent(uid, ref ev);
|
||||||
|
|
||||||
if (ev.Affected)
|
if (ev.Affected)
|
||||||
{
|
|
||||||
Spawn(EmpDisabledEffectPrototype, Transform(uid).Coordinates);
|
Spawn(EmpDisabledEffectPrototype, Transform(uid).Coordinates);
|
||||||
}
|
|
||||||
if (ev.Disabled)
|
if (!ev.Disabled)
|
||||||
{
|
return;
|
||||||
var disabled = EnsureComp<EmpDisabledComponent>(uid);
|
|
||||||
disabled.DisabledUntil = Timing.CurTime + TimeSpan.FromSeconds(duration);
|
var disabled = EnsureComp<EmpDisabledComponent>(uid);
|
||||||
}
|
disabled.DisabledUntil = Timing.CurTime + TimeSpan.FromSeconds(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
@@ -104,11 +100,6 @@ public sealed class EmpSystem : SharedEmpSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExamine(EntityUid uid, EmpDisabledComponent component, ExaminedEvent args)
|
|
||||||
{
|
|
||||||
args.PushMarkup(Loc.GetString("emp-disabled-comp-on-examine"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRadioSendAttempt(EntityUid uid, EmpDisabledComponent component, ref RadioSendAttemptEvent args)
|
private void OnRadioSendAttempt(EntityUid uid, EmpDisabledComponent component, ref RadioSendAttemptEvent args)
|
||||||
{
|
{
|
||||||
args.Cancelled = true;
|
args.Cancelled = true;
|
||||||
@@ -133,9 +124,7 @@ public sealed class EmpSystem : SharedEmpSystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised on an entity before <see cref="EmpPulseEvent"/>. Cancel this to prevent the emp event being raised.
|
/// Raised on an entity before <see cref="EmpPulseEvent"/>. Cancel this to prevent the emp event being raised.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class EmpAttemptEvent : CancellableEntityEventArgs
|
public sealed partial class EmpAttemptEvent : CancellableEntityEventArgs;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public record struct EmpPulseEvent(float EnergyConsumption, bool Affected, bool Disabled, TimeSpan Duration);
|
public record struct EmpPulseEvent(float EnergyConsumption, bool Affected, bool Disabled, TimeSpan Duration);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Shared.Examine;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
@@ -7,6 +8,13 @@ public abstract class SharedEmpSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] protected readonly IGameTiming Timing = default!;
|
[Dependency] protected readonly IGameTiming Timing = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<EmpDisabledComponent, ExaminedEvent>(OnExamine);
|
||||||
|
}
|
||||||
|
|
||||||
protected const string EmpDisabledEffectPrototype = "EffectEmpDisabled";
|
protected const string EmpDisabledEffectPrototype = "EffectEmpDisabled";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -19,4 +27,9 @@ public abstract class SharedEmpSystem : EntitySystem
|
|||||||
public virtual void EmpPulse(MapCoordinates coordinates, float range, float energyConsumption, float duration)
|
public virtual void EmpPulse(MapCoordinates coordinates, float range, float energyConsumption, float duration)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnExamine(Entity<EmpDisabledComponent> ent, ref ExaminedEvent args)
|
||||||
|
{
|
||||||
|
args.PushMarkup(Loc.GetString("emp-disabled-comp-on-examine"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user