#define DEBUG
using System;
using System.Diagnostics;
using System.IO;
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 Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BehemothProc")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ef1e3442346f4f71e1d92e8d5aedf7200ddb01cb")]
[assembly: AssemblyProduct("BehemothProc")]
[assembly: AssemblyTitle("BehemothProc")]
[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 BehemothProc
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Braquen.Let_Behemoth_Proc", "Let_Behemoth_Proc", "1.0.0")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class MountainItemPlugin : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static Manipulator <0>__GlobalEventManager_OnHitAllProcess;
public static Func<ProcChainMask, ProcChainMask> <1>__AddBehemothProc;
public static Func<DamageInfo, float> <2>__InsertProcCoefficient;
}
public const string PluginGUID = "Braquen.Let_Behemoth_Proc";
public const string PluginAuthor = "Braquen";
public const string PluginName = "Let_Behemoth_Proc";
public const string PluginVersion = "1.0.0";
public static PluginInfo pluginInfo;
public static AssetBundle AssetBundle;
public static ConfigEntry<float> ProcCoefficient;
public void Awake()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
pluginInfo = ((BaseUnityPlugin)this).Info;
ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "braquen-LetBehemothProc.cfg"), true);
ProcCoefficient = val.Bind<float>("LET HIM PROC!", "Proc Coefficient", 0.5f, "This number is multiplied by the proc coefficient of the original attack to determine the explosion's proc coefficient, i.e. its the Proc Coefficient's Coefficient. Set to 0 to return to normal functionality.");
ModSettingsManager.AddOption((BaseOption)new StepSliderOption(ProcCoefficient, new StepSliderConfig
{
min = 0f,
max = 10f,
increment = 0.1f
}));
object obj = <>O.<0>__GlobalEventManager_OnHitAllProcess;
if (obj == null)
{
Manipulator val2 = GlobalEventManager_OnHitAllProcess;
<>O.<0>__GlobalEventManager_OnHitAllProcess = val2;
obj = (object)val2;
}
GlobalEventManager.OnHitAllProcess += (Manipulator)obj;
}
private static void GlobalEventManager_OnHitAllProcess(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
Log.Debug("Changing proc chain mask");
try
{
val.GotoNext((MoveType)0, new Func<Instruction, bool>[4]
{
(Instruction x) => ILPatternMatchingExt.MatchDup(x),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<DamageInfo>(x, "procChainMask"),
(Instruction x) => ILPatternMatchingExt.MatchStfld<BlastAttack>(x, "procChainMask")
});
val.Index += 3;
val.EmitDelegate<Func<ProcChainMask, ProcChainMask>>((Func<ProcChainMask, ProcChainMask>)AddBehemothProc);
}
catch (Exception e)
{
ErrorHookFailed("Add Behemoth to mask", e);
}
Log.Debug("Changing proc coefficient");
try
{
val.GotoNext((MoveType)0, new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchDup(x),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0f),
(Instruction x) => ILPatternMatchingExt.MatchStfld<BlastAttack>(x, "procCoefficient")
});
val.Index += 1;
val.Remove();
val.Emit(OpCodes.Ldarg, 1);
val.EmitDelegate<Func<DamageInfo, float>>((Func<DamageInfo, float>)InsertProcCoefficient);
}
catch (Exception e2)
{
ErrorHookFailed("Edit Behemoth Proc Coefficient", e2);
}
}
private static ProcChainMask AddBehemothProc(ProcChainMask procChainMask)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
((ProcChainMask)(ref procChainMask)).AddProc((ProcType)0);
return procChainMask;
}
private static float InsertProcCoefficient(DamageInfo damageInfo)
{
return damageInfo.procCoefficient * ProcCoefficient.Value;
}
internal static void ErrorHookFailed(string name, Exception e)
{
Log.Error(name + " hook failed: " + e.Message);
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
[Conditional("DEBUG")]
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
}