// // Copyright 2021–2022 alterNERDtive. // // This file is part of EDNA. // // EDNA is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // EDNA is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with EDNA. If not, see <https://www.gnu.org/licenses/>. // using System; using System.Collections.Generic; using System.Threading.Tasks; namespace alterNERDtive.Edna { /// /// A star system in the galaxy of Elite Dangerous. /// public class StarSystem : Locatable { private static readonly Dictionary NameCache = new Dictionary(); private static readonly Dictionary Id64Cache = new Dictionary(); private Coordinates? coordinates = null; /// /// Initializes a new instance of the class. /// /// The system’s name. private StarSystem(string name) { throw new NotImplementedException(); } /// /// Initializes a new instance of the class. /// /// The system’s id64. private StarSystem(ulong id64) { throw new NotImplementedException(); } /// /// Gets the system’s name. Mostly but not necessarily unique. /// public string Name { get; private set; } /// /// Gets the systems’s id64, which _should_ be unique. /// public ulong Id64 { get; private set; } /// /// Gets the system’s Location in the galaxy. /// public new Coordinates Coordinates { get { return this.GetCoordinatesAsync().Result; } } /// /// Gets the system’s stations. /// public Station[] Stations { get => throw new NotImplementedException(); } /// /// Gets the systems Location in the galaxy, asynchronously. If you want /// blocking access, use the Property instead. /// /// A representing the result of the asynchronous operation. public async Task GetCoordinatesAsync() { if (this.coordinates == null) { // query EDSM // query spansh // query EDTS this.coordinates = new Coordinates(await Edts.EdtsApi.FindSystem(this.Name)); } return this.coordinates.Value; } /// /// Finds a star system by name. /// /// System names are not necessarily unique. /// /// The system’s name. /// The matching system. public static StarSystem Find(string name) { if (NameCache.ContainsKey(name)) { return NameCache[name]; } else { StarSystem system = new StarSystem(name); NameCache[name] = system; return system; } } /// /// Finds a star system by id64. /// /// The system’s id64. /// The matching system. public static StarSystem Find(ulong id64) { if (Id64Cache.ContainsKey(id64)) { return Id64Cache[id64]; } else { StarSystem system = new StarSystem(id64); Id64Cache[id64] = system; return system; } } /// /// Finds outdated stations in the system. /// /// The minimum age for data to be considered outdated. /// The maximum count of stations to list. /// A list of outdated stations. public List FindOutdatedStations(TimeSpan minimumAge, int count) { throw new NotImplementedException(); } } }