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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[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", "BubbleTrouble", "0.1.0")]
internal class BubbleTrouble : BaseUnityPlugin
{
private static class Update
{
internal static void Apply()
{
if (!Version.TryParse(RoR2Application.GetBuildId(), out Version result) || !(result < new Version(1, 3)))
{
flag = delegate(DamageInfo info)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
info.damageType = DamageTypeCombo.op_Implicit((DamageType)1);
};
Harmony.CreateAndPatchAll(typeof(Update), (string)null);
}
}
[HarmonyPatch(typeof(HealthComponent), "TakeDamageProcess")]
[HarmonyILManipulator]
private static void TakeDamageProcess(ILContext context)
{
TakeDamage(context);
}
}
public const string version = "0.1.0";
public const string identifier = "prototype.nerf.opal.spaces";
private static Action<DamageInfo> flag = delegate(DamageInfo info)
{
((object)info).GetType().GetField("damageType").SetValue(info, (object)(DamageType)1);
};
protected void Awake()
{
Language.onCurrentLanguageChanged += delegate
{
Language currentLanguage = Language.currentLanguage;
currentLanguage.SetStringByToken("ITEM_OUTOFCOMBATARMOR_DESC", currentLanguage.GetLocalizedStringByToken("ITEM_OUTOFCOMBATARMOR_DESC").Replace("100", "50"));
};
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Update.Apply));
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_00c1: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(context);
if (!val.TryGotoNext(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")
}))
{
return;
}
val.Emit(OpCodes.Ldarg_1);
val.EmitDelegate<Func<bool, DamageInfo, bool>>((Func<bool, DamageInfo, bool>)delegate(bool value, DamageInfo info)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Invalid comparison between Unknown and I4
if (Object.op_Implicit((Object)(object)info.attacker))
{
TeamComponent component = info.attacker.GetComponent<TeamComponent>();
if (Object.op_Implicit((Object)(object)component))
{
TeamIndex teamIndex = component.teamIndex;
if (teamIndex - -1 > 1)
{
info.procCoefficient = 0f;
info.damage *= 0.5f;
info.canRejectForce = false;
flag(info);
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));
}
}
}
}