public static Kingdom CreateKingdom(this Clan clan, Settlement capital, TextObject intro) { string kingdomId = clan.GetKingdomId(); var kingdom = Kingdom.All.SingleOrDefault(x => x.StringId == kingdomId); if (kingdom == null) { // create a rebel kingdom and set its name kingdom = MBObjectManager.Instance.CreateObject <Kingdom>(kingdomId); TextObject informalNameText = new TextObject("{=72pbZgQL}{CLAN_NAME}", null); informalNameText.SetTextVariable("CLAN_NAME", clan.Name); clan.GetKingdomNameAndRulerTitle(out var kingdomNameText, out var kingdomRulerTitleText); intro.SetTextVariable("RebelKingdom", kingdomNameText); // set colors for a rebel kingdom and the ruler clan var(color1, color2) = (0u, 0u); if (!SeparatismConfig.Settings.KeepRebelBannerColors) { (color1, color2) = ColorExtensions.GetRebelKingdomColors(); clan.Banner.ChangePrimaryColor(color1); clan.Banner.ChangeIconColors(color2); clan.Color = color1; clan.Color2 = color2; } else { (color1, color2) = clan.GetColors(); } clan.UpdateHomeSettlement(capital); kingdom.InitializeKingdom(kingdomNameText, informalNameText, clan.Culture, clan.Banner, color1, color2, capital); AccessTools.Property(typeof(Kingdom), "EncyclopediaText").SetValue(kingdom, intro); AccessTools.Property(typeof(Kingdom), "EncyclopediaTitle").SetValue(kingdom, kingdomNameText); AccessTools.Property(typeof(Kingdom), "EncyclopediaRulerTitle").SetValue(kingdom, kingdomRulerTitleText); AccessTools.Property(typeof(Kingdom), "AlternativeColor").SetValue(kingdom, color1); AccessTools.Property(typeof(Kingdom), "AlternativeColor2").SetValue(kingdom, color2); AccessTools.Property(typeof(Kingdom), "LabelColor").SetValue(kingdom, clan.Kingdom?.LabelColor ?? clan.LabelColor); kingdom.RulingClan = clan; Campaign.Current.AddKingdom(kingdom); } return(kingdom); }