Пример #1
0
        public static MainGame LoadGame(IkonComposite saveData, IEnumerable <TracableStream> staticDataSources, StateManager stateManager)
        {
            var statics = StaticsDB.Load(staticDataSources);

            var deindexer = new ObjectDeindexer();

            deindexer.AddAll(PlayerAssets.OrganizationsRaw);
            deindexer.AddAll(statics.Constructables);
            deindexer.AddAll(statics.DevelopmentTopics);
            deindexer.AddAll(statics.PredeginedDesigns);
            deindexer.AddAll(statics.ResearchTopics);
            deindexer.AddAll(statics.Armors.Values);
            deindexer.AddAll(statics.Hulls.Values);
            deindexer.AddAll(statics.IsDrives.Values);
            deindexer.AddAll(statics.MissionEquipment.Values);
            deindexer.AddAll(statics.Reactors.Values);
            deindexer.AddAll(statics.Sensors.Values);
            deindexer.AddAll(statics.Shields.Values);
            deindexer.AddAll(statics.SpecialEquipment.Values);
            deindexer.AddAll(statics.Thrusters.Values);
            deindexer.AddAll(statics.PlanetTraits.Values);
            deindexer.AddAll(statics.StarTraits.Values);

            var game = stateManager.Load <MainGame>(
                saveData.To <IkonComposite>(),
                deindexer,
                new Dictionary <Type, Action <object> >()
            {
                { typeof(Design), x => ((Design)x).CalcHash(statics) }
            }
                );

            var derivates = initDerivates(statics, game.MainPlayers, game.StareaterOrganelles, game.States);

            game.Initialze(statics, derivates);
            foreach (var player in game.MainPlayers)
            {
                var playerProc = derivates.Players.Of[player];
                playerProc.Initialize(game);
            }
            game.CalculateDerivedEffects();

            return(game);
        }