using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using Voxels.TowerDefense;
using Voxels.TowerDefense.ProfileInternals;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BadNorthUnlockAll")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BadNorthUnlockAll")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3f46435f-b020-4267-b698-17ab1c691afc")]
[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 FullUnlockMod;
[BepInPlugin("com.shanmai.fullunlock", "Full Unlock Mod", "1.0.0")]
public class FullUnlockPlugin : BaseUnityPlugin
{
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Full Unlock Mod is loading...");
Harmony val = new Harmony("com.shanmai.fullunlock");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Full Unlock Mod has been patched!");
}
}
[HarmonyPatch(typeof(Profile), "OnUserSaveLoaded")]
public static class Patch_OnUserSaveLoaded
{
private static void Postfix()
{
Debug.Log((object)"[FullUnlockPatch] OnUserSaveLoaded Postfix triggered");
FullUnlockPatch.ApplyFullUnlock();
}
}
public static class FullUnlockPatch
{
public static void ApplyFullUnlock()
{
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"[FullUnlockPatch] ApplyFullUnlock start");
try
{
UserSave userSave = Profile.userSave;
if (userSave == null)
{
Debug.Log((object)"[FullUnlockPatch] userSave == null,提前返回");
return;
}
MetaInventory inventory = userSave.inventory;
if (inventory == null)
{
Debug.Log((object)"[FullUnlockPatch] userSave.inventory == null,提前返回");
return;
}
List<HeroUpgradeTypeEnum> list = new List<HeroUpgradeTypeEnum>
{
(HeroUpgradeTypeEnum)0,
(HeroUpgradeTypeEnum)4,
(HeroUpgradeTypeEnum)3
};
foreach (HeroUpgradeDefinition item in ResourceList<HeroUpgradeDefinition>.list)
{
if (!((Object)(object)item == (Object)null))
{
int num = Math.Max(0, item.numLevels - 1);
bool flag = list.Contains(item.typeEnum);
inventory.Add(item, num, flag);
}
}
HeroUpgradeDefinition[] array = Resources.LoadAll<HeroUpgradeDefinition>("");
if (array != null)
{
HeroUpgradeDefinition[] array2 = array;
foreach (HeroUpgradeDefinition val in array2)
{
if ((Object)(object)val != (Object)null && (Object)(object)val.upgradeType != (Object)null)
{
val.upgradeType.canBeStartItem = true;
}
}
}
Profile.SaveUserSave();
Debug.Log((object)"[FullUnlockPatch] 元库存已最大化,且所有可作为初始装备的类型已开启!");
}
catch (Exception ex)
{
Debug.LogError((object)("[FullUnlockPatch] 发生错误:" + ex));
}
}
}