Emp more effects (#14550)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Slava0135
2023-05-06 04:38:09 +03:00
committed by GitHub
parent 7b667663fa
commit 4d47562dde
18 changed files with 245 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
using System.Linq;
using Content.Server.Cargo.Systems;
using Content.Server.Emp;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.UserInterface;
@@ -12,6 +13,7 @@ using Content.Shared.Destructible;
using Content.Shared.DoAfter;
using Content.Shared.Emag.Components;
using Content.Shared.Emag.Systems;
using Content.Shared.Emp;
using Content.Shared.Popups;
using Content.Shared.Throwing;
using Content.Shared.VendingMachines;
@@ -19,6 +21,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
namespace Content.Server.VendingMachines
{
@@ -31,6 +34,7 @@ namespace Content.Server.VendingMachines
[Dependency] private readonly PricingSystem _pricing = default!;
[Dependency] private readonly ThrowingSystem _throwingSystem = default!;
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
[Dependency] private readonly IGameTiming _timing = default!;
private ISawmill _sawmill = default!;
@@ -44,6 +48,7 @@ namespace Content.Server.VendingMachines
SubscribeLocalEvent<VendingMachineComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<VendingMachineComponent, DamageChangedEvent>(OnDamage);
SubscribeLocalEvent<VendingMachineComponent, PriceCalculationEvent>(OnVendingPrice);
SubscribeLocalEvent<VendingMachineComponent, EmpPulseEvent>(OnEmpPulse);
SubscribeLocalEvent<VendingMachineComponent, ActivatableUIOpenAttemptEvent>(OnActivatableUIOpenAttempt);
SubscribeLocalEvent<VendingMachineComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
@@ -437,6 +442,15 @@ namespace Content.Server.VendingMachines
}
}
}
var disabled = EntityQueryEnumerator<EmpDisabledComponent, VendingMachineComponent>();
while (disabled.MoveNext(out var uid, out _, out var comp))
{
if (comp.NextEmpEject < _timing.CurTime)
{
EjectRandom(uid, true, false, comp);
comp.NextEmpEject += TimeSpan.FromSeconds(5 * comp.EjectDelay);
}
}
}
public void TryRestockInventory(EntityUid uid, VendingMachineComponent? vendComponent = null)
@@ -473,5 +487,15 @@ namespace Content.Server.VendingMachines
args.Price += priceSets.Max();
}
private void OnEmpPulse(EntityUid uid, VendingMachineComponent component, ref EmpPulseEvent args)
{
if (!component.Broken && this.IsPowered(uid, EntityManager))
{
args.Affected = true;
args.Disabled = true;
component.NextEmpEject = _timing.CurTime;
}
}
}
}