using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Utils;
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("WispLightAlwaysOn")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WispLightAlwaysOn")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace WispLightAlwaysOn;
public static class Configs
{
public static ConfigEntry<bool> EnableWisplightOnlyAfterCrafted;
public static ConfigurationManagerAttributes IsAdminOnly = new ConfigurationManagerAttributes
{
IsAdminOnly = true
};
public static void SetupConfigs(ConfigFile config)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
EnableWisplightOnlyAfterCrafted = config.Bind<bool>("General", GenerateConfigKey("EnableWisplightOnlyAfterCrafted"), true, new ConfigDescription("Enable wisplight only after having crafted it at least once. It does not have to be equipped in order for it to be active. Set it to false to always have it equipped since the beginning of the game.", (AcceptableValueBase)null, new object[1] { IsAdminOnly }));
}
public static string GenerateConfigKey(string key)
{
return GenerateConfigKey(key, null);
}
public static string GenerateConfigKey(string key, string unit)
{
key = string.Concat(key.Select((char x) => char.IsUpper(x) ? (" " + x) : x.ToString())).TrimStart(new char[1] { ' ' });
if (!string.IsNullOrEmpty(unit))
{
key += $" ({unit})";
}
return key;
}
}
[BepInPlugin("WispLightAlwaysOn", "WispLightAlwaysOn", "1.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class WispLightAlwaysOn : BaseUnityPlugin
{
[HarmonyPatch(typeof(Player), "OnSpawned")]
public static class Player_OnSpawned_Patch
{
public static void Postfix(Player __instance)
{
AddDemisterEffect(__instance);
}
}
[HarmonyPatch(typeof(Player), "OnRespawn")]
public static class Player_OnRespawn_Patch
{
public static void Postfix(Player __instance)
{
AddDemisterEffect(__instance);
}
}
[HarmonyPatch(typeof(Player), "Update")]
public static class Player_Update_Patch
{
public static void Postfix(Player __instance)
{
updateTimer -= Time.deltaTime;
if (updateTimer <= 0f)
{
AddDemisterEffect(__instance);
updateTimer += 1f;
}
}
}
public const string PluginGUID = "WispLightAlwaysOn";
public const string PluginName = "WispLightAlwaysOn";
public const string PluginVersion = "1.1.1";
public static int s_StatusEffectDemister = StringExtensionMethods.GetStableHashCode("Demister");
private static float updateTimer = 1f;
private static Harmony harmony;
private void Awake()
{
Configs.SetupConfigs(((BaseUnityPlugin)this).Config);
harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "WispLightAlwaysOn");
}
private void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
public static void AddDemisterEffect(Player player)
{
if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Character)player).GetSEMan().HaveStatusEffect(s_StatusEffectDemister) && (!Configs.EnableWisplightOnlyAfterCrafted.Value || player.IsMaterialKnown("$item_demister")))
{
((Character)player).GetSEMan().AddStatusEffect(s_StatusEffectDemister, false, 0, 0f);
}
}
}