private static WormholeCollection createWormholes(IList <StarSystem> starList, IEnumerable <WormholeEndpoints> wormholeEndpoints) { var wormholes = new WormholeCollection(); wormholes.Add(wormholeEndpoints.Select( x => new Wormhole( starList[x.FromIndex].Star, starList[x.ToIndex].Star ) )); return(wormholes); }
private static Tuple <StatesDB, Player[], Player> loadSaveData(IkonComposite saveData, ObjectDeindexer deindexer, StaticsDB statics) { var stateData = saveData[MainGame.StatesKey].To <IkonComposite>(); var ordersData = saveData[MainGame.OrdersKey].To <IkonArray>(); var stars = new StarCollection(); foreach (var rawData in stateData[StatesDB.StarsKey].To <IEnumerable <IkonComposite> >()) { stars.Add(StarData.Load(rawData, deindexer)); } var planets = new PlanetCollection(); foreach (var rawData in stateData[StatesDB.PlanetsKey].To <IEnumerable <IkonComposite> >()) { planets.Add(Planet.Load(rawData, deindexer)); } var wormholes = new WormholeCollection(); foreach (var rawData in stateData[StatesDB.WormholesKey].To <IEnumerable <IkonComposite> >()) { wormholes.Add(Wormhole.Load(rawData, deindexer)); } var players = new List <Player>(); foreach (var rawData in saveData[MainGame.PlayersKey].To <IEnumerable <IkonComposite> >()) { players.Add(Player.Load(rawData, deindexer)); } var organellePlayer = Player.Load(saveData[MainGame.OrganellePlayerKey].To <IkonComposite>(), deindexer); var developments = new DevelopmentProgressCollection(); foreach (var rawData in stateData[StatesDB.DevelopmentAdvancesKey].To <IEnumerable <IkonComposite> >()) { developments.Add(DevelopmentProgress.Load(rawData, deindexer)); } var research = new ResearchProgressCollection(); foreach (var rawData in stateData[StatesDB.ResearchAdvancesKey].To <IEnumerable <IkonComposite> >()) { research.Add(ResearchProgress.Load(rawData, deindexer)); } var treaties = new TreatyCollection(); foreach (var rawData in stateData[StatesDB.TreatiesKey].To <IEnumerable <IkonComposite> >()) { treaties.Add(Treaty.Load(rawData, deindexer)); } var reports = new ReportCollection(); foreach (var rawData in stateData[StatesDB.ReportsKey].To <IEnumerable <IkonComposite> >()) { reports.Add(ReportFactory.Load(rawData, deindexer)); } var designs = new DesignCollection(); foreach (var rawData in stateData[StatesDB.DesignsKey].To <IEnumerable <IkonComposite> >()) { var design = Design.Load(rawData, deindexer); design.CalcHash(statics); designs.Add(design); deindexer.Add(design.ConstructionProject, design.ConstructionProject.IdCode); } var colonizations = new ColonizationCollection(); foreach (var rawData in stateData[StatesDB.ColonizationKey].To <IEnumerable <IkonComposite> >()) { colonizations.Add(ColonizationProject.Load(rawData, deindexer)); } var fleets = new FleetCollection(); foreach (var rawData in stateData[StatesDB.IdleFleetsKey].To <IEnumerable <IkonComposite> >()) { fleets.Add(Fleet.Load(rawData, deindexer)); } var colonies = new ColonyCollection(); foreach (var rawData in stateData[StatesDB.ColoniesKey].To <IEnumerable <IkonComposite> >()) { colonies.Add(Colony.Load(rawData, deindexer)); } var stellarises = new StellarisCollection(); foreach (var rawData in stateData[StatesDB.StellarisesKey].To <IEnumerable <IkonComposite> >()) { stellarises.Add(StellarisAdmin.Load(rawData, deindexer)); } for (int i = 0; i < players.Count; i++) { players[i].Orders = PlayerOrders.Load(ordersData[i].To <IkonComposite>(), deindexer); } organellePlayer.Orders = PlayerOrders.Load(saveData[MainGame.OrganelleOrdersKey].To <IkonComposite>(), deindexer); return(new Tuple <StatesDB, Player[], Player>( new StatesDB(stars, wormholes, planets, colonies, stellarises, developments, research, treaties, reports, designs, fleets, colonizations), players.ToArray(), organellePlayer )); }