Decompiled source of TeleporterOnlyYellow v1.0.0

BepInEx/plugins/TeleporterOnlyYellow/TeleporterOnlyYellow.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Microsoft.CodeAnalysis;
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("TeleporterOnlyYellow")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+81530522f0f3634d579e798de42c9c44aa88c7f5")]
[assembly: AssemblyProduct("TeleporterOnlyYellow")]
[assembly: AssemblyTitle("TeleporterOnlyYellow")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TeleporterOnlyYellow
{
	[BepInPlugin("com.teleporteronlyyellow.mod", "Teleporter Only Yellow", "1.0.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.teleporteronlyyellow.mod";

		public const string PluginName = "Teleporter Only Yellow";

		public const string PluginVersion = "1.0.0";

		private BasicPickupDropTable _yellowDropTable;

		private void Awake()
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			_yellowDropTable = ScriptableObject.CreateInstance<BasicPickupDropTable>();
			((Object)_yellowDropTable).name = "dtTeleporterOnlyYellow";
			_yellowDropTable.tier1Weight = 0f;
			_yellowDropTable.tier2Weight = 0f;
			_yellowDropTable.tier3Weight = 0f;
			_yellowDropTable.bossWeight = 1f;
			_yellowDropTable.lunarItemWeight = 0f;
			_yellowDropTable.equipmentWeight = 0f;
			_yellowDropTable.lunarEquipmentWeight = 0f;
			_yellowDropTable.voidTier1Weight = 0f;
			_yellowDropTable.voidTier2Weight = 0f;
			_yellowDropTable.voidTier3Weight = 0f;
			_yellowDropTable.voidBossWeight = 0f;
			BossGroup.DropRewards += new hook_DropRewards(BossGroup_DropRewards);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Teleporter Only Yellow 1.0.0 loaded.");
		}

		private void OnDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			BossGroup.DropRewards -= new hook_DropRewards(BossGroup_DropRewards);
			if ((Object)(object)_yellowDropTable != (Object)null)
			{
				Object.Destroy((Object)(object)_yellowDropTable);
				_yellowDropTable = null;
			}
		}

		private void BossGroup_DropRewards(orig_DropRewards orig, BossGroup self)
		{
			TeleporterInteraction instance = TeleporterInteraction.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.bossGroup != (Object)(object)self || (Object)(object)_yellowDropTable == (Object)null)
			{
				orig.Invoke(self);
				return;
			}
			PickupDropTable dropTable = self.dropTable;
			float bossDropChance = self.bossDropChance;
			try
			{
				self.dropTable = (PickupDropTable)(object)_yellowDropTable;
				self.bossDropChance = 0f;
				orig.Invoke(self);
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Failed while replacing teleporter rewards: {arg}");
				throw;
			}
			finally
			{
				self.dropTable = dropTable;
				self.bossDropChance = bossDropChance;
			}
		}
	}
}