using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Wip")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Wip")] [assembly: AssemblyCopyright("Copyright © 2019")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("f88dcfe5-655e-48a7-a41d-4a5d75b024df")] [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 EraserElixir { [BepInPlugin("fr.lasyan3.eraserelixir", "EraserElixir", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class PotionResetSkills : BaseUnityPlugin { private const string ID = "fr.lasyan3.eraserelixir"; private const string NAME = "EraserElixir"; private const string VERSION = "1.0.1"; public static PotionResetSkills Instance; public ManualLogSource MyLogger => ((BaseUnityPlugin)this).Logger; internal void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) try { Instance = this; new Harmony("fr.lasyan3.eraserelixir").PatchAll(); MyLogger.LogDebug((object)"Awaken"); } catch (Exception ex) { MyLogger.LogError((object)("Awake: " + ex.Message)); } } private void SL_BeforePacksLoaded() { } } } namespace EraserElixir.Hooks { [HarmonyPatch(typeof(Item), "OnUse")] public class RemoveSkillsOnUse { [HarmonyPrefix] public static bool OnUse(Item __instance, Character _targetChar) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_targetChar != (Object)null && __instance.ItemID == 4300191) { SkillSchool[] obj = (SkillSchool[])AccessTools.Field(typeof(SkillTreeHolder), "m_skillTrees").GetValue(SkillTreeHolder.Instance); int num = 0; SkillSchool[] array = obj; foreach (SkillSchool val in array) { int num2 = 42; foreach (BaseSkillSlot skillSlot in val.SkillSlots) { if (skillSlot is SkillSlot) { if (skillSlot.IsBreakthrough) { num2 = val.SkillSlots.IndexOf(skillSlot); } SkillSlot val2 = (SkillSlot)skillSlot; if (_targetChar.Inventory.LearnedSkill((Item)(object)val2.Skill) && val.SkillSlots.IndexOf(skillSlot) >= num2) { Item itemFromItemID = ((CharacterKnowledge)_targetChar.Inventory.SkillKnowledge).GetItemFromItemID(((Item)val2.Skill).ItemID); ItemManager.Instance.DestroyItem(itemFromItemID.UID); num++; if (skillSlot.IsBreakthrough) { AccessTools.Field(typeof(PlayerCharacterStats), "m_usedBreakthroughCount").SetValue(_targetChar.PlayerStats, _targetChar.PlayerStats.UsedBreakthroughCount - 1); } } } else { if (!(skillSlot is SkillSlotFork)) { continue; } if (skillSlot.IsBreakthrough) { num2 = val.SkillSlots.IndexOf(skillSlot); } SkillSlot[] skillsToChooseFrom = ((SkillSlotFork)skillSlot).SkillsToChooseFrom; foreach (SkillSlot val3 in skillsToChooseFrom) { if (_targetChar.Inventory.LearnedSkill((Item)(object)val3.Skill) && val.SkillSlots.IndexOf(skillSlot) >= num2) { Item itemFromItemID2 = ((CharacterKnowledge)_targetChar.Inventory.SkillKnowledge).GetItemFromItemID(((Item)val3.Skill).ItemID); ItemManager.Instance.DestroyItem(itemFromItemID2.UID); num++; if (skillSlot.IsBreakthrough) { AccessTools.Field(typeof(PlayerCharacterStats), "m_usedBreakthroughCount").SetValue(_targetChar.PlayerStats, _targetChar.PlayerStats.UsedBreakthroughCount - 1); } } } } } } _targetChar.CharacterUI.ShowInfoNotification(string.Format("Your mind has been freed from the weight of your desires and is ready for new discoveries...", num), __instance.ItemIcon); __instance.RemoveQuantity(1); return false; } } catch (Exception ex) { PotionResetSkills.Instance.MyLogger.LogError((object)("Item_OnUse: " + ex.Message)); } return true; } } }