using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using On.RoR2;
using RoR2;
using UnityEngine;
[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.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("GoldShield")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GoldShield")]
[assembly: AssemblyTitle("GoldShield")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GoldShield;
[BepInPlugin("com.NoSym.goldshield", "Gold Shield", "1.1.2")]
public class GoldShield : BaseUnityPlugin
{
public void Awake()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
string shieldFormula = ((BaseUnityPlugin)this).Config.Wrap<string>("Settings", "ShieldFormula", "Gold Shield Formula\n'percent' Uses Brittle Crown's gold loss formula.\n'flat' Uses a flat 1:1 ratio between damage blocked and gold lost.", "percent").Value;
int blockRatio = ((BaseUnityPlugin)this).Config.Wrap<int>("Settings", "BlockRatio", "What percent of damage should be blockable with gold.", 100).Value;
if (blockRatio > 100)
{
blockRatio = 100;
}
else if (blockRatio < 0)
{
blockRatio = 0;
}
HealthComponent.TakeDamage += (hook_TakeDamage)delegate(orig_TakeDamage orig, HealthComponent self, DamageInfo damager)
{
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)self != (Object)null && (Object)(object)self.body != (Object)null && (Object)(object)self.body.master != (Object)null && (Object)(object)((Component)self.body.master).GetComponent<PlayerCharacterMasterController>() != (Object)null)
{
CharacterMaster master = self.body.master;
float num = damager.damage * (float)blockRatio / 100f;
float num2 = damager.damage * (1f - (float)blockRatio / 100f);
uint money = master.money;
if (shieldFormula.ToLowerInvariant() == "flat")
{
int money2 = (int)master.money;
int num3 = 0;
num3 = ((money2 < (int)num) ? money2 : ((int)num));
master.money -= (uint)num3;
damager.damage -= (float)num3;
}
else if ((float)master.money * (num / self.fullCombinedHealth) > num)
{
int num4 = (int)((float)master.money * (num / self.fullCombinedHealth));
if (num4 > master.money)
{
master.money = 0u;
num *= Mathf.Max(1f, Mathf.Abs(num / self.fullCombinedHealth - 1f));
damager.damage = num + num2;
}
else
{
num = 0f;
master.money -= (uint)num4;
damager.damage = num + num2;
}
}
else
{
int num5 = (int)master.money - (int)num;
if (num5 < 0)
{
num = Mathf.Abs(num5);
master.money = 0u;
damager.damage = num + num2;
}
else
{
num = 0f;
master.money = (uint)num5;
damager.damage = num + num2;
}
}
for (int i = 0; i < money - master.money; i += 100)
{
EffectManager.instance.SimpleImpactEffect(Resources.Load<GameObject>("Prefabs/Effects/ImpactEffects/CoinImpact"), damager.position, Vector3.up, true);
}
}
orig.Invoke(self, damager);
};
}
public void Update()
{
}
}