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); }
protected override void OnInitialize() { TaleWorlds.Core.Game currentGame = this.CurrentGame; currentGame.FirstInitialize(false); InitializeGameTexts(currentGame.GameTextManager); IGameStarter gameStarter = new BasicGameStarter(); InitializeGameModels(gameStarter); GameManager.OnGameStart(currentGame, gameStarter); MBObjectManager objectManager = currentGame.ObjectManager; currentGame.SecondInitialize(gameStarter.Models); currentGame.CreateGameManager(); GameManager.BeginGameStart(currentGame); currentGame.ThirdInitialize(); currentGame.CreateObjects(); currentGame.InitializeDefaultGameObjects(); currentGame.LoadBasicFiles(false); LoadXmls(); currentGame.SetDefaultEquipments((IReadOnlyDictionary <string, Equipment>) new Dictionary <string, Equipment>()); currentGame.CreateLists(); ObjectManager.LoadXML("MPClassDivisions"); objectManager.ClearEmptyObjects(); MultiplayerClassDivisions.Initialize(); GameManager.OnCampaignStart(this.CurrentGame, (object)null); GameManager.OnAfterCampaignStart(this.CurrentGame); GameManager.OnGameInitializationFinished(this.CurrentGame); CurrentGame.AddGameHandler <ChatBox>(); }
public static T GetGameModel <T>(this TaleWorlds.Core.Game game) where T : GameModel { foreach (GameModel model in game.BasicModels.GetGameModels()) { if (model is T t) { return(t); } } return(null); }
public override void OnGameEnd(TaleWorlds.Core.Game game) { }
public override void OnGameEnd(TaleWorlds.Core.Game game) { base.OnGameEnd(game); EnhancedBattleTestPartyController.OnGameEnd(); }
public override void OnGameStart(TaleWorlds.Core.Game game, IGameStarter gameStarter) { base.OnGameStart(game, gameStarter); InitializeGameTexts(TaleWorlds.Core.Game.Current.GameTextManager); }
public override void OnGameStart(TaleWorlds.Core.Game game, IGameStarter gameStarter) { base.OnGameStart(game, gameStarter); InitializeGameModels(gameStarter); }