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 SnepMods v1.2.2
BepInEx/plugins/SnepMods.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using SnepMods.Features.AreaRepair; using SnepMods.Features.AutoShield; using SnepMods.Features.Compass; using SnepMods.Features.FloatingItems; using SnepMods.UI; using UnityEngine; [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("SnepMods")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Valheim mod pack with multiple gameplay tweaks (AutoShield, Compass, AreaRepair).")] [assembly: AssemblyFileVersion("1.2.2.0")] [assembly: AssemblyInformationalVersion("1.2.2")] [assembly: AssemblyProduct("SnepMods")] [assembly: AssemblyTitle("SnepMods")] [assembly: AssemblyVersion("1.2.2.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 SnepMods { [BepInPlugin("snep.valheim.snepmods", "SnepMods", "1.2.2")] public class SnepModsPlugin : BaseUnityPlugin { public const string PluginGuid = "snep.valheim.snepmods"; public const string PluginName = "SnepMods"; public const string PluginVersion = "1.2.2"; private Harmony _harmony; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _harmony = new Harmony("snep.valheim.snepmods"); _harmony.PatchAll(); AutoShieldFeature.Init(((BaseUnityPlugin)this).Config); CompassFeature.Init(((BaseUnityPlugin)this).Config); AreaRepairFeature.Init(((BaseUnityPlugin)this).Config); FloatingItemsFeature.Init(((BaseUnityPlugin)this).Config); ModMenu.Init(((BaseUnityPlugin)this).Config); } private void Update() { AutoShieldFeature.Update(); CompassFeature.Update(); AreaRepairFeature.Update(); FloatingItemsFeature.Update(); ModMenu.Update(); } private void OnGUI() { CompassHud.OnGUI(); ModMenu.OnGUI(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace SnepMods.UI { internal static class ModMenu { [CompilerGenerated] private static class <>O { public static WindowFunction <0>__DrawWindow; } private static ConfigFile _config; private static bool _visible; private static string _selectedSection; private static ConfigEntry<KeyboardShortcut> _capturingEntry; private static Rect _windowRect = new Rect(20f, 20f, 380f, 400f); private static GUIStyle _titleStyle; public static void Init(ConfigFile config) { _config = config; } public static void Update() { //IL_0060: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00c4: Unknown result type (might be due to invalid IL or missing references) if ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) && Input.GetKeyDown((KeyCode)112)) { SetVisible(!_visible); } if (_visible) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } if (_visible && _capturingEntry != null && Input.GetKeyDown((KeyCode)27)) { _capturingEntry.Value = KeyboardShortcut.Empty; _capturingEntry = null; } else { if (!_visible || _capturingEntry == null || !Input.anyKeyDown) { return; } foreach (KeyCode value in Enum.GetValues(typeof(KeyCode))) { if (Input.GetKeyDown(value) && !IsModifierKey(value)) { _capturingEntry.Value = new KeyboardShortcut(value, Array.Empty<KeyCode>()); _capturingEntry = null; break; } } } } public static void OnGUI() { //IL_0037: 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_001e: 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_0032: Expected O, but got Unknown //IL_0061: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown if (_visible) { if (_titleStyle == null) { _titleStyle = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)1, fontSize = 14 }; } Rect windowRect = _windowRect; object obj = <>O.<0>__DrawWindow; if (obj == null) { WindowFunction val = DrawWindow; <>O.<0>__DrawWindow = val; obj = (object)val; } _windowRect = GUILayout.Window(1399156336, windowRect, (WindowFunction)obj, "SnepMods", Array.Empty<GUILayoutOption>()); } } private static void SetVisible(bool visible) { _visible = visible; _capturingEntry = null; if (visible) { _selectedSection = null; } Cursor.lockState = (CursorLockMode)(!visible); Cursor.visible = visible; } private static void DrawWindow(int id) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (_selectedSection == null) { DrawModList(); } else { DrawModConfig(_selectedSection); } GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f)); } private static void DrawModList() { GUILayout.Label("Installed mods", _titleStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); foreach (string section in GetSections()) { if (GUILayout.Button(section, Array.Empty<GUILayoutOption>())) { _selectedSection = section; } } } private static void DrawModConfig(string section) { if (GUILayout.Button("< Back", Array.Empty<GUILayoutOption>())) { _selectedSection = null; return; } GUILayout.Label(section, _titleStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); foreach (ConfigDefinition item in _config.Keys.Where((ConfigDefinition d) => d.Section == section).ToList()) { DrawEntry(_config[item]); } } private static void DrawEntry(ConfigEntryBase entry) { //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(entry.Definition.Key, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) }); if (entry.SettingType == typeof(bool)) { ConfigEntry<bool> val = (ConfigEntry<bool>)(object)entry; val.Value = GUILayout.Toggle(val.Value, val.Value ? "On" : "Off", Array.Empty<GUILayoutOption>()); } else if (entry.SettingType == typeof(float)) { ConfigEntry<float> val2 = (ConfigEntry<float>)(object)entry; float num = 0f; float num2 = 1f; if (entry.Description.AcceptableValues is AcceptableValueRange<float> val3) { num = val3.MinValue; num2 = val3.MaxValue; } val2.Value = GUILayout.HorizontalSlider(val2.Value, num, num2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUILayout.Label(val2.Value.ToString("0.00"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); } else if (entry.SettingType == typeof(KeyboardShortcut)) { ConfigEntry<KeyboardShortcut> val4 = (ConfigEntry<KeyboardShortcut>)(object)entry; if (_capturingEntry == val4) { GUILayout.Label("press a key...", Array.Empty<GUILayoutOption>()); } else if (GUILayout.Button(((object)val4.Value/*cast due to .constrained prefix*/).ToString(), Array.Empty<GUILayoutOption>())) { _capturingEntry = val4; } } else { GUILayout.Label(entry.BoxedValue?.ToString() ?? "", Array.Empty<GUILayoutOption>()); } GUILayout.EndHorizontal(); } private static IEnumerable<string> GetSections() { HashSet<string> seen = new HashSet<string>(); foreach (ConfigDefinition key in _config.Keys) { if (seen.Add(key.Section)) { yield return key.Section; } } } private static bool IsModifierKey(KeyCode keyCode) { //IL_0000: 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_0008: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if (keyCode - 303 <= 5 || (int)keyCode == 323) { return true; } return false; } } } namespace SnepMods.Features.FloatingItems { internal static class FloatingItemsFeature { private const string Category = "FloatingItems"; public static ConfigEntry<bool> Enabled; public static ConfigEntry<KeyboardShortcut> ToggleKey; public static ConfigEntry<float> Force; public static void Init(ConfigFile config) { //IL_0030: 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_0077: Expected O, but got Unknown Enabled = config.Bind<bool>("FloatingItems", "Enabled", true, "When enabled, dropped items float on water instead of sinking. Only affects items your client currently owns physics for (usually whichever items are nearest to you)."); ToggleKey = config.Bind<KeyboardShortcut>("FloatingItems", "ToggleKey", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), "Key to toggle floating items on/off while in-game."); Force = config.Bind<float>("FloatingItems", "Force", 0.5f, new ConfigDescription("Buoyancy strength pushing floating items back to the surface.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>())); } public static void Update() { //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) KeyboardShortcut value = ToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { Enabled.Value = !Enabled.Value; if (Object.op_Implicit((Object)(object)MessageHud.instance)) { MessageHud.instance.ShowMessage((MessageType)2, "Floating Items: " + (Enabled.Value ? "On" : "Off"), 0, (Sprite)null, false, true); } } } } [HarmonyPatch(typeof(ItemDrop), "Awake")] internal static class FloatingItemsPatch { private static void Postfix(ItemDrop __instance) { if (!FloatingItemsFeature.Enabled.Value) { return; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && ZRoutedRpc.instance != null) { if ((Object)(object)((Component)__instance).GetComponent<Floating>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<Floating>().m_force = FloatingItemsFeature.Force.Value; } __instance.RequestOwn(); } } } } namespace SnepMods.Features.Compass { internal static class CompassFeature { private const string Category = "Compass"; public static ConfigEntry<bool> Enabled; public static ConfigEntry<KeyboardShortcut> ToggleKey; public static ConfigEntry<float> Width; public static ConfigEntry<float> Height; private static readonly (PinType Type, string Key, string Description)[] MarkerDefs = new(PinType, string, string)[8] { ((PinType)4, "ShowDeathMarkers", "Show death markers on the compass."), ((PinType)9, "ShowBossMarkers", "Show boss markers on the compass."), ((PinType)10, "ShowPlayers", "Show other players on the compass (requires their position to be shared)."), ((PinType)0, "ShowCampfireMarkers", "Show campfire pins on the compass."), ((PinType)1, "ShowHomeMarkers", "Show home pins on the compass."), ((PinType)2, "ShowHammerMarkers", "Show crafting pins on the compass."), ((PinType)3, "ShowCircleMarkers", "Show circle pins on the compass."), ((PinType)6, "ShowPortalMarkers", "Show portal pins on the compass.") }; private static readonly Dictionary<PinType, ConfigEntry<bool>> MarkerToggles = new Dictionary<PinType, ConfigEntry<bool>>(); public static void Init(ConfigFile config) { //IL_0030: 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_0077: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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) Enabled = config.Bind<bool>("Compass", "Enabled", true, "Show the compass HUD."); ToggleKey = config.Bind<KeyboardShortcut>("Compass", "ToggleKey", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Key to toggle the compass on/off while in-game."); Width = config.Bind<float>("Compass", "Width", 420f, new ConfigDescription("Width of the compass bar, in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(200f, 1000f), Array.Empty<object>())); Height = config.Bind<float>("Compass", "Height", 36f, new ConfigDescription("Height of the compass bar, in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 100f), Array.Empty<object>())); (PinType, string, string)[] markerDefs = MarkerDefs; for (int i = 0; i < markerDefs.Length; i++) { var (key, text, text2) = markerDefs[i]; MarkerToggles[key] = config.Bind<bool>("Compass", text, true, text2); } } public static bool IsMarkerVisible(PinType type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (MarkerToggles.TryGetValue(type, out var value)) { return value.Value; } return true; } public static void Update() { //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) KeyboardShortcut value = ToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { Enabled.Value = !Enabled.Value; if (Object.op_Implicit((Object)(object)MessageHud.instance)) { MessageHud.instance.ShowMessage((MessageType)2, "Compass: " + (Enabled.Value ? "On" : "Off"), 0, (Sprite)null, false, true); } } } } internal static class CompassHud { private const float FovDegrees = 180f; private static readonly FieldRef<Minimap, List<PinData>> PinsField = AccessTools.FieldRefAccess<Minimap, List<PinData>>("m_pins"); private static GUIStyle _labelStyle; public static void OnGUI() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00d3: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0115: 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: Invalid comparison between Unknown and I4 //IL_0141: Unknown result type (might be due to invalid IL or missing references) if (!CompassFeature.Enabled.Value || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)GameCamera.instance)) { return; } if (_labelStyle == null) { _labelStyle = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1 }; } float value = CompassFeature.Width.Value; float value2 = CompassFeature.Height.Value; Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - value) / 2f, 10f, value, value2); GUI.Box(val, GUIContent.none); float y = ((Component)GameCamera.instance).transform.eulerAngles.y; DrawDirection(val, y, 0f, "N"); DrawDirection(val, y, 90f, "E"); DrawDirection(val, y, 180f, "S"); DrawDirection(val, y, 270f, "W"); if (!((Object)(object)Minimap.instance != (Object)null)) { return; } foreach (PinData item in PinsField.Invoke(Minimap.instance)) { if (CompassFeature.IsMarkerVisible(item.m_type)) { bool flag = (int)item.m_type == 10; if (!((Object)(object)item.m_icon == (Object)null) || flag) { DrawPin(val, y, item, flag); } } } } private static void DrawDirection(Rect bar, float heading, float directionDegrees, string label) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.DeltaAngle(heading, directionDegrees); if (!(Mathf.Abs(num) > 90f)) { GUI.Label(new Rect(((Rect)(ref bar)).x + ((Rect)(ref bar)).width / 2f + num / 90f * (((Rect)(ref bar)).width / 2f) - 15f, ((Rect)(ref bar)).y, 30f, ((Rect)(ref bar)).height), label, _labelStyle); } } private static void DrawPin(Rect bar, float heading, PinData pin, bool isPlayer) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001a: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_0117: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pin.m_pos - ((Component)Player.m_localPlayer).transform.position; float num = Mathf.Atan2(val.x, val.z) * 57.29578f; if (num < 0f) { num += 360f; } float num2 = Mathf.DeltaAngle(heading, num); if (Mathf.Abs(num2) > 90f) { return; } float num3 = ((Rect)(ref bar)).x + ((Rect)(ref bar)).width / 2f + num2 / 90f * (((Rect)(ref bar)).width / 2f); float num4 = ((Rect)(ref bar)).height * 0.8f; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num3 - num4 / 2f, ((Rect)(ref bar)).y + (((Rect)(ref bar)).height - num4) / 2f, num4, num4); if ((Object)(object)pin.m_icon != (Object)null) { DrawSprite(val2, pin.m_icon); } else if (isPlayer) { GUI.Box(val2, GUIContent.none); if (!string.IsNullOrEmpty(pin.m_name)) { GUI.Label(new Rect(num3 - 50f, ((Rect)(ref bar)).y - 16f, 100f, 16f), pin.m_name, _labelStyle); } } } internal static void DrawSprite(Rect rect, Sprite sprite) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) Vector2[] uv = sprite.uv; float num = uv[0].x; float num2 = uv[0].x; float num3 = uv[0].y; float num4 = uv[0].y; for (int i = 1; i < uv.Length; i++) { num = Mathf.Min(num, uv[i].x); num2 = Mathf.Max(num2, uv[i].x); num3 = Mathf.Min(num3, uv[i].y); num4 = Mathf.Max(num4, uv[i].y); } Rect val = default(Rect); ((Rect)(ref val))..ctor(num, num3, num2 - num, num4 - num3); GUI.DrawTextureWithTexCoords(rect, (Texture)(object)sprite.texture, val); } } } namespace SnepMods.Features.AutoShield { internal static class AutoShieldFeature { private const string Category = "AutoShield"; public static ConfigEntry<bool> Enabled; public static ConfigEntry<KeyboardShortcut> ToggleKey; internal static string LastShieldName; public static void Init(ConfigFile config) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) Enabled = config.Bind<bool>("AutoShield", "Enabled", true, "When enabled, equipping a one-handed weapon will automatically re-equip your last shield."); ToggleKey = config.Bind<KeyboardShortcut>("AutoShield", "ToggleKey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Key to toggle AutoShield on/off while in-game."); } public static void Update() { //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) KeyboardShortcut value = ToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { Enabled.Value = !Enabled.Value; if (Object.op_Implicit((Object)(object)MessageHud.instance)) { MessageHud.instance.ShowMessage((MessageType)2, "AutoShield: " + (Enabled.Value ? "On" : "Off"), 0, (Sprite)null, false, true); } } } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] internal static class EquipPatch { private static void Postfix(Humanoid __instance, ItemData item, bool __result) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 if (!__result || !AutoShieldFeature.Enabled.Value) { return; } Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return; } if ((int)item.m_shared.m_itemType == 5) { AutoShieldFeature.LastShieldName = item.m_shared.m_name; } else { if ((int)item.m_shared.m_itemType != 3 || ((Humanoid)val).LeftItem != null || string.IsNullOrEmpty(AutoShieldFeature.LastShieldName)) { return; } foreach (ItemData allItem in ((Humanoid)val).GetInventory().GetAllItems()) { if ((int)allItem.m_shared.m_itemType == 5 && allItem.m_shared.m_name == AutoShieldFeature.LastShieldName) { ((Humanoid)val).EquipItem(allItem, true); break; } } } } } } namespace SnepMods.Features.AreaRepair { internal static class AreaRepairFeature { private const string Category = "AreaRepair"; public static ConfigEntry<bool> Enabled; public static ConfigEntry<KeyboardShortcut> ToggleKey; public static ConfigEntry<float> Radius; public static void Init(ConfigFile config) { //IL_0030: 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_0077: Expected O, but got Unknown Enabled = config.Bind<bool>("AreaRepair", "Enabled", true, "When enabled, repairing a piece with the hammer also repairs damaged pieces around it."); ToggleKey = config.Bind<KeyboardShortcut>("AreaRepair", "ToggleKey", new KeyboardShortcut((KeyCode)290, Array.Empty<KeyCode>()), "Key to toggle area repair on/off while in-game."); Radius = config.Bind<float>("AreaRepair", "Radius", 5f, new ConfigDescription("Radius (in meters) around the repaired piece to also repair.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>())); } public static void Update() { //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) KeyboardShortcut value = ToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { Enabled.Value = !Enabled.Value; if (Object.op_Implicit((Object)(object)MessageHud.instance)) { MessageHud.instance.ShowMessage((MessageType)2, "Area Repair: " + (Enabled.Value ? "On" : "Off"), 0, (Sprite)null, false, true); } } } } [HarmonyPatch(typeof(Player), "Repair")] internal static class AreaRepairPatch { private static void Postfix(Player __instance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!AreaRepairFeature.Enabled.Value) { return; } Piece hoveringPiece = __instance.GetHoveringPiece(); if (!Object.op_Implicit((Object)(object)hoveringPiece)) { return; } HashSet<WearNTear> hashSet = new HashSet<WearNTear>(); Collider[] array = Physics.OverlapSphere(((Component)hoveringPiece).transform.position, AreaRepairFeature.Radius.Value); int num = 0; Collider[] array2 = array; for (int i = 0; i < array2.Length; i++) { WearNTear componentInParent = ((Component)array2[i]).GetComponentInParent<WearNTear>(); if (!((Object)(object)componentInParent == (Object)null) && hashSet.Add(componentInParent) && PrivateArea.CheckAccess(((Component)componentInParent).transform.position, 0f, false, false) && componentInParent.Repair()) { num++; } } if (num > 0 && Object.op_Implicit((Object)(object)MessageHud.instance)) { MessageHud.instance.ShowMessage((MessageType)1, "Area repaired " + num + " nearby piece(s)", 0, (Sprite)null, false, true); } } } }