using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using HiddenAbilitiesMod.Patches;
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("HiddenAbilitiesMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HiddenAbilitiesMod")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("35db14c7-bcc7-4cea-be46-5de91def6c99")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HiddenAbilities
{
[BepInPlugin("fawd.HiddenAbilities", "Hidden Abilities", "1.2.0")]
public class HiddenAbilitiesBase : BaseUnityPlugin
{
private const string ModGUID = "fawd.HiddenAbilities";
private const string ModName = "Hidden Abilities";
private const string ModVersion = "1.2.0";
private readonly Harmony harmony = new Harmony("fawd.HiddenAbilities");
private static HiddenAbilitiesBase Instance;
internal ManualLogSource mls;
private string[] config;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("fawd.HiddenAbilities");
mls.LogInfo((object)"The hidden ability mod has awoken.");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string path = Path.Combine(directoryName, "HiddenAbilitiesConfig.txt");
if (File.Exists(path))
{
config = File.ReadAllLines(path);
string[] array = config;
foreach (string text in array)
{
mls.LogInfo((object)text);
}
}
else
{
string contents = "Hide abilities for local players: 0";
File.WriteAllText(path, contents);
config = File.ReadAllLines(path);
}
harmony.PatchAll(typeof(HiddenAbilitiesBase));
if (config[0].EndsWith("0"))
{
harmony.PatchAll(typeof(SlimeControllerPatchNonLocalOnly));
}
else if (config[0].EndsWith("1"))
{
harmony.PatchAll(typeof(SlimeControllerPatch));
}
else
{
mls.LogInfo((object)"WARNING: Hidden Ability Mod did not activate -- config file formatting error.");
}
}
}
}
namespace HiddenAbilitiesMod.Patches
{
[HarmonyPatch(typeof(SlimeController))]
internal class SlimeControllerPatch
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void Patch(ref AbilityReadyIndicator[] ___AbilityReadyIndicators, ref NamedSpriteList ___abilityIconsFull, ref int ___playerNumber)
{
if (___AbilityReadyIndicators != null)
{
AbilityReadyIndicator[] array = ___AbilityReadyIndicators;
foreach (AbilityReadyIndicator val in array)
{
val.SetSprite(___abilityIconsFull.GetSprite(1), false);
}
}
}
}
[HarmonyPatch(typeof(SlimeController))]
internal class SlimeControllerPatchNonLocalOnly
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void Patch(ref AbilityReadyIndicator[] ___AbilityReadyIndicators, ref NamedSpriteList ___abilityIconsFull, ref int ___playerNumber)
{
if (___AbilityReadyIndicators != null && !PlayerHandler.Get().GetPlayer(___playerNumber).IsLocalPlayer)
{
AbilityReadyIndicator[] array = ___AbilityReadyIndicators;
foreach (AbilityReadyIndicator val in array)
{
val.SetSprite(___abilityIconsFull.GetSprite(1), false);
}
}
}
}
}