using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BTD_Mod_Helper;
using BTD_Mod_Helper.Api;
using BTD_Mod_Helper.Api.Data;
using BTD_Mod_Helper.Api.Helpers;
using BTD_Mod_Helper.Api.ModOptions;
using BTD_Mod_Helper.Api.UI;
using BTD_Mod_Helper.Extensions;
using FasterForward;
using HarmonyLib;
using Il2CppAssets.Scripts;
using Il2CppAssets.Scripts.Unity;
using Il2CppAssets.Scripts.Unity.UI_New.InGame;
using Il2CppAssets.Scripts.Unity.UI_New.Popups;
using Il2CppAssets.Scripts.Unity.UI_New.Upgrade;
using Il2CppSystem;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem.Utilities;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(FasterForwardMod), "Faster Forward", "1.1.6", "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("FasterForward")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f5b4143d7c6af4212fbd566a91f0e9ec11546b0d")]
[assembly: AssemblyProduct("FasterForward")]
[assembly: AssemblyTitle("FasterForward")]
[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 FasterForward
{
public class FasterForwardMod : BloonsTD6Mod
{
[HarmonyPatch(typeof(UpgradeDetails), "Update")]
internal static class UpgradeDetails_Update
{
[HarmonyPrefix]
internal static void Prefix(UpgradeDetails __instance)
{
if (__instance.beginShowPopup)
{
__instance.popupTimer += 3f * Time.unscaledDeltaTime - Time.fixedUnscaledDeltaTime;
}
}
}
public static readonly ModSettingHotkey Hotkey1 = new ModSettingHotkey((KeyCode)282, (HotkeyModifier)0)
{
displayName = "First Speed Hotkey"
};
public static readonly ModSettingInt Speed1;
public static readonly ModSettingHotkey Hotkey2;
public static readonly ModSettingInt Speed2;
public static readonly ModSettingHotkey Hotkey3;
public static readonly ModSettingInt Speed3;
public static readonly ModSettingHotkey Hotkey4;
public static readonly ModSettingInt Speed4;
public static readonly ModSettingHotkey SpeedCustom;
private static readonly ModSettingBool ShowMessages;
public override void OnUpdate()
{
if (Hotkey1.JustPressed())
{
SetSpeed(ModSettingInt.op_Implicit(Speed1));
}
if (Hotkey2.JustPressed())
{
SetSpeed(ModSettingInt.op_Implicit(Speed2));
}
if (Hotkey3.JustPressed())
{
SetSpeed(ModSettingInt.op_Implicit(Speed3));
}
if (Hotkey4.JustPressed())
{
SetSpeed(ModSettingInt.op_Implicit(Speed4));
}
if (SpeedCustom.JustPressed() && (Object)(object)InGame.instance != (Object)null)
{
SetCustomSpeed();
}
}
public static void SetCustomSpeed()
{
PopupScreen.instance.ShowSetValuePopup("Custom Fast Forward Speed", "Sets the Fast Forward speed to the specified value", Action<int>.op_Implicit((Action<int>)delegate(int s)
{
SetSpeed(Mathf.Clamp(s, 1, 100));
}), (int)TimeHelper.OverrideFastForwardTimeScale);
}
public static void SetSpeed(double speed)
{
if (NumberHelpers.Approximately(TimeHelper.OverrideFastForwardTimeScale, speed))
{
return;
}
TimeHelper.OverrideFastForwardTimeScale = speed;
if (!((Object)(object)InGame.instance == (Object)null) && InGame.Bridge != null)
{
bool flag = NumberHelpers.Approximately(speed, Constants.fastForwardTimeScaleMultiplier);
string text = $"Fast Forward Speed is now {speed}x{(flag ? " (Default)" : "")}";
if (ModSettingBool.op_Implicit(ShowMessages))
{
GameExt.ShowMessage(Game.instance, text, 1f, (string)null);
}
else
{
ModHelper.Msg<FasterForwardMod>((object)text);
}
}
}
static FasterForwardMod()
{
//IL_0006: 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_001b: Expected O, but got Unknown
//IL_001c: 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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_004c: Expected O, but got Unknown
//IL_0052: 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_0067: Expected O, but got Unknown
//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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_0098: Expected O, but got Unknown
//IL_009e: 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_00b3: Expected O, but got Unknown
//IL_00b5: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Expected O, but got Unknown
//IL_00e5: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Expected O, but got Unknown
//IL_0132: Expected O, but got Unknown
//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_014d: Expected O, but got Unknown
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Expected O, but got Unknown
ModSettingInt val = new ModSettingInt(3)
{
displayName = "First Speed"
};
((ModSettingNumber<long>)val).min = 1L;
((ModSettingNumber<long>)val).max = 100L;
Speed1 = val;
Hotkey2 = new ModSettingHotkey((KeyCode)283, (HotkeyModifier)0)
{
displayName = "Second Speed Hotkey"
};
ModSettingInt val2 = new ModSettingInt(5)
{
displayName = "Second Speed"
};
((ModSettingNumber<long>)val2).min = 1L;
((ModSettingNumber<long>)val2).max = 100L;
Speed2 = val2;
Hotkey3 = new ModSettingHotkey((KeyCode)284, (HotkeyModifier)0)
{
displayName = "Third Speed Hotkey"
};
ModSettingInt val3 = new ModSettingInt(10)
{
displayName = "Third Speed"
};
((ModSettingNumber<long>)val3).min = 1L;
((ModSettingNumber<long>)val3).max = 100L;
Speed3 = val3;
Hotkey4 = new ModSettingHotkey((KeyCode)285, (HotkeyModifier)0)
{
displayName = "Fourth Speed Hotkey"
};
ModSettingInt val4 = new ModSettingInt(25)
{
displayName = "Fourth Speed"
};
((ModSettingNumber<long>)val4).min = 1L;
((ModSettingNumber<long>)val4).max = 100L;
Speed4 = val4;
SpeedCustom = new ModSettingHotkey((KeyCode)286, (HotkeyModifier)0)
{
displayName = "Custom Speed Hotkey"
};
ShowMessages = new ModSettingBool(true)
{
description = "Whether to show the in game message popups for fast forward speed changing"
};
}
}
public static class ModHelperData
{
public const string WorksOnVersion = "55.0";
public const string Version = "1.1.6";
public const string RepoOwner = "doombubbles";
public const string PrevRepoName = "faster-forward";
public const string RepoName = "FasterForward";
public const string Name = "Faster Forward";
public const string Description = "Allows you to increase the Fast Forward speed using the FN keys.\r\n\r\nF1: 3x Speed (Default)\r\nF2: 5x Speed\r\nF3: 10x Speed\r\nF4: 25x Speed\r\nF5: Custom Speed";
}
public class Speed : ModStartMenuEntry, IModSettings, IModContent
{
private static readonly ModSettingBool AddStartMenuEntry = new ModSettingBool(false)
{
description = "Adds an entry to the Mod Helper in game Start Menu for changing the fast forward speed without hotkeys"
};
public override string Icon => ((ModContent)this).GetTextureGUID("Icon");
public override float IconScale => 1.2f;
public override bool DontAddToStartMenu => !ModSettingBool.op_Implicit(AddStartMenuEntry);
}
public abstract class SpeedEntry : ModStartMenuEntry<Speed>
{
public abstract int Speed { get; }
public override string DisplayName => $"{Speed:N0}x";
public override void StartMenuEntryClicked()
{
FasterForwardMod.SetSpeed(Speed);
}
public override bool IsSelected()
{
return NumberHelpers.Approximately(TimeHelper.OverrideFastForwardTimeScale, (double)Speed);
}
}
public class Speed1 : SpeedEntry
{
public override int Speed => ModSettingInt.op_Implicit(FasterForwardMod.Speed1);
}
public class Speed2 : SpeedEntry
{
public override int Speed => ModSettingInt.op_Implicit(FasterForwardMod.Speed2);
}
public class Speed3 : SpeedEntry
{
public override int Speed => ModSettingInt.op_Implicit(FasterForwardMod.Speed3);
}
public class Speed4 : SpeedEntry
{
public override int Speed => ModSettingInt.op_Implicit(FasterForwardMod.Speed4);
}
public class Custom : ModStartMenuEntry<Speed>
{
public override void StartMenuEntryClicked()
{
FasterForwardMod.SetCustomSpeed();
}
public override bool IsSelected()
{
return ModContent.GetContent<SpeedEntry>().All((SpeedEntry entry) => !((ModStartMenuEntry)entry).IsSelected());
}
}
}