Decompiled source of BisonSteakDrop v1.0.0

BisonSteakDrop.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace BisonSteakDrop;

[BepInPlugin("com.bisonsteakdrop", "BisonSteakDrop", "1.0.0")]
public class BisonSteakDrop : BaseUnityPlugin
{
	public static ConfigEntry<float> DropChance;

	public static ConfigEntry<bool> RequirePlayerKill;

	private static BodyIndex bisonBodyIndex = (BodyIndex)(-1);

	public void Awake()
	{
		DropChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DropChance", 10f, "Percent chance (0 to 100) that a Bighorn Bison drops a Bison Steak when it dies.");
		RequirePlayerKill = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RequirePlayerKill", true, "Only drop a steak when a player (or a player's minion) gets the kill.");
		RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			bisonBodyIndex = BodyCatalog.FindBodyIndex("BisonBody");
		});
		GlobalEventManager.onCharacterDeathServer += OnCharacterDeath;
	}

	private static void OnCharacterDeath(DamageReport report)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Invalid comparison between Unknown and I4
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: 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)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active || report == null || !Object.op_Implicit((Object)(object)report.victimBody) || (int)bisonBodyIndex == -1 || report.victimBody.bodyIndex != bisonBodyIndex)
		{
			return;
		}
		if (RequirePlayerKill.Value)
		{
			CharacterMaster val = report.attackerMaster;
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.minionOwnership) && Object.op_Implicit((Object)(object)val.minionOwnership.ownerMaster))
			{
				val = val.minionOwnership.ownerMaster;
			}
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.playerCharacterMasterController))
			{
				return;
			}
		}
		if (Util.CheckRoll(DropChance.Value, 0f, (CharacterMaster)null))
		{
			PickupIndex val2 = PickupCatalog.FindPickupIndex(Items.FlatHealth.itemIndex);
			if (!(val2 == PickupIndex.none))
			{
				Vector3 val3 = report.victimBody.corePosition + Vector3.up * 1.5f;
				PickupDropletController.CreatePickupDroplet(new UniquePickup(val2), val3, Vector3.up * 15f);
			}
		}
	}
}