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


@if ( Entities.Count == 0 )
{
    <SpawnMenuEmptyState Icon="search_off" Title="#spawnmenu.entity.no_results" Subtitle="#spawnmenu.empty.try_another_category" />
    return;
}

<VirtualGrid Items=@Entities ItemSize=@(new Vector2( 160, 120 ))>
    <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; }
    public bool IncludeSubcategories { get; set; } = true;

    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 => SpawnMenuCategory.Matches( e.Category, Category, IncludeSubcategories ) )
        ).ToList();
    }
}