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 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")]
[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";
}
[HarmonyPatch(typeof(Player), "UpdateHover")]
public class Player_AddHoverForVisuals
{
public 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 customTag = "";
}
public class Drawer : Component
{
private static Shader? lineShader;
private static Shader LineShader => lineShader ?? (lineShader = ((IEnumerable<Shader>)Resources.FindObjectsOfTypeAll<Shader>()).FirstOrDefault((Func<Shader, bool>)((Shader shader) => ((Object)shader).name == "Particles/Standard Unlit2")) ?? throw new Exception("Shader not found."));
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 LineRenderer CreateRenderer(GameObject obj, Color color, float width)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_001e: 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_003c: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
LineRenderer obj2 = obj.AddComponent<LineRenderer>();
obj2.useWorldSpace = false;
Material val = new Material(LineShader);
val.SetColor("_Color", color);
val.SetFloat("_BlendOp", 1f);
Texture2D val2 = new Texture2D(1, 1);
val2.SetPixel(0, 0, Color.gray);
val.SetTexture("_MainTex", (Texture)(object)val2);
((Renderer)obj2).material = val;
((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)0;
obj2.widthMultiplier = width / 100f;
return obj2;
}
private static void ChangeColor(GameObject obj, Color color)
{
//IL_0019: 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]).material.SetColor("_Color", 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>().customTag = tag;
}
public static void Remove(MonoBehaviour parent, string tag)
{
Visualization[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Visualization>(true);
foreach (Visualization visualization in componentsInChildren)
{
if (visualization.customTag == tag)
{
Object.Destroy((Object)(object)((Component)visualization).gameObject);
}
}
}
public static void SetColor(string tag, Color color)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
Visualization[] array = Resources.FindObjectsOfTypeAll<Visualization>();
foreach (Visualization visualization in array)
{
if (visualization.customTag == tag)
{
ChangeColor(((Component)visualization).gameObject, color);
}
}
}
public static void SetLineWidth(string tag, float width)
{
Visualization[] array = Resources.FindObjectsOfTypeAll<Visualization>();
foreach (Visualization visualization in array)
{
if (visualization.customTag == tag)
{
ChangeLineWidth(((Component)visualization).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, Color color, float width, Vector3 center, Vector3 extents)
{
//IL_0007: 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)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return DrawBox(tag, ((Component)parent).gameObject, color, width, center, extents);
}
public static GameObject DrawBox(string tag, GameObject parent, Color color, float width, Vector3 center, Vector3 extents)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_0026: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_0073: 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_0081: 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_0090: 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_009f: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: 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_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: 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_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: 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_0197: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: 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_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: 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_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: 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)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: 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)
};
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;
}
}
[BepInPlugin("ore_support", "Ore Support", "1.9")]
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.9";
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 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
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);
};
}
}
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_004b: 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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: 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_003d: 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)
Color color = ((tag == "OreSupport_CriticalMineRock") ? Settings.CriticalMineRockColor : ((tag == "OreSupport_MineRock") ? Settings.MineRockColor : ((tag == "OreSupport_ClearedMineRock") ? Settings.ClearedMineRockColor : Settings.DestructibleColor)));
Drawer.AddText(Drawer.DrawBox(tag, obj, color, 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));
}
}
}