diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs index e230315e1..bf954d466 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs @@ -242,6 +242,14 @@ namespace Barotrauma.Items.Components IsActive = false; } + public bool CanBeDeattached() + { + if (!attachable || !attached) return true; + + //don't allow deattaching if outside hulls and not in sub editor + return item.CurrentHull != null || Screen.Selected == GameMain.SubEditorScreen; + } + public override bool Pick(Character picker) { if (!attachable) @@ -249,6 +257,8 @@ namespace Barotrauma.Items.Components return base.Pick(picker); } + if (!CanBeDeattached()) return false; + if (Attached) { return base.Pick(picker); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs b/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs index 96333d162..9ffc74290 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs @@ -224,6 +224,9 @@ namespace Barotrauma if (GameMain.Server != null) { + var holdable = item.GetComponent(); + if (holdable != null && !holdable.CanBeDeattached()) continue; + if (!item.CanClientAccess(c)) continue; } TryPutItem(item, i, true, true, c.Character, false); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index 04776d7ea..bdf40b09d 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -1236,6 +1236,7 @@ namespace Barotrauma { if (string.IsNullOrEmpty(ic.Msg)) continue; if (!ic.CanBePicked && !ic.CanBeSelected) continue; + if (ic is Holdable holdable && !holdable.CanBeDeattached()) continue; Color color = Color.Red; if (ic.HasRequiredSkills(character) && ic.HasRequiredItems(character, false)) color = Color.Orange;