using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using R2API;
using R2API.Utils;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
[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 = "")]
[assembly: AssemblyCompany("MochaAntler")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MochaAntler")]
[assembly: AssemblyTitle("MochaAntler")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MochaAntler;
[BepInPlugin("com.kking117.MochaAntler", "MochaAntler", "1.0.1")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class MainPlugin : BaseUnityPlugin
{
public const string MODUID = "com.kking117.MochaAntler";
public const string MODNAME = "MochaAntler";
public const string MODVERSION = "1.0.1";
public static float Stack_MoveSpeed;
public static float Stack_Armor;
public void Awake()
{
ReadConfig();
((ResourceAvailability)(ref GameModeCatalog.availability)).CallWhenAvailable((Action)PostLoad);
}
public void PostLoad()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(GetStatCoefficients);
UpdateText();
UpdateItemDef();
HealthComponent.TakeDamageProcess += new Manipulator(IL_DisableOldEffect);
}
private void UpdateItemDef()
{
//IL_0006: 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)
ItemDef val = Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/DLC2/Items/NegateAttack/NegateAttack.asset").WaitForCompletion();
if (Object.op_Implicit((Object)(object)val))
{
List<ItemTag> list = val.tags.ToList();
list.Remove((ItemTag)4);
list.Remove((ItemTag)11);
val.tags = list.ToArray();
}
}
private void UpdateText()
{
string text = "Slightly increase";
string text2 = "Increases";
if (Stack_Armor > 0f)
{
text += " armor";
text2 += string.Format(" <style=cIsHealing>armor</style> by <style=cIsHealing>{0}</style> <style=cStack>(+{0} per stack)</style>", Stack_Armor);
if (Stack_MoveSpeed > 0f)
{
text += " and";
text2 += " and";
}
}
if (Stack_MoveSpeed > 0f)
{
text += " movement speed";
text2 += string.Format(" <style=cIsUtility>movement speed</style> by <style=cIsUtility>{0}%</style> <style=cStack>(+{0}% per stack)</style>", Stack_MoveSpeed * 100f);
}
LanguageAPI.Add("ITEM_NEGATEATTACK_PICKUP", text + ".");
LanguageAPI.Add("ITEM_NEGATEATTACK_DESC", text2 + ".");
}
private static void GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
{
if (Object.op_Implicit((Object)(object)sender.inventory))
{
int itemCount = sender.inventory.GetItemCount(Items.NegateAttack);
if (itemCount > 0)
{
args.moveSpeedMultAdd += (float)itemCount * Stack_MoveSpeed;
args.armorAdd += (float)itemCount * Stack_Armor;
}
}
}
public void ReadConfig()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0030: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_0069: Expected O, but got Unknown
Stack_MoveSpeed = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("General", "Movement Speed"), 0.07f, new ConfigDescription("Movement Speed given per stack of the item.", (AcceptableValueBase)null, Array.Empty<object>())).Value;
Stack_Armor = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("General", "Armor"), 7.5f, new ConfigDescription("Armor given per stack of the item.", (AcceptableValueBase)null, Array.Empty<object>())).Value;
}
private void IL_DisableOldEffect(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_004b: 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)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(ItemCounts), "antlerShield")
}))
{
val.Index += 1;
val.Emit(OpCodes.Ldc_I4_0);
val.Emit(OpCodes.Mul);
}
else
{
Debug.LogError((object)"MochaAntler: IL Hook failed");
}
}
}