Add viewer parameter to Identity.Entity (#35861)
* Add viewer parameter to Identity.Entity * Docs
This commit is contained in:
@@ -49,11 +49,17 @@ public static class Identity
|
||||
/// This is an extension method because of its simplicity, and if it was any harder to call it might not
|
||||
/// be used enough for loc.
|
||||
/// </summary>
|
||||
public static EntityUid Entity(EntityUid uid, IEntityManager ent)
|
||||
/// <param name="viewer">
|
||||
/// If this entity can see through identities, this method will always return the actual target entity.
|
||||
/// </param>
|
||||
public static EntityUid Entity(EntityUid uid, IEntityManager ent, EntityUid? viewer = null)
|
||||
{
|
||||
if (!ent.TryGetComponent<IdentityComponent>(uid, out var identity))
|
||||
return uid;
|
||||
|
||||
if (viewer != null && CanSeeThroughIdentity(uid, viewer.Value, ent))
|
||||
return uid;
|
||||
|
||||
return identity.IdentityEntitySlot.ContainedEntity ?? uid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user