mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-02-14 23:14:45 +01:00
Fix broken vending machine UI behavior (#42110)
* Fix broken vending machine UI behavior * begone --------- Co-authored-by: beck-thompson <beck314159@hotmail.com>
This commit is contained in:
@@ -6,11 +6,9 @@ using Content.Server.Vocalization.Systems;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Emp;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.UserInterface;
|
||||
using Content.Shared.VendingMachines;
|
||||
using Content.Shared.Wall;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -31,12 +29,10 @@ namespace Content.Server.VendingMachines
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<VendingMachineComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
SubscribeLocalEvent<VendingMachineComponent, BreakageEventArgs>(OnBreak);
|
||||
SubscribeLocalEvent<VendingMachineComponent, DamageChangedEvent>(OnDamageChanged);
|
||||
SubscribeLocalEvent<VendingMachineComponent, PriceCalculationEvent>(OnVendingPrice);
|
||||
SubscribeLocalEvent<VendingMachineComponent, TryVocalizeEvent>(OnTryVocalize);
|
||||
|
||||
SubscribeLocalEvent<VendingMachineComponent, ActivatableUIOpenAttemptEvent>(OnActivatableUIOpenAttempt);
|
||||
SubscribeLocalEvent<VendingMachineComponent, VendingMachineSelfDispenseEvent>(OnSelfDispense);
|
||||
|
||||
SubscribeLocalEvent<VendingMachineRestockComponent, PriceCalculationEvent>(OnPriceCalculation);
|
||||
@@ -70,24 +66,11 @@ namespace Content.Server.VendingMachines
|
||||
}
|
||||
}
|
||||
|
||||
private void OnActivatableUIOpenAttempt(EntityUid uid, VendingMachineComponent component, ActivatableUIOpenAttemptEvent args)
|
||||
{
|
||||
if (component.Broken)
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, VendingMachineComponent component, ref PowerChangedEvent args)
|
||||
{
|
||||
TryUpdateVisualState((uid, component));
|
||||
}
|
||||
|
||||
private void OnBreak(EntityUid uid, VendingMachineComponent vendComponent, BreakageEventArgs eventArgs)
|
||||
{
|
||||
vendComponent.Broken = true;
|
||||
Dirty(uid, vendComponent);
|
||||
TryUpdateVisualState((uid, vendComponent));
|
||||
}
|
||||
|
||||
private void OnDamageChanged(EntityUid uid, VendingMachineComponent component, DamageChangedEvent args)
|
||||
{
|
||||
if (!args.DamageIncreased && component.Broken)
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Advertise.Components;
|
||||
using Content.Shared.Advertise.Systems;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.Emag.Systems;
|
||||
@@ -10,6 +11,7 @@ using Content.Shared.Emp;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Power.EntitySystems;
|
||||
using Content.Shared.UserInterface;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
@@ -43,6 +45,8 @@ public abstract partial class SharedVendingMachineSystem : EntitySystem
|
||||
SubscribeLocalEvent<VendingMachineComponent, GotEmaggedEvent>(OnEmagged);
|
||||
SubscribeLocalEvent<VendingMachineComponent, EmpPulseEvent>(OnEmpPulse);
|
||||
SubscribeLocalEvent<VendingMachineComponent, RestockDoAfterEvent>(OnRestockDoAfter);
|
||||
SubscribeLocalEvent<VendingMachineComponent, ActivatableUIOpenAttemptEvent>(OnActivatableUIOpenAttempt);
|
||||
SubscribeLocalEvent<VendingMachineComponent, BreakageEventArgs>(OnBreak);
|
||||
|
||||
SubscribeLocalEvent<VendingMachineRestockComponent, AfterInteractEvent>(OnAfterInteract);
|
||||
|
||||
@@ -425,4 +429,19 @@ public abstract partial class SharedVendingMachineSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnActivatableUIOpenAttempt(EntityUid uid, VendingMachineComponent component, ActivatableUIOpenAttemptEvent args)
|
||||
{
|
||||
if (component.Broken)
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnBreak(EntityUid uid, VendingMachineComponent vendComponent, BreakageEventArgs eventArgs)
|
||||
{
|
||||
vendComponent.Broken = true;
|
||||
Dirty(uid, vendComponent);
|
||||
TryUpdateVisualState((uid, vendComponent));
|
||||
|
||||
UISystem.CloseUi(uid, VendingMachineUiKey.Key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user