using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using EntityStates;
using EntityStates.Toolbot;
using HarmonyLib;
using RoR2;
using RoR2.Skills;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
namespace Prototype;
[BepInPlugin("prototype.override.mode", "OverridePowerMode", "0.1.0")]
public class OverridePowerMode : BaseUnityPlugin
{
public const string identifier = "prototype.override.mode";
public const string version = "0.1.0";
public void Awake()
{
Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
}
[HarmonyPatch(typeof(ToolbotDualWieldBase), "OnEnter")]
[HarmonyPostfix]
private static void OnEnter(ToolbotDualWieldBase __instance)
{
OverridePrimarySkill(enable: true, __instance);
}
[HarmonyPatch(typeof(ToolbotDualWieldBase), "OnExit")]
[HarmonyPostfix]
private static void OnExit(ToolbotDualWieldBase __instance)
{
OverridePrimarySkill(enable: false, __instance);
}
private static void OverridePrimarySkill(bool enable, ToolbotDualWieldBase entity)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
GenericSkill val = (Object.op_Implicit((Object)(object)((EntityState)entity).skillLocator) ? ((EntityState)entity).skillLocator.primary : null);
SkillDef val2 = (Object.op_Implicit((Object)(object)entity.primary2Slot) ? entity.primary2Slot.skillDef : null);
if (!Object.op_Implicit((Object)(object)val) || !entity.allowPrimarySkills)
{
return;
}
SkillOverridePriority val3 = (SkillOverridePriority)4;
if (enable)
{
if ((Object)(object)val2 != (Object)(object)val.skillDef)
{
val.SetSkillOverride((object)entity, val2, val3);
}
}
else
{
val.UnsetSkillOverride((object)entity, val2, val3);
}
}
}