using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("GsiX.MultiCraft")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ec8230a820957b25ee4987c9023e0cad3c7e993d")]
[assembly: AssemblyProduct("GsiX.MultiCraft")]
[assembly: AssemblyTitle("GsiX.MultiCraft")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MultiCraft;
[BepInPlugin("GsiX.MultiCraft", "GsiX MultiCraft", "2.0.6")]
public class MultiCraftPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(ZNetScene), "Awake")]
public static class ZNetScene_Awake_Patch
{
[HarmonyPostfix]
public static void Postfix(ZNetScene __instance)
{
if ((Object)(object)__instance != (Object)null)
{
MultiSupport.InitAuga(ref Status_Auga);
MultiSupport.InitAeden(ref Status_Aeden);
MultiSupport.InitVPlus(ref Status_VPlus);
}
}
}
[HarmonyPatch(typeof(Player), "Start")]
private static class Player_Start_Patch
{
private static void Postfix(Player __instance)
{
if (PluginEnable.Value && !((Object)(object)__instance == (Object)null) && ((Character)__instance).IsPlayer() && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && (Object)(object)MultiHelper.GuiBuffer != (Object)null && !MultiHelper.IsMultiCraftButtonReady())
{
if (MultiHelper.ConstructButton(MultiHelper.GuiBuffer))
{
MultiHelper.DLog("MultiCraft Button Success");
}
else
{
MultiHelper.DLog("MultiCraft Button Failed", iserror: true);
}
MultiHelper.GuiBuffer = null;
}
}
}
[HarmonyPatch(typeof(InventoryGui), "Awake")]
private static class InventoryGui_Awake_Patch
{
private static void Postfix(InventoryGui __instance)
{
if (PluginEnable.Value && !((Object)(object)__instance == (Object)null))
{
MultiHelper.GuiBuffer = __instance;
}
}
}
[HarmonyPatch(typeof(InventoryGui), "Show")]
private static class InventoryGui_Show_Patch
{
private static void Postfix(InventoryGui __instance, Container container, int activeGroup)
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
if (!PluginEnable.Value && MultiHelper.IsMultiCraftButtonReady())
{
MultiHelper.SetVisible(((Component)MultiHelper.BACKGROUND).gameObject, setactive: false);
return;
}
if (AutoRepairItem.Value)
{
MultiHelper.RepairAllItems(__instance);
}
if (MultiHelper.myInventory == null)
{
MultiHelper.myInventory = ((Humanoid)Player.m_localPlayer).GetInventory();
}
MultiHelper.OldSelection = "";
MultiHelper.ConstructButton(__instance);
MultiHelper.CURRENTMAXIMUM = -1;
MultiHelper.RecipeNameBuffers = " ";
if (ZInput.IsGamepadActive())
{
MultiHelper.GamepadStats = !ZInput.IsGamepadActive();
}
}
}
[HarmonyPatch(typeof(InventoryGui), "Hide")]
private static class InventoryGui_Hide_Patch
{
private static void Postfix()
{
if (PluginEnable.Value && MultiHelper.IsMultiCraftButtonReady())
{
MultiHelper.ResetCurrentAmount();
}
}
}
[HarmonyPatch(typeof(InventoryGui), "SetupRequirementList")]
private static class InventoryGui_SetupRequirementList_Patch
{
private static void Prefix(InventoryGui __instance, int quality, Player player, bool allowedQuality, int amount, ref KeyValuePair<Recipe, ItemData> ___m_selectedRecipe, ref List<Requirement> ___m_reqList, ref bool __runOriginal)
{
if (!PluginEnable.Value || (Object)(object)__instance == (Object)null || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer)
{
return;
}
if (allowedQuality && !MultiHelper.InProgress && ___m_selectedRecipe.Key.m_requireOnlyOneIngredient)
{
___m_reqList.Clear();
Requirement[] resources = ___m_selectedRecipe.Key.m_resources;
foreach (Requirement val in resources)
{
if (player.IsKnownMaterial(val.m_resItem.m_itemData.m_shared.m_name) && val.GetAmount(quality) > 0)
{
___m_reqList.Add(val);
}
}
int num = 0;
int num2 = 0;
List<int> list = new List<int>();
List<string> list2 = new List<string>();
bool flag = FlipIconValue.Value;
for (int j = 0; j < ___m_reqList.Count; j++)
{
if (InventoryGui.SetupRequirement(__instance.m_recipeRequirementList[num].transform, ___m_reqList[j], player, true, quality, amount))
{
list2.Add(___m_reqList[j].m_resItem.m_itemData.m_shared.m_name);
num++;
}
if (num < __instance.m_recipeRequirementList.Length)
{
continue;
}
num = 0;
for (int k = 0; k < __instance.m_recipeRequirementList.Length; k++)
{
int result = 0;
int result2 = 0;
Transform transform = __instance.m_recipeRequirementList[k].transform;
Image component = ((Component)((Component)transform).transform.Find("res_icon")).GetComponent<Image>();
if (!((UIBehaviour)component).IsActive())
{
continue;
}
string text = ((Component)((Component)transform).transform.Find("res_amount")).GetComponent<TMP_Text>().text;
string text2;
if (text.Contains("color"))
{
text2 = "MyLittleUI";
string[] array = text.Replace(" ", "").Split(new char[1] { '<' });
string[] array2 = array[1].Split(new char[1] { '(' });
int.TryParse(array[0], out result2);
int.TryParse(array2[1].Replace(")", ""), out result);
}
else if (Enumerable.Contains(text, '/'))
{
text2 = "Valheim+ and CFC";
string[] array3 = text.Split(new char[1] { '/' });
int.TryParse(array3[0], out result);
int.TryParse(array3[1], out result2);
}
else
{
text2 = "Vanilla";
int.TryParse(text, out result2);
result = ((Humanoid)player).GetInventory().CountItems(list2[k], -1, true);
flag = false;
}
if (flag)
{
if (result == 0)
{
Debug.LogWarning((object)(text2 + ": Unable to read crafting requirement type A"));
}
else
{
list.Add(result2 / result);
}
}
else if (result2 == 0)
{
Debug.LogWarning((object)(text2 + ": Unable to read crafting requirement type B"));
}
else
{
list.Add(result / result2);
}
}
list2.Clear();
}
if (list.Count > 0)
{
foreach (int item in list)
{
num2 += item;
}
}
if (MultiHelper.CURRENTMAXIMUM < 0)
{
MultiHelper.CURRENTMAXIMUM = num2;
}
if (num2 < MultiHelper.CURRENTMAXIMUM)
{
MultiHelper.CURRENTMAXIMUM = num2;
}
}
__runOriginal = true;
}
private static void Postfix(InventoryGui __instance, int quality, Player player, bool allowedQuality, KeyValuePair<Recipe, ItemData> ___m_selectedRecipe)
{
if (!PluginEnable.Value || (Object)(object)__instance == (Object)null || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer)
{
return;
}
MultiHelper.ShowNoCostText();
if (allowedQuality && !MultiHelper.InProgress && !___m_selectedRecipe.Key.m_requireOnlyOneIngredient)
{
MultiHelper.ResetDuplicateRequirementName(___m_selectedRecipe.Key.m_item);
Requirement[] resources = ___m_selectedRecipe.Key.m_resources;
foreach (Requirement val in resources)
{
if (player.IsKnownMaterial(val.m_resItem.m_itemData.m_shared.m_name) && val.GetAmount(quality) > 0)
{
string text = Localization.instance.Localize(val.m_resItem.m_itemData.m_shared.m_name);
if (!MultiHelper.RequirementNameList.ContainsKey(text))
{
MultiHelper.RequirementNameList.Add(text, val.m_resItem.m_itemData.m_shared.m_name);
}
else
{
MultiHelper.ShowDuplicateRequirementWarning(text);
}
}
}
int num = 0;
int num2 = 0;
List<int> list = new List<int>();
bool flag = FlipIconValue.Value;
for (num = 0; num < __instance.m_recipeRequirementList.Length; num++)
{
int result = 0;
int result2 = 0;
Transform transform = __instance.m_recipeRequirementList[num].transform;
Image component = ((Component)((Component)transform).transform.Find("res_icon")).GetComponent<Image>();
if (!((UIBehaviour)component).IsActive())
{
continue;
}
string text2 = ((Component)((Component)transform).transform.Find("res_name")).GetComponent<TMP_Text>().text;
string text3 = ((Component)((Component)transform).transform.Find("res_amount")).GetComponent<TMP_Text>().text;
string text4;
if (text3.Contains("color"))
{
text4 = "MyLittleUI";
string[] array = text3.Replace(" ", "").Split(new char[1] { '<' });
string[] array2 = array[1].Split(new char[1] { '(' });
int.TryParse(array[0], out result2);
int.TryParse(array2[1].Replace(")", ""), out result);
}
else if (Enumerable.Contains(text3, '/'))
{
text4 = "Valheim+ and CFC";
string[] array3 = text3.Split(new char[1] { '/' });
int.TryParse(array3[0], out result);
int.TryParse(array3[1], out result2);
}
else
{
text4 = "Vanilla";
if (MultiHelper.RequirementNameList.TryGetValue(text2, out var value))
{
int.TryParse(text3, out result2);
result = ((Humanoid)player).GetInventory().CountItems(value, -1, true);
flag = false;
}
}
if (flag)
{
if (result == 0)
{
Debug.LogWarning((object)(text4 + ": Unable to read crafting requirement type C"));
}
else
{
list.Add(result2 / result);
}
}
else if (result2 == 0)
{
Debug.LogWarning((object)(text4 + ": Unable to read crafting requirement type D"));
}
else
{
list.Add(result / result2);
}
}
if (list.Count > 0)
{
num2 = Mathf.Max(list.Min(), 0);
}
if (MultiHelper.CURRENTMAXIMUM < 0)
{
MultiHelper.CURRENTMAXIMUM = num2;
}
if (num2 < MultiHelper.CURRENTMAXIMUM)
{
MultiHelper.CURRENTMAXIMUM = num2;
}
}
if (MultiHelper.RecipeNameCurrent != __instance.m_recipeName.text)
{
MultiHelper.RecipeNameCurrent = __instance.m_recipeName.text;
}
}
}
[HarmonyPatch(typeof(InventoryGui), "SetRecipe")]
private static class InventoryGui_SetRecipe_Patch
{
private static void Postfix(InventoryGui __instance, int index, bool center)
{
if (PluginEnable.Value && !((Object)(object)__instance == (Object)null) && !MultiHelper.InProgress && MultiHelper.IsMultiCraftButtonReady())
{
MultiHelper.CURRENTMAXIMUM = -1;
MultiHelper.ResetCurrentAmount();
}
}
}
[HarmonyPatch(typeof(InventoryGui), "OnCraftPressed")]
private static class InventoryGui_OnCraftPressed_Patch
{
private static bool Prefix(InventoryGui __instance, ref Recipe ___m_craftRecipe, ref KeyValuePair<Recipe, ItemData> ___m_selectedRecipe, ref bool __runOriginal)
{
if (!PluginEnable.Value)
{
return true;
}
if (__instance.InCraftTab())
{
if (MultiHelper.CURRENTAMOUNT <= 0)
{
MultiHelper.CenterMsg("Set Current Crafting Amount");
__runOriginal = false;
return false;
}
MultiHelper.InProgress = true;
MultiHelper.ShowMultiCraftUI(MultiHelper.ButtonShowType.BUTTON_TYP_STOP);
MultiHelper.SetCraftingCompleted("");
}
__runOriginal = true;
return true;
}
}
[HarmonyPatch(typeof(InventoryGui), "OnCraftCancelPressed")]
private static class InventoryGui_OnCraftCancelPressed_Patch
{
private static void Postfix(InventoryGui __instance)
{
if (PluginEnable.Value)
{
if (__instance.InCraftTab())
{
MultiHelper.ShowMultiCraftUI(MultiHelper.ButtonTypeBuffer);
MultiHelper.ButtonTypeBuffer = MultiHelper.ButtonShowType.BUTTON_TYP_MULT;
}
else
{
MultiHelper.ShowMultiCraftUI(MultiHelper.ButtonShowType.BUTTON_TYP_HIDE);
MultiHelper.ButtonTypeBuffer = MultiHelper.ButtonShowType.BUTTON_TYP_MULT;
}
MultiHelper.DeductAmount = false;
MultiHelper.InProgress = false;
}
}
}
[HarmonyPatch(typeof(InventoryGui), "OnSelectedRecipe")]
private static class InventoryGui_OnSelectedRecipe_Patch
{
private static void Postfix(ref InventoryGui __instance, GameObject button)
{
if (PluginEnable.Value && (Object)(object)__instance != (Object)null)
{
if (MultiHelper.InProgress)
{
MultiHelper.OnStopButtonPressed();
}
MultiHelper.RecipeNameBuffers = " ";
}
}
}
[HarmonyPatch(typeof(InventoryGui), "UpdateRecipeGamepadInput")]
private static class InventoryGui_UpdateRecipeGamepadInput_Patch
{
private static void Postfix(InventoryGui __instance, ref List<KeyValuePair<Recipe, ItemData>> ___m_availableRecipes)
{
if (!PluginEnable.Value || !((Object)(object)__instance != (Object)null) || !MultiHelper.InProgress || ___m_availableRecipes.Count <= 0)
{
return;
}
if (MultiSupport.IsRunning_Auga)
{
if (ZInput.GetButton("JoyLStickDown") || ZInput.GetButton("JoyDPadDown"))
{
StopOrReset();
}
if (ZInput.GetButton("JoyLStickUp") || ZInput.GetButton("JoyDPadUp"))
{
StopOrReset();
}
}
else if (ZInput.GetButtonDown("JoyLStickDown") || ZInput.GetButtonDown("JoyDPadDown") || ZInput.GetButtonDown("JoyLStickUp") || ZInput.GetButtonDown("JoyDPadUp"))
{
StopOrReset();
}
static void StopOrReset()
{
if (MultiHelper.InProgress)
{
MultiHelper.OnStopButtonPressed();
}
MultiHelper.RecipeNameBuffers = " ";
}
}
}
public const string PluginGUID = "GsiX.MultiCraft";
public const string PluginName = "GsiX MultiCraft";
public const string PluginVersion = "2.0.6";
private readonly Harmony harmony = new Harmony("GsiX.MultiCraft");
public static ConfigEntry<bool> DeveloperConsole;
public static ConfigEntry<bool> PluginEnable;
public static ConfigEntry<bool> ShowMaxCraftable;
public static ConfigEntry<float> CraftingDuration;
public static ConfigEntry<bool> CapMaxCraftable;
public static ConfigEntry<bool> FlipIconValue;
public static ConfigEntry<bool> AutoRepairItem;
public static ConfigEntry<bool> Status_Auga;
public static ConfigEntry<bool> Status_Aeden;
public static ConfigEntry<bool> Status_VPlus;
public static ConfigEntry<KeyboardShortcut> KBDeltaSmall;
public static ConfigEntry<KeyboardShortcut> KBDeltaMedium;
public static ConfigEntry<GamepadInput> JYCraftButton;
public static ConfigEntry<GamepadInput> JYAmountPlus;
public static ConfigEntry<GamepadInput> JYAmountMinus;
public static ConfigEntry<GamepadInput> JYDeltaSmall;
public static ConfigEntry<GamepadInput> JYDeltaMedium;
public void Awake()
{
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
MultiHelper.InitLogger(((BaseUnityPlugin)this).Logger);
DeveloperConsole = ((BaseUnityPlugin)this).Config.Bind<bool>("DEVELOPER", "DebugOutput", false, "Allow Developer console output. You dont need this.");
PluginEnable = ((BaseUnityPlugin)this).Config.Bind<bool>("GENERAL", "PluginEnable", true, "Plugin Enabled/Disabled");
ShowMaxCraftable = ((BaseUnityPlugin)this).Config.Bind<bool>("GENERAL", "ShowCraftable", false, "Show maximum craftable amount at center text");
CraftingDuration = ((BaseUnityPlugin)this).Config.Bind<float>("GENERAL", "CraftingDuration", 0.5f, "Crafting time. 2f is ingame default value");
CapMaxCraftable = ((BaseUnityPlugin)this).Config.Bind<bool>("GENERAL", "CapMaxCraftable", true, "If true, maximum craftable capped at maximum amount of resources.");
FlipIconValue = ((BaseUnityPlugin)this).Config.Bind<bool>("GENERAL", "FlipIconValue", false, "If true, ICON available resources CALCULATION flipped >>> Requirement/Available");
AutoRepairItem = ((BaseUnityPlugin)this).Config.Bind<bool>("AUTO REPAIR", "AutoRepairItem", true, "Enable auto repair inventory items.");
KBDeltaSmall = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("KEYBOARD SHORTCUT", "KeyboardDelta_10", new KeyboardShortcut((KeyCode)304, Array.Empty<KeyCode>()), "Keyboard shortcut amount +/- 10");
KBDeltaMedium = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("KEYBOARD SHORTCUT", "KeyboardDelta_100", new KeyboardShortcut((KeyCode)306, Array.Empty<KeyCode>()), "Keyboard shortcut amount +/- 100");
JYCraftButton = ((BaseUnityPlugin)this).Config.Bind<GamepadInput>("GAMEPAD SHORTCUT", "GamePadCraftButton", (GamepadInput)7, "GamePad Crafting on/off for Project Auga");
JYAmountPlus = ((BaseUnityPlugin)this).Config.Bind<GamepadInput>("GAMEPAD SHORTCUT", "GamePadAmount_Plus", (GamepadInput)2, "GamePad amount plus");
JYAmountMinus = ((BaseUnityPlugin)this).Config.Bind<GamepadInput>("GAMEPAD SHORTCUT", "GamePadAmount_Minus", (GamepadInput)1, "GamePad amount minus");
JYDeltaSmall = ((BaseUnityPlugin)this).Config.Bind<GamepadInput>("GAMEPAD SHORTCUT", "GamePad_Delta10", (GamepadInput)5, "GamePad shortcut amount +/- 10");
JYDeltaMedium = ((BaseUnityPlugin)this).Config.Bind<GamepadInput>("GAMEPAD SHORTCUT", "GamePad_Delta100", (GamepadInput)14, "GamePad shortcut amount +/- 100");
Status_Auga = ((BaseUnityPlugin)this).Config.Bind<bool>("CUSTOM SUPPORT STATUS", "Status_Auga", false, "Show Project Auga STATUS is running");
Status_Aeden = ((BaseUnityPlugin)this).Config.Bind<bool>("CUSTOM SUPPORT STATUS", "Status_Aeden", false, "Show Aeden CraftFromContainers STATUS is running");
Status_VPlus = ((BaseUnityPlugin)this).Config.Bind<bool>("CUSTOM SUPPORT STATUS", "Status_VPlus", false, "Show Valheim Plus STATUS is running");
UpdateConfigChanges();
UpdateStatusChanged();
PluginEnable.SettingChanged += delegate
{
UpdateConfigChanges();
};
CapMaxCraftable.SettingChanged += delegate
{
UpdateConfigChanges();
};
ShowMaxCraftable.SettingChanged += delegate
{
UpdateConfigChanges();
};
DeveloperConsole.SettingChanged += delegate
{
UpdateConfigChanges();
};
CraftingDuration.SettingChanged += delegate
{
UpdateConfigChanges();
};
KBDeltaSmall.SettingChanged += delegate
{
UpdateConfigChanges();
};
KBDeltaMedium.SettingChanged += delegate
{
UpdateConfigChanges();
};
JYCraftButton.SettingChanged += delegate
{
UpdateConfigChanges();
};
JYAmountPlus.SettingChanged += delegate
{
UpdateConfigChanges();
};
JYAmountMinus.SettingChanged += delegate
{
UpdateConfigChanges();
};
JYDeltaSmall.SettingChanged += delegate
{
UpdateConfigChanges();
};
JYDeltaMedium.SettingChanged += delegate
{
UpdateConfigChanges();
};
Status_Auga.SettingChanged += delegate
{
UpdateStatusChanged();
};
Status_Aeden.SettingChanged += delegate
{
UpdateStatusChanged();
};
Status_VPlus.SettingChanged += delegate
{
UpdateStatusChanged();
};
harmony.PatchAll();
static void UpdateConfigChanges()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
MultiHelper.DeveloperConsole = DeveloperConsole.Value;
MultiHelper.PluginEnable = PluginEnable.Value;
MultiHelper.CapMaxCraftable = CapMaxCraftable.Value;
MultiHelper.ShowMaxCraftable = ShowMaxCraftable.Value;
MultiHelper.CraftingDuration = CraftingDuration.Value;
MultiHelper.KBDeltaSmall = KBDeltaSmall.Value;
MultiHelper.KBDeltaMedium = KBDeltaMedium.Value;
MultiPad.JYCraftButton = MultiPad.GetGamepadButton(JYCraftButton.Value);
MultiPad.JYAmountPlus = MultiPad.GetGamepadButton(JYAmountPlus.Value);
MultiPad.JYAmountMinus = MultiPad.GetGamepadButton(JYAmountMinus.Value);
MultiPad.JYDeltaSmall = MultiPad.GetGamepadButton(JYDeltaSmall.Value);
MultiPad.JYDeltaMedium = MultiPad.GetGamepadButton(JYDeltaMedium.Value);
}
static void UpdateStatusChanged()
{
Status_Auga.Value = MultiSupport.IsRunning_Auga;
Status_Aeden.Value = MultiSupport.IsRunning_Aeden;
Status_VPlus.Value = MultiSupport.IsRunning_VPlus;
}
}
public void Update()
{
if (!PluginEnable.Value || (Object)(object)Player.m_localPlayer == (Object)null || MultiHelper.myInventory == null || !MultiHelper.IsMultiCraftButtonReady())
{
return;
}
if (MultiHelper.GUI.InCraftTab())
{
if (!MultiHelper.UIShown)
{
MultiHelper.UIShown = true;
MultiHelper.ButtonTypeBuffer = MultiHelper.ButtonShowType.BUTTON_TYP_MULT;
MultiHelper.OnStopButtonPressed();
MultiHelper.RecipeNameBuffers = " ";
}
MultiHelper.UpdateGamepad();
}
else if (MultiHelper.UIShown)
{
MultiHelper.UIShown = false;
MultiHelper.ButtonTypeBuffer = MultiHelper.ButtonShowType.BUTTON_TYP_HIDE;
MultiHelper.OnStopButtonPressed();
MultiHelper.RecipeNameBuffers = " ";
MultiHelper.CURRENTMAXIMUM = -1;
MultiHelper.ResetCurrentAmount();
MultiHelper.GamepadStats = false;
MultiHelper.SetCraftingCompleted("");
}
if (MultiHelper.InProgress)
{
if (!(Time.time - MultiHelper.CraftingStart >= MultiHelper.GUI.m_craftDuration) || ((Component)MultiHelper.GUI.m_craftProgressBar).gameObject.activeInHierarchy)
{
return;
}
if (MultiHelper.DeductAmount)
{
MultiHelper.DeductAmount = false;
MultiHelper.CURRENTAMOUNT--;
MultiHelper.CURRENTMAXIMUM--;
MultiHelper.UpdateCraftingAmount();
if (MultiHelper.CURRENTAMOUNT <= 0)
{
MultiHelper.SetCraftingCompleted("<color=yellow>" + MultiHelper.RecipeNameCurrent + "</color> \nCompleted");
}
}
if (MultiHelper.CURRENTAMOUNT > 0)
{
if (MultiHelper.myInventory.HaveEmptySlot())
{
MultiHelper.DeductAmount = true;
MultiHelper.CraftingStart = Time.time;
((UnityEvent)((Component)MultiHelper.GUI.m_craftButton).GetComponent<Button>().onClick).Invoke();
return;
}
MultiHelper.CenterMsg("MultiCraft Minimum One <color=#00ff00>Extra</color> Empty Slot");
}
MultiHelper.OnStopButtonPressed();
if (MultiHelper.CURRENTMAXIMUM > 0)
{
MultiHelper.CURRENTAMOUNT = 1;
MultiHelper.UpdateCraftingAmount();
}
}
else if (MultiHelper.CURRENTMAXIMUM >= 0 && MultiHelper.RecipeNameBuffers != MultiHelper.RecipeNameCurrent)
{
MultiHelper.RecipeNameBuffers = MultiHelper.RecipeNameCurrent;
if (MultiHelper.CURRENTMAXIMUM > 0)
{
MultiHelper.CURRENTAMOUNT = 1;
MultiHelper.ShowCraftableText("#00ff00");
}
else
{
MultiHelper.CURRENTAMOUNT = 0;
MultiHelper.ShowCraftableText("#404040");
}
MultiHelper.UpdateCraftingAmount();
MultiHelper.SetCraftingCompleted("");
}
}
}
internal class MultiHelper
{
public enum ButtonShowType
{
BUTTON_TYP_MULT,
BUTTON_TYP_STOP,
BUTTON_TYP_JOY,
BUTTON_TYP_HIDE
}
public static ButtonShowType ButtonTypeBuffer = ButtonShowType.BUTTON_TYP_MULT;
public static ManualLogSource log;
public static InventoryGui GUI;
public static InventoryGui GuiBuffer;
public static Inventory myInventory;
public static RectTransform BUTTON_CRAFT;
public static RectTransform BUTTON_PROGS;
public static RectTransform BUTTON_PLUS;
public static RectTransform BUTTON_MINUS;
public static RectTransform BUTTON_STOP;
public static RectTransform AMOUNT_TEXTMIN;
public static RectTransform AMOUNT_TEXTMAX;
public static RectTransform NOTE_JOYPAD;
public static RectTransform NOTE_NOCOST;
public static RectTransform NOTE_NOTE;
public static RectTransform BACKGROUND;
public static TMP_Text AMOUNT_TMPMin;
public static TMP_Text AMOUNT_TMPMax;
public static TMP_Text NOTE_TMPNoCost;
public static TMP_Text NOTE_TMPNote;
public static bool GamepadStats;
public static bool InProgress;
public static bool UIShown;
public static bool DeductAmount;
public static int CURRENTMAXIMUM = -1;
public static int CURRENTAMOUNT = 0;
public static float CraftingStart = Time.time;
public static float NoCostStart = Time.time;
public static float RangeToCount = -1f;
public static string RecipeNameCurrent = "";
public static string RecipeNameBuffers = "";
public const string NAME_PLUS = "multicraft_plus";
public const string NAME_MINUS = "multicraft_minus";
public const string NAME_STOP = "multicraft_stop";
public const string NAME_AMOUNTMIN = "multicraft_amt_min";
public const string NAME_AMOUNTMAX = "multicraft_amt_max";
public const string NAME_AMOUNTJOY = "multicraft_amt_joy";
public const string NAME_NOCOST = "multicraft_nocost";
public const string NAME_NOTE = "multicraft_note";
public const string NAME_BACKGROUND = "multicraft_bkg";
public const string colorOFF = "#404040";
public const string colorONS = "#00ff00";
public const float bkgNormY = -590f;
public const float bkgAugaY = -440f;
public const float width = 50f;
public const float height = 40f;
public const float posY = 0f;
public static bool PluginEnable;
public static bool CapMaxCraftable;
public static bool ShowMaxCraftable;
public static bool DeveloperConsole;
public static float CraftingDuration;
public static KeyboardShortcut KBDeltaSmall;
public static KeyboardShortcut KBDeltaMedium;
public static string CraftButtonPanel = "craft_button_panel";
public static string CraftButtonProgs = "Progress";
public static string CraftButtonTextName = "Text";
public static string OldSelection;
public static string NewSelection;
public static readonly List<string> DuplicateRequirementName = new List<string>();
public static readonly Dictionary<string, string> RequirementNameList = new Dictionary<string, string>();
private static List<ItemData> TempWornItem = new List<ItemData>();
public static void InitLogger(ManualLogSource loG)
{
log = loG;
}
public static void DLog(string text, bool iserror = false)
{
if (iserror)
{
log.LogWarning((object)text);
}
else
{
log.LogInfo((object)text);
}
}
public static bool IsMultiCraftButtonReady()
{
return (Object)(object)GUI != (Object)null && (Object)(object)BACKGROUND != (Object)null && (Object)(object)BUTTON_CRAFT != (Object)null && (Object)(object)BUTTON_PROGS != (Object)null && (Object)(object)BUTTON_PLUS != (Object)null && (Object)(object)BUTTON_MINUS != (Object)null && (Object)(object)BUTTON_STOP != (Object)null && (Object)(object)AMOUNT_TEXTMIN != (Object)null && (Object)(object)AMOUNT_TEXTMAX != (Object)null && (Object)(object)NOTE_JOYPAD != (Object)null && (Object)(object)NOTE_NOCOST != (Object)null;
}
public static void SetVisible(GameObject button, bool setactive = true)
{
if (button != null)
{
button.SetActive(setactive);
}
}
public static void OnStopButtonPressed()
{
if (PluginEnable && (Object)(object)GUI != (Object)null)
{
((MonoBehaviour)GUI).Invoke("OnCraftCancelPressed", 0f);
}
}
public static void OnPlusButtonPressed()
{
AmountChanges(isPlus: true);
}
public static void OnMinusButtonPressed()
{
AmountChanges(isPlus: false);
}
public static void AmountChanges(bool isPlus)
{
if (!PluginEnable)
{
return;
}
int num = (isPlus ? 1 : (-1));
if (ZInput.IsGamepadActive())
{
if (ZInput.GetButton(MultiPad.JYDeltaSmall))
{
num *= 10;
}
else if (ZInput.GetButton(MultiPad.JYDeltaMedium))
{
num *= 100;
}
}
else if (((KeyboardShortcut)(ref KBDeltaSmall)).IsPressed())
{
num *= 10;
}
else if (((KeyboardShortcut)(ref KBDeltaMedium)).IsPressed())
{
num *= 100;
}
CURRENTAMOUNT += num;
if (CURRENTAMOUNT <= 0)
{
if (CURRENTMAXIMUM > 0)
{
CURRENTAMOUNT = 1;
}
else
{
CURRENTAMOUNT = 0;
}
}
else if (CURRENTAMOUNT > CURRENTMAXIMUM)
{
if (!IsNoCraftCost() && CapMaxCraftable)
{
CURRENTAMOUNT = CURRENTMAXIMUM;
}
if (CURRENTMAXIMUM > 0)
{
ShowCraftableText("#00ff00");
}
else
{
ShowCraftableText("#404040");
}
}
UpdateCraftingAmount();
SetCraftingCompleted("");
}
public static void ResetCurrentAmount()
{
CURRENTAMOUNT = 0;
UpdateCraftingAmount();
}
public static void UpdateCraftingAmount()
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)AMOUNT_TMPMin != (Object)null)
{
AMOUNT_TMPMin.text = $"{CURRENTAMOUNT}";
if (CURRENTAMOUNT <= 0 || !((Selectable)GUI.m_craftButton).IsInteractable())
{
((Graphic)AMOUNT_TMPMin).color = Color.grey;
}
else
{
((Graphic)AMOUNT_TMPMin).color = Color.green;
}
}
if ((Object)(object)AMOUNT_TMPMax != (Object)null)
{
if (CURRENTMAXIMUM <= 0)
{
AMOUNT_TMPMax.text = "0";
}
else
{
AMOUNT_TMPMax.text = $"{CURRENTMAXIMUM}";
}
if (CURRENTMAXIMUM <= 0 || !((Selectable)GUI.m_craftButton).IsInteractable())
{
((Graphic)AMOUNT_TMPMax).color = Color.grey;
}
else
{
((Graphic)AMOUNT_TMPMax).color = Color.magenta;
}
}
}
public static void ShowCraftableText(string coloritem)
{
if (GUI.InCraftTab() && ShowMaxCraftable)
{
string text = coloritem;
if (!((Selectable)GUI.m_craftButton).IsInteractable() && text != "#404040")
{
text = "#404040";
}
if (CapMaxCraftable)
{
CenterMsg("<color=" + text + ">" + GUI.m_recipeName.text + "</color>\nMaximum Craftable" + $"\n<color={text}>{CURRENTMAXIMUM}</color>");
}
else
{
CenterMsg("<color=" + text + ">" + GUI.m_recipeName.text + "</color>\nUncapped Maximum Craftable" + $"\n<color={text}>{CURRENTMAXIMUM}</color>");
}
}
}
public static bool ConstructButton(InventoryGui inventoriGui)
{
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Expected O, but got Unknown
//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
//IL_0339: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Expected O, but got Unknown
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
//IL_0371: Unknown result type (might be due to invalid IL or missing references)
//IL_0377: Expected O, but got Unknown
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
//IL_03db: Expected O, but got Unknown
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_039f: Expected O, but got Unknown
//IL_0415: Unknown result type (might be due to invalid IL or missing references)
//IL_041f: Expected O, but got Unknown
//IL_051e: Unknown result type (might be due to invalid IL or missing references)
//IL_0528: Expected O, but got Unknown
//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0605: Expected O, but got Unknown
//IL_048c: Unknown result type (might be due to invalid IL or missing references)
//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
//IL_04bc: Expected O, but got Unknown
//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
//IL_06e2: Expected O, but got Unknown
//IL_0592: Unknown result type (might be due to invalid IL or missing references)
//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
//IL_05c2: Expected O, but got Unknown
//IL_0815: Unknown result type (might be due to invalid IL or missing references)
//IL_081f: Expected O, but got Unknown
//IL_066f: Unknown result type (might be due to invalid IL or missing references)
//IL_0695: Unknown result type (might be due to invalid IL or missing references)
//IL_069f: Expected O, but got Unknown
//IL_0952: Unknown result type (might be due to invalid IL or missing references)
//IL_095c: Expected O, but got Unknown
//IL_072d: Unknown result type (might be due to invalid IL or missing references)
//IL_0737: Expected O, but got Unknown
//IL_0a86: Unknown result type (might be due to invalid IL or missing references)
//IL_0a90: Expected O, but got Unknown
//IL_086a: Unknown result type (might be due to invalid IL or missing references)
//IL_0874: Expected O, but got Unknown
//IL_07a2: Unknown result type (might be due to invalid IL or missing references)
//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0bc3: Unknown result type (might be due to invalid IL or missing references)
//IL_0bcd: Expected O, but got Unknown
//IL_09a7: Unknown result type (might be due to invalid IL or missing references)
//IL_09b1: Expected O, but got Unknown
//IL_08df: Unknown result type (might be due to invalid IL or missing references)
//IL_090e: Unknown result type (might be due to invalid IL or missing references)
//IL_0adb: Unknown result type (might be due to invalid IL or missing references)
//IL_0ae5: Expected O, but got Unknown
//IL_0a1c: Unknown result type (might be due to invalid IL or missing references)
//IL_0a42: Unknown result type (might be due to invalid IL or missing references)
//IL_0c18: Unknown result type (might be due to invalid IL or missing references)
//IL_0c22: Expected O, but got Unknown
//IL_0b50: Unknown result type (might be due to invalid IL or missing references)
//IL_0b7f: Unknown result type (might be due to invalid IL or missing references)
//IL_0d3d: Unknown result type (might be due to invalid IL or missing references)
//IL_0d5c: Unknown result type (might be due to invalid IL or missing references)
//IL_0d7b: Unknown result type (might be due to invalid IL or missing references)
//IL_0c8d: Unknown result type (might be due to invalid IL or missing references)
//IL_0cbc: Unknown result type (might be due to invalid IL or missing references)
GUI = inventoriGui;
if (MultiSupport.IsRunning_Auga)
{
RectTransform val = (RectTransform)((Component)inventoriGui.m_craftButton).transform.parent.parent;
BACKGROUND = (RectTransform)((Component)val).transform.Find("multicraft_bkg");
if ((Object)(object)BACKGROUND == (Object)null)
{
RectTransform val2 = (RectTransform)((Component)inventoriGui.m_craftButton).transform.parent.parent.parent.parent;
if ((Object)(object)val2 == (Object)null)
{
DLog("Auga dummyparent failed stage 1", iserror: true);
return false;
}
val2 = (RectTransform)((Component)val2).transform.Find("WorkbenchContent");
if ((Object)(object)val2 == (Object)null)
{
DLog("Auga dummyparent failed stage 2", iserror: true);
return false;
}
RectTransform val3 = (RectTransform)((Component)val2).transform.Find("Background");
if ((Object)(object)val3 != (Object)null)
{
Transform val4 = (Transform)(object)Object.Instantiate<RectTransform>(val3, ((Component)val3).transform.parent);
((Object)val4).name = "multicraft_bkg";
((Component)val4).transform.SetAsFirstSibling();
BACKGROUND = (RectTransform)((Component)val4).transform;
((Transform)BACKGROUND).SetParent((Transform)(object)val);
BACKGROUND.SetSizeWithCurrentAnchors((Axis)0, 360f);
BACKGROUND.SetSizeWithCurrentAnchors((Axis)1, 60f);
((Transform)BACKGROUND).localPosition = new Vector3(90f, -440f, 0f);
((Component)BACKGROUND).gameObject.SetActive(false);
DLog("Valheim Auga Success.");
}
}
}
else
{
RectTransform val2 = (RectTransform)((Component)inventoriGui.m_craftButton).transform.parent.parent;
if ((Object)(object)val2 == (Object)null)
{
DLog("panel parent failed at Awake", iserror: true);
return false;
}
BACKGROUND = (RectTransform)((Component)val2).transform.Find("multicraft_bkg");
if ((Object)(object)BACKGROUND == (Object)null)
{
RectTransform val5 = (RectTransform)((Component)((Transform)val2).parent).transform.Find("Bkg");
if ((Object)(object)val5 != (Object)null)
{
Transform val6 = (Transform)(object)Object.Instantiate<RectTransform>(val5, ((Component)val5).transform.parent);
((Object)val6).name = "multicraft_bkg";
((Component)val6).transform.SetAsFirstSibling();
BACKGROUND = (RectTransform)((Component)val6).transform;
((Transform)BACKGROUND).SetParent((Transform)(object)val2);
BACKGROUND.SetSizeWithCurrentAnchors((Axis)0, 360f);
BACKGROUND.SetSizeWithCurrentAnchors((Axis)1, 60f);
((Transform)BACKGROUND).localPosition = new Vector3(-175f, -590f, 0f);
((Component)BACKGROUND).gameObject.SetActive(false);
DLog("Valheim Vanilla Success.");
}
}
}
if ((Object)(object)BACKGROUND == (Object)null)
{
DLog("Background was Failed.", iserror: true);
return false;
}
RectTransform val7 = (RectTransform)((Component)inventoriGui.m_craftButton).transform.parent;
if ((Object)(object)val7 == (Object)null)
{
DLog("panel parent failed at Awake", iserror: true);
return false;
}
RectTransform val8 = (RectTransform)((Transform)val7).parent.Find(CraftButtonPanel);
if ((Object)(object)val8 != (Object)null)
{
BUTTON_PROGS = (RectTransform)((Component)val8).transform.Find(CraftButtonProgs);
if ((Object)(object)BUTTON_PROGS == (Object)null)
{
DLog("button progress failed at Awake", iserror: true);
return false;
}
}
BUTTON_CRAFT = (RectTransform)((Component)inventoriGui.m_craftButton).transform;
if ((Object)(object)BUTTON_CRAFT == (Object)null)
{
DLog("button craft failed at Awake", iserror: true);
return false;
}
BUTTON_STOP = (RectTransform)((Component)BACKGROUND).transform.Find("multicraft_stop");
if ((Object)(object)BUTTON_STOP == (Object)null)
{
BUTTON_STOP = CreateMultiCraftButton(inventoriGui, "multicraft_stop", "STOP", 100f, 40f);
if (!((Object)(object)BUTTON_STOP != (Object)null))
{
DLog("Button Stop Failed.", iserror: true);
return false;
}
((Transform)BUTTON_STOP).SetParent((Transform)(object)BACKGROUND);
((Transform)BUTTON_STOP).localPosition = new Vector3(110f, 0f, 0f);
((UnityEvent)((Component)BUTTON_STOP).gameObject.GetComponent<Button>().onClick).AddListener(new UnityAction(OnStopButtonPressed));
TMP_Text component = ((Component)BUTTON_STOP).GetComponent<TMP_Text>();
if ((Object)(object)component != (Object)null)
{
component.fontSize = 5f;
}
ButtonDebug("Button Stop Created.");
}
BUTTON_PLUS = (RectTransform)((Component)BACKGROUND).transform.Find("multicraft_plus");
if ((Object)(object)BUTTON_PLUS == (Object)null)
{
BUTTON_PLUS = CreateMultiCraftButton(inventoriGui, "multicraft_plus", "+", 50f, 40f);
if (!((Object)(object)BUTTON_PLUS != (Object)null))
{
DLog("Button Plus Failed.", iserror: true);
return false;
}
((Transform)BUTTON_PLUS).SetParent((Transform)(object)BACKGROUND);
((Transform)BUTTON_PLUS).localPosition = new Vector3(135f, 0f, 0f);
((UnityEvent)((Component)BUTTON_PLUS).gameObject.GetComponent<Button>().onClick).AddListener(new UnityAction(OnPlusButtonPressed));
ButtonDebug("Button Plus Created.");
}
BUTTON_MINUS = (RectTransform)((Component)BACKGROUND).transform.Find("multicraft_minus");
if ((Object)(object)BUTTON_MINUS == (Object)null)
{
BUTTON_MINUS = CreateMultiCraftButton(inventoriGui, "multicraft_minus", "-", 50f, 40f);
if (!((Object)(object)BUTTON_MINUS != (Object)null))
{
DLog("Button Minus Failed.", iserror: true);
return false;
}
((Transform)BUTTON_MINUS).SetParent((Transform)(object)BACKGROUND);
((Transform)BUTTON_MINUS).localPosition = new Vector3(85f, 0f, 0f);
((UnityEvent)((Component)BUTTON_MINUS).gameObject.GetComponent<Button>().onClick).AddListener(new UnityAction(OnMinusButtonPressed));
ButtonDebug("Button Minus Created.");
}
AMOUNT_TEXTMIN = (RectTransform)((Component)BACKGROUND).transform.Find("multicraft_amt_min");
if ((Object)(object)AMOUNT_TEXTMIN == (Object)null)
{
Transform val9 = ((Component)inventoriGui.m_craftButton).transform.Find(CraftButtonTextName);
if ((Object)(object)val9 != (Object)null)
{
AMOUNT_TEXTMIN = (RectTransform)Object.Instantiate<Transform>(val9, ((Component)val7).transform);
if (!((Object)(object)AMOUNT_TEXTMIN != (Object)null))
{
DLog("Amount Text Min Failed.", iserror: true);
return false;
}
((Object)AMOUNT_TEXTMIN).name = "multicraft_amt_min";
AMOUNT_TEXTMIN.SetSizeWithCurrentAnchors((Axis)0, 100f);
AMOUNT_TEXTMIN.SetSizeWithCurrentAnchors((Axis)1, 40f);
((Transform)AMOUNT_TEXTMIN).SetParent((Transform)(object)BACKGROUND);
((Transform)AMOUNT_TEXTMIN).localPosition = new Vector3(-100f, 0f, 0f);
AMOUNT_TMPMin = ((Component)AMOUNT_TEXTMIN).GetComponent<TMP_Text>();
AMOUNT_TMPMin.text = "1";
((Graphic)AMOUNT_TMPMin).color = Color.green;
ButtonDebug("Text Amount Min Created.");
}
}
AMOUNT_TEXTMAX = (RectTransform)((Component)BACKGROUND).transform.Find("multicraft_amt_max");
if ((Object)(object)AMOUNT_TEXTMAX == (Object)null)
{
Transform val10 = ((Component)inventoriGui.m_craftButton).transform.Find(CraftButtonTextName);
if ((Object)(object)val10 != (Object)null)
{
AMOUNT_TEXTMAX = (RectTransform)Object.Instantiate<Transform>(val10, ((Component)val7).transform);
if (!((Object)(object)AMOUNT_TEXTMAX != (Object)null))
{
DLog("Amount Text Max Failed.", iserror: true);
return false;
}
((Object)AMOUNT_TEXTMAX).name = "multicraft_amt_max";
AMOUNT_TEXTMAX.SetSizeWithCurrentAnchors((Axis)0, 100f);
AMOUNT_TEXTMAX.SetSizeWithCurrentAnchors((Axis)1, 40f);
((Transform)AMOUNT_TEXTMAX).SetParent((Transform)(object)BACKGROUND);
((Transform)AMOUNT_TEXTMAX).localPosition = new Vector3(0f, 0f, 0f);
AMOUNT_TMPMax = ((Component)AMOUNT_TEXTMAX).GetComponent<TMP_Text>();
AMOUNT_TMPMax.text = "1";
((Graphic)AMOUNT_TMPMax).color = Color.magenta;
ButtonDebug("Text Amount Max Created.");
}
}
NOTE_JOYPAD = (RectTransform)((Component)BACKGROUND).transform.Find("multicraft_amt_joy");
if ((Object)(object)NOTE_JOYPAD == (Object)null)
{
Transform val11 = ((Component)inventoriGui.m_craftButton).transform.Find(CraftButtonTextName);
if ((Object)(object)val11 != (Object)null)
{
NOTE_JOYPAD = (RectTransform)Object.Instantiate<Transform>(val11, ((Component)val7).transform);
if (!((Object)(object)NOTE_JOYPAD != (Object)null))
{
DLog("Text Joypad Failed.", iserror: true);
return false;
}
((Object)NOTE_JOYPAD).name = "multicraft_amt_joy";
NOTE_JOYPAD.SetSizeWithCurrentAnchors((Axis)0, 100f);
NOTE_JOYPAD.SetSizeWithCurrentAnchors((Axis)1, 40f);
((Transform)NOTE_JOYPAD).SetParent((Transform)(object)BACKGROUND);
((Transform)NOTE_JOYPAD).localPosition = new Vector3(105f, 0f, 0f);
TMP_Text component2 = ((Component)NOTE_JOYPAD).GetComponent<TMP_Text>();
component2.text = "JOYPAD";
((Graphic)component2).color = Color.black;
ButtonDebug("Text Joypad Created.");
}
}
NOTE_NOCOST = (RectTransform)((Component)BACKGROUND).transform.Find("multicraft_nocost");
if ((Object)(object)NOTE_NOCOST == (Object)null)
{
Transform val12 = ((Component)inventoriGui.m_craftButton).transform.Find(CraftButtonTextName);
if ((Object)(object)val12 != (Object)null)
{
NOTE_NOCOST = (RectTransform)Object.Instantiate<Transform>(val12, ((Component)val7).transform);
if (!((Object)(object)NOTE_NOCOST != (Object)null))
{
DLog("Text No Cost Failed.", iserror: true);
return false;
}
((Object)NOTE_NOCOST).name = "multicraft_nocost";
NOTE_NOCOST.SetSizeWithCurrentAnchors((Axis)0, 200f);
NOTE_NOCOST.SetSizeWithCurrentAnchors((Axis)1, 40f);
((Transform)NOTE_NOCOST).SetParent((Transform)(object)BACKGROUND);
((Transform)NOTE_NOCOST).localPosition = new Vector3(0f, -50f, 0f);
NOTE_TMPNoCost = ((Component)NOTE_NOCOST).GetComponent<TMP_Text>();
NOTE_TMPNoCost.text = "NO CRAFTING COST";
((Graphic)NOTE_TMPNoCost).color = Color.yellow;
ButtonDebug("Text No Cost Created.");
}
}
NOTE_NOTE = (RectTransform)((Component)BACKGROUND).transform.Find("multicraft_note");
if ((Object)(object)NOTE_NOTE == (Object)null)
{
Transform val13 = ((Component)inventoriGui.m_craftButton).transform.Find(CraftButtonTextName);
if ((Object)(object)val13 != (Object)null)
{
NOTE_NOTE = (RectTransform)Object.Instantiate<Transform>(val13, ((Component)val7).transform);
if (!((Object)(object)NOTE_NOTE != (Object)null))
{
DLog("Text No Cost Failed.", iserror: true);
return false;
}
((Object)NOTE_NOTE).name = "multicraft_note";
NOTE_NOTE.SetSizeWithCurrentAnchors((Axis)0, 300f);
NOTE_NOTE.SetSizeWithCurrentAnchors((Axis)1, 60f);
((Transform)NOTE_NOTE).SetParent((Transform)(object)BACKGROUND);
((Transform)NOTE_NOTE).localPosition = new Vector3(0f, -90f, 0f);
NOTE_TMPNote = ((Component)NOTE_NOTE).GetComponent<TMP_Text>();
NOTE_TMPNote.text = "NO CRAFTING COST";
((Graphic)NOTE_TMPNote).color = Color.green;
ButtonDebug("Text No Cost Created.");
}
}
ResetCurrentAmount();
if (GUI.m_craftDuration != CraftingDuration)
{
GUI.m_craftDuration = CraftingDuration;
}
if (MultiSupport.IsRunning_Auga)
{
((Transform)BUTTON_PLUS).localPosition = new Vector3(140f, 0f, 0f);
((Transform)BUTTON_MINUS).localPosition = new Vector3(93f, 0f, 0f);
((Transform)BUTTON_STOP).localPosition = new Vector3(116f, 0f, 0f);
}
return true;
static RectTransform CreateMultiCraftButton(InventoryGui invgui, string name, string sometext, float axisZero, float axisOne)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
Transform transform = ((Component)invgui.m_craftButton).transform;
Transform val14 = Object.Instantiate<Transform>(transform, ((Component)transform).transform.parent);
((Object)val14).name = name;
RectTransform val15 = (RectTransform)((Component)val14).transform;
val15.SetSizeWithCurrentAnchors((Axis)0, axisZero);
val15.SetSizeWithCurrentAnchors((Axis)1, axisOne);
RectTransform val16 = (RectTransform)((Component)val15).transform.Find(CraftButtonTextName);
if ((Object)(object)val16 == (Object)null)
{
DLog("rectransform null", iserror: true);
return null;
}
val16.SetSizeWithCurrentAnchors((Axis)0, axisZero);
val16.SetSizeWithCurrentAnchors((Axis)1, axisOne);
TMP_Text component3 = ((Component)val16).GetComponent<TMP_Text>();
component3.text = sometext;
((Component)val15).gameObject.SetActive(false);
return val15;
}
}
public static void ShowMultiCraftUI(ButtonShowType type)
{
if (!PluginEnable)
{
if (IsMultiCraftButtonReady())
{
SetVisible(((Component)BACKGROUND).gameObject, setactive: false);
}
DLog("MultiCraft Disabled", iserror: true);
return;
}
if (!IsMultiCraftButtonReady())
{
DLog("ShowMultiCraftUI Button Not Ready", iserror: true);
return;
}
switch (type)
{
case ButtonShowType.BUTTON_TYP_MULT:
if (!GamepadStats)
{
SetVisible(((Component)BACKGROUND).gameObject);
SetVisible(((Component)BUTTON_STOP).gameObject, setactive: false);
SetVisible(((Component)BUTTON_PLUS).gameObject);
SetVisible(((Component)BUTTON_MINUS).gameObject);
SetVisible(((Component)NOTE_JOYPAD).gameObject, setactive: false);
if (DeveloperConsole)
{
DLog("BUTTON_TYP_MULT");
}
}
break;
case ButtonShowType.BUTTON_TYP_STOP:
if (!GamepadStats)
{
SetVisible(((Component)BACKGROUND).gameObject);
SetVisible(((Component)BUTTON_PLUS).gameObject, setactive: false);
SetVisible(((Component)BUTTON_MINUS).gameObject, setactive: false);
SetVisible(((Component)BUTTON_STOP).gameObject);
SetVisible(((Component)NOTE_JOYPAD).gameObject, setactive: false);
if (DeveloperConsole)
{
DLog("BUTTON_TYP_STOP");
}
}
break;
case ButtonShowType.BUTTON_TYP_JOY:
SetVisible(((Component)BACKGROUND).gameObject);
SetVisible(((Component)BUTTON_STOP).gameObject, setactive: false);
SetVisible(((Component)BUTTON_PLUS).gameObject, setactive: false);
SetVisible(((Component)BUTTON_MINUS).gameObject, setactive: false);
SetVisible(((Component)NOTE_JOYPAD).gameObject);
if (DeveloperConsole)
{
DLog("BUTTON_TYP_JOY");
}
break;
case ButtonShowType.BUTTON_TYP_HIDE:
SetVisible(((Component)BACKGROUND).gameObject, setactive: false);
if (DeveloperConsole)
{
DLog("BUTTON_TYP_HIDE");
}
break;
default:
if (DeveloperConsole)
{
DLog("Unknown Button type");
}
break;
}
}
public static void UpdateGamepad()
{
if (MultiSupport.IsRunning_Auga && (Object)(object)GUI != (Object)null && ZInput.IsGamepadActive() && GUI.InCraftTab())
{
((MonoBehaviour)GUI).Invoke("UpdateRecipeGamepadInput", 0f);
if (ZInput.GetButtonDown(MultiPad.JYCraftButton))
{
if (InProgress)
{
((MonoBehaviour)GUI).Invoke("OnCraftCancelPressed", 0f);
}
else
{
((MonoBehaviour)GUI).Invoke("OnCraftPressed", 0f);
}
}
}
if (GamepadStats != ZInput.IsGamepadActive())
{
GamepadStats = ZInput.IsGamepadActive();
if (GamepadStats)
{
ShowMultiCraftUI(ButtonShowType.BUTTON_TYP_JOY);
}
else if (InProgress)
{
ShowMultiCraftUI(ButtonShowType.BUTTON_TYP_STOP);
}
else
{
ShowMultiCraftUI(ButtonShowType.BUTTON_TYP_MULT);
}
}
if (!InProgress)
{
if (ZInput.GetButtonDown(MultiPad.JYAmountPlus))
{
OnPlusButtonPressed();
}
else if (ZInput.GetButtonDown(MultiPad.JYAmountMinus))
{
OnMinusButtonPressed();
}
}
}
public static void CenterMsg(string text)
{
Player localPlayer = Player.m_localPlayer;
if (localPlayer != null)
{
((Character)localPlayer).Message((MessageType)2, Localization.instance.Localize(text), 0, (Sprite)null);
}
}
private static bool IsNoCraftCost()
{
return (Object)(object)Player.m_localPlayer != (Object)null && Player.m_localPlayer.NoCostCheat();
}
public static void ShowNoCostText()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if (IsNoCraftCost())
{
SetVisible(((Component)NOTE_NOCOST).gameObject);
((Graphic)NOTE_TMPNoCost).color = ((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : Color.yellow);
}
else
{
SetVisible(((Component)NOTE_NOCOST).gameObject, setactive: false);
}
}
public static void SetCraftingCompleted(string text)
{
NOTE_TMPNote.text = text;
SetVisible(((Component)NOTE_NOTE).gameObject, text != "");
}
private static void ButtonDebug(string text)
{
if (DeveloperConsole)
{
DLog(text);
}
}
public static void RepairAllItems(InventoryGui inventoryGui)
{
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation();
if ((Object)(object)currentCraftingStation == (Object)null || !currentCraftingStation.CheckUsable(Player.m_localPlayer, false))
{
return;
}
int num = 0;
TempWornItem.Clear();
((Humanoid)Player.m_localPlayer).GetInventory().GetWornItems(TempWornItem);
foreach (ItemData item in TempWornItem)
{
if (Traverse.Create((object)inventoryGui).Method("CanRepair", new object[1] { item }).GetValue<bool>())
{
num++;
item.m_durability = item.GetMaxDurability();
if (Object.op_Implicit((Object)(object)currentCraftingStation))
{
currentCraftingStation.m_repairItemDoneEffects.Create(((Component)currentCraftingStation).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
}
((Character)Player.m_localPlayer).Message((MessageType)1, Localization.instance.Localize("$msg_repaired", new string[1] { item.m_shared.m_name }), 0, (Sprite)null);
}
}
if (num > 0)
{
((Character)Player.m_localPlayer).Message((MessageType)1, "MultiCraft: " + num + " items repaired", 0, (Sprite)null);
}
}
public static void ResetDuplicateRequirementName(ItemDrop item)
{
RequirementNameList.Clear();
NewSelection = ((Object)item).name;
if (OldSelection != NewSelection)
{
OldSelection = NewSelection;
DuplicateRequirementName.Clear();
}
}
public static void ShowDuplicateRequirementWarning(string itemName)
{
if (!DuplicateRequirementName.Contains(itemName))
{
DuplicateRequirementName.Add(itemName);
DLog(" " + NewSelection + " contain duplicate requirement: " + itemName, iserror: true);
DLog(" Check " + NewSelection + " config otherwise contact the " + NewSelection + " plugin's author", iserror: true);
}
}
}
internal class MultiPad
{
public static string JYCraftButton;
public static string JYAmountPlus;
public static string JYAmountMinus;
public static string JYDeltaSmall;
public static string JYDeltaMedium;
public static string GetGamepadButton(GamepadInput zinput)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected I4, but got Unknown
GamepadInput val = zinput;
GamepadInput val2 = val;
switch (val2 - 1)
{
case 0:
return "JoyDPadLeft";
case 1:
return "JoyDPadRight";
case 2:
return "JoyDPadDown";
case 3:
return "JoyDPadUp";
case 4:
return "JoyButtonA";
case 5:
return "JoyButtonB";
case 6:
return "JoyButtonX";
case 7:
return "JoyButtonY";
case 10:
return "JoyLStick";
case 13:
return "JoyRStick";
case 14:
return "JoyLBumper";
case 15:
return "JoyRBumper";
case 16:
return "JoyLTrigger";
case 17:
return "JoyRTrigger";
case 18:
return "JoyBack";
case 19:
return "JoyStart";
default:
MultiHelper.DLog("<<< " + ((object)(GamepadInput)(ref zinput)).ToString() + " >>> currently not supported", iserror: true);
return "None";
}
}
}
internal class MultiSupport
{
private static readonly string GUID_Auga = "randyknapp.mods.auga";
private static readonly string AugaButtonPanel = "RightColumn";
private static readonly string AugaButtonProgs = "CraftProgress";
private static readonly string AugaButtonTextName = "Label";
public static bool IsRunning_Auga = false;
private static readonly string GUID_Aeden = "aedenthorn.CraftFromContainers";
public static bool IsRunning_Aeden = false;
private static readonly string GUID_VPlus = "org.bepinex.plugins.valheim_plus";
public static bool IsRunning_VPlus = false;
public static bool InitAuga(ref ConfigEntry<bool> statusConfig)
{
IsRunning_Auga = false;
if (Chainloader.PluginInfos.TryGetValue(GUID_Auga, out var value))
{
IsRunning_Auga = true;
MultiHelper.CraftButtonProgs = AugaButtonProgs;
MultiHelper.CraftButtonTextName = AugaButtonTextName;
MultiHelper.CraftButtonPanel = AugaButtonPanel;
MultiHelper.DLog($"{value.Instance.Info.Metadata.GUID} | Version: {value.Instance.Info.Metadata.Version}");
}
statusConfig.Value = IsRunning_Auga;
return IsRunning_Auga;
}
public static bool InitAeden(ref ConfigEntry<bool> statusConfig)
{
IsRunning_Aeden = false;
if (Chainloader.PluginInfos.TryGetValue(GUID_Aeden, out var value))
{
IsRunning_Aeden = true;
MultiHelper.DLog($"{value.Instance.Info.Metadata.GUID} | Version: {value.Instance.Info.Metadata.Version}");
}
statusConfig.Value = IsRunning_Aeden;
return IsRunning_Aeden;
}
public static bool InitVPlus(ref ConfigEntry<bool> statusConfig)
{
IsRunning_VPlus = false;
if (Chainloader.PluginInfos.TryGetValue(GUID_VPlus, out var value))
{
IsRunning_VPlus = true;
MultiHelper.DLog($"{value.Instance.Info.Metadata.GUID} | Version: {value.Instance.Info.Metadata.Version}");
}
statusConfig.Value = IsRunning_VPlus;
return IsRunning_VPlus;
}
}