private static void Postfix(PlayerTownVisitCampaignBehavior __instance, CampaignGameStarter campaignGameSystemStarter) { campaignGameSystemStarter.AddGameMenuOption("town", "cps_town_courier", "Find a courier", new GameMenuOption.OnConditionDelegate(game_menu_town_find_courier_on_condition), new GameMenuOption.OnConsequenceDelegate(game_menu_town_find_courier_on_consequence), false, 4, false); campaignGameSystemStarter.AddGameMenu("cps_town_courier", "You find a Calradian Postal Service agent. They can send a missive by raven for a small fee.", new OnInitDelegate(cps_town_courier_on_init), 0, GameMenu.MenuFlags.none, null); campaignGameSystemStarter.AddGameMenuOption("cps_town_courier", "cps_town_courier_missive", "Pay a {AMOUNT}{GOLD_ICON} fee to send the missive", new GameMenuOption.OnConditionDelegate(game_menu_cps_town_courier_missive_on_condition), new GameMenuOption.OnConsequenceDelegate(game_menu_cps_town_courier_missive_on_consequence), false, -1, false); campaignGameSystemStarter.AddGameMenuOption("cps_town_courier", "cps_town_courier_back", "{=qWAmxyYz}Back to town center", new GameMenuOption.OnConditionDelegate(back_on_condition), (MenuCallbackArgs x) => GameMenu.SwitchToMenu("town"), true, -1, false); }
private static bool Prefix(PlayerTownVisitCampaignBehavior __instance, MenuCallbackArgs args) { //PlayerTownVisitCampaignBehavior.UpdateMenuLocations(args.MenuContext.GameMenu.StringId); //Traverse.Create(__instance).Method("UpdateMenuLocations").GetValue(new object[] { args.MenuContext.GameMenu.StringId }); typeof(PlayerTownVisitCampaignBehavior).GetMethod("UpdateMenuLocations", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly).Invoke(__instance, new object[] { args.MenuContext.GameMenu.StringId }); if (Settlement.CurrentSettlement == null || !Settlement.CurrentSettlement.IsTown || Campaign.Current.TournamentManager.GetTournamentGame(Settlement.CurrentSettlement.Town) == null || !Campaign.Current.IsDay) { MBTextManager.SetTextVariable("ADDITIONAL_STRING", GameTexts.FindText("str_town_empty_arena_text", null), false); } else { TextObject name = Campaign.Current.TournamentManager.GetTournamentGame(Settlement.CurrentSettlement.Town).Prize.Name; //Need to turn this into a transpiler instead var currentPool = TournamentPrizePoolBehavior.GetTournamentPrizePool(Settlement.CurrentSettlement); if (!string.IsNullOrWhiteSpace(currentPool.SelectedPrizeStringId)) { var ire = currentPool.Prizes.Where(x => x.EquipmentElement.Item.StringId == currentPool.SelectedPrizeStringId).FirstOrDefault(); name = ire.EquipmentElement.GetModifiedItemName(); } MBTextManager.SetTextVariable("ITEM", name, false); MBTextManager.SetTextVariable("ADDITIONAL_STRING", GameTexts.FindText("str_town_new_tournament_text", null), false); } //var checknext = (bool)Traverse.Create(__instance).Method("CheckAndOpenNextLocation").GetValue(new object[] { args }); var checknext = (bool)typeof(PlayerTownVisitCampaignBehavior).GetMethod("CheckAndOpenNextLocation", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly).Invoke(__instance, new object[] { args }); //if (PlayerTownVisitCampaignBehavior.CheckAndOpenNextLocation(args)) if (checknext) { return(false); } args.MenuTitle = new TextObject("{=mMU3H6HZ}Arena", null); return(false); }