Ejemplo n.º 1
0
        public static SaveOutput SaveGame(TaleWorlds.Core.Game game, ISaveDriver driver)
        {
            EntitySystem <GameHandler> entitySystem =
                Utils.GetPrivateField <EntitySystem <GameHandler> >(
                    typeof(TaleWorlds.Core.Game),
                    "_gameEntitySystem",
                    game);
            MetaData metaData = GetMetaData();

            // Code copied from TaleWorlds.Game.Save(MetaData, ISaveDriver)
            foreach (GameHandler gameHandler in entitySystem.Components)
            {
                gameHandler.OnBeforeSave();
            }

            SaveOutput saveOutput = SaveManager.Save(game, metaData, driver);

            saveOutput.PrintStatus();
            foreach (GameHandler gameHandler2 in entitySystem.Components)
            {
                gameHandler2.OnAfterSave();
            }
            // End code copy

            return(saveOutput);
        }
Ejemplo n.º 2
0
        public static SaveGameData SaveGame(Game game, ISaveDriver driver)
        {
            EntitySystem <GameHandler> entitySystem =
                Utils.GetPrivateField <EntitySystem <GameHandler> >(
                    typeof(Game),
                    "_gameEntitySystem",
                    game);
            MetaData metaData = GetMetaData();

            foreach (GameHandler gameHandler in entitySystem.Components)
            {
                gameHandler.OnBeforeSave();
            }

            SaveOutput saveOutput = SaveManager.Save(game, metaData, driver);

            saveOutput.PrintStatus();
            foreach (GameHandler gameHandler2 in entitySystem.Components)
            {
                gameHandler2.OnAfterSave();
            }

            return(new SaveGameData(metaData, saveOutput));
        }