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 On.RoR2;
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("BossDropRework")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BossDropRework")]
[assembly: AssemblyTitle("BossDropRework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BossDropRework;
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.RiskOfBrainrot.FruityBossDrops", "FruityBossDrops", "1.0.1")]
[R2APISubmoduleDependency(new string[] { "LanguageAPI", "ContentAddition", "DirectorAPI" })]
public class BossDropReworkPlugin : BaseUnityPlugin
{
public delegate void BossDropChanceHandler(CharacterBody victim, CharacterBody attacker, ref float dropChance);
public delegate void TricornFireHandler(CharacterBody attacker, CharacterBody victim, ref bool shouldFire);
public const string guid = "com.RiskOfBrainrot.FruityBossDrops";
public const string teamName = "RiskOfBrainrot";
public const string modName = "FruityBossDrops";
public const string version = "1.0.1";
public static GameObject overgrownPrinterPrefab = LegacyResourcesAPI.Load<GameObject>("prefabs/networkedobjects/chest/DuplicatorWild");
public static bool affectAurelionite = true;
public static float baseDropChance = 4f;
public static float specialDropChance = 7f;
public static float eliteBonusDropChance = 3f;
public static BuffDef bossHunterDebuff;
private float tricornDamageCoefficient = 70f;
private float tricornProcCoefficient = 2f;
private int tricornDebuffDuration = 999;
private bool reworkTricorn = true;
public static PluginInfo PInfo { get; private set; }
public static event BossDropChanceHandler ModifyBossItemDropChance;
public static event TricornFireHandler ShouldTricornFireAndBreak;
public void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
bossHunterDebuff = ScriptableObject.CreateInstance<BuffDef>();
bossHunterDebuff.buffColor = new Color(0.2f, 0.9f, 0.8f, 1f);
bossHunterDebuff.canStack = false;
bossHunterDebuff.isDebuff = true;
((Object)bossHunterDebuff).name = "TrophyHunterDebuff";
bossHunterDebuff.iconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/LunarSkillReplacements/texBuffLunarDetonatorIcon.tif").WaitForCompletion();
ContentAddition.AddBuffDef(bossHunterDebuff);
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ReworkBossItemDrops));
}
private void ReworkBossItemDrops()
{
BossesDropBossItems();
TricornRework();
DirectorAPI.InteractableActions += DeleteYellowPrinters;
}
private void BossesDropBossItems()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
BossGroup.Awake += new hook_Awake(RemoveBossItemDropsFromTeleporter);
GlobalEventManager.OnCharacterDeath += new hook_OnCharacterDeath(BossesDropTrophies);
}
private void DeleteYellowPrinters(DccsPool pool, StageInfo currentStage)
{
Helpers.RemoveExistingInteractable(InteractableNames.PrinterOvergrown3D);
}
private void RemoveBossItemDropsFromTeleporter(orig_Awake orig, BossGroup self)
{
orig.Invoke(self);
self.bossDropChance = 0f;
}
public static float InvokeModifyBossItemDropChance(CharacterBody victim, CharacterBody attacker, ref float dropChance)
{
BossDropReworkPlugin.ModifyBossItemDropChance?.Invoke(victim, attacker, ref dropChance);
return dropChance;
}
public void BossesDropTrophies(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, damageReport);
if ((int)damageReport.victimTeamIndex == 1)
{
return;
}
CharacterBody attackerBody = damageReport.attackerBody;
CharacterBody victimBody = damageReport.victimBody;
if ((Object)(object)attackerBody == (Object)null || (Object)(object)victimBody == (Object)null)
{
return;
}
BodyIndex bodyIndex = victimBody.bodyIndex;
if ((bodyIndex == BodyCatalog.FindBodyIndex("TitanGoldBody") && !affectAurelionite) || victimBody.healthComponent.alive)
{
return;
}
CharacterMaster attackerMaster = damageReport.attackerMaster;
ItemDef val = null;
int participatingPlayerCount = Run.instance.participatingPlayerCount;
PickupDropTable dropTable;
float dropChance = GetBaseBossItemDropChanceFromBody(victimBody, out dropTable);
if (dropChance > 0f && InvokeModifyBossItemDropChance(victimBody, attackerBody, ref dropChance) > 0f)
{
PickupIndex val2 = dropTable.GenerateDrop(attackerBody.equipmentSlot.rng);
if (Util.CheckRoll(dropChance, attackerMaster) && val2 != PickupCatalog.FindPickupIndex("VoidCoin"))
{
Vector3 val3 = (Object.op_Implicit((Object)(object)victimBody) ? victimBody.corePosition : Vector3.zero);
Vector3 val4 = val3 - attackerBody.corePosition;
Vector3 normalized = ((Vector3)(ref val4)).normalized;
PickupDropletController.CreatePickupDroplet(val2, val3, normalized * 15f);
}
}
}
public static float GetBaseBossItemDropChanceFromBody(CharacterBody body, out PickupDropTable dropTable)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
DeathRewards deathRewardsFromTarget = GetDeathRewardsFromTarget(body);
if ((Object)(object)deathRewardsFromTarget == (Object)null || (Object)(object)deathRewardsFromTarget.bossDropTable == (Object)null)
{
dropTable = null;
return 0f;
}
dropTable = deathRewardsFromTarget.bossDropTable;
float num = 0f;
BodyIndex bodyIndex = body.bodyIndex;
if (bodyIndex == BodyCatalog.FindBodyIndex("TitanGoldBody"))
{
return affectAurelionite ? 100 : 0;
}
num = ((bodyIndex != BodyCatalog.FindBodyIndex("SuperRoboBallBossBody")) ? baseDropChance : specialDropChance);
if (body.isElite || bodyIndex == BodyCatalog.FindBodyIndex("ElectricWormBody"))
{
num += eliteBonusDropChance;
}
return num;
}
public static DeathRewards GetDeathRewardsFromTarget(HurtBox hurtBox)
{
DeathRewards result = null;
if ((Object)(object)hurtBox != (Object)null)
{
HealthComponent healthComponent = hurtBox.healthComponent;
if ((Object)(object)healthComponent != (Object)null)
{
result = GetDeathRewardsFromTarget(healthComponent.body);
}
}
return result;
}
public static DeathRewards GetDeathRewardsFromTarget(CharacterBody enemyBody)
{
DeathRewards result = null;
if ((Object)(object)enemyBody != (Object)null)
{
GameObject gameObject = ((Component)enemyBody).gameObject;
result = (((Object)(object)gameObject != (Object)null) ? gameObject.GetComponent<DeathRewards>() : null);
}
return result;
}
private void TricornRework()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
EquipmentSlot.FireBossHunter += new hook_FireBossHunter(FireTricornFix);
ModifyBossItemDropChance += TricornDropChance;
LanguageAPI.Add("EQUIPMENT_BOSSHUNTER_PICKUP", "Cripple a large monster and claim its <style=cIsDamage>trophy</style> after it dies. Consumed on use.");
LanguageAPI.Add("EQUIPMENT_BOSSHUNTER_DESC", "Targets any enemy capable of dropping a <style=cIsDamage>unique reward</style>, " + $"dealing <style=cIsDamage>{tricornDamageCoefficient * 100f}% damage</style>, " + "then <style=cIsUtility>Crippling and Hemorrhaging</style> it " + $"for <style=cIsUtility>{tricornDebuffDuration}</style> seconds. " + "When the enemy dies, it has a 100% chance to drop it's <style=cIsDamage>trophy</style>. Equipment is <style=cIsUtility>consumed</style> on use.");
}
private void TricornDropChance(CharacterBody victim, CharacterBody attacker, ref float dropChance)
{
if (victim.HasBuff(bossHunterDebuff) && dropChance != 0f)
{
dropChance = 100f;
}
}
public static bool GetTricornFireAndBreak(CharacterBody attacker, CharacterBody victim, ref bool shouldFire)
{
BossDropReworkPlugin.ShouldTricornFireAndBreak?.Invoke(attacker, victim, ref shouldFire);
return shouldFire;
}
private bool FireTricornFix(orig_FireBossHunter orig, EquipmentSlot self)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Expected O, but got Unknown
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Expected O, but got Unknown
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Expected O, but got Unknown
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0392: Unknown result type (might be due to invalid IL or missing references)
//IL_042a: Unknown result type (might be due to invalid IL or missing references)
//IL_042f: Unknown result type (might be due to invalid IL or missing references)
//IL_0437: Unknown result type (might be due to invalid IL or missing references)
//IL_0442: Unknown result type (might be due to invalid IL or missing references)
//IL_0443: Unknown result type (might be due to invalid IL or missing references)
//IL_044c: Unknown result type (might be due to invalid IL or missing references)
//IL_0451: Unknown result type (might be due to invalid IL or missing references)
//IL_0456: Unknown result type (might be due to invalid IL or missing references)
//IL_045b: Unknown result type (might be due to invalid IL or missing references)
//IL_0460: Unknown result type (might be due to invalid IL or missing references)
//IL_0465: Unknown result type (might be due to invalid IL or missing references)
//IL_046d: Unknown result type (might be due to invalid IL or missing references)
//IL_0482: Expected O, but got Unknown
//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: Unknown result type (might be due to invalid IL or missing references)
//IL_041b: Expected O, but got Unknown
//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0506: Unknown result type (might be due to invalid IL or missing references)
self.UpdateTargets(Equipment.BossHunter.equipmentIndex, true);
HurtBox hurtBox = self.currentTarget.hurtBox;
DeathRewards deathRewardsFromTarget = GetDeathRewardsFromTarget(hurtBox);
if (Object.op_Implicit((Object)(object)hurtBox) && Object.op_Implicit((Object)(object)deathRewardsFromTarget))
{
HealthComponent healthComponent = hurtBox.healthComponent;
if ((Object)(object)healthComponent != (Object)null)
{
CharacterBody characterBody = self.characterBody;
CharacterBody body = healthComponent.body;
if ((Object)(object)body != (Object)null && (Object)(object)characterBody != (Object)null)
{
bool flag = false;
Vector3 val = (Object.op_Implicit((Object)(object)body) ? body.corePosition : Vector3.zero);
Vector3 val2 = val - characterBody.corePosition;
Vector3 normalized = ((Vector3)(ref val2)).normalized;
Object val3 = (val3 = (Object)(object)(((Object)(object)body != (Object)null) ? body.master : null));
if (Object.op_Implicit(val3))
{
bool shouldFire = true;
if (GetTricornFireAndBreak(characterBody, body, ref shouldFire))
{
body.AddBuff(bossHunterDebuff);
flag = true;
}
if (reworkTricorn)
{
DamageInfo val4 = new DamageInfo();
val4.attacker = ((Component)self).gameObject;
val4.force = normalized * 1500f;
val4.damage = characterBody.damage * tricornDamageCoefficient;
val4.procCoefficient = tricornProcCoefficient;
healthComponent.TakeDamage(val4);
body.AddTimedBuffAuthority(Buffs.Cripple.buffIndex, (float)tricornDebuffDuration);
DotController.InflictDot(((Component)healthComponent).gameObject, val4.attacker, (DotIndex)6, (float)tricornDebuffDuration, 1f, (uint?)null);
}
else
{
body.master.TrueKill(((Component)this).gameObject, (GameObject)null, default(DamageTypeCombo));
}
}
CharacterModel component = ((Component)hurtBox.hurtBoxGroup).GetComponent<CharacterModel>();
if (Object.op_Implicit((Object)(object)component))
{
TemporaryOverlayInstance val5 = TemporaryOverlayManager.AddOverlay(((Component)component).gameObject);
val5.duration = 0.1f;
val5.animateShaderAlpha = true;
val5.alphaCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
val5.destroyComponentOnEnd = true;
val5.originalMaterial = LegacyResourcesAPI.Load<Material>("Materials/matHuntressFlashBright");
val5.AddToCharacterModel(component);
TemporaryOverlayInstance val6 = TemporaryOverlayManager.AddOverlay(((Component)component).gameObject);
val6.duration = 1.2f;
val6.animateShaderAlpha = true;
val6.alphaCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
val6.destroyComponentOnEnd = true;
val6.originalMaterial = LegacyResourcesAPI.Load<Material>("Materials/matGhostEffect");
val6.AddToCharacterModel(component);
}
DamageInfo val7 = new DamageInfo();
val7.attacker = ((Component)self).gameObject;
val7.force = -normalized * 2500f;
self.healthComponent.TakeDamageForce(val7, true, false);
GameObject val8 = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/BossHunterKillEffect");
Quaternion rotation = Util.QuaternionSafeLookRotation(normalized, Vector3.up);
EffectManager.SpawnEffect(val8, new EffectData
{
origin = val,
rotation = rotation
}, true);
ModelLocator component2 = ((Component)this).gameObject.GetComponent<ModelLocator>();
CharacterModel val9;
if ((Object)(object)component2 == (Object)null)
{
val9 = null;
}
else
{
Transform modelTransform = component2.modelTransform;
val9 = (((Object)(object)modelTransform != (Object)null) ? ((Component)modelTransform).GetComponent<CharacterModel>() : null);
}
CharacterModel val10 = val9;
if (Object.op_Implicit((Object)(object)val10))
{
foreach (GameObject equipmentDisplayObject in val10.GetEquipmentDisplayObjects(Equipment.BossHunter.equipmentIndex))
{
if (((Object)equipmentDisplayObject).name.Contains("DisplayTricorn"))
{
EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/BossHunterHatEffect"), new EffectData
{
origin = equipmentDisplayObject.transform.position,
rotation = equipmentDisplayObject.transform.rotation,
scale = equipmentDisplayObject.transform.localScale.x
}, true);
}
else
{
EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/BossHunterGunEffect"), new EffectData
{
origin = equipmentDisplayObject.transform.position,
rotation = Util.QuaternionSafeLookRotation(val - equipmentDisplayObject.transform.position, Vector3.up),
scale = equipmentDisplayObject.transform.localScale.x
}, true);
}
}
}
if (Object.op_Implicit((Object)(object)(((Object)(object)characterBody != (Object)null) ? characterBody.inventory : null)) && flag)
{
CharacterMasterNotificationQueue.PushEquipmentTransformNotification(self.characterBody.master, self.characterBody.inventory.currentEquipmentIndex, Equipment.BossHunterConsumed.equipmentIndex, (TransformationType)0);
self.characterBody.inventory.SetEquipmentIndex(Equipment.BossHunterConsumed.equipmentIndex);
}
self.InvalidateCurrentTarget();
return true;
}
}
}
return false;
}
}