Decompiled source of SonorousDrones v1.0.0

plugins/DroneSonorous/DroneOnKillPlugin.dll

Decompiled 2 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("DroneOnKillPlugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DroneOnKillPlugin")]
[assembly: AssemblyTitle("DroneOnKillPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace DroneOnKillPlugin;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("RubyInkay.DroneOnKillItems", "DroneOnKillItems", "1.0.0")]
public class DroneOnKillPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "RubyInkay.DroneOnKillItems";

	public const string PluginAuthor = "RubyInkay";

	public const string PluginName = "DroneOnKillItems";

	public const string PluginVersion = "1.0.0";

	public void Awake()
	{
		GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_droneOwnerKillEffect;
	}

	private void GlobalEventManager_droneOwnerKillEffect(DamageReport report)
	{
		//IL_004d: 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_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: 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_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)report.attacker) || !Object.op_Implicit((Object)(object)report.attackerBody) || !Object.op_Implicit((Object)(object)report.attackerOwnerMaster))
		{
			return;
		}
		CharacterBody attackerBody = report.attackerBody;
		CharacterBody body = report.attackerOwnerMaster.GetBody();
		if (!Object.op_Implicit((Object)(object)body) || !body.isPlayerControlled || attackerBody.bodyIndex == BodyPrefabs.EngiTurretBody.bodyIndex || attackerBody.bodyIndex == BodyPrefabs.EngiWalkerTurretBody.bodyIndex)
		{
			return;
		}
		int itemCountEffective = body.inventory.GetItemCountEffective(Items.ItemDropChanceOnKill);
		if (itemCountEffective > 0)
		{
			int itemCountEffective2 = body.inventory.GetItemCountEffective(Items.Clover);
			int itemCountEffective3 = body.inventory.GetItemCountEffective(Items.LunarBadLuck);
			int num = 0;
			if (body.GetBuffCount(Buffs.UltimateMealBoost) > 0)
			{
				num = body.inventory.GetItemCountEffective(Items.UltimateMeal);
			}
			int itemCountEffective4 = body.inventory.GetItemCountEffective(Items.RandomlyLunar);
			CreatePickupInfo val = default(CreatePickupInfo);
			if (report.victimIsElite)
			{
				PickupIndex val2 = RollItem(itemCountEffective2 + 2 * num - itemCountEffective3, isChampion: false, isElite: true, itemCountEffective, itemCountEffective4);
				val._pickupState = new UniquePickup(val2);
				((CreatePickupInfo)(ref val)).pickup = new UniquePickup(val2);
				val.position = report.victim.body.corePosition;
				GenericPickupController.CreatePickup(ref val);
			}
			if (report.victimIsChampion)
			{
				PickupIndex val2 = RollItem(itemCountEffective2 + 2 * num - itemCountEffective3, isChampion: true, isElite: false, itemCountEffective, itemCountEffective4);
				val._pickupState = new UniquePickup(val2);
				((CreatePickupInfo)(ref val)).pickup = new UniquePickup(val2);
				val.position = report.victim.body.corePosition;
				GenericPickupController.CreatePickup(ref val);
			}
		}
	}

	private PickupIndex RollItem(int luck, bool isChampion, bool isElite, int sonorousCount, int eulogyCount)
	{
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: 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_009f: Unknown result type (might be due to invalid IL or missing references)
		if (isElite || isChampion)
		{
			int i = luck + 1;
			bool flag = true;
			if (luck >= 0 && !isChampion)
			{
				flag = false;
				while (!flag && i > 0)
				{
					flag = Random.Range(1, 101) <= sonorousCount + 4;
					i--;
				}
			}
			else if (!isChampion)
			{
				for (; i - 1 <= 0; i++)
				{
					bool flag2 = Random.Range(1, 101) <= sonorousCount + 4;
					if (flag)
					{
						flag = flag2;
					}
				}
			}
			if (isChampion || flag)
			{
				if (Random.Range(0, 100) < 5 * eulogyCount)
				{
					return RandomLunarItem();
				}
				int num = Random.Range(0, 1001);
				if (num == 1000)
				{
					return RandomRedItem();
				}
				if (num <= 199)
				{
					return RandomGreenItem();
				}
				return RandomWhiteItem();
			}
		}
		return PickupIndex.none;
	}

	private PickupIndex RandomRedItem()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		List<PickupIndex> list = Run.instance?.availableTier3DropList;
		int index = Random.Range(0, list.Count());
		return list[index];
	}

	private PickupIndex RandomGreenItem()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		List<PickupIndex> list = Run.instance?.availableTier2DropList;
		int index = Random.Range(0, list.Count());
		return list[index];
	}

	private PickupIndex RandomWhiteItem()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		List<PickupIndex> list = Run.instance?.availableTier1DropList;
		int index = Random.Range(0, list.Count());
		return list[index];
	}

	private PickupIndex RandomLunarItem()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		List<PickupIndex> list = Run.instance?.availableLunarItemDropList;
		int index = Random.Range(0, list.Count());
		return list[index];
	}
}
internal static class Log
{
	private static ManualLogSource _logSource;

	internal static void Init(ManualLogSource logSource)
	{
		_logSource = logSource;
	}

	internal static void Debug(object data)
	{
		_logSource.LogDebug(data);
	}

	internal static void Error(object data)
	{
		_logSource.LogError(data);
	}

	internal static void Fatal(object data)
	{
		_logSource.LogFatal(data);
	}

	internal static void Info(object data)
	{
		_logSource.LogInfo(data);
	}

	internal static void Message(object data)
	{
		_logSource.LogMessage(data);
	}

	internal static void Warning(object data)
	{
		_logSource.LogWarning(data);
	}
}