Please disclose if your mod was created primarily 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 Ore Support v1.11.0
OreSupport.dll
Decompiled a year agousing 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 BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [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("OreSupport")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1b294e0d8979e5d6fce40db65acccb7a0a2966cc")] [assembly: AssemblyProduct("OreSupport")] [assembly: AssemblyTitle("OreSupport")] [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 OreSupport { public static class Constants { public const string TriggerLayer = "character_trigger"; } public static class Tag { public const string MineRock = "OreSupport_MineRock"; public const string CriticalMineRock = "OreSupport_CriticalMineRock"; public const string ClearedMineRock = "OreSupport_ClearedMineRock"; public const string Destructible = "OreSupport_Destructible"; } public class Drawer { private static readonly Texture2D Texture = new Texture2D(1, 1); private static Shader? lineShader; private static string shaderName = "Sprites/Default"; private static readonly Dictionary<string, Color> colors = new Dictionary<string, Color>(); private static readonly Dictionary<Color, Material> materials = new Dictionary<Color, Material>(); private static Shader LineShader => lineShader ?? (lineShader = ((IEnumerable<Shader>)Resources.FindObjectsOfTypeAll<Shader>()).FirstOrDefault((Func<Shader, bool>)((Shader shader) => ((Object)shader).name == shaderName)) ?? ((IEnumerable<Shader>)Resources.FindObjectsOfTypeAll<Shader>()).FirstOrDefault((Func<Shader, bool>)((Shader shader) => ((Object)shader).name == "Sprites/Default")) ?? throw new Exception("Shader not found.")); public static void SetShader(string name) { shaderName = name; lineShader = null; materials.Clear(); Visualization[] visualizations = Utils.GetVisualizations(); for (int i = 0; i < visualizations.Length; i++) { ChangeColor(((Component)visualizations[i]).gameObject); } } public static Color GetColor(string tag) { //IL_0019: 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) if (!colors.ContainsKey(tag)) { return Color.white; } return colors[tag]; } private static void ChangeColor(GameObject obj) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) LineRenderer component = obj.GetComponent<LineRenderer>(); if (Object.op_Implicit((Object)(object)component)) { ((Renderer)component).sharedMaterial = GetMaterial(GetColor(((Object)obj).name)); } } public static void Init() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Texture.SetPixel(0, 0, Color.gray); } private static GameObject CreateObject(GameObject parent, string tag = "", bool fixRotation = false) { //IL_0000: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0034: 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) GameObject val = new GameObject { layer = LayerMask.NameToLayer("character_trigger"), name = tag }; val.transform.parent = parent.transform; val.transform.localPosition = Vector3.zero; if (!fixRotation) { val.transform.localRotation = Quaternion.identity; } if (tag != "") { AddTag(val, tag); } return val; } private static Material GetMaterial(Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002a: 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_0012: Unknown result type (might be due to invalid IL or missing references) if (materials.ContainsKey(color)) { return materials[color]; } Material val = new Material(LineShader); val.SetColor("_Color", color); val.SetFloat("_BlendOp", 1f); val.SetTexture("_MainTex", (Texture)(object)Texture); materials[color] = val; return val; } private static LineRenderer CreateRenderer(GameObject obj, Color color, float width) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) LineRenderer obj2 = obj.AddComponent<LineRenderer>(); obj2.useWorldSpace = false; ((Renderer)obj2).sharedMaterial = GetMaterial(color); ((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)0; obj2.widthMultiplier = width / 100f; return obj2; } private static void ChangeColor(GameObject obj, Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) LineRenderer[] componentsInChildren = obj.GetComponentsInChildren<LineRenderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).sharedMaterial = GetMaterial(color); } } private static void ChangeLineWidth(GameObject obj, float width) { LineRenderer[] componentsInChildren = obj.GetComponentsInChildren<LineRenderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].widthMultiplier = width / 100f; } } public static void AddText(GameObject obj, string title, string text) { StaticText staticText = obj.AddComponent<StaticText>(); staticText.text = text; staticText.title = title; } public static void AddTag(GameObject obj, string tag) { obj.AddComponent<Visualization>().Tag = tag; } public static void Remove(MonoBehaviour parent, string tag) { Visualization[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Visualization>(true); foreach (Visualization visualization in componentsInChildren) { if (visualization.Tag == tag) { Object.Destroy((Object)(object)((Component)visualization).gameObject); } } } public static void SetColor(string tag, Color color) { //IL_0006: 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) colors[tag] = color; Visualization[] visualizations = Utils.GetVisualizations(tag); for (int i = 0; i < visualizations.Length; i++) { ChangeColor(((Component)visualizations[i]).gameObject, color); } } public static void SetLineWidth(string tag, float width) { Visualization[] visualizations = Utils.GetVisualizations(tag); for (int i = 0; i < visualizations.Length; i++) { ChangeLineWidth(((Component)visualizations[i]).gameObject, width); } } private static void AddBoxCollider(GameObject obj, Vector3 center, Vector3 size) { //IL_000e: 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) BoxCollider obj2 = obj.AddComponent<BoxCollider>(); ((Collider)obj2).isTrigger = true; obj2.center = center; obj2.size = size; } private static GameObject DrawLineSub(GameObject obj, Vector3 start, Vector3 end, Color color, float width) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) LineRenderer obj2 = CreateRenderer(obj, color, width); obj2.SetPosition(0, start); obj2.SetPosition(1, end); return obj; } public static GameObject DrawBox(string tag, MonoBehaviour parent, float width, Vector3 center, Vector3 extents) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return DrawBox(tag, ((Component)parent).gameObject, width, center, extents); } public static GameObject DrawBox(string tag, GameObject parent, float width, Vector3 center, Vector3 extents) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0024: 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_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_003e: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_007a: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_009e: 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) //IL_00aa: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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) //IL_010f: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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_024d: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(center.x - extents.x, center.y - extents.y, center.z - extents.z), new Vector3(center.x - extents.x, center.y - extents.y, center.z + extents.z), new Vector3(center.x - extents.x, center.y + extents.y, center.z - extents.z), new Vector3(center.x - extents.x, center.y + extents.y, center.z + extents.z), new Vector3(center.x + extents.x, center.y - extents.y, center.z - extents.z), new Vector3(center.x + extents.x, center.y - extents.y, center.z + extents.z), new Vector3(center.x + extents.x, center.y + extents.y, center.z - extents.z), new Vector3(center.x + extents.x, center.y + extents.y, center.z + extents.z) }; Color color = GetColor(tag); GameObject val = CreateObject(parent, tag, fixRotation: true); for (int i = 0; i < array.Length; i++) { Vector3 val2 = array[i]; for (int j = i + 1; j < array.Length; j++) { Vector3 val3 = array[j]; int num = 0; if (val2.x == val3.x) { num++; } if (val2.y == val3.y) { num++; } if (val2.z == val3.z) { num++; } if (num == 2) { DrawLineSub(CreateObject(val), array[i], array[j], color, width); } } } AddBoxCollider(val, center, extents * 2f); return val; } } public class Utils { public static Visualization[] GetVisualizations(string tag) { string tag2 = tag; return (from obj in GetVisualizations() where obj.Tag == tag2 select obj).ToArray(); } public static Visualization[] GetVisualizations() { return Resources.FindObjectsOfTypeAll<Visualization>(); } } [HarmonyPatch(typeof(Player), "UpdateHover")] public class Player_AddHoverForVisuals { private static void Postfix(ref GameObject ___m_hovering, ref GameObject ___m_hoveringCreature) { //IL_004a: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00e3: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)___m_hovering) || Object.op_Implicit((Object)(object)___m_hoveringCreature) || !Settings.Enable || !Object.op_Implicit((Object)(object)SupportUpdater.Tracked)) { return; } float num = 100f; int mask = LayerMask.GetMask(new string[1] { "character_trigger" }); RaycastHit[] array = Physics.RaycastAll(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, num, mask); RaycastHit[] array2 = Physics.RaycastAll(((Component)GameCamera.instance).transform.position + ((Component)GameCamera.instance).transform.forward * num, -((Component)GameCamera.instance).transform.forward, num, mask); RaycastHit[] array3 = CollectionExtensions.AddRangeToArray<RaycastHit>(array, array2); Array.Sort(array3, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance)); RaycastHit[] array4 = array3; for (int i = 0; i < array4.Length; i++) { RaycastHit val = array4[i]; if ((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent<Visualization>() != (Object)null) { ___m_hovering = ((Component)((RaycastHit)(ref val)).collider).gameObject; break; } } } } public class StaticText : MonoBehaviour, Hoverable { public string title = ""; public string text = ""; public string GetHoverText() { return Format.String(title) + "\n" + text; } public string GetHoverName() { return title; } } public class Visualization : MonoBehaviour { public string Tag = ""; } [BepInPlugin("ore_support", "Ore Support", "1.11")] public class OreSupport : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__5_0; internal void <InitCommands>b__5_0(ConsoleEventArgs args) { Settings.configEnable.Value = !Settings.Enable; args.Context.AddString("Ore support " + (Settings.Enable ? "enabled" : "disabled") + "."); SupportUpdater.UpdateSupport(); } } private const string GUID = "ore_support"; private const string NAME = "Ore Support"; private const string VERSION = "1.11"; public void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Settings.Init(((BaseUnityPlugin)this).Config); new Harmony("ore_support").PatchAll(); InitCommands(); } private void LateUpdate() { SupportUpdater.RefreshSupport(Time.deltaTime); } private static void InitCommands() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //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_0029: Expected O, but got Unknown object obj = <>c.<>9__5_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { Settings.configEnable.Value = !Settings.Enable; args.Context.AddString("Ore support " + (Settings.Enable ? "enabled" : "disabled") + "."); SupportUpdater.UpdateSupport(); }; <>c.<>9__5_0 = val; obj = (object)val; } new ConsoleCommand("ore_support", "Toggles mine rock support visibility.", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } public class Settings { public static ConfigEntry<float> configLineWidth; public static ConfigEntry<float> configRefreshInterval; public static ConfigEntry<int> configMaxBoxes; public static ConfigEntry<int> configMinSize; public static ConfigEntry<string> configMineRockColor; public static ConfigEntry<string> configClearedMineRockColor; public static ConfigEntry<string> configCriticalMineRockColor; public static ConfigEntry<string> configDestructibleColor; public static ConfigEntry<bool> configShowSupporting; public static ConfigEntry<bool> configEnable; public static ConfigEntry<string> configShader; public static float LineWidth => Math.Max(0.01f, configLineWidth.Value); public static float RefreshInterval => Math.Max(1f, configRefreshInterval.Value); public static int MaxBoxes => configMaxBoxes.Value; public static int MinSize => configMinSize.Value; public static Color MineRockColor => ParseColor(configMineRockColor.Value); public static Color ClearedMineRockColor => ParseColor(configClearedMineRockColor.Value); public static Color CriticalMineRockColor => ParseColor(configCriticalMineRockColor.Value); public static Color DestructibleColor => ParseColor(configDestructibleColor.Value); public static bool ShowSupporting => configShowSupporting.Value; public static bool Enable => configEnable.Value; private static Color ParseColor(string color) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); if (ColorUtility.TryParseHtmlString(color, ref result)) { return result; } return Color.white; } public static void Init(ConfigFile config) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) string text = "General"; configEnable = config.Bind<bool>(text, "Enabled", true, "Whether this mod is enabled. Can be toggled with command ore_support."); configRefreshInterval = config.Bind<float>(text, "Refresh interval", 5f, new ConfigDescription("How often the support is checked. Higher values lower performance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>())); configMaxBoxes = config.Bind<int>(text, "Maximum shown boxes", 200, new ConfigDescription("Maximum amount of boxes to display. Higher values lower performance.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>())); configMinSize = config.Bind<int>(text, "Minimum deposit size", 75, new ConfigDescription("Excludes smaller deposits like iron scrap piles.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>())); configLineWidth = config.Bind<float>(text, "Line width", 2f, new ConfigDescription("Line width of the bounding boxes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); configShowSupporting = config.Bind<bool>(text, "Supporting objects", true, "Show supporting objects. Enabling lowers performance."); configLineWidth.SettingChanged += delegate { Drawer.SetLineWidth("OreSupport_MineRock", LineWidth); Drawer.SetLineWidth("OreSupport_Destructible", LineWidth); }; configMineRockColor = config.Bind<string>(text, "Supported color", "red", "Color of supported pieces."); configMineRockColor.SettingChanged += delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Drawer.SetColor("OreSupport_MineRock", MineRockColor); }; configCriticalMineRockColor = config.Bind<string>(text, "Critical supported color", "orange", "Color of pieces that will cause the rock to collapse."); configCriticalMineRockColor.SettingChanged += delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Drawer.SetColor("OreSupport_CriticalMineRock", CriticalMineRockColor); }; configClearedMineRockColor = config.Bind<string>(text, "Unsupported color", "green", "Color of pieces that are no longer supported."); configClearedMineRockColor.SettingChanged += delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Drawer.SetColor("OreSupport_ClearedMineRock", ClearedMineRockColor); }; configDestructibleColor = config.Bind<string>(text, "Support color", "yellow", "Color of supporting objects."); configDestructibleColor.SettingChanged += delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Drawer.SetColor("OreSupport_Destructible", DestructibleColor); }; Drawer.SetColor("OreSupport_MineRock", MineRockColor); Drawer.SetColor("OreSupport_CriticalMineRock", CriticalMineRockColor); Drawer.SetColor("OreSupport_ClearedMineRock", ClearedMineRockColor); Drawer.SetColor("OreSupport_Destructible", DestructibleColor); configShader = config.Bind<string>(text, "Shader", "Sprites/Default", "Shader for the line."); configShader.SettingChanged += delegate { Drawer.SetShader(configShader.Value); }; Drawer.SetShader(configShader.Value); } } public class Box { private Vector3 position; private Vector3 size; private readonly string title; private readonly string text; private readonly string tag; private readonly GameObject obj; public bool IsSupported => tag == "OreSupport_MineRock"; public Box(string tag, GameObject obj, Vector3 position, Vector3 size, string title, string text = "") { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references) this.tag = tag; this.obj = obj; this.position = position; this.size = size; this.title = title; this.text = text; } public void Draw() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) Drawer.AddText(Drawer.DrawBox(tag, obj, Settings.LineWidth, position, size), title, text); } } public class SupportChecker { private static readonly Collider[] tempColliders = (Collider[])(object)new Collider[128]; private static IEnumerable<Collider> Filter(IEnumerable<Collider> colliders, MineRock5 obj, HitArea area) { HitArea area2 = area; MineRock5 obj2 = obj; return colliders.Where(delegate(Collider collider) { if ((Object)(object)collider == (Object)(object)area2.m_collider || (Object)(object)collider.attachedRigidbody != (Object)null || collider.isTrigger) { return false; } return (((Component)collider).gameObject.GetComponentInParent<IDestructible>() != obj2) ? true : false; }); } private static bool CheckColliders(IEnumerable<Collider> colliders, MineRock5 obj, List<Box> boxes, int groundLayer) { //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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0077: 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_0080: Unknown result type (might be due to invalid IL or missing references) if (Settings.ShowSupporting) { IEnumerable<Collider> source = colliders.Where((Func<Collider, bool>)obj.GetSupport); foreach (Collider item in source.Where((Collider collider) => ((Component)collider).gameObject.layer != groundLayer)) { GameObject gameObject = ((Component)obj).gameObject; Bounds bounds = item.bounds; Vector3 position = ((Bounds)(ref bounds)).center - ((Component)obj).transform.position; bounds = item.bounds; boxes.Add(new Box("OreSupport_Destructible", gameObject, position, ((Bounds)(ref bounds)).extents, "Supports mine rock")); } return source.Count() > 0; } return colliders.Any((Func<Collider, bool>)obj.GetSupport); } public static IList<Box> CalculateBoundingBoxes(MineRock5 obj, ISet<int> supportedAreas) { //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_01fd: 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_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) MineRock5 obj2 = obj; List<Box> boxes = new List<Box>(); int index = 0; Dictionary<HitArea, int> dictionary = obj2.m_hitAreas.ToDictionary((HitArea area) => area, (HitArea _) => index++); Dictionary<HitArea, bool> dictionary2 = obj2.m_hitAreas.Where((HitArea area) => area.m_health > 0f).ToDictionary((HitArea area) => area, delegate(HitArea area) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) BoundData bound2 = area.m_bound; Vector3 pos2 = bound2.m_pos; Vector3 size2 = bound2.m_size; Quaternion rot = bound2.m_rot; int count = Physics.OverlapBoxNonAlloc(((Component)obj2).transform.position + pos2, size2, tempColliders, rot, MineRock5.m_rayMask); return CheckColliders(Filter(tempColliders.Take(count), obj2, area), obj2, boxes, MineRock5.m_groundLayer); }); int num = dictionary2.Count(); int num2 = dictionary2.Where((KeyValuePair<HitArea, bool> kvp) => kvp.Value).Count(); foreach (KeyValuePair<HitArea, bool> item in dictionary2) { index = dictionary[item.Key]; bool value = item.Value; bool flag = supportedAreas.Contains(index); BoundData bound = item.Key.m_bound; Vector3 pos = bound.m_pos; Vector3 size = bound.m_size; if (value || flag) { if (value) { supportedAreas.Add(index); } string tag = (value ? "OreSupport_MineRock" : "OreSupport_ClearedMineRock"); if (num2 == 0) { tag = "OreSupport_CriticalMineRock"; } if (num2 == 1 && value) { tag = "OreSupport_CriticalMineRock"; } string text = "Index: " + Format.Int(index); text = text + "\nSupported: " + Format.Int(num2) + " / " + Format.Int(num); boxes.Add(new Box(tag, ((Component)obj2).gameObject, pos, size, "Size: " + Format.Coordinates(2f * size, "F1"), text)); } } return boxes; } } public class SupportUpdater { public static MineRock5? Tracked = null; private static float timer = 0f; private static readonly HashSet<int> supportedAreas = new HashSet<int>(); private static void Clear(MineRock5? obj) { if (Object.op_Implicit((Object)(object)obj) && !((Object)(object)obj == (Object)null)) { Drawer.Remove((MonoBehaviour)(object)obj, "OreSupport_MineRock"); Drawer.Remove((MonoBehaviour)(object)obj, "OreSupport_ClearedMineRock"); Drawer.Remove((MonoBehaviour)(object)obj, "OreSupport_Destructible"); Drawer.Remove((MonoBehaviour)(object)obj, "OreSupport_CriticalMineRock"); } } private static bool IsValid(MineRock5 obj) { if (!Object.op_Implicit((Object)(object)obj)) { return false; } if (!obj.m_supportCheck) { return false; } ZNetView nview = obj.m_nview; if (!Object.op_Implicit((Object)(object)nview)) { return false; } return nview.IsValid(); } public static void DrawSupport(MineRock5 obj) { if ((Object)(object)obj != (Object)(object)Tracked) { Clear(Tracked); Tracked = obj; } supportedAreas.Clear(); UpdateSupport(); } public static void RefreshSupport(float delta) { timer += delta; if (timer >= Settings.RefreshInterval) { UpdateSupport(); } } public static void UpdateSupport() { timer = 0f; if ((Object)(object)Tracked == (Object)null) { return; } Clear(Tracked); if (!IsValid(Tracked)) { Tracked = null; } else { if (!Settings.Enable || Settings.LineWidth == 0f || Settings.MaxBoxes == 0 || Tracked.m_hitAreas.Count() < Settings.MinSize) { return; } IList<Box> list = SupportChecker.CalculateBoundingBoxes(Tracked, supportedAreas); if (list.Count > Settings.MaxBoxes) { return; } foreach (Box item in list) { item.Draw(); } } } } [HarmonyPatch(typeof(MineRock5), "RPC_Damage")] public class MineRock5_Damage { public static void Postfix(MineRock5 __instance) { if (!((Object)(object)SupportUpdater.Tracked == (Object)(object)__instance)) { if (!__instance.m_haveSetupBounds) { __instance.SetupColliders(); __instance.m_haveSetupBounds = true; } SupportUpdater.DrawSupport(__instance); } } } [HarmonyPatch(typeof(MineRock5), "UpdateSupport")] public class MineRock5_Support { public static void Postfix(MineRock5 __instance) { SupportUpdater.DrawSupport(__instance); } } public class Format { public const string FORMAT = "0.##"; public static string String(string value, string color = "yellow") { return "<color=" + color + ">" + value + "</color>"; } public static string Int(double value, string color = "yellow") { return String(value.ToString("N0"), color); } public static string JoinRow(IEnumerable<string> lines) { return string.Join(", ", lines.Where((string line) => line != "")); } public static string Coordinates(Vector3 coordinates, string format = "F0", string color = "yellow") { string color2 = color; return JoinRow(from value in ((Vector3)(ref coordinates)).ToString(format).Replace("(", "").Replace(")", "") .Split(new char[1] { ',' }) select String(value.Trim(), color2)); } } }