Improve stripping UI (#9768)
This commit is contained in:
@@ -2,12 +2,15 @@ using System.Linq;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Hands.Systems;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Cuffs.Components;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Server.Containers;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -17,9 +20,6 @@ using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Cuffs.Components
|
||||
{
|
||||
[ByRefEvent]
|
||||
public readonly struct CuffedStateChangeEvent {}
|
||||
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedCuffableComponent))]
|
||||
public sealed class CuffableComponent : SharedCuffableComponent
|
||||
@@ -39,18 +39,12 @@ namespace Content.Server.Cuffs.Components
|
||||
|
||||
public IReadOnlyList<EntityUid> StoredEntities => Container.ContainedEntities;
|
||||
|
||||
/// <summary>
|
||||
/// Container of various handcuffs currently applied to the entity.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public Container Container { get; set; } = default!;
|
||||
|
||||
private bool _uncuffing;
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
Container = _sysMan.GetEntitySystem<ContainerSystem>().EnsureContainer<Container>(Owner, _componentFactory.GetComponentName(GetType()));
|
||||
|
||||
Owner.EnsureComponentWarn<HandsComponent>();
|
||||
}
|
||||
|
||||
@@ -101,19 +95,19 @@ namespace Content.Server.Cuffs.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
var sys = _sysMan.GetEntitySystem<SharedHandsSystem>();
|
||||
var sys = _entMan.EntitySysManager.GetEntitySystem<SharedHandsSystem>();
|
||||
|
||||
// Success!
|
||||
sys.TryDrop(user, handcuff);
|
||||
|
||||
Container.Insert(handcuff);
|
||||
CanStillInteract = _entMan.TryGetComponent(Owner, out HandsComponent? ownerHands) && ownerHands.Hands.Count() > CuffedHandCount;
|
||||
_sysMan.GetEntitySystem<ActionBlockerSystem>().UpdateCanMove(Owner);
|
||||
_entMan.EntitySysManager.GetEntitySystem<ActionBlockerSystem>().UpdateCanMove(Owner);
|
||||
|
||||
var ev = new CuffedStateChangeEvent();
|
||||
_entMan.EventBus.RaiseLocalEvent(Owner, ref ev, true);
|
||||
UpdateAlert();
|
||||
UpdateHeldItems();
|
||||
UpdateHeldItems(handcuff);
|
||||
Dirty(_entMan);
|
||||
return true;
|
||||
}
|
||||
@@ -126,29 +120,43 @@ namespace Content.Server.Cuffs.Components
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check how many items the user is holding and if it's more than the number of cuffed hands, drop some items.
|
||||
/// Adds virtual cuff items to the user's hands.
|
||||
/// </summary>
|
||||
public void UpdateHeldItems()
|
||||
public void UpdateHeldItems(EntityUid handcuff)
|
||||
{
|
||||
// TODO when ecs-ing this, we probably don't just want to use the generic virtual-item entity, and instead
|
||||
// want to add our own item, so that use-in-hand triggers an uncuff attempt and the like.
|
||||
|
||||
if (!_entMan.TryGetComponent(Owner, out HandsComponent? handsComponent)) return;
|
||||
|
||||
var sys = _sysMan.GetEntitySystem<SharedHandsSystem>();
|
||||
var handSys = _entMan.EntitySysManager.GetEntitySystem<SharedHandsSystem>();
|
||||
|
||||
var freeHandCount = handsComponent.Hands.Count() - CuffedHandCount;
|
||||
|
||||
foreach (var hand in handsComponent.Hands.Values)
|
||||
var freeHands = 0;
|
||||
foreach (var hand in handSys.EnumerateHands(Owner, handsComponent))
|
||||
{
|
||||
if (hand.IsEmpty)
|
||||
continue;
|
||||
|
||||
if (freeHandCount > 0)
|
||||
if (hand.HeldEntity == null)
|
||||
{
|
||||
freeHandCount--;
|
||||
freeHands++;
|
||||
continue;
|
||||
}
|
||||
|
||||
sys.TryDrop(Owner, hand, checkActionBlocker: false, handsComp: handsComponent);
|
||||
// Is this entity removable? (it might be an existing handcuff blocker)
|
||||
if (_entMan.HasComponent<UnremoveableComponent>(hand.HeldEntity))
|
||||
continue;
|
||||
|
||||
handSys.DoDrop(Owner, hand, true, handsComponent);
|
||||
freeHands++;
|
||||
if (freeHands == 2)
|
||||
break;
|
||||
}
|
||||
|
||||
var virtSys = _entMan.EntitySysManager.GetEntitySystem<HandVirtualItemSystem>();
|
||||
|
||||
if (virtSys.TrySpawnVirtualItemInHand(handcuff, Owner, out var virtItem1))
|
||||
_entMan.EnsureComponent<UnremoveableComponent>(virtItem1.Value);
|
||||
|
||||
if (virtSys.TrySpawnVirtualItemInHand(handcuff, Owner, out var virtItem2))
|
||||
_entMan.EnsureComponent<UnremoveableComponent>(virtItem2.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -247,7 +255,7 @@ namespace Content.Server.Cuffs.Components
|
||||
{
|
||||
SoundSystem.Play(cuff.EndUncuffSound.GetSound(), Filter.Pvs(Owner), Owner);
|
||||
|
||||
Container.ForceRemove(cuffsToRemove.Value);
|
||||
_entMan.EntitySysManager.GetEntitySystem<HandVirtualItemSystem>().DeleteInHandsMatching(user, cuffsToRemove.Value);
|
||||
_entMan.EntitySysManager.GetEntitySystem<SharedHandsSystem>().PickupOrDrop(user, cuffsToRemove.Value);
|
||||
|
||||
if (cuff.BreakOnRemove)
|
||||
@@ -264,12 +272,9 @@ namespace Content.Server.Cuffs.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (_entMan.TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
CanStillInteract = handsComponent.SortedHands.Count() > CuffedHandCount;
|
||||
else
|
||||
CanStillInteract = true;
|
||||
CanStillInteract = _entMan.TryGetComponent(Owner, out HandsComponent? handsComponent) && handsComponent.SortedHands.Count() > CuffedHandCount;
|
||||
_entMan.EntitySysManager.GetEntitySystem<ActionBlockerSystem>().UpdateCanMove(Owner);
|
||||
|
||||
_sysMan.GetEntitySystem<ActionBlockerSystem>().UpdateCanMove(Owner);
|
||||
var ev = new CuffedStateChangeEvent();
|
||||
_entMan.EventBus.RaiseLocalEvent(Owner, ref ev, true);
|
||||
UpdateAlert();
|
||||
|
||||
@@ -179,6 +179,8 @@ namespace Content.Server.Cuffs.Components
|
||||
|
||||
Cuffing = false;
|
||||
|
||||
// TODO these pop-ups need third-person variants (i.e. {$user} is cuffing {$target}!
|
||||
|
||||
if (result != DoAfterStatus.Cancelled)
|
||||
{
|
||||
if (cuffs.TryAddNewCuffs(user, Owner))
|
||||
|
||||
@@ -8,6 +8,9 @@ using Content.Shared.Verbs;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Player;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Content.Server.Hands.Systems;
|
||||
using Content.Shared.MobState.EntitySystems;
|
||||
|
||||
namespace Content.Server.Cuffs
|
||||
@@ -16,6 +19,7 @@ namespace Content.Server.Cuffs
|
||||
public sealed class CuffableSystem : SharedCuffableSystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||
[Dependency] private readonly HandVirtualItemSystem _virtualSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
@@ -28,6 +32,13 @@ namespace Content.Server.Cuffs
|
||||
SubscribeLocalEvent<UncuffAttemptEvent>(OnUncuffAttempt);
|
||||
SubscribeLocalEvent<CuffableComponent, GetVerbsEvent<Verb>>(AddUncuffVerb);
|
||||
SubscribeLocalEvent<HandcuffComponent, AfterInteractEvent>(OnCuffAfterInteract);
|
||||
SubscribeLocalEvent<CuffableComponent, EntRemovedFromContainerMessage>(OnCuffsRemoved);
|
||||
}
|
||||
|
||||
private void OnCuffsRemoved(EntityUid uid, CuffableComponent component, EntRemovedFromContainerMessage args)
|
||||
{
|
||||
if (args.Container.ID == component.Container.ID)
|
||||
_virtualSystem.DeleteInHandsMatching(uid, args.Entity);
|
||||
}
|
||||
|
||||
private void AddUncuffVerb(EntityUid uid, CuffableComponent component, GetVerbsEvent<Verb> args)
|
||||
@@ -62,6 +73,8 @@ namespace Content.Server.Cuffs
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO these messages really need third-party variants. I.e., "{$user} starts cuffing {$target}!"
|
||||
|
||||
if (component.Broken)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("handcuff-component-cuffs-broken-error"), args.User, Filter.Entities(args.User));
|
||||
@@ -93,7 +106,7 @@ namespace Content.Server.Cuffs
|
||||
else
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("handcuff-component-start-cuffing-target-message",("targetName", args.Target)), args.User, Filter.Entities(args.User));
|
||||
_popup.PopupEntity(Loc.GetString("handcuff-component-start-cuffing-by-other-message",("otherName", args.User)), target, Filter.Entities(args.User));
|
||||
_popup.PopupEntity(Loc.GetString("handcuff-component-start-cuffing-by-other-message",("otherName", args.User)), target, Filter.Entities(args.Target.Value));
|
||||
}
|
||||
|
||||
_audio.PlayPvs(component.StartCuffSound, uid);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Threading;
|
||||
using System.Threading;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Ensnaring.Components;
|
||||
using Content.Shared.Alert;
|
||||
@@ -64,6 +64,7 @@ public sealed partial class EnsnareableSystem
|
||||
component.Ensnared = target;
|
||||
ensnareable.Container.Insert(component.Owner);
|
||||
ensnareable.IsEnsnared = true;
|
||||
Dirty(ensnareable);
|
||||
|
||||
UpdateAlert(ensnareable);
|
||||
var ev = new EnsnareEvent(component.WalkSpeed, component.SprintSpeed);
|
||||
@@ -127,6 +128,7 @@ public sealed partial class EnsnareableSystem
|
||||
|
||||
ensnareable.Container.ForceRemove(component.Owner);
|
||||
ensnareable.IsEnsnared = false;
|
||||
Dirty(ensnareable);
|
||||
component.Ensnared = null;
|
||||
|
||||
UpdateAlert(ensnareable);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Ensnaring.Components;
|
||||
using Content.Server.Ensnaring.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Ensnaring;
|
||||
using Content.Shared.Ensnaring.Components;
|
||||
@@ -37,6 +37,7 @@ public sealed partial class EnsnareableSystem : SharedEnsnareableSystem
|
||||
|
||||
component.Container.Remove(args.EnsnaringEntity);
|
||||
component.IsEnsnared = false;
|
||||
Dirty(component);
|
||||
ensnaring.Ensnared = null;
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("ensnare-component-try-free-complete", ("ensnare", args.EnsnaringEntity)),
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Content.Server.Entry
|
||||
"ClientEntitySpawner",
|
||||
"HandheldGPS",
|
||||
"CableVisualizer",
|
||||
"EnsnareableVisualizer",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using JetBrains.Annotations;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Content.Server.Hands.Systems
|
||||
{
|
||||
@@ -10,16 +11,21 @@ namespace Content.Server.Hands.Systems
|
||||
{
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
|
||||
public bool TrySpawnVirtualItemInHand(EntityUid blockingEnt, EntityUid user)
|
||||
public bool TrySpawnVirtualItemInHand(EntityUid blockingEnt, EntityUid user) => TrySpawnVirtualItemInHand(blockingEnt, user, out _);
|
||||
|
||||
public bool TrySpawnVirtualItemInHand(EntityUid blockingEnt, EntityUid user, [NotNullWhen(true)] out EntityUid? virtualItem)
|
||||
{
|
||||
if (!_handsSystem.TryGetEmptyHand(user, out var hand))
|
||||
{
|
||||
virtualItem = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
var pos = EntityManager.GetComponent<TransformComponent>(user).Coordinates;
|
||||
var virtualItem = EntityManager.SpawnEntity("HandVirtualItem", pos);
|
||||
var virtualItemComp = EntityManager.GetComponent<HandVirtualItemComponent>(virtualItem);
|
||||
virtualItem = EntityManager.SpawnEntity("HandVirtualItem", pos);
|
||||
var virtualItemComp = EntityManager.GetComponent<HandVirtualItemComponent>(virtualItem.Value);
|
||||
virtualItemComp.BlockingEntity = blockingEnt;
|
||||
_handsSystem.DoPickup(user, hand, virtualItem);
|
||||
_handsSystem.DoPickup(user, hand, virtualItem.Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,23 +106,6 @@ namespace Content.Server.Hands.Systems
|
||||
}
|
||||
|
||||
#region EntityInsertRemove
|
||||
public override void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, SharedHandsComponent? hands = null)
|
||||
{
|
||||
base.DoDrop(uid, hand,doDropInteraction, hands);
|
||||
|
||||
// update gui of anyone stripping this entity.
|
||||
_strippableSystem.SendUpdate(uid);
|
||||
}
|
||||
|
||||
public override void DoPickup(EntityUid uid, Hand hand, EntityUid entity, SharedHandsComponent? hands = null)
|
||||
{
|
||||
base.DoPickup(uid, hand, entity, hands);
|
||||
|
||||
// update gui of anyone stripping this entity.
|
||||
_strippableSystem.SendUpdate(uid);
|
||||
}
|
||||
|
||||
|
||||
public override void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition,
|
||||
EntityUid? exclude)
|
||||
{
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
using System.Threading;
|
||||
using Content.Server.Cuffs.Components;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Ensnaring;
|
||||
using Content.Server.Ensnaring.Components;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Inventory;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Ensnaring.Components;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Strip.Components;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.CombatMode;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using System.Threading;
|
||||
|
||||
namespace Content.Server.Strip
|
||||
{
|
||||
@@ -38,93 +34,69 @@ namespace Content.Server.Strip
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<StrippableComponent, GetVerbsEvent<Verb>>(AddStripVerb);
|
||||
SubscribeLocalEvent<StrippableComponent, GetVerbsEvent<ExamineVerb>>(AddExamineVerb);
|
||||
SubscribeLocalEvent<StrippableComponent, DidEquipEvent>(OnDidEquip);
|
||||
SubscribeLocalEvent<StrippableComponent, DidUnequipEvent>(OnDidUnequip);
|
||||
SubscribeLocalEvent<StrippableComponent, ComponentInit>(OnCompInit);
|
||||
SubscribeLocalEvent<StrippableComponent, CuffedStateChangeEvent>(OnCuffStateChange);
|
||||
SubscribeLocalEvent<StrippableComponent, EnsnaredChangedEvent>(OnEnsnareChange);
|
||||
|
||||
// BUI
|
||||
SubscribeLocalEvent<StrippableComponent, StrippingInventoryButtonPressed>(OnStripInvButtonMessage);
|
||||
SubscribeLocalEvent<StrippableComponent, StrippingHandButtonPressed>(OnStripHandMessage);
|
||||
SubscribeLocalEvent<StrippableComponent, StrippingHandcuffButtonPressed>(OnStripHandcuffMessage);
|
||||
SubscribeLocalEvent<StrippableComponent, StrippingEnsnareButtonPressed>(OnStripEnsnareMessage);
|
||||
SubscribeLocalEvent<StrippableComponent, StrippingSlotButtonPressed>(OnStripButtonPressed);
|
||||
SubscribeLocalEvent<EnsnareableComponent, StrippingEnsnareButtonPressed>(OnStripEnsnareMessage);
|
||||
}
|
||||
private void OnStripHandcuffMessage(EntityUid uid, StrippableComponent component, StrippingHandcuffButtonPressed args)
|
||||
|
||||
private void OnStripEnsnareMessage(EntityUid uid, EnsnareableComponent component, StrippingEnsnareButtonPressed args)
|
||||
{
|
||||
if (args.Session.AttachedEntity is not {Valid: true} user)
|
||||
return;
|
||||
|
||||
if (TryComp<CuffableComponent>(component.Owner, out var cuffed))
|
||||
{
|
||||
foreach (var entity in cuffed.StoredEntities)
|
||||
{
|
||||
if (entity != args.Handcuff) continue;
|
||||
cuffed.TryUncuff(user, entity);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStripEnsnareMessage(EntityUid uid, StrippableComponent component, StrippingEnsnareButtonPressed args)
|
||||
{
|
||||
if (args.Session.AttachedEntity is not {Valid: true} user)
|
||||
return;
|
||||
|
||||
var ensnareQuery = GetEntityQuery<EnsnareableComponent>();
|
||||
|
||||
foreach (var entity in ensnareQuery.GetComponent(uid).Container.ContainedEntities)
|
||||
foreach (var entity in component.Container.ContainedEntities)
|
||||
{
|
||||
if (!TryComp<EnsnaringComponent>(entity, out var ensnaring))
|
||||
continue;
|
||||
|
||||
if (entity != args.Ensnare)
|
||||
continue;
|
||||
|
||||
_ensnaring.TryFree(component.Owner, ensnaring, user);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStripHandMessage(EntityUid uid, StrippableComponent component, StrippingHandButtonPressed args)
|
||||
private void OnStripButtonPressed(EntityUid uid, StrippableComponent component, StrippingSlotButtonPressed args)
|
||||
{
|
||||
if (args.Session.AttachedEntity is not {Valid: true} user ||
|
||||
!TryComp<HandsComponent>(user, out var userHands))
|
||||
return;
|
||||
|
||||
var placingItem = userHands.ActiveHandEntity != null;
|
||||
|
||||
if (TryComp<HandsComponent>(component.Owner, out var hands))
|
||||
if (args.IsHand)
|
||||
{
|
||||
if (hands.Hands.TryGetValue(args.Hand, out var hand) && !hand.IsEmpty)
|
||||
placingItem = false;
|
||||
|
||||
if (placingItem)
|
||||
PlaceActiveHandItemInHands(user, args.Hand, component);
|
||||
else
|
||||
TakeItemFromHands(user, args.Hand, component);
|
||||
StripHand(uid, user, args.Slot, component, userHands);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryComp<InventoryComponent>(component.Owner, out var inventory))
|
||||
return;
|
||||
|
||||
var hasEnt = _inventorySystem.TryGetSlotEntity(component.Owner, args.Slot, out _, inventory);
|
||||
|
||||
if (userHands.ActiveHandEntity != null && !hasEnt)
|
||||
PlaceActiveHandItemInInventory(user, args.Slot, component);
|
||||
else if (userHands.ActiveHandEntity == null && hasEnt)
|
||||
TakeItemFromInventory(user, args.Slot, component);
|
||||
}
|
||||
|
||||
private void OnStripInvButtonMessage(EntityUid uid, StrippableComponent component, StrippingInventoryButtonPressed args)
|
||||
private void StripHand(EntityUid target, EntityUid user, string handId, StrippableComponent component, HandsComponent userHands)
|
||||
{
|
||||
if (args.Session.AttachedEntity is not {Valid: true} user ||
|
||||
!TryComp<HandsComponent>(user, out var userHands))
|
||||
if (!TryComp<HandsComponent>(target, out var targetHands)
|
||||
|| !targetHands.Hands.TryGetValue(handId, out var hand))
|
||||
return;
|
||||
|
||||
var placingItem = userHands.ActiveHandEntity != null;
|
||||
|
||||
if (TryComp<InventoryComponent>(component.Owner, out var inventory))
|
||||
// is the target a handcuff?
|
||||
if (TryComp(hand.HeldEntity, out HandVirtualItemComponent? virt)
|
||||
&& TryComp(target, out CuffableComponent? cuff)
|
||||
&& cuff.Container.Contains(virt.BlockingEntity))
|
||||
{
|
||||
if (_inventorySystem.TryGetSlotEntity(component.Owner, args.Slot, out _, inventory))
|
||||
placingItem = false;
|
||||
|
||||
if (placingItem)
|
||||
PlaceActiveHandItemInInventory(user, args.Slot, component);
|
||||
else
|
||||
TakeItemFromInventory(user, args.Slot, component);
|
||||
cuff.TryUncuff(user, virt.BlockingEntity);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hand.IsEmpty && userHands.ActiveHandEntity != null)
|
||||
PlaceActiveHandItemInHands(user, handId, component);
|
||||
else if (!hand.IsEmpty && userHands.ActiveHandEntity == null)
|
||||
TakeItemFromHands(user, handId, component);
|
||||
}
|
||||
|
||||
public void StartOpeningStripper(EntityUid user, StrippableComponent component, bool openInCombat = false)
|
||||
@@ -140,124 +112,6 @@ namespace Content.Server.Strip
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCompInit(EntityUid uid, StrippableComponent component, ComponentInit args)
|
||||
{
|
||||
EnsureComp<ServerInventoryComponent>(uid);
|
||||
SendUpdate(uid, component);
|
||||
}
|
||||
|
||||
private void OnCuffStateChange(EntityUid uid, StrippableComponent component, ref CuffedStateChangeEvent args)
|
||||
{
|
||||
UpdateState(uid, component);
|
||||
}
|
||||
|
||||
private void OnEnsnareChange(EntityUid uid, StrippableComponent component, EnsnaredChangedEvent args)
|
||||
{
|
||||
SendUpdate(uid, component);
|
||||
}
|
||||
|
||||
private void OnDidUnequip(EntityUid uid, StrippableComponent component, DidUnequipEvent args)
|
||||
{
|
||||
SendUpdate(uid, component);
|
||||
}
|
||||
|
||||
private void OnDidEquip(EntityUid uid, StrippableComponent component, DidEquipEvent args)
|
||||
{
|
||||
SendUpdate(uid, component);
|
||||
}
|
||||
|
||||
public void SendUpdate(EntityUid uid, StrippableComponent? strippableComponent = null)
|
||||
{
|
||||
var bui = uid.GetUIOrNull(StrippingUiKey.Key);
|
||||
|
||||
if (!Resolve(uid, ref strippableComponent, false) || bui == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var cuffs = new Dictionary<EntityUid, string>();
|
||||
var ensnare = new Dictionary<EntityUid, string>();
|
||||
var inventory = new Dictionary<(string ID, string Name), string>();
|
||||
var hands = new Dictionary<string, string>();
|
||||
|
||||
if (TryComp(uid, out CuffableComponent? cuffed))
|
||||
{
|
||||
foreach (var entity in cuffed.StoredEntities)
|
||||
{
|
||||
var name = Name(entity);
|
||||
cuffs.Add(entity, name);
|
||||
}
|
||||
}
|
||||
|
||||
var ensnareQuery = GetEntityQuery<EnsnareableComponent>();
|
||||
|
||||
if (ensnareQuery.TryGetComponent(uid, out var _))
|
||||
{
|
||||
foreach (var entity in ensnareQuery.GetComponent(uid).Container.ContainedEntities)
|
||||
{
|
||||
var name = Name(entity);
|
||||
ensnare.Add(entity, name);
|
||||
}
|
||||
}
|
||||
|
||||
if (_inventorySystem.TryGetSlots(uid, out var slots))
|
||||
{
|
||||
foreach (var slot in slots)
|
||||
{
|
||||
var name = "None";
|
||||
|
||||
if (_inventorySystem.TryGetSlotEntity(uid, slot.Name, out var item))
|
||||
{
|
||||
if (!slot.StripHidden)
|
||||
{
|
||||
name = Name(item.Value);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
name = Loc.GetString("strippable-bound-user-interface-stripping-menu-obfuscate");
|
||||
}
|
||||
}
|
||||
|
||||
inventory[(slot.Name, slot.DisplayName)] = name;
|
||||
}
|
||||
}
|
||||
|
||||
if (TryComp(uid, out HandsComponent? handsComp))
|
||||
{
|
||||
foreach (var hand in handsComp.Hands.Values)
|
||||
{
|
||||
if (hand.HeldEntity == null || HasComp<HandVirtualItemComponent>(hand.HeldEntity))
|
||||
{
|
||||
hands[hand.Name] = "None";
|
||||
continue;
|
||||
}
|
||||
|
||||
hands[hand.Name] = Name(hand.HeldEntity.Value);
|
||||
}
|
||||
}
|
||||
|
||||
bui.SetState(new StrippingBoundUserInterfaceState(inventory, hands, cuffs, ensnare));
|
||||
}
|
||||
|
||||
private void AddExamineVerb(EntityUid uid, StrippableComponent component, GetVerbsEvent<ExamineVerb> args)
|
||||
{
|
||||
if (args.Hands == null || !args.CanAccess || !args.CanInteract || args.Target == args.User)
|
||||
return;
|
||||
|
||||
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
|
||||
return;
|
||||
|
||||
ExamineVerb verb = new()
|
||||
{
|
||||
Text = Loc.GetString("strip-verb-get-data-text"),
|
||||
IconTexture = "/Textures/Interface/VerbIcons/outfit.svg.192dpi.png",
|
||||
Act = () => StartOpeningStripper(args.User, component, true),
|
||||
Category = VerbCategory.Examine,
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void AddStripVerb(EntityUid uid, StrippableComponent component, GetVerbsEvent<Verb> args)
|
||||
{
|
||||
if (args.Hands == null || !args.CanAccess || !args.CanInteract || args.Target == args.User)
|
||||
@@ -275,11 +129,6 @@ namespace Content.Server.Strip
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void UpdateState(EntityUid uid, StrippableComponent component)
|
||||
{
|
||||
SendUpdate(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places item in user's active hand to an inventory slot.
|
||||
/// </summary>
|
||||
@@ -354,8 +203,6 @@ namespace Content.Server.Strip
|
||||
{
|
||||
_inventorySystem.TryEquip(user, component.Owner, held, slot);
|
||||
}
|
||||
|
||||
UpdateState(component.Owner, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -488,8 +335,6 @@ namespace Content.Server.Strip
|
||||
|
||||
_handsSystem.PickupOrDrop(user, item.Value);
|
||||
}
|
||||
|
||||
UpdateState(component.Owner, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user