EntityWhitelist uses EntityUid
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
|
||||
private void OnComponentInit(EntityUid uid, SharedItemSlotsComponent itemSlots, ComponentInit args)
|
||||
{
|
||||
// create container for each slot
|
||||
// create container for each slot
|
||||
foreach (var pair in itemSlots.Slots)
|
||||
{
|
||||
var slotName = pair.Key;
|
||||
@@ -131,7 +131,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
foreach (var (slotName, slot) in itemSlots.Slots)
|
||||
{
|
||||
// check if item allowed in whitelist
|
||||
if (slot.Whitelist != null && !slot.Whitelist.IsValid(item))
|
||||
if (slot.Whitelist != null && !slot.Whitelist.IsValid(item.Uid))
|
||||
continue;
|
||||
|
||||
// check if slot does not contain the item currently being inserted???
|
||||
@@ -179,7 +179,7 @@ namespace Content.Shared.Containers.ItemSlots
|
||||
return false;
|
||||
|
||||
// check if item allowed in whitelist
|
||||
if (slot.Whitelist != null && !slot.Whitelist.IsValid(item))
|
||||
if (slot.Whitelist != null && !slot.Whitelist.IsValid(item.Uid))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -67,11 +67,13 @@ namespace Content.Shared.Whitelist
|
||||
/// <summary>
|
||||
/// Returns whether a given entity fits the whitelist.
|
||||
/// </summary>
|
||||
public bool IsValid(IEntity entity)
|
||||
public bool IsValid(EntityUid uid, IEntityManager? entityManager = null)
|
||||
{
|
||||
if (Tags != null)
|
||||
entityManager ??= IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (Tags != null && entityManager.TryGetComponent(uid, out TagComponent? tags))
|
||||
{
|
||||
if (entity.HasAnyTag(Tags))
|
||||
if (tags.HasAnyTag(Tags))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -79,7 +81,7 @@ namespace Content.Shared.Whitelist
|
||||
{
|
||||
foreach (var reg in _registrations)
|
||||
{
|
||||
if (entity.HasComponent(reg.Type))
|
||||
if (entityManager.HasComponent(uid, reg.Type))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user