/// <summary> /// Sorts <see cref="StarSystem"/>s relative to a the reference <paramref name="position"/>, with a result <paramref name="radius"/> /// </summary> /// <param name="position">Reference position to sort systems towards</param> /// <param name="radius">Radius to choose voxels from</param> /// <param name="filter">If not null, only sorts and returns systems matching the filter settings</param> /// <returns>Sorted list of <see cref="StarSystem"/>s wrapped in <see cref="DistanceWrapper{StarSystem}"/> structs</returns> public IReadOnlyList <DistanceWrapper <StarSystem> > GetSortedSystemsNear(Vector3 position, int radius = 100, SystemSearchFilter?filter = null) { IReadOnlyList <StarSystem> systemsNear = GetSystemsNear(position, radius, filter); DistanceSortedList <StarSystem> sortedSystems = systemsNear.GetDistanceSortedList(position); return(sortedSystems.Sorted); }
public bool TryGetMaterialTradersOrderedByDistance(TraderType type, Vector3 position, out IReadOnlyList <DistanceWrapper <StarSystem> > result) { if (materialTraders.TryGetValue(type, out HashSet <StarSystem> systems)) { DistanceSortedList <StarSystem> list = systems.GetDistanceSortedList(position); result = list.Sorted; return(true); } result = null; return(false); }
/// <summary> /// Sorts all stored <see cref="StarSystem"/>s to a reference <paramref name="position"/> /// </summary> /// <param name="position">Reference position to sort systems towards</param> /// <param name="filter">If not null, only sorts and returns systems matching the filter settings</param> /// <returns>Sorted list of <see cref="StarSystem"/>s wrapped in <see cref="DistanceWrapper{StarSystem}"/> structs</returns> public IReadOnlyList <DistanceWrapper <StarSystem> > SortAllSystems(Vector3 position, SystemSearchFilter?filter) { if (filter.HasValue) { if (FilterAllSystems(filter.Value, out List <StarSystem> filteredSystems)) { DistanceSortedList <StarSystem> sorted = filteredSystems.GetDistanceSortedList(position); return(sorted.Sorted); } else { return(new List <DistanceWrapper <StarSystem> >(0)); } } else { DistanceSortedList <StarSystem> sorted = systems.Values.GetDistanceSortedList(position); return(sorted.Sorted); } }
private IReadOnlyList <DistanceWrapper <SystemVoxel> > GetVoxelsSorted(Vector3 position) { DistanceSortedList <SystemVoxel> result = voxels.Values.GetDistanceSortedList(position); return(result.Sorted); }
/// <summary> /// Constructs a new <see cref="DistanceSortedList{T}"/> object /// </summary> /// <typeparam name="T">A type implementing the <see cref="IDistanceProvider"/> interface</typeparam> /// <param name="source">Collection of items as base list contents</param> /// <param name="position">Relative position to calculate distances to</param> public static DistanceSortedList <T> GetDistanceSortedList <T>(this IReadOnlyCollection <T> source, Vector3 position) where T : IDistanceProvider { DistanceSortedList <T> result = new DistanceSortedList <T>(source, position); return(result); }