public Savegame(string fileLoc) { this._playerShips = new ObservableCollection <Ship>(); this._shipyards = new ObservableCollection <Shipyard>(); this._stations = new ObservableCollection <Station>(); Path = fileLoc; Data = XElement.Load(_path, LoadOptions.PreserveWhitespace); IEnumerable <XElement> ships = from ship in _data.Descendants().Elements("component") where (string)ship.Attribute("owner") == "player" && (string)ship.Attribute("state") != "wreck" && ((string)ship.Attribute("class") == "ship_xl" | (string)ship.Attribute("class") == "ship_l" | (string)ship.Attribute("class") == "ship_s" | (string)ship.Attribute("class") == "ship_xs") orderby(string) ship.Attribute("name") select ship; foreach (XElement ship in ships) { PlayerShips.Add(new Ship(ship)); } IEnumerable <XElement> shipyards = this._data.Descendants().Elements("component").Where(delegate(XElement shipyard) { bool result = false; if (shipyard.Attribute("macro") != null && shipyard.Attribute("macro").Value.ToString().EndsWith("yard_macro")) { result = true; } return(result); } ); foreach (XElement shipyard in shipyards) { Shipyards.Add(new Shipyard(shipyard)); } IEnumerable <XElement> stations = this._data.Descendants().Elements("component").Where(delegate(XElement ele) { bool result = false; if (ele.Attribute("owner") != null && ele.Attribute("class") != null && (ele.Attribute("owner").Value.ToString() == "player") && ele.Attribute("class").Value.Contains("station")) { result = true; } return(result); }); foreach (XElement station in stations) { Stations.Add(new Station(station)); } }
} // SPECIAL USE ONLY - DOES NOT COMPUTE ALL THE OTHER STUFF #region Entry processing // Called on a New Entry, by EDDiscoveryController:NewEntry, to add an journal entry in. May return null or empty list, or multiple entries. public List <HistoryEntry> AddJournalEntryToHistory(JournalEntry je, Action <string> logerror) { HistoryEntry he = HistoryEntry.FromJournalEntry(je, hlastprocessed); // we may check edsm for this entry he.UpdateMaterialsCommodities(MaterialCommoditiesMicroResources.Process(je, hlastprocessed?.journalEntry, he.Status.TravelState == HistoryEntryStatus.TravelStateType.SRV)); // IN THIS order, so suits can be added, then weapons, then loadouts he.UpdateSuits(SuitList.Process(je, he.WhereAmI, he.System)); he.UpdateWeapons(WeaponList.Process(je, he.WhereAmI, he.System)); he.UpdateLoadouts(SuitLoadoutList.Process(je, WeaponList, he.WhereAmI, he.System)); // check here to see if we want to remove the entry.. can move this lower later, but at first point where we have the data he.UpdateStats(je, statisticsaccumulator, he.StationFaction); he.UpdateSystemNote(); CashLedger.Process(je); he.Credits = CashLedger.CashTotal; Shipyards.Process(je); Outfitting.Process(je); Tuple <ShipInformation, ModulesInStore> ret = ShipInformationList.Process(je, he.WhereAmI, he.System); he.UpdateShipInformation(ret.Item1); he.UpdateShipStoredModules(ret.Item2); he.UpdateMissionList(MissionListAccumulator.Process(je, he.System, he.WhereAmI)); hlastprocessed = he; var reorderlist = ReorderRemove(he); foreach (var heh in reorderlist.EmptyIfNull()) { heh.Index = historylist.Count; // store its index historylist.Add(heh); // then add to history AddToVisitsScan(logerror); // add to scan database and complain if can't add. Do this after history add, so it has a list. } return(reorderlist); }
// Called on a New Entry, by EDDiscoveryController:NewEntry, to add an journal entry in. May return null if don't want it in history public HistoryEntry AddJournalEntryToHistory(JournalEntry je, Action <string> logerror) { HistoryEntry hprev = GetLast; HistoryEntry he = HistoryEntry.FromJournalEntry(je, hprev); // we may check edsm for this entry he.UpdateMaterialsCommodities(MaterialCommoditiesMicroResources.Process(je)); if (CheckForRemoval(he, hprev)) // check here to see if we want to remove the entry.. can move this lower later, but at first point where we have the data { return(null); } he.UpdateStats(je, statisticsaccumulator, he.StationFaction); he.UpdateSystemNote(); CashLedger.Process(je); he.Credits = CashLedger.CashTotal; Shipyards.Process(je); Outfitting.Process(je); Tuple <ShipInformation, ModulesInStore> ret = ShipInformationList.Process(je, he.WhereAmI, he.System); he.UpdateShipInformation(ret.Item1); he.UpdateShipStoredModules(ret.Item2); he.UpdateMissionList(MissionListAccumulator.Process(je, he.System, he.WhereAmI)); he.UpdateWeapons(WeaponList.Process(je, he.WhereAmI, he.System)); // update the entries in suit entry list he.UpdateSuits(SuitList.Process(je, he.WhereAmI, he.System)); he.UpdateLoadouts(SuitLoadoutList.Process(je, WeaponList, he.WhereAmI, he.System)); historylist.Add(he); // then add to history AddToVisitsScan(this, this.historylist.Count - 1, logerror); // add to scan database and complain if can't add. Do this after history add, so it has a list. return(he); }
// Called on a New Entry, by EDDiscoveryController:NewEntry, to add an journal entry in. May return null if don't want it in history public HistoryEntry AddJournalEntryToHistory(JournalEntry je, Action <string> logerror) { HistoryEntry hprev = GetLast; HistoryEntry he = HistoryEntry.FromJournalEntry(je, hprev); // we may check edsm for this entry he.UpdateMaterialsCommodities(je, hprev?.MaterialCommodity); // let some processes which need the user db to work Debug.Assert(he.MaterialCommodity != null); if (CheckForRemoval(he, hprev)) // check here to see if we want to remove the entry.. can move this lower later, but at first point where we have the data { return(null); } he.UpdateStats(je, hprev?.Stats, he.StationFaction); he.UpdateSystemNote(); CashLedger.Process(je); he.Credits = CashLedger.CashTotal; Shipyards.Process(je); Outfitting.Process(je); Tuple <ShipInformation, ModulesInStore> ret = ShipInformationList.Process(je, he.WhereAmI, he.System); he.UpdateShipInformation(ret.Item1); he.UpdateShipStoredModules(ret.Item2); he.UpdateMissionList(missionlistaccumulator.Process(je, he.System, he.WhereAmI)); historylist.Add(he); // then add to history AddToVisitsScan(this, he, logerror); // add to scan database and complain if can't add. Do this after history add, so it has a list. return(he); }