using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("RemoveExaltedLifeDrain")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Removes the life drain effect from the Exalted status in Outward")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RemoveExaltedLifeDrain")]
[assembly: AssemblyTitle("RemoveExaltedLifeDrain")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace RemoveExaltedLifeDrain
{
[BepInPlugin("com.removeexaltedlifedrain.mod", "Remove Exalted Life Drain", "1.4.0")]
public class RemoveExaltedLifeDrainMod : BaseUnityPlugin
{
public static RemoveExaltedLifeDrainMod Instance;
private void Awake()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
new Harmony("com.removeexaltedlifedrain.mod").PatchAll();
((BaseUnityPlugin)this).Logger.LogMessage((object)"Remove Exalted Life Drain Mod v1.4.0 loaded successfully!");
}
public static void Log(string message)
{
if ((Object)(object)Instance != (Object)null)
{
((BaseUnityPlugin)Instance).Logger.LogMessage((object)("[ExaltedLifeDrain] " + message));
}
}
}
[HarmonyPatch(typeof(Character), "Update")]
public class Character_Update_Patch
{
private static float lastCheckTime;
private static void Postfix(Character __instance)
{
if (Time.time - lastCheckTime < 0.5f)
{
return;
}
lastCheckTime = Time.time;
if (!((Object)(object)__instance != (Object)null) || !__instance.IsLocalPlayer || !((Object)(object)__instance.StatusEffectMngr != (Object)null))
{
return;
}
try
{
List<StatusEffect> statuses = __instance.StatusEffectMngr.Statuses;
if (statuses == null || statuses.Count <= 0)
{
return;
}
List<StatusEffect> list = new List<StatusEffect>();
foreach (StatusEffect item in statuses)
{
if ((Object)(object)item != (Object)null && item.IdentifierName != null)
{
string text = item.IdentifierName.ToLower();
if (text.Contains("life drain") || text.Contains("lifedrain") || text.Contains("life_drain"))
{
list.Add(item);
}
}
}
foreach (StatusEffect item2 in list)
{
try
{
__instance.StatusEffectMngr.CleanseStatusEffect(item2);
RemoveExaltedLifeDrainMod.Log("Removed life drain effect: " + item2.IdentifierName);
}
catch (Exception ex)
{
RemoveExaltedLifeDrainMod.Log("Error removing " + item2.IdentifierName + ": " + ex.Message);
}
}
}
catch (Exception ex2)
{
RemoveExaltedLifeDrainMod.Log("Error in Character_Update: " + ex2.Message);
}
}
}
[HarmonyPatch(typeof(StatusEffect), "Update")]
public class StatusEffect_Update_Patch
{
private static bool Prefix(StatusEffect __instance)
{
if ((Object)(object)__instance != (Object)null && __instance.IdentifierName != null)
{
string text = __instance.IdentifierName.ToLower();
if (text.Contains("life drain") || text.Contains("lifedrain") || text.Contains("life_drain"))
{
return false;
}
}
return true;
}
}
}