using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AutoSpellLearn")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AutoSpellLearn")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("db9d5b62-804a-48c9-97c4-915466a23adf")]
[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")]
[BepInPlugin("com.recks.autospelllearn", "Auto Spell Learn", "1.0.4")]
[BepInProcess("Erenshor.exe")]
public class AutoSpellLearnPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Stats), "DoLevelUp")]
public static class Stats_DoLevelUp_Patch
{
public static void Postfix(Stats __instance)
{
if ((Object)(object)__instance.Myself == (Object)null || __instance.Myself.isNPC)
{
return;
}
int level = __instance.Level;
Class characterClass = __instance.CharacterClass;
if ((Object)(object)__instance.Myself.MySpells != (Object)null)
{
Spell[] spellDatabase = GameData.SpellDatabase.SpellDatabase;
foreach (Spell spell in spellDatabase)
{
if (!((Object)(object)spell == (Object)null) && spell.UsedBy.Contains(characterClass) && spell.RequiredLevel <= level && !__instance.Myself.MySpells.KnownSpells.Exists((Spell x) => x.SpellName == spell.SpellName))
{
__instance.Myself.MySpells.KnownSpells.Add(spell);
UpdateSocialLog.LogAdd("You have learned the spell: " + spell.SpellName, true);
}
}
}
if (!((Object)(object)__instance.Myself.MySkills != (Object)null))
{
return;
}
Skill[] skillDatabase = GameData.SkillDatabase.SkillDatabase;
foreach (Skill val in skillDatabase)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
bool flag = false;
switch (characterClass.ClassName)
{
case "Duelist":
if (val.DuelistRequiredLevel > 0 && val.DuelistRequiredLevel <= level)
{
flag = true;
}
break;
case "Paladin":
if (val.PaladinRequiredLevel > 0 && val.PaladinRequiredLevel <= level)
{
flag = true;
}
break;
case "Arcanist":
if (val.ArcanistRequiredLevel > 0 && val.ArcanistRequiredLevel <= level)
{
flag = true;
}
break;
case "Druid":
if (val.DruidRequiredLevel > 0 && val.DruidRequiredLevel <= level)
{
flag = true;
}
break;
}
if (flag && !__instance.Myself.MySkills.KnownSkills.Contains(val))
{
__instance.Myself.MySkills.KnownSkills.Add(val);
UpdateSocialLog.LogAdd("You have learned the skill: " + val.SkillName, true);
}
}
}
}
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("com.recks.autospelllearn");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"AutoSpellLearn loaded.");
}
}