using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using IL.RoR2;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("VoidFogNerf")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VoidFogNerf")]
[assembly: AssemblyTitle("VoidFogNerf")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace VoidFogNerf
{
internal static class VFNConfig
{
public static ConfigEntry<float> fogDamageAmp;
public static ConfigEntry<bool> useCurrentHealth;
private static ConfigEntry<bool> bypassArmor;
private static ConfigEntry<bool> bypassBlock;
private static ConfigEntry<bool> nonlethal;
public static int damageType;
public static void InitializeConfig()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
ConfigFile val = new ConfigFile(Paths.ConfigPath + "\\OakPrime.VoidFogNerf.cfg", true);
useCurrentHealth = val.Bind<bool>("Main", "Use current health", true, "Change fog damage to percent of current health instead of max health");
fogDamageAmp = val.Bind<float>("Main", "Void Fog damage multiplier", 1.3f, "Multiplier for void fog damage. Default: 1.3 (x current health). Vanilla: 1.0 (x max health).");
bypassArmor = val.Bind<bool>("Main", "Bypass armor", false, "Void fog bypasses armor and repulsion armor. Default: false. Vanilla: true.");
bypassBlock = val.Bind<bool>("Main", "Bypass block", false, "Void fog bypasses block from bears. Default: false. Vanilla: true.");
nonlethal = val.Bind<bool>("Main", "Nonlethal", false, "Void fog damage cannot take you below 1 hp.");
damageType = 2;
damageType = (bypassArmor.Value ? 2 : 0) + (bypassBlock.Value ? 64 : 0) + (nonlethal.Value ? 1 : 0);
}
}
[BepInPlugin("OakPrime.VoidFogNerf", "VoidFogNerf", "1.2.2")]
public class VoidFogNerf : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Func<Instruction, bool> <>9__4_1;
public static Func<Instruction, bool> <>9__4_2;
public static Func<HealthComponent, float> <>9__4_3;
public static Func<Instruction, bool> <>9__4_4;
public static Func<Instruction, bool> <>9__4_5;
public static Func<Instruction, bool> <>9__4_6;
public static Func<int, int> <>9__4_7;
public static Manipulator <>9__4_0;
internal void <Awake>b__4_0(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (VFNConfig.useCurrentHealth.Value)
{
val.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_healthComponent"),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "get_fullCombinedHealth")
});
int index = val.Index;
val.Index = index + 1;
val.RemoveRange(1);
val.EmitDelegate<Func<HealthComponent, float>>((Func<HealthComponent, float>)((HealthComponent healthComponent) => healthComponent.combinedHealth));
index = val.Index;
val.Index = index + 1;
val.Emit(OpCodes.Ldc_R4, VFNConfig.fogDamageAmp.Value);
val.Emit(OpCodes.Mul);
}
MethodReference val2 = default(MethodReference);
val.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchDup(x),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 66),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val2)
});
val.Index += 2;
val.EmitDelegate<Func<int, int>>((Func<int, int>)((int damageType) => VFNConfig.damageType));
}
internal bool <Awake>b__4_1(Instruction x)
{
return ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_healthComponent");
}
internal bool <Awake>b__4_2(Instruction x)
{
return ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "get_fullCombinedHealth");
}
internal float <Awake>b__4_3(HealthComponent healthComponent)
{
return healthComponent.combinedHealth;
}
internal bool <Awake>b__4_4(Instruction x)
{
return ILPatternMatchingExt.MatchDup(x);
}
internal bool <Awake>b__4_5(Instruction x)
{
return ILPatternMatchingExt.MatchLdcI4(x, 66);
}
internal bool <Awake>b__4_6(Instruction x)
{
MethodReference val = default(MethodReference);
return ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val);
}
internal int <Awake>b__4_7(int damageType)
{
return VFNConfig.damageType;
}
}
public const string PluginGUID = "OakPrime.VoidFogNerf";
public const string PluginAuthor = "OakPrime";
public const string PluginName = "VoidFogNerf";
public const string PluginVersion = "1.2.2";
public void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
try
{
VFNConfig.InitializeConfig();
object obj = <>c.<>9__4_0;
if (obj == null)
{
Manipulator val = delegate(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
ILCursor val2 = new ILCursor(il);
if (VFNConfig.useCurrentHealth.Value)
{
val2.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_healthComponent"),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "get_fullCombinedHealth")
});
int index = val2.Index;
val2.Index = index + 1;
val2.RemoveRange(1);
val2.EmitDelegate<Func<HealthComponent, float>>((Func<HealthComponent, float>)((HealthComponent healthComponent) => healthComponent.combinedHealth));
index = val2.Index;
val2.Index = index + 1;
val2.Emit(OpCodes.Ldc_R4, VFNConfig.fogDamageAmp.Value);
val2.Emit(OpCodes.Mul);
}
MethodReference val3 = default(MethodReference);
val2.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchDup(x),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 66),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val3)
});
val2.Index += 2;
val2.EmitDelegate<Func<int, int>>((Func<int, int>)((int damageType) => VFNConfig.damageType));
};
<>c.<>9__4_0 = val;
obj = (object)val;
}
FogDamageController.MyFixedUpdate += (Manipulator)obj;
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)(ex.Message + " - " + ex.StackTrace));
}
}
}
}
namespace ExamplePlugin
{
internal static class Log
{
internal static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void LogDebug(object data)
{
_logSource.LogDebug(data);
}
internal static void LogError(object data)
{
_logSource.LogError(data);
}
internal static void LogFatal(object data)
{
_logSource.LogFatal(data);
}
internal static void LogInfo(object data)
{
_logSource.LogInfo(data);
}
internal static void LogMessage(object data)
{
_logSource.LogMessage(data);
}
internal static void LogWarning(object data)
{
_logSource.LogWarning(data);
}
}
}