@layout PageLayout @inherits BasePage @inject TechTreeService techTreeService @inject IEntityDialogService entityDialogService @inject NavigationManager NavigationManager @page "/tech-tree" Tech Tree Faction: SelectFaction(null)">All @foreach (var faction in factions) { var factionName = GetFactionName(faction); SelectFaction(faction)">@factionName } @if (!string.IsNullOrEmpty(highlightEntityId)) { Clear Highlight } Produces Requires Building Requires Research Morph Upgrade @if (currentGraph != null && currentGraph.Nodes.Count > 0) { } else { No data available for the selected faction. } @code { private TechTreeGraphModel? currentGraph; private List factions = new(); private string? selectedFaction; private string searchText = ""; private string? highlightEntityId; protected override void OnInitialized() { base.OnInitialized(); LoadGraph(); } void LoadGraph() { currentGraph = techTreeService.BuildGraph(selectedFaction); factions = techTreeService.GetFactions(); } void SelectFaction(string? faction) { selectedFaction = faction; highlightEntityId = null; LoadGraph(); } void OnSearchChanged() { if (string.IsNullOrWhiteSpace(searchText)) { highlightEntityId = null; return; } var found = currentGraph?.Nodes .FirstOrDefault(n => n.Name.Contains(searchText, StringComparison.OrdinalIgnoreCase)); highlightEntityId = found?.Id; } void ClearHighlight() { highlightEntityId = null; searchText = ""; } void OnEntitySelected(string entityId) { highlightEntityId = entityId; } string GetFactionName(string factionId) { var entities = EntityData.Get(); return entities.TryGetValue(factionId, out var entity) ? entity.Info()?.Name ?? factionId : factionId; } }
No data available for the selected faction.