Files
necromants-tome-7d2d-3-2/HarmonySrc/RecipeSmelterFilter.cs
T
AlexCubeandClaude Opus 5.5 6ed3dc21bd Рецепты: без дублей кузни в окне навыка, все урны видны (#72)
- Список рецептов по предмету/id/ингредиенту отсеивает версию кузни
  «плавильня/лом» по настройке мира, как список верстака
  (RecipeSmelterFilter, выключатель necrosmelterfilter).
- Урны в окне некромантии - одной иконкой с recipes=: в строке
  14 иконок, было 17, последние три урны не показывались.

DLL с этой правкой закоммитится вместе с оссуарием (#66).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 22:34:47 +03:00

75 lines
3.0 KiB
C#

using System.Collections.Generic;
using HarmonyLib;
namespace NecromancerTome
{
/// <summary>
/// Кузнечные рецепты в двух версиях (плавильня - use_smelter, лом - replace_smelter) игра разводит по настройке мира
/// только в списке верстака (FilterRecipesByWorkstation) и в поиске по имени (FilterRecipesByName). Список по предмету
/// (клик по иконке в окне навыка), по id и по ингредиенту показывал обе версии - 22.10.2026 на стриме рецепт оссуария
/// «задвоился» (4 строки вместо 2: кровь/сок × плавильня/лом), у кузнечных урн так же. Здесь тот же фильтр, что у игры.
/// Выключатель - necrosmelterfilter off.
/// </summary>
public static class RecipeSmelterFilter
{
public static bool Enabled = true;
public static void Apply(List<Recipe> _list)
{
if (!Enabled || _list == null)
return;
_list.RemoveAll(r => r != null && r.craftingArea == "forge" &&
((XUiM_Recipes.DisableSmelter && r.tags.Test_AnySet(XUiM_Recipes.useSmelterTag)) ||
(!XUiM_Recipes.DisableSmelter && r.tags.Test_AnySet(XUiM_Recipes.replaceSmelterTag))));
}
}
[HarmonyPatch(typeof(XUiM_Recipes), nameof(XUiM_Recipes.FilterRecipesByItem))]
public static class Patch_XUiM_Recipes_FilterRecipesByItem_Smelter
{
public static void Postfix(List<Recipe> __result) => RecipeSmelterFilter.Apply(__result);
}
[HarmonyPatch(typeof(XUiM_Recipes), nameof(XUiM_Recipes.FilterRecipesByID))]
public static class Patch_XUiM_Recipes_FilterRecipesByID_Smelter
{
public static void Postfix(List<Recipe> __result) => RecipeSmelterFilter.Apply(__result);
}
[HarmonyPatch(typeof(XUiM_Recipes), nameof(XUiM_Recipes.FilterRecipesByIngredient))]
public static class Patch_XUiM_Recipes_FilterRecipesByIngredient_Smelter
{
public static void Postfix(List<Recipe> __result) => RecipeSmelterFilter.Apply(__result);
}
public class ConsoleCmdNecroSmelterFilter : ConsoleCmdAbstract
{
public override bool IsExecuteOnClient => true;
public override bool AllowedInMainMenu => true;
public override string[] getCommands()
{
return new string[] { "necrosmelterfilter" };
}
public override string getDescription()
{
return "Necromancer's Tome: hide forge recipe versions that do not match the smelter setting in item/ingredient recipe lists.";
}
public override string getHelp()
{
return "necrosmelterfilter on|off - off: lists by item/ingredient show both forge versions, as in the base game";
}
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
{
SdtdConsole con = SingletonMonoBehaviour<SdtdConsole>.Instance;
if (_params.Count > 0 && (_params[0] == "on" || _params[0] == "off"))
RecipeSmelterFilter.Enabled = _params[0] == "on";
con.Output("necrosmelterfilter: " + (RecipeSmelterFilter.Enabled ? "on" : "off"));
}
}
}