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 HarmonyLib;
using HolyCrapForkIsBack;
using HolyCrapForkIsBack.Items;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FixFork")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FixFork")]
[assembly: AssemblyTitle("FixFork")]
[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 FixFork
{
[BepInPlugin("_score.FixFork", "FixFork", "0.0.1")]
public class FixForkPlugin : BaseUnityPlugin
{
public const string PluginGUID = "_score.FixFork";
public const string PluginAuthor = "score";
public const string PluginName = "FixFork";
public const string PluginVersion = "0.0.1";
public void Awake()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if (AccessTools.Field(typeof(Main), "PluginVersion").GetValue(null) as string == "1.0.7")
{
new Harmony("_score.FixFork").CreateClassProcessor(typeof(Fix)).Patch();
return;
}
Debug.LogError((object)"Fork is fixed, uninstall this mod :)");
Object.Destroy((Object)(object)this);
}
}
[HarmonyPatch]
public class Fix
{
[CompilerGenerated]
private static class <>O
{
public static hook_UpdateLastHitTime <0>__HealthComponent_UpdateLastHitTime;
}
[HarmonyPatch(typeof(Chopsticks), "SetupHooks")]
[HarmonyPrefix]
public static bool ApplyHooks(Chopsticks __instance)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//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>__HealthComponent_UpdateLastHitTime;
if (obj == null)
{
hook_UpdateLastHitTime val = HealthComponent_UpdateLastHitTime;
<>O.<0>__HealthComponent_UpdateLastHitTime = val;
obj = (object)val;
}
HealthComponent.UpdateLastHitTime += (hook_UpdateLastHitTime)obj;
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(__instance.RecalculateStatsAPI_GetStatCoefficients);
return false;
}
private static void HealthComponent_UpdateLastHitTime(orig_UpdateLastHitTime orig, HealthComponent self, float damageValue, Vector3 damagePosition, bool damageIsSilent, GameObject attacker, bool delayedDamage, bool firstHitOfDelayedDamage)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, damageValue, damagePosition, damageIsSilent, attacker, delayedDamage, firstHitOfDelayedDamage);
if (self.alive && self.isHealthLow && Object.op_Implicit((Object)(object)self.body))
{
int num = (Object.op_Implicit((Object)(object)self.body.inventory) ? self.body.inventory.GetItemCount(Chopsticks.chopsticksItemDef) : 0);
if (num > 0)
{
CharacterMasterNotificationQueue.PushItemTransformNotification(self.body.master, Chopsticks.chopsticksItemDef.itemIndex, ((ItemBase)ItemBase<BrokenChopsticks>.instance).itemDef.itemIndex, (TransformationType)0);
self.body.inventory.RemoveItem(Chopsticks.chopsticksItemDef, num);
self.body.inventory.GiveItem(BrokenChopsticks.brokenChopsticksItemDef, num);
}
}
}
}
}