Files
tbd-station-14/Content.Client/Strip/StrippableSystem.cs
metalgearsloth 5896e68752 Content update for UI prediction (#27214)
* Content update for UI refactor

* Big update

* Sharing

* Remaining content updates

* First big update

* Prototype updates

* AUGH

* Fix UI comp ref

* Cleanup

- Fix predicted message, fix item slots, fix interaction range check.

* Fix regressions

* Make this predictive

idk why it wasn't.

* Fix slime merge

* Merge conflict

* Fix merge
2024-04-26 18:16:24 +10:00

45 lines
1.5 KiB
C#

using Content.Client.Inventory;
using Content.Shared.Cuffs.Components;
using Content.Shared.Ensnaring.Components;
using Content.Shared.Hands;
using Content.Shared.Inventory.Events;
using Content.Shared.Strip;
using Content.Shared.Strip.Components;
namespace Content.Client.Strip;
/// <summary>
/// This is the client-side stripping system, which just triggers UI updates on events.
/// </summary>
public sealed class StrippableSystem : SharedStrippableSystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<StrippableComponent, CuffedStateChangeEvent>(OnCuffStateChange);
SubscribeLocalEvent<StrippableComponent, DidEquipEvent>(UpdateUi);
SubscribeLocalEvent<StrippableComponent, DidUnequipEvent>(UpdateUi);
SubscribeLocalEvent<StrippableComponent, DidEquipHandEvent>(UpdateUi);
SubscribeLocalEvent<StrippableComponent, DidUnequipHandEvent>(UpdateUi);
SubscribeLocalEvent<StrippableComponent, EnsnaredChangedEvent>(UpdateUi);
}
private void OnCuffStateChange(EntityUid uid, StrippableComponent component, ref CuffedStateChangeEvent args)
{
UpdateUi(uid, component);
}
public void UpdateUi(EntityUid uid, StrippableComponent? component = null, EntityEventArgs? args = null)
{
if (!TryComp(uid, out UserInterfaceComponent? uiComp))
return;
foreach (var ui in uiComp.ClientOpenInterfaces.Values)
{
if (ui is StrippableBoundUserInterface stripUi)
stripUi.DirtyMenu();
}
}
}