Крольчатник (#2): блок по образцу курятника
- blocks.xml: cntRabbitHutch (Class Collector, тип ChickenCoop) - 6 производителей (мешки wildRabbit), 9 ячеек вывода, корм resourcePlantFibers, без модификаций (RequiredMods пустой, пустую панель инструментов скрывает DLL); префаб-заглушка от станка объединения; 15 волокон и 2 игровых дня на кролика, минимум 2 кролика. - recipes.xml: рецепт как у курятника. Localization: +5 ключей на 13 языках. - HutchWindow.cs: скрытие пустой панели «Инструменты» (+ rabbithutch mods on|off). - ModInfo 0.2.0, ReadMe. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RabbitHutch
|
||||
{
|
||||
/// <summary>
|
||||
/// Крольчатник (#2) сделан без модификаций (указание 10.11.2026: «Модификаций не будем добавлять»), поэтому
|
||||
/// у блока RequiredMods пустой и ваниль рисовала бы пустую панель «Инструменты» с мёртвыми слотами - а слот
|
||||
/// без списка допустимых предметов ещё и принял бы любой предмет в ModSlots. Патч скрывает окно инструментов,
|
||||
/// когда у блока модов нет, тем же приёмом, каким сама игра прячет окно топлива/катализатора в OnOpen.
|
||||
/// Курятник и рососборник не трогаем: у них моды есть. Выключатель - консоль: rabbithutch mods off
|
||||
/// (действует со следующего открытия окна).
|
||||
/// </summary>
|
||||
public static class HutchWindow
|
||||
{
|
||||
/// <summary>Скрывать панель «Инструменты» у блоков-сборщиков без модификаций.</summary>
|
||||
public static bool HideEmptyMods = true;
|
||||
|
||||
public static bool HasNoMods(BlockCollector blockCollector)
|
||||
{
|
||||
string[] mods = blockCollector?.RequiredMods;
|
||||
return mods == null || mods.Length == 0
|
||||
|| (mods.Length == 1 && string.IsNullOrEmpty(mods[0]));
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_DewCollectorWindowGroup), "OnOpen")]
|
||||
public static class Patch_XUiC_DewCollectorWindowGroup_OnOpen_NoMods
|
||||
{
|
||||
public static void Postfix(XUiC_DewCollectorWindowGroup __instance)
|
||||
{
|
||||
if (!HutchWindow.HideEmptyMods)
|
||||
{
|
||||
return;
|
||||
}
|
||||
BlockCollector blockCollector = __instance.te?.blockValue.Block as BlockCollector;
|
||||
if (blockCollector == null || !HutchWindow.HasNoMods(blockCollector))
|
||||
{
|
||||
return;
|
||||
}
|
||||
XUiController modsWindow = __instance.GetChildById("windowDewCollectorMods");
|
||||
if (modsWindow?.ViewComponent != null)
|
||||
{
|
||||
modsWindow.ViewComponent.IsVisible = false;
|
||||
Debug.Log("[RabbitHutch] HutchWindow: hiding the empty Tools panel (block has no mods)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,8 +164,9 @@ namespace RabbitHutch
|
||||
|
||||
public override string getHelp()
|
||||
{
|
||||
return "rabbithutch - status\n" +
|
||||
"rabbithutch on|off - off: vanilla grab, the sack goes to the hand like a chicken";
|
||||
return "rabbithutch - status\n" +
|
||||
"rabbithutch on|off - off: vanilla grab, the sack goes to the hand like a chicken\n" +
|
||||
"rabbithutch mods on|off - hutch: hide the empty Tools panel (on by default)";
|
||||
}
|
||||
|
||||
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
|
||||
@@ -175,7 +176,12 @@ namespace RabbitHutch
|
||||
{
|
||||
RabbitGrab.Enabled = _params[0] == "on";
|
||||
}
|
||||
con.Output("rabbithutch: " + (RabbitGrab.Enabled ? "on - rabbit sack goes to the backpack" : "off - vanilla grab"));
|
||||
if (_params.Count >= 2 && _params[0] == "mods" && (_params[1] == "on" || _params[1] == "off"))
|
||||
{
|
||||
HutchWindow.HideEmptyMods = _params[1] == "on";
|
||||
}
|
||||
con.Output("rabbithutch: " + (RabbitGrab.Enabled ? "on - rabbit sack goes to the backpack" : "off - vanilla grab")
|
||||
+ "; mods panel " + (HutchWindow.HideEmptyMods ? "hidden when empty" : "always shown"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user