private bool eventDocked(DockedEvent theEvent) { updateCurrentSystem(theEvent.system); if (CurrentStation != null && CurrentStation.name == theEvent.station) { // We are already at this station; nothing to do Logging.Debug("Already at station " + theEvent.station); return false; } // Update the station Logging.Debug("Now at station " + theEvent.station); Station station = CurrentStarSystem.stations.Find(s => s.name == theEvent.station); if (station == null) { // This station is unknown to us, might not be in EDDB or we might not have connectivity. Use a placeholder station = new Station(); station.name = theEvent.station; station.systemname = theEvent.system; } // Information from the event might be more current than that from EDDB so use it in preference station.state = theEvent.factionstate; station.faction = theEvent.faction; station.government = theEvent.government; station.allegiance = theEvent.allegiance; CurrentStation = station; // Now call refreshProfile() to obtain the outfitting and commodity information refreshProfile(); return true; }
public static List<Station> StationsFromEDDP(string systemName, dynamic json) { List<Station> Stations = new List<Station>(); if (json["stations"] != null) { foreach (dynamic station in json["stations"]) { Station Station = new Station(); Station.EDDBID = (long)station["id"]; Station.name = (string)station["name"]; Station.systemname = systemName; Station.economies = new List<string>(); if (station["economies"] != null) { foreach (dynamic economy in station["economies"]) { Station.economies.Add((string)economy); } } Station.allegiance = (string)station["allegiance"]; Station.government = (string)station["government"]; Station.faction = (string)station["faction"]; Station.state = (string)station["state"] == "None" ? null : (string)station["state"]; Station.distancefromstar = (long?)station["distance_to_star"]; Station.hasrefuel = (bool?)station["has_refuel"]; Station.hasrearm = (bool?)station["has_rearm"]; Station.hasrepair = (bool?)station["has_repair"]; Station.hasoutfitting = (bool?)station["has_outfitting"]; Station.hasshipyard = (bool?)station["has_shipyard"]; Station.hasmarket = (bool?)station["has_market"]; Station.hasblackmarket = (bool?)station["has_blackmarket"]; if (((string)station["type"]) != null) { Station.model = ((string)station["type"]); if (!stationModels.Contains((string)station["type"])) { Logging.Report("Unknown station model " + ((string)station["type"])); } } string largestpad = (string)station["max_landing_pad_size"]; if (largestpad == "S") { largestpad = "Small"; } if (largestpad == "M") { largestpad = "Medium"; } if (largestpad == "L") { largestpad = "Large"; } Station.largestpad = largestpad; Stations.Add(Station); } } return Stations; }
private bool eventLocation(LocationEvent theEvent) { updateCurrentSystem(theEvent.system); // Always update the current system with the current co-ordinates, just in case things have changed CurrentStarSystem.x = theEvent.x; CurrentStarSystem.y = theEvent.y; CurrentStarSystem.z = theEvent.z; if (theEvent.docked == true) { // In this case body === station if (CurrentStation != null && CurrentStation.name == theEvent.body) { // We are already at this station; nothing to do Logging.Debug("Already at station " + theEvent.body); return false; } // Update the station Logging.Debug("Now at station " + theEvent.body); Station station = CurrentStarSystem.stations.Find(s => s.name == theEvent.body); if (station == null) { // This station is unknown to us, might not be in EDDB or we might not have connectivity. Use a placeholder station = new Station(); station.name = theEvent.body; station.systemname = theEvent.system; } // Information from the event might be more current than that from EDDB so use it in preference station.state = theEvent.factionstate; station.faction = theEvent.faction; station.government = theEvent.government; station.allegiance = theEvent.allegiance; CurrentStation = station; // Now call refreshProfile() to obtain the outfitting and commodity information refreshProfile(); } return true; }
/// <summary>Set values for a station</summary> private static void setStationValues(Station station, string prefix, ref dynamic vaProxy) { Logging.Debug("Setting station information"); if (station == null) { // We don't have any data so remove any info that we might have in history vaProxy.SetText(prefix + " name", null); vaProxy.SetDecimal(prefix + " distance from star", null); vaProxy.SetText(prefix + " government", null); vaProxy.SetText(prefix + " allegiance", null); vaProxy.SetText(prefix + " faction", null); vaProxy.SetText(prefix + " state", null); vaProxy.SetText(prefix + " primary economy", null); vaProxy.SetText(prefix + " secondary economy", null); vaProxy.SetText(prefix + " tertiary economy", null); vaProxy.SetBoolean(prefix + " has refuel", null); vaProxy.SetBoolean(prefix + " has repair", null); vaProxy.SetBoolean(prefix + " has rearm", null); vaProxy.SetBoolean(prefix + " has market", null); vaProxy.SetBoolean(prefix + " has black market", null); vaProxy.SetBoolean(prefix + " has outfitting", null); vaProxy.SetBoolean(prefix + " has shipyard", null); } else { vaProxy.SetText(prefix + " name", station.name); vaProxy.SetDecimal(prefix + " distance from star", station.distancefromstar); vaProxy.SetText(prefix + " government", station.government); vaProxy.SetText(prefix + " allegiance", station.allegiance); vaProxy.SetText(prefix + " faction", station.faction); vaProxy.SetText(prefix + " state", station.state); if (station.economies != null) { if (station.economies.Count > 0) { vaProxy.SetText(prefix + " primary economy", station.economies[0]); } if (station.economies.Count > 1) { vaProxy.SetText(prefix + " secondary economy", station.economies[1]); } if (station.economies.Count > 2) { vaProxy.SetText(prefix + " tertiary economy", station.economies[2]); } } // Services vaProxy.SetBoolean(prefix + " has refuel", station.hasrefuel); vaProxy.SetBoolean(prefix + " has repair", station.hasrepair); vaProxy.SetBoolean(prefix + " has rearm", station.hasrearm); vaProxy.SetBoolean(prefix + " has market", station.hasmarket); vaProxy.SetBoolean(prefix + " has black market", station.hasblackmarket); vaProxy.SetBoolean(prefix + " has outfitting", station.hasoutfitting); vaProxy.SetBoolean(prefix + " has shipyard", station.hasshipyard); } Logging.Debug("Set station information"); }