示例#1
0
        private void InitializeKingdom(Hero leader, Settlement target)
        {
            Kingdom newKingdom = MBObjectManager.Instance.CreateObject <Kingdom>();

            try
            {
                TextObject name = new TextObject("{=!}{CLAN_NAME}");

                string origin = target.Name.ToString().Replace("Castle", "").Trim();

                name.SetTextVariable("CLAN_NAME", leader.Name + " of " + origin);

                newKingdom.InitializeKingdom(name,
                                             name,
                                             leader.Culture,
                                             Banner.CreateRandomClanBanner(leader.StringId.GetDeterministicHashCode()),
                                             0,
                                             0,
                                             new Vec2(target.GatePosition.X, target.GatePosition.Y));

                ChangeKingdomAction.ApplyByJoinToKingdom(leader.Clan, newKingdom, false);
                newKingdom.RulingClan = leader.Clan;

                newKingdom.AddPolicy(DefaultPolicies.NobleRetinues);

                MBObjectManager.Instance.RegisterObject(newKingdom);
            }
            catch (Exception e)
            {
                Log.Info("Exception in InitializeKingdom");
                Log.Error(e);
            }
        }
示例#2
0
        public CustomKingdom(String name, String informalName, CultureObject culture)
        {
            this.name          = name;
            this.informalName  = informalName;
            this.culture       = culture;
            this.banner        = Banner.CreateRandomClanBanner();
            this.kingdomColor1 = 7468453;
            this.kingdomColor2 = 7461621;

            kingdom = new Kingdom();
            kingdom.InitializeKingdom(new TextObject(name), new TextObject(informalName), culture, banner, kingdomColor1, kingdomColor2);
        }
        public static void CSCreateKingdom()
        {//This is from cheat, works but not thourughly tested
            Kingdom    kingdom    = MBObjectManager.Instance.CreateObject <Kingdom>("player_kingdom");
            TextObject textObject = new TextObject("{=yGaGlXgQ}Player Kingdom", null);

            kingdom.InitializeKingdom(textObject, textObject, Clan.PlayerClan.Culture, Clan.PlayerClan.Banner, Clan.PlayerClan.Color, Clan.PlayerClan.Color2, cultureSettlement(Clan.PlayerClan.Culture.StringId));
            ChangeKingdomAction.ApplyByJoinToKingdom(Clan.PlayerClan, kingdom, true);
            kingdom.RulingClan = Clan.PlayerClan;
            //Fix for basegame bug of influence not being gained until loaded again
            if (!Kingdom.All.Contains(MobileParty.MainParty.MapFaction))//Checking to see if devs fix, so it hopefully doesnt break on update
            {
                List <Kingdom> curkingdoms = new List <Kingdom>(Campaign.Current.Kingdoms.ToList());
                curkingdoms.Add(kingdom);
                AccessTools.Field(Campaign.Current.GetType(), "_kingdoms").SetValue(Campaign.Current, new MBReadOnlyList <Kingdom>(curkingdoms));
            }
        }