]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add viewer parameter to Identity.Entity (#35861)
authorTayrtahn <tayrtahn@gmail.com>
Sun, 16 Mar 2025 21:07:46 +0000 (17:07 -0400)
committerGitHub <noreply@github.com>
Sun, 16 Mar 2025 21:07:46 +0000 (14:07 -0700)
* Add viewer parameter to Identity.Entity

* Docs

Content.Shared/IdentityManagement/Identity.cs

index cdb3c81adacc53a7f349dd23a5f0896bc88b589d..836adfcdf851c3e0e17bd2df0a7b5d5d24709251 100644 (file)
@@ -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;
     }