Fix access system (#8585)
This commit is contained in:
@@ -52,23 +52,22 @@ namespace Content.Shared.Access.Systems
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches an <see cref="AccessComponent"/> in the entity itself, in its active hand or in its ID slot.
|
/// Searches the given entity for access tags
|
||||||
/// Then compares the found access with the configured access lists to see if it is allowed.
|
/// then compares it with the readers access list to see if it is allowed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <param name="entity">The entity that wants access.</param>
|
||||||
/// If no access is found, an empty set is used instead.
|
/// <param name="reader">A reader from a different entity</param>
|
||||||
/// </remarks>
|
public bool IsAllowed(EntityUid entity, AccessReaderComponent reader)
|
||||||
/// <param name="entity">The entity to bor access.</param>
|
|
||||||
/// <param name="reader"></param>
|
|
||||||
public bool IsAllowed(EntityUid entity, AccessReaderComponent? reader = null)
|
|
||||||
{
|
{
|
||||||
if (!Resolve(entity, ref reader, false))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
var tags = FindAccessTags(entity);
|
var tags = FindAccessTags(entity);
|
||||||
return IsAllowed(tags, reader);
|
return IsAllowed(tags, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compares the given tags with the readers access list to see if it is allowed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="accessTags">A list of access tags</param>
|
||||||
|
/// <param name="reader">An access reader to check against</param>
|
||||||
public bool IsAllowed(ICollection<string> accessTags, AccessReaderComponent reader)
|
public bool IsAllowed(ICollection<string> accessTags, AccessReaderComponent reader)
|
||||||
{
|
{
|
||||||
if (!reader.Enabled)
|
if (!reader.Enabled)
|
||||||
@@ -90,6 +89,10 @@ namespace Content.Shared.Access.Systems
|
|||||||
return reader.AccessLists.Count == 0 || reader.AccessLists.Any(a => a.IsSubsetOf(accessTags));
|
return reader.AccessLists.Count == 0 || reader.AccessLists.Any(a => a.IsSubsetOf(accessTags));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finds the access tags on the given entity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity that to search.</param>
|
||||||
public ICollection<string> FindAccessTags(EntityUid uid)
|
public ICollection<string> FindAccessTags(EntityUid uid)
|
||||||
{
|
{
|
||||||
HashSet<string>? tags = null;
|
HashSet<string>? tags = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user