From ddb10d8b99bf0ef21af130bb4b8aaea111d1d2a9 Mon Sep 17 00:00:00 2001
From: Rane <60792108+Elijahrane@users.noreply.github.com>
Date: Sat, 8 Oct 2022 13:53:34 -0400
Subject: [PATCH] whitelist and blacklist support for inventory slots (#11766)
---
Content.Shared/Inventory/InventorySystem.Equip.cs | 12 ++++++++++++
.../Inventory/InventoryTemplatePrototype.cs | 13 ++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs
index 6fc9bfb8b1..3a779c37ba 100644
--- a/Content.Shared/Inventory/InventorySystem.Equip.cs
+++ b/Content.Shared/Inventory/InventorySystem.Equip.cs
@@ -281,6 +281,18 @@ public abstract partial class InventorySystem
return false;
}
+ if (slotDefinition.Whitelist != null && !slotDefinition.Whitelist.IsValid(itemUid))
+ {
+ reason = "inventory-component-can-equip-does-not-fit";
+ return false;
+ }
+
+ if (slotDefinition.Blacklist != null && slotDefinition.Blacklist.IsValid(itemUid))
+ {
+ reason = "inventory-component-can-equip-does-not-fit";
+ return false;
+ }
+
var attemptEvent = new IsEquippingAttemptEvent(actor, target, itemUid, slotDefinition);
RaiseLocalEvent(target, attemptEvent, true);
if (attemptEvent.Cancelled)
diff --git a/Content.Shared/Inventory/InventoryTemplatePrototype.cs b/Content.Shared/Inventory/InventoryTemplatePrototype.cs
index 89884c36a8..ad8f7a5993 100644
--- a/Content.Shared/Inventory/InventoryTemplatePrototype.cs
+++ b/Content.Shared/Inventory/InventoryTemplatePrototype.cs
@@ -1,4 +1,5 @@
-using Robust.Shared.Prototypes;
+using Content.Shared.Whitelist;
+using Robust.Shared.Prototypes;
namespace Content.Shared.Inventory;
@@ -38,6 +39,16 @@ public sealed class SlotDefinition
/// Offset for the clothing sprites.
///
[DataField("offset")] public Vector2 Offset { get; } = Vector2.Zero;
+
+ ///
+ /// Entity whitelist for CanEquip checks.
+ ///
+ [DataField("whitelist")] public EntityWhitelist? Whitelist = null;
+
+ ///
+ /// Entity blacklist for CanEquip checks.
+ ///
+ [DataField("blacklist")] public EntityWhitelist? Blacklist = null;
}
public enum SlotUIContainer