using System.Collections.Generic; using System.Linq; using System.Numerics; using Dalamud.Plugin.Services; using Lumina.Excel; using Lumina.Excel.Sheets; using Microsoft.Extensions.Logging; using SmartNav.Model.Navigation; namespace SmartNav.Data; public sealed class TaxiStandDataService { public sealed record TaxiStandInfo(uint StandRowId, string PlaceName, ushort TerritoryId, Vector3 Position, uint NpcDataId, TaxiRoute[] Routes); public sealed record TaxiRoute(uint DestStandRowId, int Fare, int TimeRequiredSeconds); public IReadOnlyDictionary Stands { get; } public IReadOnlyDictionary StandsByNpcDataId { get; } public int TotalStands { get; } public int TotalRoutes { get; } public TaxiStandDataService(IDataManager dataManager, SmartNavDataOptions dataOptions, ILogger logger) { IReadOnlyList stands = AssemblyTaxiStandLoader.GetStands(dataOptions.DevSourceDirectory?.FullName); Dictionary dictionary = new Dictionary(); foreach (TaxiStandEntry item in stands) { dictionary[item.ChocoboTaxiStandId] = item; } Dictionary dictionary2 = new Dictionary(); int num = 0; ExcelSheet excelSheet = dataManager.GetExcelSheet(); foreach (var (num3, taxiStandEntry2) in dictionary) { if (!excelSheet.HasRow(num3)) { continue; } ChocoboTaxiStand row = excelSheet.GetRow(num3); string text = row.PlaceName.ToString(); if (string.IsNullOrEmpty(text)) { text = $"TaxiStand 0x{num3:X}"; } List list = new List(); for (int i = 0; i < 8; i++) { ChocoboTaxi? valueNullable = row.TargetLocations[i].ValueNullable; if (valueNullable.HasValue && valueNullable.Value.TimeRequired != 0) { uint rowId = valueNullable.Value.Location.RowId; if (rowId != 0) { list.Add(new TaxiRoute(rowId, valueNullable.Value.Fare, valueNullable.Value.TimeRequired * 60)); } } } num += list.Count; dictionary2[num3] = new TaxiStandInfo(num3, text, taxiStandEntry2.TerritoryId, taxiStandEntry2.Location, taxiStandEntry2.Id, list.ToArray()); } Stands = dictionary2; StandsByNpcDataId = dictionary2.Values.ToDictionary((TaxiStandInfo s) => s.NpcDataId, (TaxiStandInfo s) => s); TotalStands = dictionary2.Count; TotalRoutes = num; logger.LogDebug("TaxiStandDataService: {Stands} stands, {Routes} routes loaded", TotalStands, TotalRoutes); } }