using Core.Models.Eft.Common.Tables; using System.Text.Json.Serialization; namespace Core.Models.Spt.Server; public record Locations { [JsonPropertyName("bigmap")] public Eft.Common.Location? Bigmap { get; set; } [JsonPropertyName("develop")] public Eft.Common.Location? Develop { get; set; } [JsonPropertyName("factory4_day")] public Eft.Common.Location? Factory4Day { get; set; } [JsonPropertyName("factory4_night")] public Eft.Common.Location? Factory4Night { get; set; } [JsonPropertyName("hideout")] public Eft.Common.Location? Hideout { get; set; } [JsonPropertyName("interchange")] public Eft.Common.Location? Interchange { get; set; } [JsonPropertyName("laboratory")] public Eft.Common.Location? Laboratory { get; set; } [JsonPropertyName("lighthouse")] public Eft.Common.Location? Lighthouse { get; set; } [JsonPropertyName("privatearea")] public Eft.Common.Location? PrivateArea { get; set; } [JsonPropertyName("rezervbase")] public Eft.Common.Location? RezervBase { get; set; } [JsonPropertyName("shoreline")] public Eft.Common.Location? Shoreline { get; set; } [JsonPropertyName("suburbs")] public Eft.Common.Location? Suburbs { get; set; } [JsonPropertyName("tarkovstreets")] public Eft.Common.Location? TarkovStreets { get; set; } [JsonPropertyName("terminal")] public Eft.Common.Location? Terminal { get; set; } [JsonPropertyName("town")] public Eft.Common.Location? Town { get; set; } [JsonPropertyName("woods")] public Eft.Common.Location? Woods { get; set; } [JsonPropertyName("sandbox")] public Eft.Common.Location? Sandbox { get; set; } [JsonPropertyName("sandbox_high")] public Eft.Common.Location? SandboxHigh { get; set; } /** Holds a mapping of the linkages between locations on the UI */ [JsonPropertyName("base")] public LocationsBase? Base { get; set; } private Dictionary? _locationDictionaryCache; /// /// Get map locations as a dictionary, keyed by its name e.g. factory4_day /// /// public Dictionary GetDictionary() { if (_locationDictionaryCache is null) { var classProps = typeof(Locations).GetProperties().Where(p => p.PropertyType == typeof(Eft.Common.Location) && p.Name != "Item"); _locationDictionaryCache = classProps .ToDictionary(propertyInfo => propertyInfo.Name, propertyInfo => propertyInfo.GetValue(this, null) as Eft.Common.Location); } return _locationDictionaryCache; } private Dictionary _locationMappings = new() { { "factory4_day", "Factory4Day" }, { "bigmap", "bigmap" }, { "develop", "Develop" }, { "factory4_night", "Factory4Night" }, { "hideout", "Hideout" }, { "interchange", "Interchange" }, { "laboratory", "Laboratory" }, { "lighthouse", "Lighthouse" }, { "privatearea", "PrivateArea" }, { "rezervbase", "RezervBase" }, { "shoreline", "Shoreline" }, { "suburbs", "Suburbs" }, { "tarkovstreets", "TarkovStreets" }, { "terminal", "Terminal" }, { "town", "Town" }, { "woods", "Woods" }, { "sandbox", "Sandbox" }, { "sandbox_high", "SandboxHigh" } }; }