using MfGames.Gallium; namespace MfGames.Nitride.Contents; /// /// Various extension methods for working with text content. /// public static class EntityTextContentExtensions { /// /// Determines if the entity has a registered ITextContent component. /// /// The entity to inspect. /// True if there is a component extending `IContent`. public static bool HasTextContent(this Entity entity) { return entity.Has(); } /// /// Remove all existing content components from the entity and then adds /// the new text content as a component into the entity before /// returning it. /// /// The entity to query and modify. /// The content to add to the entity. /// The base type of the content. /// The entity or a copy with the new component. public static Entity SetTextContent( this Entity entity, TType content) where TType : ITextContent { return entity.SetContent(content); } /// /// Remove all existing content components from the entity and then adds /// the new text content as a component into the entity before /// returning it. /// /// The entity to query and modify. /// The content to add to the entity. /// The base type of the content. /// The entity or a copy with the new component. public static Entity SetTextContent( this Entity entity, string content) { return entity.SetTextContent(new StringTextContent(content)); } }