Ejemplo n.º 1
0
        public void OnWeeklyTickSettlement(Settlement settlement)
        {
            if (WeekCounter.ContainsKey(settlement))
            {
                Dictionary <Settlement, int> dictionary = WeekCounter;
                dictionary[settlement]++;

                if (this.IsSettlementDue(settlement))
                {
                    Transform(settlement, true);
                }
            }
        }
Ejemplo n.º 2
0
        private void OnGameLoaded(CampaignGameStarter obj)
        {
            Dictionary <Settlement, CultureObject> startingCultures = new();

            if (BannerlordTweaksSettings.Instance is { } settings)
            {
                OverrideCulture = null;
                foreach (CultureObject Culture in from kingdom in Campaign.Current.Kingdoms where settings.PlayerCultureOverride.SelectedValue == kingdom.Culture.StringId || (settings.PlayerCultureOverride.SelectedValue == "khergit" && kingdom.Culture.StringId == "rebkhu") select kingdom.Culture)
                {
                    OverrideCulture = Culture;
                    break;
                }
                if (OverrideCulture == null && settings.ChangeToKingdomCulture && Clan.PlayerClan.Kingdom != null)
                {
                    OverrideCulture = Clan.PlayerClan.Kingdom.Culture;
                }
                else if (OverrideCulture == null)
                {
                    OverrideCulture = Clan.PlayerClan.Culture;
                }
            }

            foreach (Settlement settlement in from settlement in Campaign.Current.Settlements where settlement.IsTown || settlement.IsCastle || settlement.IsVillage select settlement)
            {
                startingCultures.Add(settlement, settlement.Culture);
                if (BannerlordTweaksSettings.Instance is { } settings2)
                {
                    bool PlayerOverride  = settlement.OwnerClan == Clan.PlayerClan && OverrideCulture != settlement.Culture;
                    bool KingdomOverride = settlement.OwnerClan != Clan.PlayerClan && settings2.ChangeToKingdomCulture && settlement.OwnerClan.Kingdom != null && settlement.OwnerClan.Kingdom.Culture != settlement.Culture;
                    bool ClanCulture     = settlement.OwnerClan != Clan.PlayerClan && (!settings2.ChangeToKingdomCulture || settlement.OwnerClan.Kingdom == null) && settlement.OwnerClan.Culture != settlement.Culture;

                    if ((PlayerOverride || KingdomOverride || ClanCulture) && !WeekCounter.ContainsKey(settlement))
                    {
                        this.AddCounter(settlement);
                    }
                    else if ((PlayerOverride || KingdomOverride || ClanCulture) && this.IsSettlementDue(settlement))
                    {
                        this.Transform(settlement, false);
                    }
                }
            }
            ChangeSettlementCulture.initialCultureDictionary = startingCultures;

            obj.AddGameMenuOption("village", "village_culture_changer", "Culture Transformation", new GameMenuOption.OnConditionDelegate(ChangeSettlementCulture.Game_menu_village_change_culture_on_condition), new GameMenuOption.OnConsequenceDelegate(ChangeSettlementCulture.Game_menu_change_culture_on_consequence), false, 5, false);
            obj.AddGameMenuOption("town", "town_culture_changer", "Culture Transformation", new GameMenuOption.OnConditionDelegate(ChangeSettlementCulture.Game_menu_town_change_culture_on_condition), new GameMenuOption.OnConsequenceDelegate(ChangeSettlementCulture.Game_menu_change_culture_on_consequence), false, 5, false);
            obj.AddGameMenuOption("castle", "castle_culture_changer", "Culture Transformation", new GameMenuOption.OnConditionDelegate(ChangeSettlementCulture.Game_menu_castle_change_culture_on_condition), new GameMenuOption.OnConsequenceDelegate(ChangeSettlementCulture.Game_menu_change_culture_on_consequence), false, 5, false);
        }