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); } }