using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[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 Prototype
{
[BepInPlugin("prototype.nerf.opal.spaces", "BubbleIsBad", "0.1.0")]
internal class BubbleIsBad : BaseUnityPlugin
{
public const string version = "0.1.0";
public const string identifier = "prototype.nerf.opal.spaces";
protected void Awake()
{
Language.onCurrentLanguageChanged += delegate
{
Language currentLanguage = Language.currentLanguage;
currentLanguage.SetStringByToken("ITEM_OUTOFCOMBATARMOR_DESC", currentLanguage.GetLocalizedStringByToken("ITEM_OUTOFCOMBATARMOR_DESC").Replace("100", "50"));
};
Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
}
[HarmonyPatch(typeof(HealthComponent), "TakeDamage")]
[HarmonyILManipulator]
private static void TakeDamage(ILContext context)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(context);
val.GotoNext(new Func<Instruction, bool>[5]
{
(Instruction il) => ILPatternMatchingExt.MatchStfld<DamageInfo>(il, "rejected"),
(Instruction il) => ILPatternMatchingExt.MatchLdarg(il, 0),
(Instruction il) => ILPatternMatchingExt.MatchLdfld<HealthComponent>(il, "body"),
(Instruction il) => ILPatternMatchingExt.MatchLdsfld(il, typeof(Buffs).GetField("BearVoidReady")),
(Instruction il) => ILPatternMatchingExt.MatchCallvirt<CharacterBody>(il, "RemoveBuff")
});
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldarg_1);
val.EmitDelegate<Func<bool, HealthComponent, DamageInfo, bool>>((Func<bool, HealthComponent, DamageInfo, bool>)delegate(bool value, HealthComponent target, DamageInfo info)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Invalid comparison between Unknown and I4
if (Object.op_Implicit((Object)(object)info.attacker))
{
TeamComponent teamComponent = target.body.teamComponent;
TeamComponent component = info.attacker.GetComponent<TeamComponent>();
if (Object.op_Implicit((Object)(object)teamComponent) && Object.op_Implicit((Object)(object)component))
{
TeamIndex teamIndex = component.teamIndex;
if (teamIndex - -1 > 1)
{
info.damage *= 0.5f;
info.canRejectForce = false;
return info.rejected;
}
}
}
return value;
});
}
[HarmonyPatch(typeof(CharacterBody), "RecalculateStats")]
[HarmonyPostfix]
private static void RecalculateStats(CharacterBody __instance)
{
Inventory inventory = __instance.inventory;
if (__instance.HasBuff(Buffs.OutOfCombatArmorBuff) && Object.op_Implicit((Object)(object)inventory))
{
__instance.armor -= (float)(50 * inventory.GetItemCount(Items.OutOfCombatArmor));
}
}
}
}