Add GetBaseName method to NameModifierSystem (#35633)

* Add GetBaseName method to NameModifierSystem

* Use Name
This commit is contained in:
Tayrtahn 2025-03-02 20:03:16 -05:00 committed by deltanedas
parent e3d168a50b
commit 3734782997
1 changed files with 12 additions and 0 deletions

View 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.