示例#1
0
        public static void Postfix(ref bool __result, FloatMenuOption __instance)
        {
            if (!Ad2Mod.settings.useRightClickMenu || !PatchFloatMenu.IsTracked(__instance))
            {
                return;
            }

            if (!__result || Event.current.button != 1)
            {
                return;
            }

            __result = false;
            var recipe = Ad2.GetRecipeByLabel(__instance.Label);

            if (recipe == null || !Ad2.IsSrcRecipe(recipe))
            {
                return;
            }

            var nlst = Ad2.GetNewRecipesList(recipe);

            if (nlst == null)
            {
                return;
            }

            Find.WindowStack.Add(new FloatMenu(RecipeOptionsMaker(nlst)));
        }
        public static void Prefix(ref Func <List <FloatMenuOption> > recipeOptionsMaker, BillStack __instance)
        {
            inDoListing   = true;
            lastBillStack = __instance;
            if (!Ad2Mod.settings.useRightClickMenu)
            {
                return;
            }

            var list = recipeOptionsMaker();

            recipeOptionsMaker = delegate
            {
                var newList = new List <FloatMenuOption>();
                foreach (var opt in list)
                {
                    var recipe = Ad2.GetRecipeByLabel(opt.Label);
                    if (recipe == null || !Ad2.IsNewRecipe(recipe))
                    {
                        newList.Add(opt);
                    }
                }

                return(newList);
            };
        }