Fix two interaction prediction issues (#7356)
This commit is contained in:
@@ -3,13 +3,13 @@ namespace Content.Shared.Emag.Components
|
||||
[RegisterComponent]
|
||||
public sealed class EmagComponent : Component
|
||||
{
|
||||
[DataField("maxCharges")]
|
||||
[DataField("maxCharges"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public int MaxCharges = 3;
|
||||
|
||||
[DataField("charges")]
|
||||
[DataField("charges"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public int Charges = 3;
|
||||
|
||||
[DataField("rechargeTime")]
|
||||
[DataField("rechargeTime"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float RechargeTime = 90f;
|
||||
public float Accumulator = 0f;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Shared.Emag.Systems
|
||||
{
|
||||
@@ -15,13 +10,9 @@ namespace Content.Shared.Emag.Systems
|
||||
/// 4. Past the check, add all the effects you desire and HANDLE THE EVENT ARGUMENT so a charge is spent
|
||||
public sealed class SharedEmagSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly SharedAdminLogSystem _adminLog = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<EmagComponent, AfterInteractEvent>(OnAfterInteract);
|
||||
SubscribeLocalEvent<EmagComponent, ExaminedEvent>(OnExamine);
|
||||
}
|
||||
|
||||
@@ -36,28 +27,6 @@ namespace Content.Shared.Emag.Systems
|
||||
}
|
||||
args.PushMarkup(Loc.GetString("emag-recharging", ("seconds", Math.Round(timeRemaining))));
|
||||
}
|
||||
|
||||
private void OnAfterInteract(EntityUid uid, EmagComponent component, AfterInteractEvent args)
|
||||
{
|
||||
if (!args.CanReach || args.Target == null)
|
||||
return;
|
||||
|
||||
if (component.Charges <= 0)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("emag-no-charges"), args.User, Filter.Entities(args.User));
|
||||
return;
|
||||
}
|
||||
|
||||
var emaggedEvent = new GotEmaggedEvent(args.User);
|
||||
RaiseLocalEvent(args.Target.Value, emaggedEvent, false);
|
||||
if (emaggedEvent.Handled)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("emag-success",("target", args.Target)), args.User, Filter.Entities(args.User));
|
||||
_adminLog.Add(LogType.Emag, LogImpact.High, $"{ToPrettyString(args.User):player} emagged {ToPrettyString(args.Target.Value):target}");
|
||||
component.Charges--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class GotEmaggedEvent : HandledEntityEventArgs
|
||||
@@ -66,7 +35,7 @@ namespace Content.Shared.Emag.Systems
|
||||
|
||||
public GotEmaggedEvent(EntityUid userUid)
|
||||
{
|
||||
userUid = UserUid;
|
||||
UserUid = userUid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user