Ejemplo n.º 1
0
 public static void RefreshPatch(EncyclopediaHeroPageVM __instance)
 {
     try
     {
         Hero PageHero = __instance.Obj as Hero;
         if (!Settings.Instance.UseAdvancedHeroTooltips || PageHero == Hero.MainHero)
         {
             return;
         }
         __instance.Allies.Clear();
         __instance.Enemies.Clear();
         EncyclopediaPage pageOf1 = Campaign.Current.EncyclopediaManager.GetPageOf(typeof(Hero));
         foreach (Hero hero in Hero.All)
         {
             if (pageOf1.IsValidEncyclopediaItem(hero) && !hero.IsNotable && hero != PageHero)
             {
                 if (PageHero.IsFriend(hero))
                 {
                     __instance.Allies.Add(new HeroVMcontactExtension(hero, PageHero));
                 }
                 else if (PageHero.IsEnemy(hero))
                 {
                     __instance.Enemies.Add(new HeroVMcontactExtension(hero, PageHero));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MethodInfo methodInfo = MethodBase.GetCurrentMethod() as MethodInfo;
         DebugHelper.HandleException(ex, methodInfo, "Harmony patch for EncyclopediaHeroPageVM.Refresh");
     }
 }
Ejemplo n.º 2
0
        public static void RefreshPatch(EncyclopediaHeroPageVM __instance)
        {
            try
            {
                Hero?PageHero = __instance.Obj as Hero;
                if (!Settings.Instance !.UseAdvancedHeroTooltips || PageHero == Hero.MainHero)
                {
                    return;
                }
                __instance.Allies.Clear();
                __instance.Enemies.Clear();
                EncyclopediaPage pageOf1 = Campaign.Current.EncyclopediaManager.GetPageOf(typeof(Hero));
#if STABLE
                foreach (Hero hero in Hero.All)
#else
                foreach (Hero hero in Hero.AllAliveHeroes)
#endif
                {
                    if (pageOf1.IsValidEncyclopediaItem(hero) && !hero.IsNotable && hero != PageHero)
                    {
                        if (PageHero !.IsFriend(hero))
                        {
                            __instance.Allies.Add(new HeroVMcontactExtension(hero, PageHero));
                        }
                        else if (PageHero.IsEnemy(hero))
                        {
                            __instance.Enemies.Add(new HeroVMcontactExtension(hero, PageHero));
                        }
                    }
                }
            }
        public override void Refresh()
        {
            base.IsLoadingOver = false;
            this.Allies.Clear();

            EncyclopediaPage clanPages = Campaign.Current.EncyclopediaManager.GetPageOf(typeof(Clan));

            foreach (IFaction faction in Enumerable.ThenBy <IFaction, string>(Enumerable.OrderBy <IFaction, bool>(Campaign.Current.Factions, (IFaction x) => !x.IsKingdomFaction), (IFaction f) => f.Name.ToString()))
            {
                if (clanPages.IsValidEncyclopediaItem(faction) && faction != this._faction && FactionManager.IsAlliedWithFaction(this._faction, faction))
                {
                    this.Allies.Add(new EncyclopediaFactionVM(faction));
                }
            }

            if (this._faction.IsKingdomFaction)
            {
                foreach (IFaction faction in Enumerable.ThenBy <IFaction, string>(Enumerable.OrderBy <IFaction, bool>(Campaign.Current.Factions, (IFaction x) => !x.IsKingdomFaction), (IFaction f) => f.Name.ToString()))
                {
                    if (clanPages.IsValidEncyclopediaItem(faction) && faction != this._faction && faction.IsKingdomFaction && DiplomaticAgreementManager.Instance.HasNonAggressionPact(this._faction as Kingdom, faction as Kingdom, out _))
                    {
                        this.NonAggressionPacts.Add(new EncyclopediaFactionVM(faction));
                    }
                }
            }

            base.Refresh();
        }
Ejemplo n.º 4
0
        public void Setup()
        {
            // Initilize Xamarin Forms
            MockForms.Init();

            //This is your App.xaml and App.xaml.cs, which can have resources, etc.
            app = new App();
            Application.Current = app;

            page = new EncyclopediaPage();
        }