Upload from upload_mods.ps1
This commit is contained in:
750
Harmony/Harmony_XUiC_ItemStack.cs
Normal file
750
Harmony/Harmony_XUiC_ItemStack.cs
Normal file
@@ -0,0 +1,750 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.XUiC_ItemStackPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_ItemStack))]
|
||||
[HarmonyPatch("AllowIconGrow")]
|
||||
[HarmonyPatch(MethodType.Getter)]
|
||||
public static class AllowIconGrowPatch
|
||||
{
|
||||
public static void Postfix(XUiC_ItemStack __instance, ref bool __result
|
||||
)
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_ItemStack))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static bool Prefix(XUiC_ItemStack __instance, ref bool __result, ref string _value, string _bindingName,
|
||||
ItemStack ___itemStack
|
||||
)
|
||||
{
|
||||
if (_bindingName == "bonustypeicon")
|
||||
{
|
||||
_value = "";
|
||||
if (RebirthUtilities.ScenarioSkip() && !___itemStack.IsEmpty())
|
||||
{
|
||||
ItemValue itemValue = __instance.itemStack.itemValue;
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue bonustypeicon POST, Item: " + itemValue.ItemClass.Name);
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue IS SPECIAL");
|
||||
_value = "ui_game_symbol_" + (string)itemValue.GetMetadata("bonus");
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue bonustypeicon _value: " + _value);
|
||||
}
|
||||
}
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Postfix(XUiC_ItemStack __instance, ref bool __result, ref string _value, string _bindingName,
|
||||
ItemStack ___itemStack
|
||||
)
|
||||
{
|
||||
if (_bindingName == "itemtypeicon" && !___itemStack.IsEmpty())
|
||||
{
|
||||
if (___itemStack.itemValue.ItemClass.AltItemTypeIcon != null && ___itemStack.itemValue.ItemClass.Properties.Values.ContainsKey("RelatedPerkName"))
|
||||
{
|
||||
string perkName = ___itemStack.itemValue.ItemClass.Properties.Values["RelatedPerkName"];
|
||||
|
||||
EntityPlayer player = __instance.xui.playerUI.entityPlayer;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
ProgressionValue progressionValue = player.Progression.GetProgressionValue(perkName);
|
||||
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (progressionValue.Level > 0)
|
||||
{
|
||||
_value = ___itemStack.itemValue.ItemClass.AltItemTypeIcon;
|
||||
__result = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = ___itemStack.itemValue.ItemClass.ItemTypeIcon;
|
||||
__result = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_bindingName == "hasbonustypeicon" && !___itemStack.IsEmpty())
|
||||
{
|
||||
_value = "false";
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
ItemValue itemValue = __instance.itemStack.itemValue;
|
||||
Log.Out("XUiC_ItemStackPatches-GetBindingValue hasbonustypeicon POST, Item: " + itemValue.ItemClass.Name);
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
Log.Out("XUiC_ItemStackPatches-GetBindingValue hasbonustypeicon CAN SEE SPECIAL");
|
||||
_value = "true";
|
||||
__result = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_bindingName == "isDurabilityVisible")
|
||||
{
|
||||
_value = "false";
|
||||
if (!___itemStack.IsEmpty())
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue item: " + ___itemStack.itemValue.ItemClass.Name);
|
||||
if (___itemStack.itemValue.ItemClass.Name.ToLower().StartsWith("armor") ||
|
||||
___itemStack.itemValue.ItemClass.HasAnyTags(FastTags<TagGroup.Global>.Parse("vehiclepart")) ||
|
||||
(___itemStack.itemValue.ItemClass.HasAnyTags(FastTags<TagGroup.Global>.Parse("melee,ranged")) && !___itemStack.itemValue.ItemClass.HasAnyTags(FastTags<TagGroup.Global>.Parse("heldTorch,ammo"))))
|
||||
{
|
||||
_value = "true";
|
||||
}
|
||||
}
|
||||
|
||||
__result = true;
|
||||
}
|
||||
else if (_bindingName == "itemcount")
|
||||
{
|
||||
if (__instance.itemStack.IsEmpty())
|
||||
{
|
||||
_value = "";
|
||||
__result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue item: " + ___itemStack.itemValue.ItemClass.Name);
|
||||
|
||||
// Check if ShowDurability is false
|
||||
if (!__instance.ShowDurability)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 1, __instance.itemClassOrMissing.Stacknumber: " + __instance.itemClassOrMissing.Stacknumber);
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 1, __instance.itemStack.count: " + __instance.itemStack.count);
|
||||
// If Stacknumber is 1, assign an empty string
|
||||
if (__instance.itemClassOrMissing.Stacknumber == 1)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 2");
|
||||
_value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 3");
|
||||
// Otherwise, format the item stack count
|
||||
_value = __instance.itemcountFormatter.Format(__instance.itemStack.count);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 4");
|
||||
// If ShowDurability is true, check the Quality value
|
||||
if (__instance.itemStack.itemValue.Quality > (ushort)0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 5");
|
||||
// Format the Quality value
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
if (!___itemStack.itemValue.ItemClass.HasAnyTags(FastTags<TagGroup.Global>.Parse("vehiclepart")))
|
||||
{
|
||||
_value = "";
|
||||
__result = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
_value = __instance.itemcountFormatter.Format((int)__instance.itemStack.itemValue.Quality);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 6");
|
||||
// If Quality is not greater than 0, check if IsMod is true
|
||||
if (__instance.itemStack.itemValue.IsMod)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 7");
|
||||
_value = "*";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 8");
|
||||
// Default to an empty string
|
||||
_value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_ItemStack))]
|
||||
[HarmonyPatch("HandleStackSwap")]
|
||||
public class HandleStackSwapPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_ItemStack __instance)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.xui.name: " + __instance.xui.name);
|
||||
if (__instance.xui.lootContainer != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.xui.lootContainer.lootListName: " + __instance.xui.lootContainer.lootListName);
|
||||
}
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.StackLocation: " + __instance.StackLocation);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.ViewComponent.Controller.GetParentWindow().ID: " + __instance.ViewComponent.Controller.GetParentWindow().ID);
|
||||
|
||||
if (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.LootContainer &&
|
||||
__instance.ViewComponent.Controller.GetParentWindow().ID == "windowLooting" &&
|
||||
__instance.xui.lootContainer != null
|
||||
)
|
||||
{
|
||||
if (__instance.xui.lootContainer.lootListName == "FuriousRamsayLootGatherer")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_ItemStack))]
|
||||
[HarmonyPatch("HandleMoveToPreferredLocation")]
|
||||
public class HandleMoveToPreferredLocationPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_ItemStack __instance)
|
||||
{
|
||||
EntityPlayer player = __instance.xui.playerUI.entityPlayer;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.xui.name: " + __instance.xui.name);
|
||||
|
||||
if (__instance.xui.lootContainer != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.xui.lootContainer.lootListName: " + __instance.xui.lootContainer.lootListName);
|
||||
}
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.StackLocation: " + __instance.StackLocation);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.ViewComponent.Controller.GetParentWindow().ID: " + __instance.ViewComponent.Controller.GetParentWindow().ID);
|
||||
|
||||
if (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.Backpack &&
|
||||
__instance.ViewComponent.Controller.GetParentWindow().ID == "windowBackpack" &&
|
||||
__instance.xui.lootContainer != null
|
||||
)
|
||||
{
|
||||
if (__instance.xui.lootContainer.lootListName == "FuriousRamsayLootGatherer")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
__instance.xui.currentPopupMenu.ClearItems();
|
||||
if (__instance.ItemStack.IsEmpty() || __instance.StackLock)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 1");
|
||||
return false;
|
||||
}
|
||||
if (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.ToolBelt)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 2");
|
||||
__instance.ItemStack.Deactivate();
|
||||
}
|
||||
int count = __instance.ItemStack.count;
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 2a, __instance.itemClass: " + __instance.itemClass.Name);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 2a, __instance.ItemStack: " + __instance.ItemStack.itemValue.ItemClass.Name);
|
||||
|
||||
switch (__instance.StackLocation)
|
||||
{
|
||||
case XUiC_ItemStack.StackLocationTypes.Backpack:
|
||||
case XUiC_ItemStack.StackLocationTypes.ToolBelt:
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3, __instance.ViewComponent.Controller.GetParentWindow().ID:" + __instance.ViewComponent.Controller.GetParentWindow().ID);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3, __instance.StackLocation:" + __instance.StackLocation);
|
||||
|
||||
bool isRepairWindow = false;
|
||||
XUiController[] itemControllers = null;
|
||||
|
||||
__instance.xui.GetOpenWindows(LocalPlayerUI.openWindows);
|
||||
foreach (XUiView openWindow in LocalPlayerUI.openWindows)
|
||||
{
|
||||
//Log.Out($"openWindow: {openWindow.id}");
|
||||
if (openWindow.id.ToLower().Contains("repairentity"))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3a1, openWindow.ID:" + openWindow.ID);
|
||||
isRepairWindow = true;
|
||||
|
||||
itemControllers = openWindow.controller.Parent.GetChildrenByType<XUiC_RepairableVehicleStack>();
|
||||
|
||||
break;
|
||||
}
|
||||
else if (openWindow.id.ToLower().Contains("repair"))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3a2, openWindow.ID:" + openWindow.ID);
|
||||
isRepairWindow = true;
|
||||
|
||||
itemControllers = openWindow.controller.Parent.GetChildrenByType<XUiC_RepairableVehicleStack>();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool flag = __instance.xui.AssembleItem?.CurrentItem != null;
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3a3, flag:" + flag);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3a3, itemControllers != null:" + (itemControllers != null));
|
||||
|
||||
if (isRepairWindow && itemControllers != null && itemControllers.Length > 0)
|
||||
{
|
||||
RepairableVehicleSlotsEnum slotEnum = RepairableVehicleSlotsEnum.None;
|
||||
if (__instance.itemClass.Properties.Values.ContainsKey("VehicleSlot"))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3a4");
|
||||
slotEnum = (RepairableVehicleSlotsEnum)Enum.Parse(typeof(RepairableVehicleSlotsEnum), __instance.itemClass.Properties.Values["VehicleSlot"]);
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3b slotEnum: " + slotEnum);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3b (int)slotEnum: " + (int)slotEnum);
|
||||
|
||||
XUiC_RepairableVehicleStackGrid itemControllerGrid = itemControllers[0].parent as XUiC_RepairableVehicleStackGrid;
|
||||
|
||||
if (slotEnum != RepairableVehicleSlotsEnum.None)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3c");
|
||||
|
||||
bool shouldStop = false;
|
||||
|
||||
for (int i = 0; i < itemControllers.Length; i++)
|
||||
{
|
||||
XUiC_RepairableVehicleStack itemController = itemControllers[i] as XUiC_RepairableVehicleStack;
|
||||
|
||||
if (itemController != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3d i: " + i);
|
||||
|
||||
for (int index = 0; index < itemController.SlotIndices.Count; ++index)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3e itemController.SlotIndices[" + index + "]: " + itemController.SlotIndices[index]);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3e (int)slotEnum: " + (int)slotEnum);
|
||||
if (itemController.SlotIndices[index] == (int)slotEnum)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.ItemStack == ItemStack.Empty: " + (itemController.ItemStack == ItemStack.Empty));
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.ItemStack == null: " + (itemController.ItemStack == null));
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.ItemStack == ItemValue.None: " + (itemController.itemValue == ItemValue.None));
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.ItemStack == null: " + (itemController.itemValue == null));
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.itemValue: " + itemController.itemValue);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.itemValue.HasQuality: " + itemController.itemValue.HasQuality);
|
||||
if (itemController.itemValue.HasQuality)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.itemValue.Quality: " + itemController.itemValue.Quality);
|
||||
}
|
||||
|
||||
bool canAdd = false;
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.itemValue.ItemClass != null: " + (itemController.itemValue.ItemClass != null));
|
||||
|
||||
if (itemController.itemValue.ItemClass != null)
|
||||
{
|
||||
string currentPart = itemController.itemValue.ItemClass.GetItemName().ToLower();
|
||||
string newPart = __instance.ItemStack.itemValue.ItemClass.GetItemName().ToLower();
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f currentPart: " + currentPart);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f newPart: " + newPart);
|
||||
|
||||
if (currentPart != newPart)
|
||||
{
|
||||
canAdd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldStop = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
canAdd = true;
|
||||
}
|
||||
|
||||
if (canAdd)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3fa");
|
||||
itemController.ItemStack = __instance.ItemStack.Clone();
|
||||
Manager.PlayXUiSound(itemController.placeSound, 0.75f);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3fb");
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3fc");
|
||||
foreach (XUiC_VehicleFrameWindowRebirth window in primaryPlayer.PlayerUI.xui.GetWindowsByType<XUiC_VehicleFrameWindowRebirth>())
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3fd");
|
||||
if (window != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3fe");
|
||||
EntityVehicleRebirth vehicle = window.Vehicle;
|
||||
|
||||
if (vehicle != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3ff");
|
||||
int playerID = player.entityId;
|
||||
int currentVehicleID = vehicle.entityId;
|
||||
float currentItemUseTimes = __instance.ItemStack.itemValue.UseTimes;
|
||||
string currentItemName = __instance.ItemStack.itemValue.ItemClass.GetItemName();
|
||||
int quality = __instance.ItemStack.itemValue.Quality;
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation playerID: " + playerID);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation currentVehicleID: " + currentVehicleID);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation quality: " + quality);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation currentItemUseTimes: " + currentItemUseTimes);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation currentItemName: " + currentItemName);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation index: " + index);
|
||||
|
||||
NetPackageVehicleUpdatePartRebirth package = NetPackageManager.GetPackage<NetPackageVehicleUpdatePartRebirth>().Setup(playerID, currentVehicleID, i, currentItemUseTimes, quality, currentItemName);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(package, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldStop)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3g STOP");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((UnityEngine.Object)__instance.xui.vehicle != (UnityEngine.Object)null && !flag)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 4");
|
||||
string vehicleSlotType = __instance.ItemStack.itemValue.ItemClass.VehicleSlotType;
|
||||
ItemStack resultStack;
|
||||
if (vehicleSlotType != "" && __instance.xui.Vehicle.SetPart(__instance.xui, vehicleSlotType, __instance.ItemStack, out resultStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 5");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = resultStack;
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.vehicle.GetVehicle().HasStorage())
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 6");
|
||||
XUiC_VehicleContainer childByType = __instance.xui.FindWindowGroupByName(XUiC_VehicleStorageWindowGroup.ID).GetChildByType<XUiC_VehicleContainer>();
|
||||
if (childByType != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 7");
|
||||
if (childByType.AddItem(__instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 8");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 9");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 10");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag && __instance.ItemStack.itemValue.ItemClass is ItemClassModifier)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation ItemClass is ItemClassModifier");
|
||||
ItemStack resultStack;
|
||||
if (__instance.xui.AssembleItem.AddPartToItem(__instance.ItemStack, out resultStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 12");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = resultStack;
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.PlayerEquipment != null && __instance.xui.PlayerEquipment.IsOpen && __instance.itemStack.itemValue.ItemClass.IsEquipment)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 13");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = __instance.xui.PlayerEquipment.EquipItem(__instance.ItemStack);
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.lootContainer != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 14");
|
||||
XUiC_LootContainer childByType = __instance.xui.FindWindowGroupByName(XUiC_LootWindowGroup.ID).GetChildByType<XUiC_LootContainer>();
|
||||
if (XUiM_LootContainer.AddItem(__instance.ItemStack, __instance.xui))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 15");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
childByType?.SetSlots(__instance.xui.lootContainer, __instance.xui.lootContainer.items);
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 16");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 17");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
childByType?.SetSlots(__instance.xui.lootContainer, __instance.xui.lootContainer.items);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (__instance.xui.currentWorkstationToolGrid != null && __instance.xui.currentWorkstationToolGrid.TryAddTool(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 18");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.currentWorkstationFuelGrid != null && (object)__instance.itemClass.FuelValue != null && __instance.itemClass.FuelValue.Value > 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 19, __instance.xui.currentWorkstation: " + __instance.xui.currentWorkstation);
|
||||
string fuelType = "";
|
||||
|
||||
Block workstation = Block.GetBlockByName(__instance.xui.currentWorkstation);
|
||||
|
||||
if (workstation != null)
|
||||
{
|
||||
fuelType = workstation.Properties.GetString("FuelType");
|
||||
}
|
||||
|
||||
if (fuelType != "" && __instance.itemClass.Name.ToLower() != fuelType.ToLower())
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 19c CAN'T STACK");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*if (__instance is XUiC_RequiredItemStack)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 19a");
|
||||
XUiC_RequiredItemStack required = (XUiC_RequiredItemStack) __instance;
|
||||
|
||||
if (required != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 19b");
|
||||
ItemStack stack = __instance.itemStack;
|
||||
|
||||
if (!required.CanSwap(stack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 19c CAN'T STACK");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (__instance.xui.currentWorkstationFuelGrid.AddItem(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 20");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 21");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 22");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (__instance.xui.currentDewCollectorModGrid != null && __instance.xui.currentDewCollectorModGrid.TryAddMod(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 23");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.currentCombineGrid != null && __instance.xui.currentCombineGrid.TryAddItemToSlot(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 24");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.powerSourceSlots != null && __instance.xui.powerSourceSlots.TryAddItemToSlot(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 25");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.powerAmmoSlots != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 26");
|
||||
if (__instance.xui.powerAmmoSlots.TryAddItemToSlot(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 27");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 28");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 29");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (__instance.xui.Trader.Trader != null && (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.Backpack || __instance.StackLocation == XUiC_ItemStack.StackLocationTypes.ToolBelt))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 30");
|
||||
__instance.HandleItemInspect();
|
||||
__instance.InfoWindow.SetMaxCountOnDirty = true;
|
||||
return false;
|
||||
}
|
||||
if (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.Backpack)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 31");
|
||||
if (__instance.xui.PlayerInventory.AddItemToToolbelt(__instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 32");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 33");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 34");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.ToolBelt)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 35");
|
||||
if (__instance.xui.PlayerInventory.AddItemToBackpack(__instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 36");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 37");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 38");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XUiC_ItemStack.StackLocationTypes.LootContainer:
|
||||
case XUiC_ItemStack.StackLocationTypes.Workstation:
|
||||
case XUiC_ItemStack.StackLocationTypes.Merge:
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 39");
|
||||
if (__instance.xui.PlayerInventory.AddItem(__instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 40");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
break;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 41");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 42");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case XUiC_ItemStack.StackLocationTypes.Creative:
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 43");
|
||||
if (!__instance.xui.PlayerInventory.AddItem(__instance.itemStack.Clone()))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 44");
|
||||
return false;
|
||||
}
|
||||
__instance.PlayPlaceSound();
|
||||
break;
|
||||
}
|
||||
__instance.xui.calloutWindow.UpdateCalloutsForItemStack(__instance.ViewComponent.UiTransform.gameObject, __instance.ItemStack, __instance.isOver);
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation END");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user