using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("RecipeDescriptionExpansion")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: AssemblyProduct("RecipeDescriptionExpansion")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: AssemblyFileVersion("1.1.5")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.5.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace RecipeDescriptionExpansion
{
public static class PlayerExtentions
{
public static IEnumerable<ItemData> GetEquipment(this Player player)
{
List<ItemData> list = new List<ItemData>();
if (((Humanoid)player).m_rightItem != null)
{
list.Add(((Humanoid)player).m_rightItem);
}
if (((Humanoid)player).m_leftItem != null)
{
list.Add(((Humanoid)player).m_leftItem);
}
if (((Humanoid)player).m_chestItem != null)
{
list.Add(((Humanoid)player).m_chestItem);
}
if (((Humanoid)player).m_legItem != null)
{
list.Add(((Humanoid)player).m_legItem);
}
if (((Humanoid)player).m_helmetItem != null)
{
list.Add(((Humanoid)player).m_helmetItem);
}
if (((Humanoid)player).m_shoulderItem != null)
{
list.Add(((Humanoid)player).m_shoulderItem);
}
if (((Humanoid)player).m_utilityItem != null)
{
list.Add(((Humanoid)player).m_utilityItem);
}
return list;
}
}
public class Functions
{
internal static void RecipeDescTweaks(ref TMP_Text? recipeDesc)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)recipeDesc != (Object)null)
{
recipeDesc.enableAutoSizing = false;
recipeDesc.fontSize = 18f;
recipeDesc.rectTransform.anchorMin = new Vector2(0f, 1f);
recipeDesc.rectTransform.anchorMax = new Vector2(1f, 1f);
recipeDesc.rectTransform.pivot = new Vector2(0f, 1f);
recipeDesc.textWrappingMode = (TextWrappingModes)1;
recipeDesc.rectTransform.anchoredPosition = new Vector2(4f, 4f);
((Graphic)recipeDesc).raycastTarget = false;
}
}
public static string CustomSetTooltip(ItemData itemData, SharedData sharedData)
{
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
string setName = (string.IsNullOrWhiteSpace(sharedData.m_setName) ? null : sharedData.m_setName);
List<ItemData> list = ((setName != null) ? (from x in Player.m_localPlayer.GetEquipment()
where x.m_shared.m_setName == setName
select x).ToList() : new List<ItemData>());
int setSize = sharedData.m_setSize;
string text = FormatSetName(itemData);
string text2 = ((list.Count == setSize) ? "#96d4fd" : "#808080ff");
StringBuilder stringBuilder = new StringBuilder($"\n\n<color={text2}>{text} ({list.Count}/{setSize}):</color>\n");
if (setName != null)
{
foreach (string pieceName in RetrieveSetPieces(ObjectDB.instance, setName))
{
bool num = list.Any((ItemData x) => x.m_shared.m_name == pieceName);
string text3 = (num ? "#FDFD96" : "#808080ff");
string text4 = (num ? "✔\ufe0f" : "❌");
stringBuilder.AppendLine("<color=#008000ff>" + text4 + "</color>\t├> <color=" + text3 + ">" + pieceName + "</color>");
}
}
float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel(sharedData.m_skillType);
string text5 = itemData.GetSetStatusEffectTooltip(itemData.m_quality, skillLevel).Replace("\n", " ");
stringBuilder.AppendLine("<color=" + text2 + ">└> " + text5 + "</color>");
return stringBuilder.ToString();
}
private static string FormatSetName(ItemData item)
{
string text = item.m_shared.m_setName ?? string.Empty;
return string.Join(" ", from i in text.Split(new char[1] { ' ' })
select char.ToUpper(i[0]) + i.Substring(1).ToLower());
}
private static List<string> RetrieveSetPieces(ObjectDB database, string setName)
{
string setName2 = setName;
return (from prefab in database.m_items
where (Object)(object)prefab != (Object)null
select prefab.GetComponent<ItemDrop>() into itemDrop
where (Object)(object)itemDrop != (Object)null
where itemDrop.m_itemData.m_shared.m_setName == setName2
select itemDrop.m_itemData.m_shared.m_name).ToList();
}
internal static GameObject GenScrollView(ref InventoryGui __instance)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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)
GameObject val = new GameObject("RecipeExpansionScrollView", new Type[3]
{
typeof(RectTransform),
typeof(ScrollRect),
typeof(Image)
});
val.transform.SetParent(__instance.m_recipeDecription.transform.parent, false);
val.transform.SetSiblingIndex(0);
Transform transform = val.transform;
RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
if ((Object)(object)val2 != (Object)null)
{
val2.anchorMin = new Vector2(0f, 1f);
val2.anchorMax = new Vector2(0f, 1f);
val2.pivot = new Vector2(0f, 1f);
val2.anchoredPosition = new Vector2(11f, -74f);
val2.SetSizeWithCurrentAnchors((Axis)0, 330f);
val2.SetSizeWithCurrentAnchors((Axis)1, 300f);
}
((Graphic)val.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.2f);
return val;
}
internal static RectTransform GenViewPort(ref GameObject scrollRectGo, ref TMP_Text? recipeDesc)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("RecipeExpansionViewport", new Type[2]
{
typeof(RectTransform),
typeof(RectMask2D)
});
val.transform.SetParent(scrollRectGo.transform, false);
Transform transform = val.transform;
RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
val2.anchorMin = new Vector2(0f, 0f);
val2.anchorMax = new Vector2(1f, 1f);
val2.sizeDelta = new Vector2(0f, 0f);
TMP_Text? obj = recipeDesc;
if (obj != null)
{
obj.transform.SetParent((Transform)(object)val2, false);
}
return val2;
}
internal static ScrollRect GenScrollRect(ref GameObject scrollRectGo, ref TMP_Text? recipeDesc, ref RectTransform vrt)
{
ScrollRect component = scrollRectGo.GetComponent<ScrollRect>();
component.viewport = vrt;
TMP_Text? obj = recipeDesc;
component.content = ((obj != null) ? obj.rectTransform : null);
component.horizontal = false;
component.vertical = true;
component.verticalScrollbarVisibility = (ScrollbarVisibility)1;
component.scrollSensitivity = 40f;
component.inertia = true;
component.movementType = (MovementType)2;
((UnityEventBase)component.onValueChanged).RemoveAllListeners();
return component;
}
internal static void GenScrollBar(ref InventoryGui __instance, ref GameObject scrollRectGo, ref ScrollRect scrollRect)
{
Scrollbar newScrollbar = Object.Instantiate<Scrollbar>(__instance.m_recipeListScroll, scrollRectGo.transform);
newScrollbar.size = 0.4f;
((UnityEvent<Vector2>)(object)scrollRect.onValueChanged).AddListener((UnityAction<Vector2>)delegate
{
newScrollbar.size = 0.4f;
});
scrollRect.verticalScrollbar = newScrollbar;
}
}
[BepInPlugin("Azumatt.RecipeDescriptionExpansion", "RecipeDescriptionExpansion", "1.1.5")]
public class RecipeDescriptionExpansionPlugin : BaseUnityPlugin
{
internal const string ModName = "RecipeDescriptionExpansion";
internal const string ModVersion = "1.1.5";
internal const string Author = "Azumatt";
private const string ModGUID = "Azumatt.RecipeDescriptionExpansion";
public static bool EpicLootPluginInstalled;
private readonly Harmony _harmony = new Harmony("Azumatt.RecipeDescriptionExpansion");
public static readonly ManualLogSource RecipeDescriptionExpansionLogger = Logger.CreateLogSource("RecipeDescriptionExpansion");
public void Awake()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
_harmony.PatchAll(executingAssembly);
}
public void Start()
{
Chainloader.PluginInfos.TryGetValue("randyknapp.mods.epicloot", out var value);
if (value != null && (Object)(object)value.Instance != (Object)null)
{
EpicLootPluginInstalled = true;
}
}
private void OnDestroy()
{
((BaseUnityPlugin)this).Config.Save();
}
}
[HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")]
[HarmonyAfter(new string[] { "org.bepinex.plugins.jewelcrafting" })]
[HarmonyPriority(700)]
public static class InventoryGuiUpdateRecipePatch
{
public static void Postfix(InventoryGui __instance)
{
TMP_Text recipeDesc = __instance.m_recipeDecription;
if ((Object)(object)recipeDesc == (Object)null)
{
return;
}
Chainloader.PluginInfos.TryGetValue("org.bepinex.plugins.jewelcrafting", out var value);
if (value != null && __instance.InCraftTab() && (Object)(object)value.Instance != (Object)null)
{
if (__instance.m_itemCraftType.text.Length > 0)
{
recipeDesc.text = recipeDesc.text + Environment.NewLine + Environment.NewLine + "<color=yellow>" + __instance.m_itemCraftType.text + "</color>";
}
__instance.m_itemCraftType.text = "";
}
if (!((Object)(object)((Component)recipeDesc).GetComponent<ContentSizeFitter>() != (Object)null))
{
((Component)recipeDesc).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
Functions.RecipeDescTweaks(ref recipeDesc);
GameObject scrollRectGo = Functions.GenScrollView(ref __instance);
RectTransform vrt = Functions.GenViewPort(ref scrollRectGo, ref recipeDesc);
ScrollRect scrollRect = Functions.GenScrollRect(ref scrollRectGo, ref recipeDesc, ref vrt);
Functions.GenScrollBar(ref __instance, ref scrollRectGo, ref scrollRect);
}
}
}
[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
{
typeof(ItemData),
typeof(int),
typeof(bool),
typeof(float),
typeof(int)
})]
[HarmonyBefore(new string[] { "Azumatt.BindOnEquip" })]
internal static class ItemDropItemDataPatch
{
[UsedImplicitly]
[HarmonyPriority(0)]
private static void Postfix(ItemData item, int qualityLevel, bool crafting, ref string __result)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (RecipeDescriptionExpansionPlugin.EpicLootPluginInstalled || item == null || (Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel(item.m_shared.m_skillType);
if (item.GetSetStatusEffectTooltip(qualityLevel, skillLevel).Length > 0)
{
int num = __result.IndexOf("\n\n$item_seteffect", StringComparison.InvariantCulture);
if (num >= 0)
{
__result = __result.Remove(num);
__result = __result.Insert(num, Functions.CustomSetTooltip(item, item.m_shared));
}
}
}
}
}