]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add GetBaseName method to NameModifierSystem (#35633)
authorTayrtahn <tayrtahn@gmail.com>
Mon, 3 Mar 2025 01:03:16 +0000 (20:03 -0500)
committerGitHub <noreply@github.com>
Mon, 3 Mar 2025 01:03:16 +0000 (02:03 +0100)
* Add GetBaseName method to NameModifierSystem

* Use Name

Content.Shared/NameModifier/EntitySystems/NameModifierSystem.cs

index 2e7c8054b3b1666591b19978e2dc4fc9b873e01e..33f6efbed50c28a8d42ba1bce1db9f5c4a78da48 100644 (file)
@@ -32,6 +32,18 @@ public sealed class NameModifierSystem : EntitySystem
         Dirty(entity);
     }
 
+    /// <summary>
+    /// Returns the base name of the entity, without any modifiers applied.
+    /// If the entity doesn't have a <see cref="NameModifierComponent"/>,
+    /// this returns the entity's metadata name.
+    /// </summary>
+    public string GetBaseName(Entity<NameModifierComponent?> entity)
+    {
+        if (Resolve(entity, ref entity.Comp, logMissing: false))
+            return entity.Comp.BaseName;
+        return Name(entity);
+    }
+
     /// <summary>
     /// Raises a <see cref="RefreshNameModifiersEvent"/> to gather modifiers and
     /// updates the entity's name to its base name with modifiers applied.