using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using REPOAlchemy;
using REPOLib.Modules;
using TMPro;
using UnityEngine;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DangerPixel")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AlchemyRecipes")]
[assembly: AssemblyTitle("AlchemyRecipes")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MenuLib.MonoBehaviors
{
public sealed class REPOSprite : REPOElement
{
public Image spriteImage;
[SerializeField]
private Sprite _sprite;
public Sprite Sprite
{
get
{
return _sprite;
}
set
{
_sprite = value;
if ((Object)(object)spriteImage != (Object)null)
{
spriteImage.sprite = _sprite;
}
}
}
public Vector2 ImageSize
{
get
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return ((REPOElement)this).rectTransform.sizeDelta;
}
set
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
((REPOElement)this).rectTransform.sizeDelta = value;
if ((Object)(object)spriteImage != (Object)null)
{
((Graphic)spriteImage).rectTransform.sizeDelta = value;
}
}
}
private void Awake()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
((REPOElement)this).rectTransform = (RectTransform)((Component)this).transform;
spriteImage = ((Component)this).GetComponentInChildren<Image>();
if ((Object)(object)spriteImage == (Object)null)
{
GameObject val = new GameObject("SpriteImage");
val.transform.SetParent(((Component)this).transform, false);
spriteImage = val.AddComponent<Image>();
}
((REPOElement)this).rectTransform.pivot = Vector2.zero;
((REPOElement)this).rectTransform.sizeDelta = new Vector2(100f, 100f);
((Graphic)spriteImage).rectTransform.pivot = Vector2.zero;
((Graphic)spriteImage).rectTransform.sizeDelta = ((REPOElement)this).rectTransform.sizeDelta;
if ((Object)(object)_sprite != (Object)null)
{
spriteImage.sprite = _sprite;
}
}
private void Start()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
((Transform)((Graphic)spriteImage).rectTransform).localPosition = Vector2.op_Implicit(Vector2.zero);
}
}
}
namespace AlchemyRecipes
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("DangerPixel.AlchemyRecipes", "AlchemyRecipes", "1.0")]
public class AlchemyRecipes : BaseUnityPlugin
{
internal static AlchemyRecipes Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
public static REPOSprite CreateREPOSprite(Sprite sprite, Transform parent, Vector2 localPosition = default(Vector2))
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = new GameObject("SpriteElement", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component).SetParent(parent, false);
((Transform)component).localPosition = Vector2.op_Implicit(localPosition);
component.sizeDelta = new Vector2(100f, 100f);
REPOSprite rEPOSprite = ((Component)component).gameObject.AddComponent<REPOSprite>();
rEPOSprite.Sprite = sprite;
return rEPOSprite;
}
}
public static class ConfigManager
{
public static ConfigEntry<bool> SimpleMenu;
public static ConfigEntry<bool> TogleMenu;
public static ConfigEntry<int> FontSize;
public static ConfigEntry<int> IconScale;
public static ConfigEntry<float> IngredientTooltipPos;
public static ConfigEntry<string> ToolTipMode;
public static void Initialize(ConfigFile config)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Expected O, but got Unknown
config.SettingChanged += delegate(object sender, SettingChangedEventArgs args)
{
if (!(args.ChangedSetting.Definition.Section == "UI"))
{
}
};
TogleMenu = config.Bind<bool>("Settings", "TogleMenu", true, "Togle Menu instead of having to hold");
FontSize = config.Bind<int>("Settings", "FontSize", 25, new ConfigDescription("Size of the font", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 64), Array.Empty<object>()));
IconScale = config.Bind<int>("Settings", "IconScale", 1, new ConfigDescription("Scale of the Icon", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
ToolTipMode = config.Bind<string>("Settings", "ToolTipMode", "Ingredients", new ConfigDescription("What to show in tooltip", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "No Tooltip", "Ingredients", "All Valuables" }), Array.Empty<object>()));
IngredientTooltipPos = config.Bind<float>("Settings", "IngredientTooltipPos", 5.8f, new ConfigDescription("IngredientTooltipPos", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
}
}
[HarmonyPatch]
internal class Patches : MonoBehaviour
{
[HarmonyPatch(typeof(PhysGrabObject))]
public static class PhyGrabObjPatch
{
private static Transform? _gameHud;
private static REPOLabel? _itemName;
[HarmonyPatch("FixedUpdate")]
[HarmonyPostfix]
private static void FixedUpdate(PhysGrabObject __instance)
{
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
if (ConfigManager.ToolTipMode.Value == "No Tooltip")
{
return;
}
object obj = null;
if (ConfigManager.ToolTipMode.Value == "Ingredients")
{
if ((Object)(object)((Component)__instance).GetComponent<ValuableObject>() == (Object)null)
{
return;
}
obj = ((Component)__instance).GetComponent<Ingredient>();
}
else
{
obj = ((Component)__instance).GetComponent<ValuableObject>();
}
if (obj == null)
{
return;
}
PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
if (__instance.playerGrabbing.Contains(val.physGrabber))
{
if ((Object)(object)_itemName != (Object)null)
{
Object.Destroy((Object)(object)((Component)_itemName).gameObject);
_itemName = null;
}
_gameHud = GameObject.Find("Game Hud").transform;
string name = obj.GetType().GetProperty("name")?.GetValue(obj)?.ToString() ?? "Unknown";
_itemName = MenuAPI.CreateREPOLabel(cleanName(name), _gameHud, new Vector2((float)(-cleanName(name).Length) * ConfigManager.IngredientTooltipPos.Value, -100f));
}
}
[HarmonyPatch("GrabEnded")]
[HarmonyPostfix]
public static void GrabEnded(PhysGrabber player)
{
if (player.isLocal && (Object)(object)_itemName != (Object)null)
{
Object.Destroy((Object)(object)((Component)_itemName).gameObject);
_itemName = null;
}
}
}
public class RegisteredRecipe
{
public List<List<string>> Ingredients { get; set; }
public string Result { get; set; }
public Sprite Icon { get; set; }
public RegisteredRecipe(List<string> ingredients, string result, Sprite icon)
{
Ingredients = new List<List<string>> { ingredients };
Result = result;
Icon = icon;
}
}
public static REPOPopupPage? _repoPage;
public static REPOPopupPage? _ingredientsPage;
private static bool IsMenuOpen;
private static bool IsSubMenuOpen;
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerController), "Update")]
private static void FlashlightPatch()
{
if (!SemiFunc.IsMultiplayer())
{
return;
}
if (Input.GetKeyDown((KeyCode)106) && !IsMenuOpen)
{
if (ChatManager.instance.chatActive)
{
return;
}
if ((Object)(object)_repoPage == (Object)null)
{
InitializeMenu();
}
if ((Object)(object)_repoPage != (Object)null)
{
if (IsSubMenuOpen && (Object)(object)_ingredientsPage != (Object)null)
{
_ingredientsPage.ClosePage(true);
}
_repoPage.OpenPage(true);
IsMenuOpen = true;
}
else
{
AlchemyRecipes.Logger.LogError((object)"repoPage is still null in KeyDown");
}
return;
}
if (Input.GetKeyDown((KeyCode)106) || (Input.GetKeyUp((KeyCode)106) && !ConfigManager.TogleMenu.Value && IsMenuOpen))
{
try
{
_repoPage.ClosePage(true);
IsMenuOpen = false;
return;
}
catch (Exception arg)
{
AlchemyRecipes.Logger.LogError((object)$"Error closing AlchemyRecipe Menu... Exception: {arg}");
return;
}
}
if (Input.GetKeyUp((KeyCode)27) && IsMenuOpen)
{
IsMenuOpen = false;
}
else if (Input.GetKeyUp((KeyCode)106) && !IsMenuOpen)
{
}
}
private static void InitializeMenu()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: 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_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
AlchemyRecipes.Logger.LogDebug((object)"Inside InitializeMenu");
if ((Object)(object)_repoPage == (Object)null)
{
_repoPage = MenuAPI.CreateREPOPopupPage("Recipes", (PresetSide)0, false, false, 3f);
_repoPage.scrollBarRectTransform.anchorMin = new Vector2(1f, _repoPage.scrollBarRectTransform.anchorMin.y);
_repoPage.scrollBarRectTransform.anchorMax = new Vector2(1f, _repoPage.scrollBarRectTransform.anchorMax.y);
_repoPage.scrollBarRectTransform.pivot = new Vector2(1f, _repoPage.scrollBarRectTransform.pivot.y);
_repoPage.scrollBarRectTransform.anchoredPosition = new Vector2(90f, _repoPage.scrollBarRectTransform.anchoredPosition.y);
_repoPage.rectTransform.pivot = new Vector2(0f, _repoPage.rectTransform.pivot.y);
_repoPage.rectTransform.sizeDelta = new Vector2(310f, _repoPage.rectTransform.sizeDelta.y);
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(_repoPage.maskRectTransform.sizeDelta.x + 210f, _repoPage.maskRectTransform.sizeDelta.y);
_repoPage.maskRectTransform.sizeDelta = val;
typeof(REPOPopupPage).GetField("defaultMaskSizeDelta", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(_repoPage, val);
LayoutRebuilder.ForceRebuildLayoutImmediate(_repoPage.rectTransform);
_repoPage.maskPadding = _repoPage.maskPadding;
_repoPage.scrollView.UpdateElements();
}
SimpleLayout();
AlchemyRecipes.Logger.LogDebug((object)"Finished getting recipes!!");
}
public static string cleanName(string name)
{
string text = Regex.Replace(name, "\\(.*?\\)", "");
text = text.Replace("Valuable ", "");
text = Regex.Replace(text, "([a-z])([A-Z])", "$1 $2");
return text.Trim();
}
public static float ScaleValue(double value)
{
float num = 1f;
float num2 = 10f;
float num3 = 1f;
float num4 = 4f;
return (float)((double)num3 + (value - (double)num) * (double)(num4 - num3) / (double)(num2 - num));
}
private static void SimpleLayout()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Expected O, but got Unknown
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Expected O, but got Unknown
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Expected O, but got Unknown
List<RegisteredRecipe> list = new List<RegisteredRecipe>();
foreach (Recipe recipe in Cauldron.recipes)
{
RegisteredRecipe registeredRecipe = list.FirstOrDefault((RegisteredRecipe cc) => cc.Result == recipe.result);
if (registeredRecipe != null)
{
registeredRecipe.Ingredients.Add(recipe.ingredients);
}
else
{
list.Add(new RegisteredRecipe(recipe.ingredients, recipe.result, recipe.icon));
}
}
foreach (RegisteredRecipe recipe2 in list)
{
AlchemyRecipes.Logger.LogDebug((object)("Working on recipe: " + recipe2.Result));
Item itemByName = Items.GetItemByName(recipe2.Result);
string cc2;
if ((Object)(object)itemByName != (Object)null)
{
cc2 = itemByName.itemName;
}
else
{
ValuableObject valuableByName = Valuables.GetValuableByName(recipe2.Result);
if ((Object)(object)valuableByName != (Object)null)
{
cc2 = ((Object)((Component)valuableByName).gameObject).name;
}
else
{
cc2 = recipe2.Result;
AlchemyRecipes.Logger.LogWarning((object)("Could not find Item or Valuable for \"" + recipe2.Result + "\""));
}
}
_repoPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
REPOSprite rEPOSprite = AlchemyRecipes.CreateREPOSprite(recipe2.Icon, scrollView);
rEPOSprite.ImageSize = new Vector2(30f * ScaleValue(ConfigManager.IconScale.Value), 30f * ScaleValue(ConfigManager.IconScale.Value));
return ((REPOElement)rEPOSprite).rectTransform;
}, 0f, 0f);
REPOLabel label = null;
_repoPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
label = MenuAPI.CreateREPOLabel(cleanName(cc2) ?? "", scrollView, default(Vector2));
((TMP_Text)label.labelTMP).fontSize = ConfigManager.FontSize.Value + 5;
((TMP_Text)label.labelTMP).fontStyle = (FontStyles)1;
return ((REPOElement)label).rectTransform;
}, 0f, 0f);
foreach (List<string> ingredients in recipe2.Ingredients)
{
_repoPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
label = MenuAPI.CreateREPOLabel(" Needs: " + cleanName(string.Join(" + ", ingredients)), scrollView, default(Vector2));
((TMP_Text)label.labelTMP).fontSize = ConfigManager.FontSize.Value;
((TMP_Text)label.labelTMP).fontStyle = (FontStyles)0;
return ((REPOElement)label).rectTransform;
}, 0f, 0f);
}
((REPOElement)label).repoScrollViewElement.bottomPadding = 50f;
}
}
public static List<AlchemyItem> GetItemsInPot(Cauldron cauldronInstance)
{
if ((Object)(object)cauldronInstance == (Object)null)
{
AlchemyRecipes.Logger.LogFatal((object)"");
}
FieldInfo field = typeof(Cauldron).GetField("itemsInPot", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null)
{
throw new Exception("Field 'itemsInPot' not found in the Cauldron class.");
}
return field.GetValue(cauldronInstance) as List<AlchemyItem>;
}
}
}