mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
EntityWhitelist uses EntityUid
This commit is contained in:
parent
5d66a08ac9
commit
1f9e1c033f
8 changed files with 20 additions and 18 deletions
|
|
@ -72,11 +72,11 @@ namespace Content.IntegrationTests.Tests.Utility
|
|||
var mapId = GetMainMapId(mapManager);
|
||||
var mapCoordinates = new MapCoordinates(0, 0, mapId);
|
||||
|
||||
var validComponent = entityManager.SpawnEntity("ValidComponentDummy", mapCoordinates);
|
||||
var validTag = entityManager.SpawnEntity("ValidTagDummy", mapCoordinates);
|
||||
var validComponent = entityManager.SpawnEntity("ValidComponentDummy", mapCoordinates).Uid;
|
||||
var validTag = entityManager.SpawnEntity("ValidTagDummy", mapCoordinates).Uid;
|
||||
|
||||
var invalidComponent = entityManager.SpawnEntity("InvalidComponentDummy", mapCoordinates);
|
||||
var invalidTag = entityManager.SpawnEntity("InvalidTagDummy", mapCoordinates);
|
||||
var invalidComponent = entityManager.SpawnEntity("InvalidComponentDummy", mapCoordinates).Uid;
|
||||
var invalidTag = entityManager.SpawnEntity("InvalidTagDummy", mapCoordinates).Uid;
|
||||
|
||||
// Test instantiated on its own
|
||||
var whitelistInst = new EntityWhitelist
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Content.Server.HandLabeler
|
|||
|
||||
private void AfterInteractOn(EntityUid uid, HandLabelerComponent handLabeler, AfterInteractEvent args)
|
||||
{
|
||||
if (args.Target == null || !handLabeler.Whitelist.IsValid(args.Target))
|
||||
if (args.Target == null || !handLabeler.Whitelist.IsValid(args.Target.Uid))
|
||||
return;
|
||||
|
||||
AddLabelTo(uid, handLabeler, args.Target, out string? result);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace Content.Server.Pinpointer
|
|||
var l = new SortedList<float, EntityUid>();
|
||||
foreach (var e in ents)
|
||||
{
|
||||
if (whitelist.IsValid(e))
|
||||
if (whitelist.IsValid(e.Uid))
|
||||
{
|
||||
var dist = (e.Transform.WorldPosition - transform.WorldPosition).LengthSquared;
|
||||
l.TryAdd(dist, e.Uid);
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ namespace Content.Server.Storage.Components
|
|||
return false;
|
||||
}
|
||||
|
||||
if (_whitelist != null && !_whitelist.IsValid(entity))
|
||||
if (_whitelist != null && !_whitelist.IsValid(entity.Uid))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ namespace Content.Server.Storage.EntitySystems
|
|||
var count = 0;
|
||||
foreach (var entity in component.StoredEntities)
|
||||
{
|
||||
if (itemCounter.Count.IsValid(entity)) count++;
|
||||
if (itemCounter.Count.IsValid(entity.Uid)) count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Content.Server.Storage.EntitySystems
|
|||
{
|
||||
foreach (var entity in containedLayers)
|
||||
{
|
||||
if (mapLayerData.Whitelist.IsValid(entity))
|
||||
if (mapLayerData.Whitelist.IsValid(entity.Uid))
|
||||
{
|
||||
list.Add(mapLayerData.Layer);
|
||||
break;
|
||||
|
|
@ -40,4 +40,4 @@ namespace Content.Server.Storage.EntitySystems
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue