internal Map(string name, Layout layout) { Id = Ids.Add(name); _loadedMaps.Add(Id, new WeakReference <Map>(this)); MapLayout = layout; MapDetails = new Details(); Connections = new List <Connection>(); Encounters = new EncounterGroups(); MapEvents = new Events(); Name = name; Save(); Ids.Save(); }
private Map(string name, int id) { var json = JObject.Parse(File.ReadAllText(Path.Combine(MapPath, name + ".json"))); MapLayout = Layout.LoadOrGet(json[nameof(Layout)].Value <string>()); MapDetails = new Details(json[nameof(Details)]); var cons = (JArray)json[nameof(Connections)]; int numConnections = cons.Count; Connections = new List <Connection>(numConnections); for (int i = 0; i < numConnections; i++) { Connections.Add(new Connection(cons[i])); } Encounters = new EncounterGroups(json[nameof(Encounters)]); MapEvents = new Events(json[nameof(Events)]); Name = name; Id = id; }