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 crosshair v1.0.1
OnionMilk_crosshair.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 OnionMilk_crosshair; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("OnionMilk_crosshair")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Crosshair plugin for BepInEx (Lethal Company)")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OnionMilk_crosshair")] [assembly: AssemblyTitle("OnionMilk_crosshair")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HealthMetrics.Patches { [HarmonyPatch(typeof(HUDManager))] internal class HealthHUDPatches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start(ref HUDManager __instance) { //IL_0005: 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) //IL_0011: 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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) GameObject val = new GameObject("Crosshair"); RectTransform val2 = val.AddComponent<RectTransform>(); Image val3 = val.AddComponent<Image>(); val.transform.SetParent(__instance.HUDContainer.transform, false); val.transform.SetAsLastSibling(); val3.sprite = Plugin.icon; ((Graphic)val3).color = Color32.op_Implicit(Plugin.color); val2.sizeDelta = new Vector2(Plugin.cfgWidth.Value, Plugin.cfgHeight.Value); } } [HarmonyPatch(typeof(MenuManager))] public static class MenuManagerOverridePatch { [CompilerGenerated] private static class <>O { public static UnityAction <0>__OnClick; } private static Image menuButtonCrosshair; private static AudioSource aud; private static AudioClip sfx; [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Awake(ref MenuManager __instance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00f7: 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_0123: 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_017c: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_0073: Expected O, but got Unknown if (!((Object)(object)__instance?.versionNumberText == (Object)null)) { Canvas componentInParent = ((Component)__instance.versionNumberText).GetComponentInParent<Canvas>(); GameObject val = new GameObject("CrosshairSettings"); RectTransform val2 = val.AddComponent<RectTransform>(); menuButtonCrosshair = val.AddComponent<Image>(); Button val3 = val.AddComponent<Button>(); ((Selectable)val3).targetGraphic = (Graphic)(object)menuButtonCrosshair; ButtonClickedEvent onClick = val3.onClick; object obj = <>O.<0>__OnClick; if (obj == null) { UnityAction val4 = OnClick; <>O.<0>__OnClick = val4; obj = (object)val4; } ((UnityEvent)onClick).AddListener((UnityAction)obj); val.transform.SetParent(((Component)componentInParent).transform, false); val.transform.SetAsLastSibling(); menuButtonCrosshair.sprite = Plugin.icon; ((Graphic)menuButtonCrosshair).color = Color32.op_Implicit(Plugin.color); val2.sizeDelta /= 3f; RectTransform obj2 = val2; RectTransform obj3 = val2; Vector2 val5 = (val2.pivot = Vector2.one); Vector2 val8 = (obj2.anchorMin = (obj3.anchorMax = val5)); val2.anchoredPosition = new Vector2(-50f, -20f); aud = __instance.MenuAudio; sfx = __instance.openMenuSound; GameObject val9 = new GameObject("CrosshairLabel"); val2 = val9.AddComponent<RectTransform>(); TextMeshProUGUI obj4 = val9.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj4).alignment = (TextAlignmentOptions)258; ((TMP_Text)obj4).SetText("Set Crosshair", true); ((TMP_Text)obj4).fontSize = ((TMP_Text)obj4).fontSize / 3f; val9.transform.SetParent(((Component)val3).transform, false); RectTransform obj5 = val2; RectTransform obj6 = val2; ((Vector2)(ref val8))..ctor(0.5f, 0f); obj6.anchorMax = val8; obj5.anchorMin = val8; val2.pivot = new Vector2(0.5f, 1f); val2.anchoredPosition = new Vector2(0f, -5f); } } private static void OnClick() { aud.PlayOneShot(sfx, 1f); List<string> list = Directory.EnumerateFiles(Plugin.GetPath, "*.png").ToList(); int num = list.FindIndex((string f) => f.Contains(Plugin.cfgImage.Value)); int num2 = 0; num2 = ((num > -1 && num < list.Count - 1) ? (num + 1) : 0); ((ConfigEntryBase)Plugin.cfgImage).SetSerializedValue(list[num2].Replace(Plugin.GetPath, string.Empty).TrimStart('\\')); Plugin.Log("Changed crosshair to: " + list[num2]); Plugin.LoadIcon(list[num2]); menuButtonCrosshair.sprite = Plugin.icon; } } } namespace OnionMilk_crosshair { [BepInPlugin("OnionMilk_crosshair", "OnionMilk_crosshair", "1.0.0")] public class Plugin : BaseUnityPlugin { private static Plugin instance; private readonly Harmony _harmony = new Harmony("OnionMilk.Crosshair"); public static ConfigEntry<bool> cfgEnabled; public static ConfigEntry<string> cfgImage; public static ConfigEntry<float> cfgWidth; public static ConfigEntry<float> cfgHeight; public static ConfigEntry<int> cfgR; public static ConfigEntry<int> cfgG; public static ConfigEntry<int> cfgB; public static ConfigEntry<int> cfgA; public static Color32 color; public static Sprite icon; private static string getPath; public static string GetPath { get { if (getPath == null) { getPath = Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path)); } return getPath; } } public static void ListChildren(Transform t, string prefix = "") { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown foreach (Transform item in t) { Transform val = item; Log(prefix + ((Object)val).name); if (t.childCount > 0) { ListChildren(val, prefix + "-"); } } } public static void Log(string msg) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)("[OnionMilk_crosshair] " + msg)); } private void Awake() { //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) instance = this; cfgR = ((BaseUnityPlugin)this).Config.Bind<int>("Color", "r", 255, "Red value of crosshair (0-255)"); cfgG = ((BaseUnityPlugin)this).Config.Bind<int>("Color", "g", 255, "Green value of crosshair (0-255)"); cfgB = ((BaseUnityPlugin)this).Config.Bind<int>("Color", "b", 255, "Blue value of crosshair (0-255)"); cfgA = ((BaseUnityPlugin)this).Config.Bind<int>("Color", "a", 255, "Alpha value of crosshair (0-255)"); cfgWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Size", "width", 10f, "Width of crosshair"); cfgHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Size", "height", 10f, "Height of crosshair"); cfgEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enabled", true, "Is crosshair visible?"); cfgImage = ((BaseUnityPlugin)this).Config.Bind<string>("General", "image", "crosshair.png", "Crosshair image, leave empty for square"); Log("Plugin is loaded!"); if (cfgEnabled.Value) { if (cfgImage.Value != string.Empty) { LoadIcon(Path.Combine(GetPath, cfgImage.Value)); } color = new Color32((byte)cfgR.Value, (byte)cfgG.Value, (byte)cfgB.Value, (byte)cfgA.Value); _harmony.PatchAll(); } } internal static void LoadIcon(string filePath) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!File.Exists(filePath)) { Log("Crosshair image not found: " + filePath + ", using default"); return; } try { byte[] array = File.ReadAllBytes(filePath); Texture2D val = new Texture2D(2, 2, (TextureFormat)5, false); ImageConversion.LoadImage(val, array); ((Texture)val).filterMode = (FilterMode)0; icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), Mathf.Min(cfgWidth.Value, cfgHeight.Value)); Log("Image " + filePath + " loaded as crosshair!"); } catch (Exception) { Log("Crosshair image is not readable PNG: " + filePath + ", using default"); } } } public static class PluginInfo { public const string PLUGIN_GUID = "OnionMilk_crosshair"; public const string PLUGIN_NAME = "OnionMilk_crosshair"; public const string PLUGIN_VERSION = "1.0.0"; } }