UI/SpawnMenu/Ents/EntityListLocal.razor
@using Sandbox;
@using Sandbox.UI;
@inherits Panel
@namespace Sandbox


<VirtualGrid Items=@Entities ItemSize=@(160)>
    <Item Context="item">
        @if (item is ScriptedEntity entry)
        {
            <SpawnMenuIcon Ident=@($"entity:{entry.ResourcePath}") [email protected] [email protected]></SpawnMenuIcon>
        }
    </Item>
</VirtualGrid>

@code
{
    public string Category { get; set; }

    List<ScriptedEntity> Entities = [];

    protected override void OnParametersSet()
    {
        base.OnParametersSet();

        var all = ResourceLibrary.GetAll<ScriptedEntity>()
            .Where( e => !e.Developer || ServerSettings.ShowDeveloperEntities );

        Entities = (Category is null
            ? all
            : all.Where( e => (string.IsNullOrWhiteSpace( e.Category ) ? "Other" : e.Category) == Category )
        ).ToList();
    }
}