using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.Injection;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SpellBrigadeMods")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SpellBrigadeMods")]
[assembly: AssemblyTitle("SpellBrigadeMods")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SpellBrigadeMods;
[BepInPlugin("com.saeed.spellbrigademods", "Spell Brigade Unlock Everything", "4.0.0")]
public sealed class Plugin : BasePlugin
{
public const string PluginGuid = "com.saeed.spellbrigademods";
public const string PluginName = "Spell Brigade Unlock Everything";
public const string PluginVersion = "4.0.0";
internal static ManualLogSource ModLog;
public override void Load()
{
ModLog = ((BasePlugin)this).Log;
ClassInjector.RegisterTypeInIl2Cpp<UnlockRunner>();
((BasePlugin)this).AddComponent<UnlockRunner>();
((BasePlugin)this).Log.LogInfo((object)"Unlock Everything v4 loaded.");
}
}
public sealed class UnlockRunner : MonoBehaviour
{
private float timer;
private bool completed;
public UnlockRunner(IntPtr pointer)
: base(pointer)
{
}
public void Update()
{
if (completed)
{
return;
}
timer += Time.deltaTime;
if (timer < 5f)
{
return;
}
timer = 0f;
LocalPlayer instance = SingletonPersistent<LocalPlayer>.Instance;
if ((Object)(object)instance == (Object)null)
{
Plugin.ModLog.LogInfo((object)"Waiting for LocalPlayer.Instance...");
return;
}
try
{
UnlockEverything(instance);
completed = true;
}
catch (Exception ex)
{
Plugin.ModLog.LogError((object)("Unlock failed: " + ex));
}
}
private static void UnlockEverything(LocalPlayer player)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
ChallengeManager challengeManager = player.GetChallengeManager();
UpgradeManager upgradeManager = player.GetUpgradeManager();
if (challengeManager == null)
{
Plugin.ModLog.LogWarning((object)"GetChallengeManager() returned null.");
return;
}
if (upgradeManager == null)
{
Plugin.ModLog.LogWarning((object)"GetUpgradeManager() returned null.");
return;
}
player.AddGold(100000000);
challengeManager.CompleteAllChallenges();
Plugin.ModLog.LogInfo((object)"Completed all challenges.");
Array values = Enum.GetValues(typeof(UpgradeIdentifier));
foreach (UpgradeIdentifier item in values)
{
int num = 0;
while (!upgradeManager.IsMaxLevel(item))
{
upgradeManager.LevelUp(item);
num++;
if (num >= 100)
{
Plugin.ModLog.LogWarning((object)("Stopped maxing " + ((object)item/*cast due to .constrained prefix*/).ToString() + " after 100 attempts."));
break;
}
}
Plugin.ModLog.LogInfo((object)("Maxed upgrade: " + ((object)item/*cast due to .constrained prefix*/).ToString()));
}
SaveManager instance = SingletonPersistent<SaveManager>.Instance;
if ((Object)(object)instance != (Object)null)
{
instance.SavePlayerData();
Plugin.ModLog.LogInfo((object)"Progress saved.");
}
else
{
Plugin.ModLog.LogWarning((object)"SaveManager.Instance is null. The game should auto-save later.");
}
Plugin.ModLog.LogInfo((object)"DONE: all challenge unlocks completed and all permanent upgrades maxed.");
Plugin.ModLog.LogInfo((object)"Restart the game once so every menu refreshes.");
}
}