[Fix] Torso Cavity Being Accessible (#300)

rezal uristov na lokalke 10 chasov

Co-authored-by: vanx <discord@vanxxxx>
This commit is contained in:
vanx
2025-03-09 14:58:26 +03:00
committed by GitHub
parent ae0f62b3b4
commit d46ece0beb
2 changed files with 11 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ using Robust.Shared.Utility;
using Content.Shared._Shitmed.Body.Events;
using Content.Shared._Shitmed.Body.Part;
using Content.Shared._Shitmed.BodyEffects;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Humanoid;
using Content.Shared.Inventory;
using Content.Shared.Random;
@@ -52,6 +53,9 @@ public partial class SharedBodySystem
// This seems to be an issue due to wiz-merge, on my old branch it was properly instantiating
// ItemInsertionSlot's container on both ends. It does show up properly on ItemSlotsComponent though.
_slots.AddItemSlot(ent, ent.Comp.ContainerName, ent.Comp.ItemInsertionSlot);
_slots.SetLock(ent.Owner, ent.Comp.ItemInsertionSlot, true); // WWDP prevent inserting items into torsos without surgery
Dirty(ent, ent.Comp);
}

View File

@@ -26,6 +26,8 @@ using Content.Shared.Popups;
using Robust.Shared.Prototypes;
using Robust.Shared.Toolshed.TypeParsers;
using System.Linq;
using Content.Shared.Inventory.VirtualItem;
namespace Content.Shared._Shitmed.Medical.Surgery;
@@ -396,15 +398,20 @@ public abstract partial class SharedSurgerySystem
if (!TryComp(args.Part, out BodyPartComponent? partComp) || partComp.PartType != BodyPartType.Torso)
return;
_itemSlotsSystem.SetLock(args.Part, partComp.ItemInsertionSlot, false); // WWDP prevent inserting items into torsos without surgery
var activeHandEntity = _hands.EnumerateHeld(args.User).FirstOrDefault();
if (activeHandEntity != default
&& ent.Comp.Action == "Insert"
&& !HasComp<VirtualItemComponent>(activeHandEntity) // WWDP prevent trying to insert virtual items
&& TryComp(activeHandEntity, out ItemComponent? itemComp)
&& (itemComp.Size.Id == "Tiny"
|| itemComp.Size.Id == "Small"))
_itemSlotsSystem.TryInsert(ent, partComp.ItemInsertionSlot, activeHandEntity, args.User);
else if (ent.Comp.Action == "Remove")
_itemSlotsSystem.TryEjectToHands(ent, partComp.ItemInsertionSlot, args.User);
_itemSlotsSystem.SetLock(args.Part, partComp.ItemInsertionSlot, true); // WWDP prevent inserting items into torsos without surgery
}
private void OnCavityCheck(Entity<SurgeryStepCavityEffectComponent> ent, ref SurgeryStepCompleteCheckEvent args)