whitelist and blacklist support for inventory slots (#11766)
This commit is contained in:
@@ -281,6 +281,18 @@ public abstract partial class InventorySystem
|
|||||||
return false;
|
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);
|
var attemptEvent = new IsEquippingAttemptEvent(actor, target, itemUid, slotDefinition);
|
||||||
RaiseLocalEvent(target, attemptEvent, true);
|
RaiseLocalEvent(target, attemptEvent, true);
|
||||||
if (attemptEvent.Cancelled)
|
if (attemptEvent.Cancelled)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Robust.Shared.Prototypes;
|
using Content.Shared.Whitelist;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Shared.Inventory;
|
namespace Content.Shared.Inventory;
|
||||||
|
|
||||||
@@ -38,6 +39,16 @@ public sealed class SlotDefinition
|
|||||||
/// Offset for the clothing sprites.
|
/// Offset for the clothing sprites.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("offset")] public Vector2 Offset { get; } = Vector2.Zero;
|
[DataField("offset")] public Vector2 Offset { get; } = Vector2.Zero;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entity whitelist for CanEquip checks.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("whitelist")] public EntityWhitelist? Whitelist = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entity blacklist for CanEquip checks.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("blacklist")] public EntityWhitelist? Blacklist = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SlotUIContainer
|
public enum SlotUIContainer
|
||||||
|
|||||||
Reference in New Issue
Block a user