Decompiled source of CleanAsteroids v1.0.0

plugins/CleanAsteroids/CleanAsteroids.dll

Decompiled 4 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CleanAsteroids.Patches;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CleanAsteroids")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CleanAsteroids")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1710f096-dc16-463a-9c30-bb275cadcd02")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CleanAsteroids
{
	public class CleanAsteroidsConfig
	{
		internal static ConfigEntry<KeyboardShortcut> toggle;

		public static void CreateConfigEntries(BaseUnityPlugin plugin)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			toggle = plugin.Config.Bind<KeyboardShortcut>("General", "Toggle Shortcut", new KeyboardShortcut((KeyCode)104, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "The shortcut to press to toggle hiding of non-pure shape asteroids.");
		}
	}
	[BepInPlugin("com.equinox.CleanAsteroids", "CleanAsteroids", "1.0.0")]
	public class CleanAsteroidsPlugin : BaseUnityPlugin
	{
		internal const string MyGUID = "com.equinox.CleanAsteroids";

		private const string PluginName = "CleanAsteroids";

		private const string VersionString = "1.0.0";

		private static readonly Harmony Harmony = new Harmony("com.equinox.CleanAsteroids");

		internal static ManualLogSource Log = new ManualLogSource("CleanAsteroids");

		internal static bool enabled = true;

		private void Awake()
		{
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: CleanAsteroids, VersionString: 1.0.0 is loading...");
			ApplyPatches();
			CleanAsteroidsConfig.CreateConfigEntries((BaseUnityPlugin)(object)this);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: CleanAsteroids, VersionString: 1.0.0 has loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
		}

		private 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 = CleanAsteroidsConfig.toggle.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				enabled = !enabled;
			}
		}

		private void ApplyPatches()
		{
			Harmony.CreateAndPatchAll(typeof(HUDShapeResourcesVisualizationPatch), (string)null);
		}
	}
}
namespace CleanAsteroids.Patches
{
	internal class HUDShapeResourcesVisualizationPatch
	{
		[HarmonyPatch(typeof(HUDShapeResourcesVisualization), "DrawResource")]
		[HarmonyPrefix]
		private static bool PatchName(ShapeDefinition definition)
		{
			if (!CleanAsteroidsPlugin.enabled)
			{
				return true;
			}
			ShapePart[] parts = definition.Layers[0].Parts;
			if (((object)(ShapePart)(ref parts[0])).ToString() != ((object)(ShapePart)(ref parts[1])).ToString())
			{
				return false;
			}
			if (((object)(ShapePart)(ref parts[0])).ToString() != ((object)(ShapePart)(ref parts[2])).ToString())
			{
				return false;
			}
			if (((object)(ShapePart)(ref parts[0])).ToString() != ((object)(ShapePart)(ref parts[3])).ToString())
			{
				return false;
			}
			return true;
		}
	}
}