Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DvergrAutomationJatifyPatch v1.0.1
DvergrAutomationJatifyPatch.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ConditionalConfigSync; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("DvergrAutomationJatifyPatch")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DvergrAutomationJatifyPatch")] [assembly: AssemblyTitle("DvergrAutomationJatifyPatch")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 DvergrAutomationJatifyPatch { [BepInPlugin("com.dreich.dvergrautomationjatifypatch", "Dvergr Automation Jatify Patch", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class DvergrAutomationJatifyPatchPlugin : BaseUnityPlugin { public const string Guid = "com.dreich.dvergrautomationjatifypatch"; public const string Name = "Dvergr Automation Jatify Patch"; public const string Version = "1.0.1"; internal const string JatifyGuid = "jatify.ui"; internal const string AutomationGuid = "MidngightsFX.DvergerAutomation"; internal const string ConfigSyncGuid = "_shudnal.ConditionalConfigSync"; internal static ManualLogSource Log; internal static bool ConfigSyncAvailable; internal static ConfigEntry<bool> ConfigLocked; internal static ConfigEntry<bool> TurnOffJatifyChests; internal static ConfigEntry<bool> StorageCounts; internal static ConfigEntry<bool> MoveDepositButton; internal static ConfigEntry<bool> StyleButtons; internal static ConfigEntry<bool> StyleStorageSwitch; private void Awake() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ConfigSyncAvailable = Chainloader.PluginInfos.ContainsKey("_shudnal.ConditionalConfigSync"); if (ConfigSyncAvailable) { ConfigSyncCompat.Initialize("com.dreich.dvergrautomationjatifypatch", "Dvergr Automation Jatify Patch", "1.0.1"); } ConfigLocked = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Lock Configuration", true, "If on, the configuration is locked and can be changed by server admins only. Requires ConditionalConfigSync."); if (ConfigSyncAvailable) { ConfigSyncCompat.AddLockingConfigEntry(ConfigLocked); } TurnOffJatifyChests = BindShared("Chests", "TurnOffJatifyChests", value: true, new ConfigDescription("Keeps Jatify UI's CraftFromChests and BuildFromChests switched off, so only Dverger Automation takes materials from storage. With both on, a craft could take its materials twice. Turning this off doesn't switch Jatify's settings back on; do that in Jatify's own config.", (AcceptableValueBase)null, Array.Empty<object>())); StorageCounts = ((BaseUnityPlugin)this).Config.Bind<bool>("Jatify UI", "StorageCounts", true, "Count what the AutoSorter's linked chests and Hoppers hold in Jatify's recipe requirements, so a recipe you can make from storage shows as ready instead of missing materials."); MoveDepositButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Jatify UI", "MoveDepositButton", true, "Put the AutoSorter's and the Hopper's deposit button right under their [C] button."); StyleButtons = ((BaseUnityPlugin)this).Config.Bind<bool>("Jatify UI", "StyleButtons", true, "Give the deposit and [C] buttons Jatify's look."); StyleStorageSwitch = ((BaseUnityPlugin)this).Config.Bind<bool>("Jatify UI", "StyleStorageSwitch", true, "Show Dverger Automation's craft-from-storage switch as a Jatify button beside Repair, and hide the wooden plate it leaves behind the Craft tab."); bool flag = Chainloader.PluginInfos.ContainsKey("jatify.ui"); bool flag2 = Chainloader.PluginInfos.ContainsKey("MidngightsFX.DvergerAutomation"); if (!flag || !flag2) { Log.LogInfo((object)((flag ? "Dverger Automation" : "Jatify UI") + " isn't installed; nothing to do.")); return; } Harmony val = new Harmony("com.dreich.dvergrautomationjatifypatch"); if (!JatifyChests.Setup()) { Log.LogWarning((object)"Jatify UI's chest settings have changed; TurnOffJatifyChests can't work."); } if (!JatifyKit.Ready) { Log.LogWarning((object)"Jatify UI has changed; the deposit buttons keep their own look."); } if (!StorageCount.Setup(val)) { Log.LogWarning((object)"Jatify UI or Dverger Automation has changed; StorageCounts is turned off."); } ((Component)this).gameObject.AddComponent<DepositButtons>(); ((Component)this).gameObject.AddComponent<StorageSwitch>(); } private ConfigEntry<T> BindShared<T>(string section, string key, T value, ConfigDescription description) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, value, description); if (ConfigSyncAvailable) { ConfigSyncCompat.AddConfigEntry<T>(val); } return val; } } internal static class ConfigSyncCompat { private static object configSync; [MethodImpl(MethodImplOptions.NoInlining)] internal static void Initialize(string guid, string name, string version) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown configSync = (object)new ConfigSync(guid) { DisplayName = name, CurrentVersion = version, MinimumRequiredVersion = version, ModRequired = true }; } [MethodImpl(MethodImplOptions.NoInlining)] internal static void AddLockingConfigEntry(ConfigEntry<bool> entry) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) ((ConditionalConfigSync)(ConfigSync)configSync).AddLockingConfigEntry<bool>(entry); } [MethodImpl(MethodImplOptions.NoInlining)] internal static void AddConfigEntry<T>(ConfigEntry<T> entry) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) ((ConditionalConfigSync)(ConfigSync)configSync).AddConfigEntry<T>(entry, (ConfigSyncMode)0); } } internal static class JatifyChests { internal static ConfigEntry<bool> Craft; internal static ConfigEntry<bool> Build; internal static bool JatifyCounts { get { if (Craft != null && Build != null) { if (!Craft.Value) { return Build.Value; } return true; } return false; } } internal static bool Setup() { Type type = AccessTools.TypeByName("Jatify.UI.Cfg"); if (type == null) { return false; } Craft = AccessTools.Field(type, "CraftFromChests")?.GetValue(null) as ConfigEntry<bool>; Build = AccessTools.Field(type, "BuildFromChests")?.GetValue(null) as ConfigEntry<bool>; if (Craft == null || Build == null) { return false; } Craft.SettingChanged += delegate { Apply(); }; Build.SettingChanged += delegate { Apply(); }; DvergrAutomationJatifyPatchPlugin.TurnOffJatifyChests.SettingChanged += delegate { Apply(); }; Apply(); return true; } private static void Apply() { if (DvergrAutomationJatifyPatchPlugin.TurnOffJatifyChests.Value) { if (Craft.Value) { Craft.Value = false; DvergrAutomationJatifyPatchPlugin.Log.LogInfo((object)"Switched off Jatify UI's CraftFromChests; Dverger Automation crafts from storage instead."); } if (Build.Value) { Build.Value = false; DvergrAutomationJatifyPatchPlugin.Log.LogInfo((object)"Switched off Jatify UI's BuildFromChests; Dverger Automation builds from storage instead."); } } } } internal static class StorageCount { private static Func<Player, List<Container>> poolFor; private static Func<List<Container>, string, int> countAvailable; private static bool failed; internal static bool Setup(Harmony harmony) { //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown Type type = AccessTools.TypeByName("Jatify.UI.Stock"); Type type2 = AccessTools.TypeByName("DvergerAutomation.ContainerNetwork"); Type type3 = AccessTools.TypeByName("DvergerAutomation.CraftFromStoragePatches"); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "InChests", new Type[2] { typeof(Player), typeof(string) }, (Type[])null) : null); MethodInfo methodInfo2 = ((type2 != null) ? AccessTools.Method(type2, "PoolFor", new Type[1] { typeof(Player) }, (Type[])null) : null); MethodInfo methodInfo3 = ((type3 != null) ? AccessTools.Method(type3, "CountAvailable", new Type[2] { typeof(List<Container>), typeof(string) }, (Type[])null) : null); if (methodInfo == null || methodInfo2 == null || methodInfo3 == null) { return false; } try { poolFor = AccessTools.MethodDelegate<Func<Player, List<Container>>>(methodInfo2, (object)null, true); countAvailable = AccessTools.MethodDelegate<Func<List<Container>, string, int>>(methodInfo3, (object)null, true); } catch (Exception ex) { DvergrAutomationJatifyPatchPlugin.Log.LogWarning((object)("Couldn't read Dverger Automation's storage: " + ex.Message)); return false; } harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(StorageCount), "CountPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static void CountPostfix(Player p, string name, ref int __result) { if (failed || !DvergrAutomationJatifyPatchPlugin.StorageCounts.Value || (Object)(object)p == (Object)null || (Object)(object)p != (Object)(object)Player.m_localPlayer || JatifyChests.JatifyCounts) { return; } try { List<Container> list = poolFor(p); if (list != null && list.Count > 0) { __result += countAvailable(list, name); } } catch (Exception ex) { failed = true; DvergrAutomationJatifyPatchPlugin.Log.LogWarning((object)("Counting Dverger Automation's storage failed and is turned off: " + ex)); } } } internal static class JatifyKit { private static bool tried; private static bool ready; private static FieldInfo pluginInstance; private static PropertyInfo themeData; private static MethodInfo box; private static MethodInfo text; private static FieldInfo fontMedium; internal static bool Ready { get { Init(); return ready; } } internal static TMP_FontAsset Medium { get { object? obj = fontMedium?.GetValue(null); return (TMP_FontAsset)((obj is TMP_FontAsset) ? obj : null); } } private static void Init() { if (tried) { return; } tried = true; try { Type type = AccessTools.TypeByName("Jatify.UI.Plugin"); Type type2 = AccessTools.TypeByName("Jatify.UI.Kit"); Type type3 = AccessTools.TypeByName("Jatify.UI.Fonts"); if (!(type == null) && !(type2 == null) && !(type3 == null)) { pluginInstance = AccessTools.Field(type, "Instance"); themeData = AccessTools.Property(type, "ThemeData"); box = AccessTools.Method(type2, "Box", new Type[5] { typeof(Transform), typeof(string), typeof(Color), typeof(Color), typeof(float) }, (Type[])null); text = AccessTools.Method(type2, "Text", new Type[6] { typeof(Transform), typeof(string), typeof(string), typeof(TMP_FontAsset), typeof(float), typeof(Color) }, (Type[])null); fontMedium = AccessTools.Field(type3, "Medium"); ready = pluginInstance != null && themeData != null && box != null && text != null; } } catch (Exception) { ready = false; } } internal static Color Colour(string name, Color fallback) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) try { object obj = pluginInstance?.GetValue(null); object obj2 = ((obj != null) ? themeData.GetValue(obj, null) : null); string text = ((obj2 != null) ? (AccessTools.Field(obj2.GetType(), name)?.GetValue(obj2) as string) : null); Color result = default(Color); if (!string.IsNullOrEmpty(text) && ColorUtility.TryParseHtmlString(text.StartsWith("#") ? text : ("#" + text), ref result)) { return result; } } catch (Exception) { } return fallback; } internal static Image Box(Transform parent, string name, Color fill, Color line, float radius, out Image fillImage) { //IL_001a: 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) fillImage = null; object obj = box.Invoke(null, new object[5] { parent, name, fill, line, radius }); if (obj == null) { return null; } object? obj2 = AccessTools.Field(obj.GetType(), "Item2")?.GetValue(obj); fillImage = (Image)((obj2 is Image) ? obj2 : null); object? obj3 = AccessTools.Field(obj.GetType(), "Item1")?.GetValue(obj); Image val = (Image)((obj3 is Image) ? obj3 : null); if ((Object)(object)val != (Object)null) { ((Graphic)val).raycastTarget = false; } if ((Object)(object)fillImage != (Object)null) { ((Graphic)fillImage).raycastTarget = false; } return val; } internal static TextMeshProUGUI Text(Transform parent, string name, string value, TMP_FontAsset font, float size, Color colour) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) object? obj = text.Invoke(null, new object[6] { parent, name, value, font, size, colour }); return (TextMeshProUGUI)((obj is TextMeshProUGUI) ? obj : null); } } internal sealed class ButtonSkin { internal Transform Target; internal string Text; private Image faceLine; private Image faceFill; private TextMeshProUGUI faceText; private Image buttonImage; private Color buttonColour; private TMP_Text originalText; private Vector3 originalTextScale; private Behaviour textColour; private Transition originalTransition; private float fontSize; internal bool Holds(Transform target) { if ((Object)(object)Target != (Object)null && (Object)(object)Target == (Object)(object)target) { return (Object)(object)faceLine != (Object)null; } return false; } internal void Take(Transform target, float size) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) Release(); Target = target; fontSize = size; Button component = ((Component)target).GetComponent<Button>(); if ((Object)(object)component != (Object)null) { originalTransition = ((Selectable)component).transition; ((Selectable)component).transition = (Transition)0; } buttonImage = ((Component)target).GetComponent<Image>(); if ((Object)(object)buttonImage != (Object)null) { buttonColour = ((Graphic)buttonImage).color; ((Graphic)buttonImage).color = new Color(0f, 0f, 0f, 0f); ((Graphic)buttonImage).raycastTarget = true; } ref Behaviour reference = ref textColour; Component component2 = ((Component)target).GetComponent("ButtonTextColor"); reference = (Behaviour)(object)((component2 is Behaviour) ? component2 : null); if ((Object)(object)textColour != (Object)null) { textColour.enabled = false; } originalText = ((Component)target).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)originalText != (Object)null) { originalTextScale = originalText.transform.localScale; originalText.transform.localScale = Vector3.zero; } faceLine = JatifyKit.Box(target, "DAJP_Face", JatifyKit.Colour("raised", new Color(0.16f, 0.17f, 0.19f)), JatifyKit.Colour("line2", new Color(1f, 1f, 1f, 0.16f)), 8f, out faceFill); RectTransform rectTransform = ((Graphic)faceLine).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; ((Transform)rectTransform).localScale = Vector3.one; ((Transform)rectTransform).SetAsFirstSibling(); faceText = JatifyKit.Text((Transform)(object)rectTransform, "T", Label(), JatifyKit.Medium, fontSize, JatifyKit.Colour("dim", new Color(0.7f, 0.7f, 0.73f))); ((TMP_Text)faceText).alignment = (TextAlignmentOptions)514; ((TMP_Text)faceText).richText = true; ((TMP_Text)faceText).enableAutoSizing = true; ((TMP_Text)faceText).fontSizeMin = 9f; ((TMP_Text)faceText).fontSizeMax = fontSize; RectTransform rectTransform2 = ((TMP_Text)faceText).rectTransform; rectTransform2.anchorMin = Vector2.zero; rectTransform2.anchorMax = Vector2.one; rectTransform2.offsetMin = new Vector2(6f, 0f); rectTransform2.offsetMax = new Vector2(-6f, 0f); } private string Label() { if (!string.IsNullOrEmpty(Text)) { return Text; } if (!((Object)(object)originalText != (Object)null)) { return ""; } return originalText.text; } internal void Update() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_0149: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)faceLine == (Object)null) && !((Object)(object)Target == (Object)null)) { string text = Label(); if (((TMP_Text)faceText).text != text) { ((TMP_Text)faceText).text = text; } Button component = ((Component)Target).GetComponent<Button>(); bool flag = (Object)(object)component == (Object)null || ((Selectable)component).interactable; bool flag2 = flag && Hovered(Target); ((Graphic)faceLine).color = (flag2 ? JatifyKit.Colour("accent", new Color(0.13f, 0.84f, 0.49f)) : JatifyKit.Colour("line2", new Color(1f, 1f, 1f, 0.16f))); if ((Object)(object)faceFill != (Object)null) { ((Graphic)faceFill).color = (flag2 ? JatifyKit.Colour("accentSoft", new Color(0.13f, 0.84f, 0.49f, 0.14f)) : JatifyKit.Colour("raised", new Color(0.16f, 0.17f, 0.19f))); } ((Graphic)faceText).color = ((!flag) ? JatifyKit.Colour("mute", new Color(0.5f, 0.5f, 0.54f)) : (flag2 ? Color.white : JatifyKit.Colour("text", new Color(0.92f, 0.93f, 0.93f)))); } } private static bool Hovered(Transform target) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)(object)((target is RectTransform) ? target : null); if ((Object)(object)val == (Object)null) { return false; } Canvas componentInParent = ((Component)val).GetComponentInParent<Canvas>(); Camera val2 = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.rootCanvas.renderMode != 0) ? componentInParent.rootCanvas.worldCamera : null); return RectTransformUtility.RectangleContainsScreenPoint(val, Vector2.op_Implicit(Input.mousePosition), val2); } internal void Release() { //IL_0049: 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_00a3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Target != (Object)null) { if ((Object)(object)faceLine != (Object)null) { Object.Destroy((Object)(object)((Component)faceLine).gameObject); } if ((Object)(object)originalText != (Object)null) { originalText.transform.localScale = originalTextScale; } if ((Object)(object)textColour != (Object)null) { textColour.enabled = true; } if ((Object)(object)buttonImage != (Object)null) { ((Graphic)buttonImage).color = buttonColour; } Button component = ((Component)Target).GetComponent<Button>(); if ((Object)(object)component != (Object)null) { ((Selectable)component).transition = originalTransition; } } Target = null; faceLine = null; faceFill = null; faceText = null; originalText = null; textColour = null; buttonImage = null; } } internal sealed class DepositButtons : MonoBehaviour { private const string Deposit = "DA_DepositAllButton"; private const string SorterFilter = "DA_DepositFilterButton"; private const string HopperFilter = "DA_HopperTargetButton"; private const float Gap = 6f; private readonly ButtonSkin depositSkin = new ButtonSkin { Text = "D" }; private readonly ButtonSkin sorterSkin = new ButtonSkin(); private readonly ButtonSkin hopperSkin = new ButtonSkin(); private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4]; private bool failed; private void LateUpdate() { if (failed) { return; } try { Tick(); } catch (Exception ex) { failed = true; DvergrAutomationJatifyPatchPlugin.Log.LogWarning((object)("Placing Dverger Automation's deposit buttons failed and is turned off: " + ex)); try { ReleaseAll(); } catch (Exception) { } } } private void ReleaseAll() { depositSkin.Release(); sorterSkin.Release(); hopperSkin.Release(); } private void Tick() { InventoryGui instance = InventoryGui.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_container == (Object)null) && ((Component)instance.m_container).gameObject.activeInHierarchy) { Transform container = (Transform)(object)instance.m_container; RectTransform val = Active(container, "DA_DepositAllButton"); RectTransform val2 = Active(container, "DA_DepositFilterButton"); RectTransform val3 = Active(container, "DA_HopperTargetButton"); RectTransform val4 = (((Object)(object)val2 != (Object)null) ? val2 : val3); bool style = DvergrAutomationJatifyPatchPlugin.StyleButtons.Value && JatifyKit.Ready && (Object)(object)container.Find("jatify-chest") != (Object)null; Skin(depositSkin, val, style, 15f); Skin(sorterSkin, val2, style, 16f); Skin(hopperSkin, val3, style, 16f); if ((Object)(object)val != (Object)null && (Object)(object)val4 != (Object)null && DvergrAutomationJatifyPatchPlugin.MoveDepositButton.Value && (Object)(object)((Transform)val).parent == (Object)(object)((Transform)val4).parent) { PlaceUnder(val, val4); } } } private static RectTransform Active(Transform container, string name) { Transform obj = container.Find(name); RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null); if (!((Object)(object)val != (Object)null) || !((Component)val).gameObject.activeSelf) { return null; } return val; } private static void Skin(ButtonSkin skin, RectTransform button, bool style, float size) { if (!style) { if ((Object)(object)skin.Target != (Object)null) { skin.Release(); } } else if (!((Object)(object)button == (Object)null)) { if (!skin.Holds((Transform)(object)button)) { skin.Take((Transform)(object)button, size); } skin.Update(); } } private void PlaceUnder(RectTransform deposit, RectTransform filter) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Transform)deposit).parent; Bounds(filter, parent, out var min, out var max); Bounds(deposit, parent, out var _, out var max2); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(max.x - max2.x, min.y - 6f - max2.y); if (!(((Vector2)(ref val)).sqrMagnitude < 0.25f)) { ((Transform)deposit).localPosition = ((Transform)deposit).localPosition + new Vector3(val.x, val.y, 0f); } } private void Bounds(RectTransform rect, Transform space, out Vector2 min, out Vector2 max) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_005b: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) rect.GetWorldCorners(corners); min = new Vector2(float.MaxValue, float.MaxValue); max = new Vector2(float.MinValue, float.MinValue); for (int i = 0; i < 4; i++) { Vector3 val = space.InverseTransformPoint(corners[i]); min = Vector2.Min(min, Vector2.op_Implicit(val)); max = Vector2.Max(max, Vector2.op_Implicit(val)); } } } internal sealed class StorageSwitch : MonoBehaviour { private const string SwitchName = "DA_CraftFromStorageToggle"; private const string PlateName = "DA_CraftFromStorageBackdrop"; private const float Gap = 6f; private readonly List<(Graphic graphic, bool enabled)> hidden = new List<(Graphic, bool)>(); private RectTransform toggle; private RectTransform image; private Vector2 imageAnchorMin; private Vector2 imageAnchorMax; private Vector2 imagePivot; private Vector2 imagePosition; private Vector2 imageSize; private Vector2 anchorMin; private Vector2 anchorMax; private Vector2 pivot; private Vector2 position; private Vector2 size; private Image faceLine; private Image faceFill; private Transition transition; private Graphic target; private GameObject plate; private bool failed; private void LateUpdate() { if (failed) { return; } try { Tick(); } catch (Exception ex) { failed = true; DvergrAutomationJatifyPatchPlugin.Log.LogWarning((object)("Styling Dverger Automation's craft-from-storage switch failed and is turned off: " + ex)); try { Release(); } catch (Exception) { } } } private void Tick() { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; RectTransform val = (((Object)(object)instance != (Object)null) ? instance.m_crafting : null); if (!DvergrAutomationJatifyPatchPlugin.StyleStorageSwitch.Value || !JatifyKit.Ready || !((Object)(object)val != (Object)null) || !((Object)(object)((Transform)val).Find("jatify-panel") != (Object)null)) { if ((Object)(object)toggle != (Object)null || (Object)(object)plate != (Object)null) { Release(); } } else { if (!((Component)val).gameObject.activeInHierarchy) { return; } Transform val2 = ((Transform)val).Find("DA_CraftFromStorageBackdrop"); if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).gameObject != (Object)(object)plate) { HidePlate(((Component)val2).gameObject); } Transform obj = ((Transform)val).Find("DA_CraftFromStorageToggle"); RectTransform val3 = (RectTransform)(object)((obj is RectTransform) ? obj : null); if ((Object)(object)val3 == (Object)null) { return; } if ((Object)(object)val3 != (Object)(object)toggle || (Object)(object)faceLine == (Object)null) { Take(val3); } if (!((Component)toggle).gameObject.activeSelf) { return; } RectTransform val4 = (RectTransform)(((Object)(object)instance.m_repairButton != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val4 != (Object)null && (Object)(object)((Transform)val4).parent == (Object)(object)((Transform)toggle).parent) { float y = val4.sizeDelta.y; toggle.anchorMin = val4.anchorMin; toggle.anchorMax = val4.anchorMax; toggle.pivot = val4.pivot; toggle.sizeDelta = new Vector2(y, y); float num = val4.anchoredPosition.x - val4.pivot.x * val4.sizeDelta.x - 6f - (1f - val4.pivot.x) * y; toggle.anchoredPosition = new Vector2(num, val4.anchoredPosition.y); if (((Transform)toggle).GetSiblingIndex() != ((Transform)toggle).parent.childCount - 1) { ((Transform)toggle).SetAsLastSibling(); } } Transform val5 = ((Transform)toggle).Find("Glow"); bool flag = (Object)(object)val5 != (Object)null && ((Component)val5).gameObject.activeSelf; bool flag2 = Hovered(toggle); ((Graphic)faceLine).color = (flag ? JatifyKit.Colour("accent", new Color(0.13f, 0.84f, 0.49f)) : (flag2 ? JatifyKit.Colour("glassLine", new Color(1f, 1f, 1f, 0.3f)) : JatifyKit.Colour("glassLine", new Color(1f, 1f, 1f, 0.15f)))); if ((Object)(object)faceFill != (Object)null) { ((Graphic)faceFill).color = (flag ? JatifyKit.Colour("accentSoft", new Color(0.13f, 0.84f, 0.49f, 0.14f)) : JatifyKit.Colour("raised", new Color(0.16f, 0.17f, 0.19f))); } } } private void HidePlate(GameObject newPlate) { plate = newPlate; Graphic[] componentsInChildren = plate.GetComponentsInChildren<Graphic>(true); foreach (Graphic val in componentsInChildren) { hidden.Add((val, ((Behaviour)val).enabled)); ((Behaviour)val).enabled = false; } } private void Take(RectTransform newToggle) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) ReleaseToggle(); toggle = newToggle; anchorMin = toggle.anchorMin; anchorMax = toggle.anchorMax; pivot = toggle.pivot; position = toggle.anchoredPosition; size = toggle.sizeDelta; ref RectTransform reference = ref image; Transform obj = ((Transform)toggle).Find("Image"); reference = (RectTransform)(object)((obj is RectTransform) ? obj : null); Graphic[] componentsInChildren = ((Component)toggle).GetComponentsInChildren<Graphic>(true); foreach (Graphic val in componentsInChildren) { if (!((Object)(object)image != (Object)null) || !((Object)(object)((Component)val).transform == (Object)(object)image)) { hidden.Add((val, ((Behaviour)val).enabled)); ((Behaviour)val).enabled = false; } } Button component = ((Component)toggle).GetComponent<Button>(); if ((Object)(object)component != (Object)null) { transition = ((Selectable)component).transition; target = ((Selectable)component).targetGraphic; ((Selectable)component).transition = (Transition)0; } faceLine = JatifyKit.Box((Transform)(object)toggle, "DAJP_SwitchFace", JatifyKit.Colour("raised", new Color(0.16f, 0.17f, 0.19f)), JatifyKit.Colour("glassLine", new Color(1f, 1f, 1f, 0.15f)), 8f, out faceFill); RectTransform rectTransform = ((Graphic)faceLine).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; ((Transform)rectTransform).localScale = Vector3.one; ((Transform)rectTransform).SetAsFirstSibling(); ((Graphic)faceLine).raycastTarget = true; if ((Object)(object)component != (Object)null && (Object)(object)faceFill != (Object)null) { ((Selectable)component).targetGraphic = (Graphic)(object)faceFill; } if ((Object)(object)image != (Object)null) { imageAnchorMin = image.anchorMin; imageAnchorMax = image.anchorMax; imagePivot = image.pivot; imagePosition = image.anchoredPosition; imageSize = image.sizeDelta; image.anchorMin = new Vector2(0.5f, 0.5f); image.anchorMax = new Vector2(0.5f, 0.5f); image.pivot = new Vector2(0.5f, 0.5f); image.anchoredPosition = Vector2.zero; image.sizeDelta = new Vector2(20f, 20f); Image component2 = ((Component)image).GetComponent<Image>(); if ((Object)(object)component2 != (Object)null) { component2.preserveAspect = true; } ((Transform)image).SetAsLastSibling(); } } private static bool Hovered(RectTransform rect) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Canvas componentInParent = ((Component)rect).GetComponentInParent<Canvas>(); Camera val = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.rootCanvas.renderMode != 0) ? componentInParent.rootCanvas.worldCamera : null); return RectTransformUtility.RectangleContainsScreenPoint(rect, Vector2.op_Implicit(Input.mousePosition), val); } private void ReleaseToggle() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)toggle != (Object)null) { if ((Object)(object)faceLine != (Object)null) { Object.Destroy((Object)(object)((Component)faceLine).gameObject); } Button component = ((Component)toggle).GetComponent<Button>(); if ((Object)(object)component != (Object)null) { ((Selectable)component).transition = transition; ((Selectable)component).targetGraphic = target; } toggle.anchorMin = anchorMin; toggle.anchorMax = anchorMax; toggle.pivot = pivot; toggle.anchoredPosition = position; toggle.sizeDelta = size; if ((Object)(object)image != (Object)null) { image.anchorMin = imageAnchorMin; image.anchorMax = imageAnchorMax; image.pivot = imagePivot; image.anchoredPosition = imagePosition; image.sizeDelta = imageSize; } } toggle = null; image = null; faceLine = null; faceFill = null; } private void Release() { ReleaseToggle(); foreach (var item in hidden) { if ((Object)(object)item.graphic != (Object)null) { ((Behaviour)item.graphic).enabled = item.enabled; } } hidden.Clear(); plate = null; } } }