commit e207b9ff0a0d2d7cf5a4f89bc9c9b48bdc9df887 Author: AlexCube Date: Tue Nov 10 12:47:04 2026 +0300 Кролик в мешке: ловля голыми руками, мешок сразу в рюкзак (перенос из Книги #71) Механизм ванильного PickupItem (как у курицы), но предмет wildRabbit кладётся в рюкзак, а не в руку. ЛКМ с мешком - выпустить, «Разобрать» в рюкзаке - мясо 10 / кожа 2 / кости 5. Выключатель: rabbithutch off - ванильный захват в руку. Перенесено из Книги некроманта (ветка 1.7, выпущено не было). Co-Authored-By: Claude Code diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd4cd55 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# Build intermediates - the shipped DLLs in the mod root are committed instead. +HarmonySrc/obj/ +HarmonySrc/bin/ +*.user diff --git a/Config/Localization.csv b/Config/Localization.csv new file mode 100644 index 0000000..768a316 --- /dev/null +++ b/Config/Localization.csv @@ -0,0 +1,30 @@ +Key,File,Type,UsedInMainMenu,NoTranslate,KeepLoaded,english,Context / Alternate Text,german,spanish,french,italian,japanese,koreana,polish,brazilian,russian,turkish,schinese,tchinese +wildRabbit,items,Item,,,,Rabbit,,Hase,Conejo,Lapin,Coniglio,ウサギ,토끼,Królik,Coelho,Кролик,Tavşan,兔子,兔子 +wildRabbitDesc,items,Item,,,,"A rabbit you caught with your bare hands. It kicks inside the sack. + +Left click - let it go. Scrap it in the backpack for meat, leather and bones.",,"Ein Hase, mit bloßen Händen gefangen. Er strampelt im Sack. + +Linksklick - freilassen. Im Rucksack zerlegen: Fleisch, Leder und Knochen.","Un conejo atrapado con las manos desnudas. Patalea dentro del saco. + +Clic izquierdo: soltarlo. Despiézalo en la mochila: carne, cuero y huesos.","Un lapin attrapé à mains nues. Il se débat dans le sac. + +Clic gauche : le relâcher. Démontez-le dans le sac à dos : viande, cuir et os.","Un coniglio preso a mani nude. Scalcia nel sacco. + +Clic sinistro: liberarlo. Smontalo nello zaino: carne, cuoio e ossa.","素手で捕まえたウサギ。袋の中で暴れている。 + +左クリック - 放す。バックパックで分解すると肉、革、骨になる。","맨손으로 잡은 토끼. 자루 안에서 발버둥친다. + +좌클릭 - 풀어준다. 배낭에서 분해하면 고기, 가죽, 뼈가 나온다.","Królik złapany gołymi rękami. Wierzga w worku. + +Lewy przycisk - wypuść. Rozbierz w plecaku na mięso, skórę i kości.","Um coelho pego com as próprias mãos. Ele esperneia no saco. + +Clique esquerdo - soltar. Desmonte na mochila: carne, couro e ossos.","Кролик, пойманный голыми руками. Брыкается в мешке. + +ЛКМ - выпустить. Разберите в рюкзаке на мясо, кожу и кости.","Çıplak elle yakalanmış bir tavşan. Çuvalın içinde tepiniyor. + +Sol tık - serbest bırak. Sırt çantasında parçala: et, deri ve kemik.","徒手抓到的兔子,在袋子里乱蹬。 + +左键 - 放走。在背包里拆解可得肉、皮革和骨头。","徒手抓到的兔子,在袋子裡亂蹬。 + +左鍵 - 放走。在背包裡拆解可得肉、皮革和骨頭。" +wildRabbitGrab,PlayerMoveController.cs,Label,,,,Press [action:local:Activate][action:permanent:Activate] to Grab the Rabbit,,"[action:local:Activate][action:permanent:Activate] drücken, um den Hasen zu packen",Pulsa [action:local:Activate][action:permanent:Activate] para atrapar el conejo,Appuyez sur [action:local:Activate][action:permanent:Activate] pour attraper le lapin,Premi [action:local:Activate][action:permanent:Activate] per afferrare il coniglio,[action:local:Activate][action:permanent:Activate]でウサギを捕まえる,[action:local:Activate][action:permanent:Activate]을(를) 눌러 토끼 잡기,"Naciśnij [action:local:Activate][action:permanent:Activate], aby złapać królika",Pressione [action:local:Activate][action:permanent:Activate] para pegar o coelho,"Нажмите [action:local:Activate][action:permanent:Activate], чтобы схватить кролика",Tavşanı yakalamak için [action:local:Activate][action:permanent:Activate] tuşuna bas,按[action:local:Activate][action:permanent:Activate]抓住兔子,按[action:local:Activate][action:permanent:Activate]抓住兔子 diff --git a/Config/entityclasses.xml b/Config/entityclasses.xml new file mode 100644 index 0000000..a4b2ea0 --- /dev/null +++ b/Config/entityclasses.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/Config/items.xml b/Config/items.xml new file mode 100644 index 0000000..0c99e2e --- /dev/null +++ b/Config/items.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HarmonySrc/RabbitGrab.cs b/HarmonySrc/RabbitGrab.cs new file mode 100644 index 0000000..860fec3 --- /dev/null +++ b/HarmonySrc/RabbitGrab.cs @@ -0,0 +1,181 @@ +using System.Collections.Generic; +using HarmonyLib; +using UnityEngine; + +namespace RabbitHutch +{ + /// + /// Живой кролик в мешке (перенесено из «Книги некроманта» 10.11.2026; там задача #71 от 22.10.2026, выпущено + /// не было). Указание 22.10: «Я бы хватал кролика, но в отличие от курицы пусть он сразу оказывается в сумке»; + /// предмет - «Живой кролик в мешке», имя в игре - просто «Кролик». Ваниль даёт схватить любое существо, у которого + /// в описании есть PickupItem (EntityAlive: команда grab голой рукой, предмет кладётся в слот руки, существо + /// уходит из мира через Collect) - так ловят курицу. Кролику PickupItem дан в entityclasses.xml, а здесь его + /// мешок кладётся сразу в рюкзак (нет места - на пояс, иначе под ноги). + /// + /// Выпустить - ЛКМ с мешком в руке (ItemActionSpawnEntity, Entity=animalRabbit): ваниль предмет не тратит, тратим + /// здесь. Разделать - «Разобрать» в рюкзаке. Выключатель - rabbithutch off: тогда захват идёт ванильно, + /// мешок - в руку, как курица. + /// + public static class RabbitGrab + { + public const string SackItem = "wildRabbit"; + public static bool Enabled = true; + + public static bool IsSackAnimal(EntityAlive _e) => _e != null && _e.EntityClass != null && _e.EntityClass.PickupItem == SackItem; + + public static bool IsSack(ItemValue _iv) => _iv != null && _iv.ItemClass != null && _iv.ItemClass.GetItemName() == SackItem; + } + + /// Захват кролика - мешок сразу в рюкзак. + [HarmonyPatch(typeof(EntityAlive), nameof(EntityAlive.OnEntityActivated))] + public static class Patch_EntityAlive_OnEntityActivated_RabbitGrab + { + public static bool Prefix(EntityAlive __instance, EntityActivationCommand _command, EntityPlayerLocal _playerFocusing) + { + if (!RabbitGrab.Enabled || _command.commandId != "grab" || _playerFocusing == null || !RabbitGrab.IsSackAnimal(__instance)) + { + return true; + } + ItemClass ic = ItemClass.GetItemClass(RabbitGrab.SackItem); + if (ic == null) + { + Debug.LogWarning("[RabbitHutch] RabbitGrab: нет предмета " + RabbitGrab.SackItem + " - захват ванильский"); + return true; + } + ItemStack sack = new ItemStack(new ItemValue(ic.Id), 1); + string where = "рюкзак"; + if (_playerFocusing.bag == null || !_playerFocusing.bag.AddItem(sack)) + { + where = "пояс"; + if (_playerFocusing.inventory == null || !_playerFocusing.inventory.AddItem(sack)) + { + where = "под ноги"; + _playerFocusing.world.gameManager.ItemDropServer(sack, _playerFocusing.GetPosition() + Vector3.up * 0.5f, Vector3.zero); + } + } + _playerFocusing.MinEventContext.Other = __instance; + _playerFocusing.FireEvent(MinEventTypes.onSelfPickupOther); + __instance.MinEventContext.Other = _playerFocusing; + __instance.FireEvent(MinEventTypes.onSelfPickedUpByOther); + Audio.Manager.PlayInsidePlayerHead(ic.Properties.GetString("SoundPickup")); + __instance.Collect(_playerFocusing.entityId); + Debug.Log("[RabbitHutch] RabbitGrab: кролик " + __instance.entityId + " пойман, мешок - " + where); + return false; + } + } + + /// Подсказка над кроликом - своя (ваниль пишет «схватить курицу» для любого существа с PickupItem). + [HarmonyPatch(typeof(EntityAlive), nameof(EntityAlive.GetActivationText))] + public static class Patch_EntityAlive_GetActivationText_RabbitGrab + { + public static void Postfix(EntityAlive __instance, ref string __result) + { + if (RabbitGrab.Enabled && RabbitGrab.IsSackAnimal(__instance)) + { + __result = Localization.Get("wildRabbitGrab"); + } + } + } + + /// Выпуск из мешка тратит мешок (ванильный SpawnEntity предмет не трогает). + [HarmonyPatch(typeof(ItemActionSpawnEntity), "Spawn", new System.Type[] { typeof(ItemActionData) })] + public static class Patch_ItemActionSpawnEntity_Spawn_RabbitSack + { + public static void Postfix(ItemActionData _actionData) + { + ItemInventoryData inv = _actionData?.invData; + if (inv?.holdingEntity == null || !RabbitGrab.IsSack(inv.itemValue)) + { + return; + } + Inventory pack = inv.holdingEntity.inventory; + ItemStack held = pack.GetItem(inv.slotIdx); + if (held == null || held.IsEmpty() || !RabbitGrab.IsSack(held.itemValue)) + { + return; + } + held = held.Clone(); + held.count--; + pack.SetItem(inv.slotIdx, held.count > 0 ? held : ItemStack.Empty.Clone()); + Debug.Log("[RabbitHutch] RabbitGrab: кролик выпущен из мешка, осталось " + Mathf.Max(0, held.count)); + } + } + + /// Разделать кролика - «Разобрать» в рюкзаке (указание 22.10: «Кролика можно будет разобрать на кожу, кости и + /// мясо»; «Разделывать будем по команде сломать»). Пункт ваниль показывает сама: мешок из кожи (Mleather, forge_category + /// leather), вес не меньше кожи. Но ванильная разборка даёт один материал через очередь крафта - у мешка она наша: + /// вся стопка сразу, на каждого кролика добыча разделки ножом (entityclasses.xml animalRabbit, butcherHarvest). + [HarmonyPatch(typeof(ItemActionEntryScrap), nameof(ItemActionEntryScrap.OnActivated))] + public static class Patch_ItemActionEntryScrap_OnActivated_RabbitSack + { + static readonly string[] Yield = { "foodRawMeat", "resourceLeather", "resourceBone" }; + static readonly int[] YieldCount = { 10, 2, 5 }; + + public static bool Prefix(ItemActionEntryScrap __instance) + { + if (!(__instance.ItemController is IItemStackController isc)) + { + return true; + } + ItemStack st = isc.ItemStack; + if (st == null || st.IsEmpty() || !RabbitGrab.IsSack(st.itemValue)) + { + return true; + } + EntityPlayerLocal player = __instance.ItemController.xui.playerUI.entityPlayer; + XUiM_PlayerInventory pack = __instance.ItemController.xui.PlayerInventory; + int n = st.count; + isc.ItemStack = ItemStack.Empty.Clone(); + for (int i = 0; i < Yield.Length; i++) + { + ItemClass ic = ItemClass.GetItemClass(Yield[i]); + if (ic == null) + { + continue; + } + ItemStack s = new ItemStack(new ItemValue(ic.Id), YieldCount[i] * n); + if (!pack.AddItem(s)) + { + GameManager.Instance.ItemDropServer(s, player.GetPosition(), new Vector3(0.5f, 0f, 0.5f)); + } + } + isc.WindowGroup?.Controller?.SetAllChildrenDirty(); + Audio.Manager.PlayInsidePlayerHead("rabbitdeath"); + Debug.Log("[RabbitHutch] RabbitGrab: разобрано мешков с кроликами - " + n); + return false; + } + } + + public class ConsoleCmdRabbitHutch : ConsoleCmdAbstract + { + public override bool IsExecuteOnClient => true; + + public override bool AllowedInMainMenu => false; + + public override string[] getCommands() + { + return new string[] { "rabbithutch" }; + } + + public override string getDescription() + { + return "RabbitHutch: grabbed rabbit goes straight to the backpack - switch."; + } + + public override string getHelp() + { + return "rabbithutch - status\n" + + "rabbithutch on|off - off: vanilla grab, the sack goes to the hand like a chicken"; + } + + public override void Execute(List _params, CommandSenderInfo _senderInfo) + { + SdtdConsole con = SingletonMonoBehaviour.Instance; + if (_params.Count >= 1 && (_params[0] == "on" || _params[0] == "off")) + { + RabbitGrab.Enabled = _params[0] == "on"; + } + con.Output("rabbithutch: " + (RabbitGrab.Enabled ? "on - rabbit sack goes to the backpack" : "off - vanilla grab")); + } + } +} diff --git a/HarmonySrc/RabbitHutchHarmony.csproj b/HarmonySrc/RabbitHutchHarmony.csproj new file mode 100644 index 0000000..5475153 --- /dev/null +++ b/HarmonySrc/RabbitHutchHarmony.csproj @@ -0,0 +1,33 @@ + + + + netstandard2.1 + RabbitHutchHarmony + RabbitHutch + latest + disable + + false + false + bin\ + + + + + + ..\..\0_TFP_Harmony\0Harmony.dll + false + + + ..\..\..\7DaysToDie_Data\Managed\Assembly-CSharp.dll + false + + + + ..\..\..\7DaysToDie_Data\Managed\UnityEngine.CoreModule.dll + false + + + + diff --git a/ModInfo.xml b/ModInfo.xml new file mode 100644 index 0000000..2211b69 --- /dev/null +++ b/ModInfo.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/RabbitHutchHarmony.dll b/RabbitHutchHarmony.dll new file mode 100644 index 0000000..30cc449 Binary files /dev/null and b/RabbitHutchHarmony.dll differ diff --git a/RabbitHutchHarmony.pdb b/RabbitHutchHarmony.pdb new file mode 100644 index 0000000..f82f231 Binary files /dev/null and b/RabbitHutchHarmony.pdb differ diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..8ecd8c7 --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,17 @@ +# Rabbit Hutch + +A 7 Days to Die mod by Alex Cube. Grab the rabbit, keep it in a sack. + +- Catch a rabbit with your bare hands, just like a chicken - but the sack lands straight in your backpack, no hand-carrying. +- Left click with the sack in hand to let the rabbit go. +- Scrap the sack in the backpack for meat, leather and bones, same as butchering with a knife. +- Console switch: `rabbithutch off` returns the vanilla hand-carry grab, `rabbithutch on` - back to the backpack. + +Text in 13 languages. DLL mod (Harmony). Made on 7 Days to Die 3.4. + +## Install + +Unzip into the game's `Mods` folder so that you get `Mods/RabbitHutch/ModInfo.xml`. +Multiplayer: install on the server and on every client. Requires EAC off. + +The rabbit catch moved here from the Necromancer's Tome dev branch (1.7, unreleased); the released Tome (1.6.x) never had it, so the two mods do not overlap.