More minor UI refactor changes (#11213)

This commit is contained in:
wrexbe
2022-09-11 21:30:11 -07:00
committed by GitHub
parent 2acae9e833
commit b3f75f9ffe
21 changed files with 34 additions and 45 deletions

View File

@@ -16,6 +16,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
protected Action<SharedHandsComponent?>? OnHandSetActive;
public override void Initialize()
{
base.Initialize();
@@ -29,7 +31,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
CommandBinds.Unregister<SharedHandsSystem>();
}
public void AddHand(EntityUid uid, string handName, HandLocation handLocation, SharedHandsComponent? handsComp = null)
public virtual void AddHand(EntityUid uid, string handName, HandLocation handLocation, SharedHandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp, false))
return;
@@ -51,7 +53,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
Dirty(handsComp);
}
public void RemoveHand(EntityUid uid, string handName, SharedHandsComponent? handsComp = null)
public virtual void RemoveHand(EntityUid uid, string handName, SharedHandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp, false))
return;
@@ -154,7 +156,6 @@ public abstract partial class SharedHandsSystem : EntitySystem
Hand? hand = null;
if (name != null && !handComp.Hands.TryGetValue(name, out hand))
return false;
return SetActiveHand(uid, hand, handComp);
}
@@ -163,7 +164,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// </summary>
/// <returns>True if the active hand was set to a NEW value. Setting it to the same value returns false and does
/// not trigger interactions.</returns>
public virtual bool SetActiveHand(EntityUid uid, Hand? hand, SharedHandsComponent? handComp = null)
public bool SetActiveHand(EntityUid uid, Hand? hand, SharedHandsComponent? handComp = null)
{
if (!Resolve(uid, ref handComp))
return false;
@@ -181,10 +182,10 @@ public abstract partial class SharedHandsSystem : EntitySystem
}
handComp.ActiveHand = hand;
OnHandSetActive?.Invoke(handComp);
if (hand.HeldEntity != null)
RaiseLocalEvent(hand.HeldEntity.Value, new HandSelectedEvent(uid), false);
Dirty(handComp);
return true;
}