diff --git a/HarmonySrc/BoneSteedFuelPatch.cs b/HarmonySrc/BoneSteedFuelPatch.cs index 2fc46c3..e7722c2 100644 --- a/HarmonySrc/BoneSteedFuelPatch.cs +++ b/HarmonySrc/BoneSteedFuelPatch.cs @@ -175,7 +175,20 @@ namespace NecromancerTome { public static bool Loading; - public static void Prefix() => Loading = true; + /// Скакун, сделанный до появления ячеек (или выданный без них), получает свои + /// 4 ячейки здесь: ItemValue размечает ячейки один раз при создании и сам не дорастает. + public static void Prefix(ItemValue _itemValue) + { + Loading = true; + if (!BoneSteedFuel.IsSteedItem(_itemValue) || _itemValue.ModificationCount >= BoneSteedFuel.Slots) + return; + var mods = new ItemValue[BoneSteedFuel.Slots]; + for (int i = 0; i < mods.Length; i++) + mods[i] = i < _itemValue.ModificationCount && _itemValue.modifications[i] != null + ? _itemValue.modifications[i] + : ItemValue.None.Clone(); + _itemValue.modifications = mods; + } public static void Finalizer(Vehicle __instance) { @@ -257,4 +270,38 @@ namespace NecromancerTome return false; } } + + /// Кнопка «Заправить» в окне обслуживания: у скакуна выключена, текст - «нельзя». + [HarmonyPatch(typeof(XUiC_VehicleFrameWindow), nameof(XUiC_VehicleFrameWindow.Update))] + public static class Patch_XUiC_VehicleFrameWindow_Update_BoneSteed + { + public static void Postfix(XUiC_VehicleFrameWindow __instance) + { + if (__instance.btnRefuel_Background != null && __instance.Vehicle != null && BoneSteed.Is(__instance.Vehicle)) + __instance.btnRefuel_Background.Enabled = false; + } + } + + [HarmonyPatch(typeof(XUiC_VehicleFrameWindow), "GetBindingValueInternal")] + public static class Patch_XUiC_VehicleFrameWindow_Binding_BoneSteed + { + public static void Postfix(XUiC_VehicleFrameWindow __instance, ref string value, string bindingName) + { + if (bindingName == "refueltext" && __instance.Vehicle != null && BoneSteed.Is(__instance.Vehicle)) + value = Localization.Get("xuiRefuelNotAllowed"); + } + } + + /// Страховка: любая ванильная заправка скакуна (кнопка, меню) ничего не делает. + [HarmonyPatch(typeof(EntityVehicle), nameof(EntityVehicle.AddFuelFromInventory))] + public static class Patch_EntityVehicle_AddFuelFromInventory_BoneSteed + { + public static bool Prefix(EntityVehicle __instance, ref bool __result) + { + if (!BoneSteed.Is(__instance)) + return true; + __result = false; + return false; + } + } }