Decompiled source of BetterAutoStart v1.1.3

BetterAutoStart.dll

Decompiled 10 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BTD_Mod_Helper;
using BTD_Mod_Helper.Api;
using BTD_Mod_Helper.Extensions;
using BetterAutoStart;
using HarmonyLib;
using Il2CppAssets.Scripts.Unity;
using Il2CppAssets.Scripts.Unity.Bridge;
using Il2CppAssets.Scripts.Unity.UI_New.InGame;
using Il2CppAssets.Scripts.Unity.UI_New.InGame.ActionMenu;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(BetterAutoStartMod), "Better Auto Start", "1.1.3", "doombubbles", null)]
[assembly: MelonGame("Ninja Kiwi", "BloonsTD6")]
[assembly: MelonGame("Ninja Kiwi", "BloonsTD6-Epic")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BetterAutoStart")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+14b27cf124b18d72f773ca32accc6f4f7d10dae6")]
[assembly: AssemblyProduct("BetterAutoStart")]
[assembly: AssemblyTitle("BetterAutoStart")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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 BetterAutoStart
{
	public class BetterAutoStartMod : BloonsTD6Mod
	{
	}
	public class BetterAutoStartUtility
	{
		[HarmonyPatch(typeof(Button), "OnPointerClick")]
		internal class Button_OnPointerClick
		{
			[HarmonyPostfix]
			internal static void Postfix(Button __instance, PointerEventData eventData)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Invalid comparison between Unknown and I4
				if (!((Object)(object)InGame.instance == (Object)null) && (int)eventData.button == 1 && !(((Object)__instance).name != "FastFoward-Go"))
				{
					bool autoPlay = !InGame.instance.bridge.simulation.autoPlay;
					GameExt.GetPlayerProfile(Game.instance).inGameSettings.autoPlay = autoPlay;
					InGame.instance.bridge.SetAutoPlay(autoPlay);
				}
			}
		}

		[HarmonyPatch(typeof(GoFastForwardToggle), "OnEnable")]
		internal static class GoFastForwardToggle_OnEnable
		{
			[HarmonyPostfix]
			private static void Postfix(GoFastForwardToggle __instance)
			{
				bool flag = true;
				UpdateTextures(__instance, GameExt.GetPlayerProfile(Game.instance).inGameSettings.autoPlay);
			}
		}

		[HarmonyPatch(typeof(UnityToSimulation), "SetAutoPlay")]
		internal static class UnityToSimulation_ToggleAutoPlay
		{
			[HarmonyPostfix]
			private static void Postfix(bool on)
			{
				if ((Object)(object)ShopMenuExt.instance != (Object)null && (Object)(object)ShopMenuExt.instance.goFFToggle != (Object)null)
				{
					UpdateTextures(ShopMenuExt.instance.goFFToggle, on);
				}
			}
		}

		private const bool IsEnabled = true;

		private static Sprite GetSprite(string name)
		{
			return ModContent.GetSprite<BetterAutoStartMod>(name, 10f);
		}

		private static void UpdateTextures(GoFastForwardToggle toggle, bool enabled)
		{
			if (enabled)
			{
				ImageExt.SetSprite(toggle.goImage.GetComponent<Image>(), GetSprite("GoBtn"));
				ImageExt.SetSprite(toggle.fastForwardOffImage.GetComponent<Image>(), GetSprite("FastForwardBtn"));
				ImageExt.SetSprite(toggle.fastForwardOnImage.GetComponent<Image>(), GetSprite("FastForwardGlowBtn"));
			}
			else
			{
				ImageExt.SetSprite(toggle.goImage.GetComponent<Image>(), "IngameUi[GoBtn]");
				ImageExt.SetSprite(toggle.fastForwardOffImage.GetComponent<Image>(), "IngameUi[FastForwardBtn]");
				ImageExt.SetSprite(toggle.fastForwardOnImage.GetComponent<Image>(), "IngameUi[FastForwardGlowBtn]");
			}
		}
	}
	public class ModHelperData
	{
		public const string WorksOnVersion = "52.2";

		public const string Version = "1.1.3";

		public const string Name = "Better Auto Start";

		public const string Description = "Adds a visual indicator on the Play / Fast Forward button to show whether Auto Start is enabled or disabled. Additionally, right clicking on the button will toggle Auto Start.\n\nAny Bloons Monkey City fans out there?";

		public const string RepoOwner = "doombubbles";

		public const string PrevRepoName = "better-auto-start";

		public const string RepoName = "BetterAutoStart";
	}
}