private static void RecruitAllAvailableTroops(MenuCallbackArgs args) { try { var minusMoney = 0; var recruitedAnyTroop = false; foreach (var notable in Settlement.CurrentSettlement.Notables) { for (var i = 0; i < 6; ++i) { if (notable.VolunteerTypes[i] == null || !HeroHelper.HeroCanRecruitFromHero(Hero.MainHero, notable, i)) { continue; } var troop = notable.VolunteerTypes[i]; var cost = Campaign.Current.Models.PartyWageModel.GetTroopRecruitmentCost(troop, Hero.MainHero, false); if (cost > Hero.MainHero.Gold) { continue; } minusMoney += cost; recruitedAnyTroop = true; GiveGoldAction.ApplyBetweenCharacters(Hero.MainHero, null, cost, true); notable.VolunteerTypes[i] = null; MobileParty.MainParty.MemberRoster.AddToCounts(troop, 1, false, 0, 0, true, -1); CampaignEventDispatcher.Instance.OnUnitRecruited(troop, 1); InformationManager.DisplayMessage(new InformationMessage($"You recruited one {troop.Name}.")); } } if (recruitedAnyTroop) { MBTextManager.SetTextVariable("GOLD_AMOUNT", minusMoney, false); InformationManager.DisplayMessage(new InformationMessage(GameTexts.FindText("str_gold_removed_with_icon", null).ToString(), "event:/ui/notification/coins_negative")); } } catch (Exception ex) { NativeMethods.MessageBox(IntPtr.Zero, ex.Message, "RecruitAllButton -- RecruitAllAvailableTroops", NativeMethods.MB_ICONERROR | NativeMethods.MB_OK); } }