Decompiled source of REDs sale star rebalence v1.0.0

RED's sale star rebalence.dll

Decompiled a week ago
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.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RoR2-Tweak-Template")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RoR2-Tweak-Template")]
[assembly: AssemblyTitle("RoR2-Tweak-Template")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SaleStarTweak;

[BepInPlugin("com.salestartweak.guaranteedstack", "Sale Star Guaranteed Stack", "1.0.0")]
public class SaleStarTweakPlugin : BaseUnityPlugin
{
	public void Awake()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Sale Star Guaranteed Stack loaded successfully!");
		Inventory.GiveItemPermanent_ItemIndex_int += new hook_GiveItemPermanent_ItemIndex_int(Inventory_GiveItemPermanent);
	}

	private void Inventory_GiveItemPermanent(orig_GiveItemPermanent_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: 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_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: 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_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		orig.Invoke(self, itemIndex, count);
		if (!((Object)(object)Items.LowerPricedChestsConsumed != (Object)null) || itemIndex != Items.LowerPricedChestsConsumed.itemIndex)
		{
			return;
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"Detected {count} Sale Star(s) consumed on this chest!");
		if (count <= 1)
		{
			return;
		}
		CharacterMaster component = ((Component)self).GetComponent<CharacterMaster>();
		if (!((Object)(object)component != (Object)null) || !((Object)(object)component.GetBody() != (Object)null))
		{
			return;
		}
		int num = count - 1;
		Vector3 corePosition = component.GetBody().corePosition;
		ChestBehavior val = null;
		float num2 = 20f;
		foreach (ChestBehavior instances in InstanceTracker.GetInstancesList<ChestBehavior>())
		{
			float num3 = Vector3.Distance(corePosition, ((Component)instances).transform.position);
			if (num3 < num2)
			{
				num2 = num3;
				val = instances;
			}
		}
		if ((Object)(object)val != (Object)null && (Object)(object)val.dropTable != (Object)null && (Object)(object)Run.instance != (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Spawning {num} extra items/cubes from '{((Object)val).name}'!");
			Vector3 val2 = (Object.op_Implicit((Object)(object)val.dropTransform) ? val.dropTransform.position : (((Component)val).transform.position + Vector3.up * 1.5f));
			for (int i = 0; i < num; i++)
			{
				UniquePickup val3 = val.dropTable.GeneratePickup(Run.instance.treasureRng);
				float num4 = ((float)i - (float)(num - 1) / 2f) * 15f;
				Vector3 val4 = Quaternion.Euler(0f, num4, 0f) * (Vector3.up * 20f + ((Component)val).transform.forward * 5f);
				PickupDropletController.CreatePickupDroplet(val3, val2, val4);
			}
		}
	}
}