public void OnFinalize()
 {
     this._armyManagementVM?.OnFinalize();
     this._mapDataSource.OnFinalize();
     this._gauntletArmyManagementMovie?.Release();
     this._movie.Release();
     this._armyManagementVM    = (ArmyManagementVM)null;
     this._gauntletLayer       = (GauntletLayer)null;
     this._mapDataSource       = (EntrepreneurMapVM)null;
     this._encyclopediaManager = (EncyclopediaScreenManager)null;
     this._mapScreen           = (MapScreen)null;
 }
Esempio n. 2
0
 static void Postfix(ArmyManagementVM __instance)
 {
     if (!Hero.MainHero.MapFaction.IsKingdomFaction || Clan.PlayerClan.IsUnderMercenaryService)
     {
         for (int x = 0; x < __instance.PartyList.Count; x++)
         {
             if (__instance.PartyList[x].Clan.Id != MobileParty.MainParty.LeaderHero.Clan.Id)
             {
                 __instance.PartyList.RemoveAt(x);
                 x--;
             }
         }
     }
 }
 private void CloseArmyManagement()
 {
     this._gauntletLayer.ReleaseMovie(this._gauntletArmyManagementMovie);
     this._armyManagementVM.OnFinalize();
     Game.Current.EventManager.TriggerEvent <TutorialContextChangedEvent>(new TutorialContextChangedEvent(TutorialContexts.MapWindow));
     this._gauntletArmyManagementMovie = (GauntletMovie)null;
     this._armyManagementVM            = (ArmyManagementVM)null;
     Campaign.Current.SetTimeControlModeLock(false);
     Campaign.Current.TimeControlMode = this._timeControlModeBeforeArmyManagementOpened;
     if (!(ScreenManager.TopScreen is MapScreen topScreen))
     {
         return;
     }
     topScreen.IsInArmyManagement = false;
 }
 private void OpenArmyManagement()
 {
     if (this._gauntletLayer == null)
     {
         return;
     }
     this._armyManagementVM            = new ArmyManagementVM(new Action(this.CloseArmyManagement));
     this._gauntletArmyManagementMovie = this._gauntletLayer.LoadMovie("ArmyManagement", (ViewModel)this._armyManagementVM);
     this._timeControlModeBeforeArmyManagementOpened = Campaign.Current.TimeControlMode;
     Campaign.Current.TimeControlMode = CampaignTimeControlMode.Stop;
     Campaign.Current.SetTimeControlModeLock(true);
     if (!(ScreenManager.TopScreen is MapScreen topScreen))
     {
         return;
     }
     topScreen.IsInArmyManagement = true;
 }
Esempio n. 5
0
        static bool Prefix(ArmyManagementVM __instance, MBBindingList <ArmyManagementItemVM> ____partiesToRemove, Action ____onClose)
        {
            // Only enable this hack if it is enabled and player is independent
            // THIS IS A PORT OF ArmyManagementVM.ExecuteDone!
            if (!Hero.MainHero.MapFaction.IsKingdomFaction && Settings.Instance.CreatePlayerKingdom)
            {
                int  num   = __instance.PartiesInCart.Sum <ArmyManagementItemVM>((Func <ArmyManagementItemVM, int>)(P => P.Cost));
                bool flag1 = num <= 0 || (double)num <= (double)Hero.MainHero.Clan.Influence;
                if (flag1 && __instance.NewCohesion > __instance.Cohesion)
                {
                    var foo = __instance.GetType().GetMethod("ApplyCohesionChange", System.Reflection.BindingFlags.NonPublic);
                    foo.Invoke(__instance, null);
                }
                if (__instance.PartiesInCart.Count > 1 & flag1 /* && MobileParty.MainParty.MapFaction.IsKingdomFaction*/)
                {
                    if (MobileParty.MainParty.Army == null)
                    {
                        string err = "";
                        if (!CampaignCheats.CheckCheatUsage(ref err))
                        {
                            InformationMessage im = new InformationMessage(err);
                            InformationManager.DisplayMessage(im);
                            return(false);
                        }
                        if ((MobileParty.MainParty.MapFaction as Kingdom) is null)
                        {
                            CampaignCheats.CreatePlayerKingdom(new List <string>());
                        }
                        ((Kingdom)MobileParty.MainParty.MapFaction).CreateArmy(Hero.MainHero, (IMapPoint)Hero.MainHero.HomeSettlement, Army.ArmyTypes.Patrolling);
                    }
                    foreach (ArmyManagementItemVM managementItemVm in (Collection <ArmyManagementItemVM>)__instance.PartiesInCart)
                    {
                        if (managementItemVm.Party != MobileParty.MainParty)
                        {
                            managementItemVm.Party.Army = MobileParty.MainParty.Army;
                            SetPartyAiAction.GetActionForEscortingParty(managementItemVm.Party, MobileParty.MainParty);
                            managementItemVm.Party.IsJoiningArmy = true;
                        }
                    }
                    Hero.MainHero.Clan.Influence -= (float)num;
                }
                if (____partiesToRemove.Count > 0)
                {
                    bool flag2 = false;
                    foreach (ArmyManagementItemVM managementItemVm in (Collection <ArmyManagementItemVM>)____partiesToRemove)
                    {
                        if (managementItemVm.Party == MobileParty.MainParty)
                        {
                            managementItemVm.Party.Army = (Army)null;
                            flag2 = true;
                        }
                    }
                    if (!flag2)
                    {
                        foreach (ArmyManagementItemVM managementItemVm in (Collection <ArmyManagementItemVM>)____partiesToRemove)
                        {
                            Army army = MobileParty.MainParty.Army;
                            if ((army != null ? (army.Parties.Contains(managementItemVm.Party) ? 1 : 0) : 0) != 0)
                            {
                                managementItemVm.Party.Army = (Army)null;
                            }
                        }
                    }
                    ____partiesToRemove.Clear();
                }
                if (flag1)
                {
                    ____onClose();
                    CampaignEventDispatcher.Instance.OnArmyOverlaySetDirty();
                }
                else
                {
                    InformationManager.AddQuickInformation(new TextObject("{=Xmw93W6a}Not Enough Influence"));
                }

                //int num = __instance.PartiesInCart.Sum<ArmyManagementItemVM>((Func<ArmyManagementItemVM, int>)(P => P.Cost));
                //bool flag1 = (double)num <= (double)Hero.MainHero.Clan.Influence;
                //if (flag1 && __instance.NewCohesion > __instance.Cohesion)
                //{
                //    if (MobileParty.MainParty.Army == null)
                //        return false;
                //    ArmyManagementCalculationModel calculationModel = Campaign.Current.Models.ArmyManagementCalculationModel;
                //    int num1 = __instance.NewCohesion - __instance.Cohesion;
                //    Army army = MobileParty.MainParty.Army;
                //    double num2 = (double)num1;
                //    int totalInfluenceCost = calculationModel.CalculateTotalInfluenceCost(army, (float)num2);
                //    MobileParty.MainParty.Army.BoostCohesionWithInfluence((float)num1, totalInfluenceCost);
                //}
                //if (__instance.PartiesInCart.Count > 1 & flag1/* && MobileParty.MainParty.MapFaction.IsKingdomFaction*/)
                //{
                //    if (MobileParty.MainParty.Army == null)
                //    {
                //        string err = "";
                //        if (!CampaignCheats.CheckCheatUsage(ref err))
                //        {
                //            InformationMessage im = new InformationMessage(err);
                //            InformationManager.DisplayMessage(im);
                //            return false;
                //        }
                //        if ((MobileParty.MainParty.MapFaction as Kingdom) is null)
                //            CampaignCheats.CreatePlayerKingdom(new List<string>());

                //        ((Kingdom)MobileParty.MainParty.MapFaction).CreateArmy(Hero.MainHero, (IMapPoint)Hero.MainHero.HomeSettlement, Army.ArmyTypes.Patrolling);
                //    }
                //    foreach (ArmyManagementItemVM managementItemVm in (Collection<ArmyManagementItemVM>)__instance.PartiesInCart)
                //    {
                //        if (managementItemVm.Party != MobileParty.MainParty)
                //        {
                //            managementItemVm.Party.Army = MobileParty.MainParty.Army;
                //            SetPartyAiAction.GetActionForEscortingParty(managementItemVm.Party, MobileParty.MainParty);
                //            managementItemVm.Party.IsJoiningArmy = true;
                //        }
                //    }
                //    Hero.MainHero.Clan.Influence -= (float)num;
                //}
                //if (____partiesToRemove.Count > 0)
                //{
                //    bool flag2 = false;
                //    foreach (ArmyManagementItemVM managementItemVm in (Collection<ArmyManagementItemVM>)____partiesToRemove)
                //    {
                //        if (managementItemVm.Party == MobileParty.MainParty)
                //        {
                //            managementItemVm.Party.Army = (Army)null;
                //            flag2 = true;
                //        }
                //    }
                //    if (!flag2)
                //    {
                //        foreach (ArmyManagementItemVM managementItemVm in (Collection<ArmyManagementItemVM>)____partiesToRemove)
                //        {
                //            Army army = MobileParty.MainParty.Army;
                //            if ((army != null ? (army.Parties.Contains(managementItemVm.Party) ? 1 : 0) : 0) != 0)
                //                managementItemVm.Party.Army = (Army)null;
                //        }
                //    }
                //    ____partiesToRemove.Clear();
                //}
                //if (flag1)
                //    ____onClose();
                //else
                //    InformationManager.AddQuickInformation(new TextObject("{=Xmw93W6a}Not Enough Influence", (Dictionary<string, TextObject>)null), 0, (BasicCharacterObject)null, "");

                return(false);
            }

            return(true);
        }