예제 #1
0
        private void AddModels(IGameStarter gameStarter)
        {
            gameStarter.AddModel(heroModel = new HeroBuilderModel());

            if (DCCSettingsUtil.Instance.CustomAgeModel)
            {
                gameStarter.AddModel(new Models.AgeModel());
            }
        }
예제 #2
0
 // Token: 0x06000003 RID: 3 RVA: 0x00002120 File Offset: 0x00000320
 protected override void OnGameStart(Game game, IGameStarter starterObject)
 {
     base.OnGameStart(game, starterObject);
     starterObject.AddModel(new BattleTweaks());
     starterObject.AddModel(new TournamentTweaks());
     starterObject.AddModel(new LostTroopTweaks());
     starterObject.AddModel(new XPTweaks());
     starterObject.AddModel(new TrainingTweaks());
 }
 private void InitializeGameModels(IGameStarter basicGameStarter)
 {
     basicGameStarter.AddModel((GameModel) new MultiplayerAgentDecideKilledOrUnconsciousModel());
     basicGameStarter.AddModel((GameModel) new CustomBattleAgentStatCalculateModel());
     basicGameStarter.AddModel((GameModel) new CustomBattleApplyWeatherEffectsModel());
     basicGameStarter.AddModel((GameModel) new MultiplayerAgentApplyDamageModel());
     basicGameStarter.AddModel((GameModel) new DefaultRidingModel());
     basicGameStarter.AddModel((GameModel) new DefaultStrikeMagnitudeModel());
     basicGameStarter.AddModel((GameModel) new EditorGameSkillList());
     basicGameStarter.AddModel((GameModel) new CustomBattleMoraleModel());
     basicGameStarter.AddModel((GameModel) new CustomBattleInitializationModel());
 }
        protected override void OnGameStart(Game game, IGameStarter gameStarter)
        {
            base.OnGameStart(game, gameStarter);

            if (Settings.Instance.SmithingXPEnabled)
            {
                gameStarter.AddModel(new ModdedSmithingModel());
            }

            if (Settings.Instance.CombatXPEnabled)
            {
                var xpModel = new ModdedCombatXpModel();
                xpModel.Setup();
                gameStarter.AddModel(xpModel);
            }
        }
 protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
 {
     if (game.GameType is Campaign)
     {
         gameStarterObject.AddModel(new CharmedPrisonerRecruitmentCalculationModel());
     }
 }
예제 #6
0
        protected void ReplaceModel<TBaseType, TChildType>(IGameStarter gameStarterObject)
            where TBaseType : GameModel
            where TChildType : TBaseType
        {
            if (!(gameStarterObject.Models is IList<GameModel> models))
            {
                return;
            }

            bool found = false;
            for (int index = 0; index < models.Count; ++index)
            {
                if (models[index] is TBaseType)
                {
                    found = true;
                    if (models[index] is TChildType)
                    {
                    }
                    else
                    {
                        models[index] = Activator.CreateInstance<TChildType>();
                    }
                }
            }

            if (!found)
            {
                gameStarterObject.AddModel(Activator.CreateInstance<TChildType>());
            }
        }
        protected void ReplaceModel <TBaseType, TChildType>(IGameStarter gameStarterObject)
            where TBaseType : GameModel
            where TChildType : TBaseType
        {
            if (!(gameStarterObject.Models is IList <GameModel> models))
            {
                Log.Error("Models was not a list");
                return;
            }

            bool found = false;

            for (int index = 0; index < models.Count; ++index)
            {
                if (models[index] is TBaseType)
                {
                    found = true;
                    if (models[index] is TChildType)
                    {
                        Log.Info($"Child model {typeof(TChildType).Name} found, skipping.");
                    }
                    else
                    {
                        Log.Info($"Base model {typeof(TBaseType).Name} found. Replacing with child model {typeof(TChildType).Name}");
                        models[index] = Activator.CreateInstance <TChildType>();
                    }
                }
            }

            if (!found)
            {
                Log.Info($"Base model {typeof(TBaseType).Name} was not found. Adding child model {typeof(TChildType).Name}");
                gameStarterObject.AddModel(Activator.CreateInstance <TChildType>());
            }
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="starter"></param>
        /// <param name="replacement"></param>
        /// <typeparam name="TReplace"></typeparam>
        /// <typeparam name="TReplacement"></typeparam>
        public static void Replace <TReplace, TReplacement>(this IGameStarter starter, TReplacement replacement)
            where TReplace : GameModel where TReplacement : GameModel
        {
            var replaceType     = typeof(TReplace);
            var replacementType = typeof(TReplacement);

            if (replaceType.BaseType is null)
            {
                throw new Exception($"{replaceType.Name} must derive from something.");
            }
            if (replacementType.BaseType is null)
            {
                throw new Exception($"{replacementType.Name} must derive from something.");
            }
            if (!replaceType.BaseType.IsAssignableFrom(replacementType))
            {
                throw new Exception($"{replaceType.Name} is not derived from {replacementType.BaseType.Name}");
            }
            var model = starter.Models.FirstOrDefault(x => x is TReplace);

            if (model is null)
            {
                return;
            }
            ;
            ((List <GameModel>)starter.Models).Remove(model);
            starter.AddModel(replacement);
            m_ledger.Add(new GameModelLedgerEntry(replaceType, replacementType));
        }
예제 #9
0
        protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
        {
            try
            {
                if (game.GameType is Campaign)
                {
                    // Reload settings here so they are fresh
                    CommonConfig     = GlobalCommonConfig.Get();
                    TournamentConfig = GlobalTournamentConfig.Get();
                    HeroClassConfig  = GlobalHeroClassConfig.Get();
                    HeroPowerConfig  = GlobalHeroPowerConfig.Get();

                    var campaignStarter = (CampaignGameStarter)gameStarterObject;
                    campaignStarter.AddBehavior(new BLTAdoptAHeroCampaignBehavior());
                    campaignStarter.AddBehavior(new BLTTournamentQueueBehavior());
                    campaignStarter.AddBehavior(new BLTCustomItemsCampaignBehavior());

                    gameStarterObject.AddModel(new BLTAgentApplyDamageModel(gameStarterObject.Models
                                                                            .OfType <AgentApplyDamageModel>().FirstOrDefault()));
                }
            }
            catch (Exception e)
            {
                Log.Exception(nameof(OnGameStart), e);
                MessageBox.Show($"Error in {nameof(OnGameStart)}, please report this on the discord: {e}", "Bannerlord Twitch Mod STARTUP ERROR");
            }
        }
예제 #10
0
 protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
 {
     if (game.GameType is Campaign)
     {
         gameStarterObject.AddModel(new HypnosisPersuasionModel());
     }
 }
예제 #11
0
 protected override void OnGameStart(Game game, IGameStarter gameStarter)
 {
     base.OnGameStart(game, gameStarter);
     try
     {
         OnGameStart2(game, gameStarter);
         gameStarter.AddModel(Utils.NPCMT_ClanTierModel.Init);
         gameStarter.AddModel(Utils.NPCMT_PregnancyModel.Init);
         //gameStarter.AddModel(Utils.NPCMT_TroopCountLimitModel.Init);
         gameStarter.AddModel(Utils.NPCMT_WorkshopModel.Init);
         gameStarter.AddAgeModel();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
예제 #12
0
 protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
 {
     if (!(game.GameType is Campaign))
     {
         return;
     }
     gameStarterObject.AddModel(new Recruitable());
 }
예제 #13
0
 protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
 {
     if (!(game.GameType is Campaign))
     {
         return;
     }
     gameStarterObject.AddModel(new ForeverSmithModel());
 }
        protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
        {
            base.OnGameStart(game, gameStarterObject);

            game.GameTextManager.LoadGameTexts(BasePath.Name + $"Modules/{ModuleId}/ModuleData/module_strings.xml");
            game.GameTextManager.LoadGameTexts(BasePath.Name + $"Modules/{ModuleId}/ModuleData/MissionLibrary.xml");
            gameStarterObject.AddModel(new ImprovedCombatAIAgentStatCalculateModel(GetGameModel <AgentStatCalculateModel>(gameStarterObject)));
        }
        protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
        {
            base.OnGameStart(game, gameStarterObject);

            game.GameTextManager.LoadGameTexts(ModuleHelper.GetXmlPath(ModuleId, "module_strings"));
            game.GameTextManager.LoadGameTexts(ModuleHelper.GetXmlPath(ModuleId, "MissionLibrary"));
            gameStarterObject.AddModel(new ImprovedCombatAIAgentStatCalculateModel(GetGameModel <AgentStatCalculateModel>(gameStarterObject)));
        }
        public static void AddAgeModel(this IGameStarter gameStarter)
        {
            var config = Config.Instance;

            if (config.EnableAgeModel)
            {
                gameStarter.AddModel(NPCMT_AgeModel.Instance);
            }
        }
예제 #17
0
 private void InitializeGameModels(IGameStarter gameStarter)
 {
     gameStarter.AddModel(new MultiplayerAgentDecideKilledOrUnconsciousModel());
     gameStarter.AddModel(new MultiplayerAgentStatCalculateModel());
     gameStarter.AddModel(new MultiplayerApplyWeatherEffectsModel());
     gameStarter.AddModel(new MultiplayerAgentApplyDamageModel());
     gameStarter.AddModel(new DefaultRidingModel());
     gameStarter.AddModel(new MultiplayerStrikeMagnitudeModel());
     gameStarter.AddModel(new DefaultSkillList());
     gameStarter.AddModel(new MultiplayerBattleMoraleModel());
 }
 private void AddGameModels(IGameStarter basicGameStarter)
 {
     basicGameStarter.AddModel((GameModel) new MultiplayerSkillList());
     basicGameStarter.AddModel((GameModel) new MultiplayerRidingModel());
     basicGameStarter.AddModel((GameModel) new MultiplayerStrikeMagnitudeModel());
     basicGameStarter.AddModel((GameModel) new MultiplayerAgentDecideKilledOrUnconsciousModel());
     basicGameStarter.AddModel((GameModel) new MultiplayerAgentStatCalculateModel());
     basicGameStarter.AddModel((GameModel) new MultiplayerAgentApplyDamageModel());
     basicGameStarter.AddModel((GameModel) new MultiplayerBattleMoraleModel());
     basicGameStarter.AddModel((GameModel) new MultiplayerBattleInitializationModel());
 }
예제 #19
0
 // https://github.com/stenellad/Recruitable/blob/master/RecruitableSubModule.cs
 protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
 {
     if (!(game.GameType is Campaign))
     {
         return;
     }
     gameStarterObject.AddModel(new JTGetDailyRecruitedPrisoners());
     // No idea if this adds onto vanilla
     ((CampaignGameStarter)gameStarterObject).AddBehavior(new JTRecruitPrisonersCampaignBehavior());
     Logs.log("JTPrisonerRecruitment loaded.", new Color(0, 1, 0));
 }
예제 #20
0
        protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
        {
            base.OnGameStart(game, gameStarterObject);
            if (game.GameType is Campaign)
            {
                CampaignGameStarter campaignGameStarter = (CampaignGameStarter)gameStarterObject;
                campaignGameStarter.AddBehavior(new RoyalArmoury());
                campaignGameStarter.AddBehavior(new StoneOfRenewal());

                gameStarterObject.AddModel(new Shadowfax());
            }
        }
예제 #21
0
 protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
 {
     if (game.GameType is Campaign)
     {
         CampaignGameStarter campaignGameStarter = (CampaignGameStarter)gameStarterObject;
         try
         {
             campaignGameStarter.AddBehavior(new RecruiterBehaviour());
             gameStarterObject.AddModel(new RecruiterSizeModel());
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
예제 #22
0
 private void InitializeGame(Game game, IGameStarter gameStarterObject)
 {
     try
     {
         ClearLastInstances();
         AddBehaviours(gameStarterObject as CampaignGameStarter);
         //do overrides
         if (ConfigLoader.Instance.Config.ModifyPartySpeeds && !removalMode)
         {
             gameStarterObject.AddModel(customSpeedModel);
         }
     }
     catch (Exception e)
     {
         ErrorHandler.HandleException(e);
     }
 }
예제 #23
0
        private void InitializeGameModels(IGameStarter basicGameStarter)
        {
            basicGameStarter.AddModel((GameModel) new MultiplayerAgentDecideKilledOrUnconsciousModel());
            basicGameStarter.AddModel((GameModel) new CustomBattleAgentStatCalculator());
            basicGameStarter.AddModel((GameModel) new MultiplayerAgentApplyDamageModel());
            basicGameStarter.AddModel((GameModel) new DefaultRidingModel());
            basicGameStarter.AddModel((GameModel) new DefaultStrikeMagnitudeModel());
            basicGameStarter.AddModel((GameModel) new BattleTestSkillList());
            basicGameStarter.AddModel((GameModel) new MultiplayerBattleMoraleModel());

            // We should use these, but some classes are internal.
            // basicGameStarter.AddModel((GameModel) new MultiplayerSkillList());
            // basicGameStarter.AddModel((GameModel) new MultiplayerRidingModel());
            // basicGameStarter.AddModel((GameModel) new MultiplayerStrikeMagnitudeModel());
            // basicGameStarter.AddModel((GameModel) new MultiplayerAgentDecideKilledOrUnconsciousModel());
            // basicGameStarter.AddModel((GameModel) new MultiplayerAgentStatCalculateModel());
            // basicGameStarter.AddModel((GameModel) new MultiplayerAgentApplyDamageModel());
            basicGameStarter.AddModel((GameModel) new MultiplayerBattleMoraleModel());
        }
예제 #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="starter"></param>
        /// <param name="replacement"></param>
        /// <typeparam name="TBaseReplace"></typeparam>
        /// <typeparam name="TReplacement"></typeparam>
        public static void ReplaceAll <TBaseReplace, TReplacement>(this IGameStarter starter, TReplacement replacement)
            where TBaseReplace : GameModel where TReplacement : GameModel
        {
            var baseType = typeof(TBaseReplace);
            var addType  = typeof(TReplacement);

            if (!baseType.IsAssignableFrom(addType))
            {
                throw new Exception($"{addType.Name} is not derived from {baseType.Name}");
            }
            var models = starter.Models.Where(x => x is TBaseReplace);

            if (models.IsEmpty())
            {
                return;
            }
            ((List <GameModel>)starter.Models).RemoveAll(x => x is TBaseReplace);
            starter.AddModel(replacement);
            m_ledger.AddRange(models.Select(x => new GameModelLedgerEntry(x.GetType(), addType)));
        }
예제 #25
0
        protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
        {
            if (!(game.GameType is Campaign))
            {
                return;
            }
            CampaignGameStarter gameInitializer = (CampaignGameStarter)gameStarterObject;

            try
            {
                gameInitializer.AddBehavior(new BuyPatrols());
                if (Settings.Instance.PatrolWagesHintBox)
                {
                    gameStarterObject.AddModel(new CalculateClanExpensesForPatrols());
                }
            } catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
예제 #26
0
        protected void ReplaceModel <TBaseType, TChildType>(IGameStarter gameStarterObject) where TBaseType : GameModel where TChildType : TBaseType
        {
            IList <GameModel> models = gameStarterObject.Models as IList <GameModel>;
            bool flag = models == null;

            if (flag)
            {
                Trace.WriteLine("Models was not a list");
            }
            else
            {
                bool found = false;
                for (int index = 0; index < models.Count; index++)
                {
                    bool flag2 = models[index] is TBaseType;
                    if (flag2)
                    {
                        found = true;
                        bool flag3 = models[index] is TChildType;
                        if (flag3)
                        {
                            Trace.WriteLine("Child model " + typeof(TChildType).Name + " found, skipping.");
                        }
                        else
                        {
                            Trace.WriteLine("Base model " + typeof(TBaseType).Name + " found. Replacing with child model " + typeof(TChildType).Name);
                            models[index] = Activator.CreateInstance <TChildType>();
                        }
                    }
                }
                bool flag4 = !found;
                if (flag4)
                {
                    Trace.WriteLine("Base model " + typeof(TBaseType).Name + " was not found. Adding child model " + typeof(TChildType).Name);
                    gameStarterObject.AddModel(Activator.CreateInstance <TChildType>());
                }
            }
        }
        protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
        {
            base.OnGameStart(game, gameStarterObject);

            gameStarterObject.AddModel(new EnhancedBattleTestMoraleModel());
        }
예제 #28
0
        private TaskStatus NHLModel <AddType, RemoveType>(IGameStarter gameI, TaskMode mode)
            where RemoveType : GameModel
            where AddType : GameModel, new()
        {
            IList <GameModel> models = gameI.Models as IList <GameModel>;
            TaskStatus        st     = TaskStatus.Pending;
            int rm = 0;

            for (int index = 0; index < models.Count; ++index)
            {
                if (mode != TaskMode.Remove && models[index] is AddType)
                {
                    Log(LogLvl.Warning, typeof(AddType) + " already installed, skipping.");
                    if (mode == TaskMode.RemoveAndAdd)
                    {
                        st = TaskStatus.Warning;
                    }
                    else
                    {
                        return(TaskStatus.Warning);
                    }
                }

                if (models[index] is RemoveType)
                {
                    if (mode == TaskMode.Replace || mode == TaskMode.ReplaceOrAdd)
                    {
                        models[index] = new AddType();
                        Log(
                            LogLvl.Info,
                            typeof(RemoveType) +
                            " found and replaced with " +
                            typeof(AddType) +
                            ".");
                        return(TaskStatus.Completed);
                    }

                    if (mode == TaskMode.Remove || mode == TaskMode.RemoveAndAdd)
                    {
                        models.RemoveAt(index); // C# rearrange the for loop on it's own.
                        rm++;
                        index--;
                    }
                }
            }

            if (mode != TaskMode.Replace && mode != TaskMode.Remove && st == TaskStatus.Pending)
            {
                gameI.AddModel(new AddType());
                Log(LogLvl.Info, typeof(AddType) + " added.");
            }

            if (mode == TaskMode.RemoveAndAdd)
            {
                if (rm == 0)
                {
                    Log(LogLvl.Warning, typeof(RemoveType) + " not found.");
                    st = TaskStatus.Warning;
                }

                if (st == TaskStatus.Pending)
                {
                    st = TaskStatus.Completed;
                }

                return(st);
            }

            if (mode == TaskMode.Remove && rm == 0)
            {
                Log(LogLvl.Warning, typeof(RemoveType) + " not found.");
                return(TaskStatus.Warning);
            }

            return(TaskStatus.Completed);
        }
예제 #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="starter"></param>
 /// <param name="add"></param>
 /// <typeparam name="TGameModel"></typeparam>
 public static void Add <TGameModel>(this IGameStarter starter, TGameModel add)
     where TGameModel : GameModel
 {
     starter.AddModel(add);
     m_ledger.Add(new GameModelLedgerEntry(null, typeof(TGameModel)));
 }
예제 #30
0
파일: main.cs 프로젝트: chinux23/Reform
 protected override void OnGameStart(Game game, IGameStarter starterObject)
 {
     starterObject.AddModel(new TerritorySpeedModel());
 }