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.Logging;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.Utils;
using R2API.Utils;
using RoR2;
using RoR2.Orbs;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CherfInheritCrit")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+502dd8bf49f4fb9390cb23c5fc1febd483ce5c21")]
[assembly: AssemblyProduct("CherfInheritCrit")]
[assembly: AssemblyTitle("CherfInheritCrit")]
[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 CherfInheritCrit
{
internal static class Log
{
internal static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
{
int num = callerPath.LastIndexOf("CherfInheritCrit\\");
if (num >= 0)
{
callerPath = callerPath.Substring(num + "CherfInheritCrit\\".Length);
}
return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
}
internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Error_NoCallerPrefix(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Fatal_NoCallerPrefix(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Info_NoCallerPrefix(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Message_NoCallerPrefix(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Warning_NoCallerPrefix(object data)
{
_logSource.LogWarning(data);
}
}
[BepInPlugin("Gorakh.CherfInheritCrit", "CherfInheritCrit", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Main : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static Manipulator <0>__GlobalEventManager_ProcessHitEnemy;
}
public const string PluginGUID = "Gorakh.CherfInheritCrit";
public const string PluginAuthor = "Gorakh";
public const string PluginName = "CherfInheritCrit";
public const string PluginVersion = "1.0.1";
internal static Main Instance { get; private set; }
private void Awake()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
Stopwatch stopwatch = Stopwatch.StartNew();
Log.Init(((BaseUnityPlugin)this).Logger);
Instance = SingletonHelper.Assign<Main>(Instance, this);
object obj = <>O.<0>__GlobalEventManager_ProcessHitEnemy;
if (obj == null)
{
Manipulator val = GlobalEventManager_ProcessHitEnemy;
<>O.<0>__GlobalEventManager_ProcessHitEnemy = val;
obj = (object)val;
}
GlobalEventManager.ProcessHitEnemy += (Manipulator)obj;
stopwatch.Stop();
Log.Info_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
}
private void OnDestroy()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
object obj = <>O.<0>__GlobalEventManager_ProcessHitEnemy;
if (obj == null)
{
Manipulator val = GlobalEventManager_ProcessHitEnemy;
<>O.<0>__GlobalEventManager_ProcessHitEnemy = val;
obj = (object)val;
}
GlobalEventManager.ProcessHitEnemy -= (Manipulator)obj;
Instance = SingletonHelper.Unassign<Main>(Instance, this);
}
private static void GlobalEventManager_ProcessHitEnemy(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
ParameterDefinition val2 = null;
for (int i = 0; i < ((MethodReference)il.Method).Parameters.Count; i++)
{
ParameterDefinition val3 = ((MethodReference)il.Method).Parameters[i];
if (Extensions.Is((MemberReference)(object)((ParameterReference)val3).ParameterType, (MemberInfo)typeof(DamageInfo)))
{
val2 = val3;
break;
}
}
if (val2 == null)
{
Log.Error("Failed to find DamageInfo parameter", "X:\\Git\\RoR2\\CherfInheritCrit\\CherfInheritCrit\\Main.cs", "GlobalEventManager_ProcessHitEnemy", 61);
}
else if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "LightningStrikeOnHit")
}))
{
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchStfld<GenericDamageOrb>(x, "isCrit")
}))
{
val.Emit(OpCodes.Ldarg, val2);
val.EmitDelegate<Func<bool, DamageInfo, bool>>((Func<bool, DamageInfo, bool>)((bool isCrit, DamageInfo damageInfo) => damageInfo.crit));
}
else
{
Log.Error("Failed to find patch location", "X:\\Git\\RoR2\\CherfInheritCrit\\CherfInheritCrit\\Main.cs", "GlobalEventManager_ProcessHitEnemy", 77);
}
}
else
{
Log.Error("Failed to find LightningStrikeOnHit item check", "X:\\Git\\RoR2\\CherfInheritCrit\\CherfInheritCrit\\Main.cs", "GlobalEventManager_ProcessHitEnemy", 82);
}
}
}
}