Decompiled source of Oops All Void v1.1.1

OopsAllVoid/OopsAllVoid.dll

Decompiled 3 months ago
using System;
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 Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("OopsAllVoid")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cdbdfa5ce0bddd8135a7eac9a9792b889f8b2538")]
[assembly: AssemblyProduct("OopsAllVoid")]
[assembly: AssemblyTitle("OopsAllVoid")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 OopsAllVoid
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("zombieseatflesh7.OopsAllVoid", "OopsAllVoid", "1.1.1")]
	public class OopsAllVoid : BaseUnityPlugin
	{
		public const string PluginGUID = "zombieseatflesh7.OopsAllVoid";

		public const string PluginAuthor = "zombieseatflesh7";

		public const string PluginName = "OopsAllVoid";

		public const string PluginVersion = "1.1.1";

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			PInfo = ((BaseUnityPlugin)this).Info;
			ModAssets.Init();
			CorruptionArtifact.Init();
		}
	}
	public static class CorruptionArtifact
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static ArtifactStateChangeDelegate <0>__OnArtifactEnabled;

			public static ArtifactStateChangeDelegate <1>__OnArtifactDisabled;

			public static hook_DropRewards <2>__BossGroup_DropRewards;

			public static Action<SceneDirector, DirectorCardCategorySelection> <3>__OnGenerateInteractableCardSelection;
		}

		public static ArtifactDef Corruption;

		public static InteractableSpawnCard duplicatorT1SpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/Duplicator/iscDuplicator.asset").WaitForCompletion();

		public static InteractableSpawnCard duplicatorT2SpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/DuplicatorLarge/iscDuplicatorLarge.asset").WaitForCompletion();

		public static InteractableSpawnCard duplicatorT3SpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/DuplicatorMilitary/iscDuplicatorMilitary.asset").WaitForCompletion();

		public static InteractableSpawnCard duplicatorBossSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/DuplicatorWild/iscDuplicatorWild.asset").WaitForCompletion();

		public static InteractableSpawnCard scrapperSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/Scrapper/iscScrapper.asset").WaitForCompletion();

		public static InteractableSpawnCard smallDamageChestSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/CategoryChest/iscCategoryChestDamage.asset").WaitForCompletion();

		public static InteractableSpawnCard smallHealingChestSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/CategoryChest/iscCategoryChestHealing.asset").WaitForCompletion();

		public static InteractableSpawnCard smallUtilityChestSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/CategoryChest/iscCategoryChestUtility.asset").WaitForCompletion();

		public static InteractableSpawnCard largeDamageChestSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC1/CategoryChest2/iscCategoryChest2Damage.asset").WaitForCompletion();

		public static InteractableSpawnCard largeHealingChestSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC1/CategoryChest2/iscCategoryChest2Healing.asset").WaitForCompletion();

		public static InteractableSpawnCard largeUtilityChestSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC1/CategoryChest2/iscCategoryChest2Utility.asset").WaitForCompletion();

		public static List<PickupDropTable> DropTables = null;

		public static float[][] DropTableValues = null;

		public static void Init()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00a7: 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_00b2: Expected O, but got Unknown
			Corruption = ScriptableObject.CreateInstance<ArtifactDef>();
			Corruption.cachedName = "ArtifactOfCorruption";
			Corruption.nameToken = "Artifact of Corruption";
			Corruption.descriptionToken = "Replaces all items except equipment and lunar items with void items.";
			Corruption.smallIconSelectedSprite = ModAssets.AssetBundle.LoadAsset<Sprite>("texArtifactCorruptionEnabled.png");
			Corruption.smallIconDeselectedSprite = ModAssets.AssetBundle.LoadAsset<Sprite>("texArtifactCorruptionDisabled.png");
			ContentAddition.AddArtifactDef(Corruption);
			object obj = <>O.<0>__OnArtifactEnabled;
			if (obj == null)
			{
				ArtifactStateChangeDelegate val = OnArtifactEnabled;
				<>O.<0>__OnArtifactEnabled = val;
				obj = (object)val;
			}
			RunArtifactManager.onArtifactEnabledGlobal += (ArtifactStateChangeDelegate)obj;
			object obj2 = <>O.<1>__OnArtifactDisabled;
			if (obj2 == null)
			{
				ArtifactStateChangeDelegate val2 = OnArtifactDisabled;
				<>O.<1>__OnArtifactDisabled = val2;
				obj2 = (object)val2;
			}
			RunArtifactManager.onArtifactDisabledGlobal += (ArtifactStateChangeDelegate)obj2;
		}

		private static void OnArtifactEnabled(RunArtifactManager runArtifactManager, ArtifactDef artifactDef)
		{
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			if ((Object)(object)artifactDef != (Object)(object)Corruption || !NetworkServer.active)
			{
				return;
			}
			DropTables = Reflection.GetFieldValue<List<PickupDropTable>>(typeof(PickupDropTable), "instancesList");
			DropTableValues = new float[DropTables.Count()][];
			int num = 0;
			foreach (BasicPickupDropTable item in DropTables.OfType<BasicPickupDropTable>())
			{
				DropTableValues[num] = new float[6];
				DropTableValues[num][0] = item.tier1Weight;
				DropTableValues[num][1] = item.tier2Weight;
				DropTableValues[num][2] = item.tier3Weight;
				DropTableValues[num][3] = item.voidTier1Weight;
				DropTableValues[num][4] = item.voidTier2Weight;
				DropTableValues[num][5] = item.voidTier3Weight;
				item.voidTier1Weight = item.tier1Weight + item.voidTier1Weight;
				item.voidTier2Weight = item.tier2Weight + item.voidTier2Weight;
				item.voidTier3Weight = item.tier3Weight + item.voidTier3Weight;
				item.tier1Weight = 0f;
				item.tier2Weight = 0f;
				item.tier3Weight = 0f;
				num++;
			}
			Reflection.InvokeMethod(typeof(PickupDropTable), "RegenerateAll", new object[1] { Run.instance });
			object obj = <>O.<2>__BossGroup_DropRewards;
			if (obj == null)
			{
				hook_DropRewards val = BossGroup_DropRewards;
				<>O.<2>__BossGroup_DropRewards = val;
				obj = (object)val;
			}
			BossGroup.DropRewards += (hook_DropRewards)obj;
			SceneDirector.onGenerateInteractableCardSelection += OnGenerateInteractableCardSelection;
		}

		private static void OnArtifactDisabled(RunArtifactManager runArtifactManager, ArtifactDef artifactDef)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			if ((Object)(object)artifactDef != (Object)(object)Corruption)
			{
				return;
			}
			int num = 0;
			foreach (BasicPickupDropTable item in DropTables.OfType<BasicPickupDropTable>())
			{
				item.tier1Weight = DropTableValues[num][0];
				item.tier2Weight = DropTableValues[num][1];
				item.tier3Weight = DropTableValues[num][2];
				item.voidTier1Weight = DropTableValues[num][3];
				item.voidTier2Weight = DropTableValues[num][4];
				item.voidTier3Weight = DropTableValues[num][5];
				num++;
			}
			DropTables = null;
			DropTableValues = null;
			object obj = <>O.<2>__BossGroup_DropRewards;
			if (obj == null)
			{
				hook_DropRewards val = BossGroup_DropRewards;
				<>O.<2>__BossGroup_DropRewards = val;
				obj = (object)val;
			}
			BossGroup.DropRewards -= (hook_DropRewards)obj;
			SceneDirector.onGenerateInteractableCardSelection -= OnGenerateInteractableCardSelection;
		}

		public static void BossGroup_DropRewards(orig_DropRewards orig, BossGroup self)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			List<PickupIndex> fieldValue = Reflection.GetFieldValue<List<PickupIndex>>((object)self, "bossDrops");
			List<PickupDropTable> fieldValue2 = Reflection.GetFieldValue<List<PickupDropTable>>((object)self, "bossDropTables");
			Xoroshiro128Plus fieldValue3 = Reflection.GetFieldValue<Xoroshiro128Plus>((object)self, "rng");
			for (int i = 0; i < fieldValue.Count; i++)
			{
				fieldValue[i] = fieldValue3.NextElementUniform<PickupIndex>(Run.instance.availableVoidBossDropList);
			}
			for (int j = 0; j < fieldValue2.Count; j++)
			{
				fieldValue.Add(fieldValue3.NextElementUniform<PickupIndex>(Run.instance.availableVoidBossDropList));
			}
			Reflection.SetFieldValue<List<PickupDropTable>>((object)self, "bossDropTables", new List<PickupDropTable>());
			orig.Invoke(self);
		}

		private static void OnGenerateInteractableCardSelection(SceneDirector sceneDirector, DirectorCardCategorySelection dccs)
		{
			dccs.RemoveCardsThatFailFilter((Predicate<DirectorCard>)InteractableFilter);
		}

		private static bool InteractableFilter(DirectorCard card)
		{
			if ((Object)(object)card.spawnCard == (Object)(object)duplicatorT1SpawnCard || (Object)(object)card.spawnCard == (Object)(object)duplicatorT2SpawnCard || (Object)(object)card.spawnCard == (Object)(object)duplicatorT3SpawnCard || (Object)(object)card.spawnCard == (Object)(object)duplicatorBossSpawnCard || (Object)(object)card.spawnCard == (Object)(object)scrapperSpawnCard || (Object)(object)card.spawnCard == (Object)(object)smallDamageChestSpawnCard || (Object)(object)card.spawnCard == (Object)(object)smallHealingChestSpawnCard || (Object)(object)card.spawnCard == (Object)(object)smallUtilityChestSpawnCard || (Object)(object)card.spawnCard == (Object)(object)largeDamageChestSpawnCard || (Object)(object)card.spawnCard == (Object)(object)largeHealingChestSpawnCard || (Object)(object)card.spawnCard == (Object)(object)largeUtilityChestSpawnCard)
			{
				return false;
			}
			return true;
		}
	}
	public static class ModAssets
	{
		public static AssetBundle AssetBundle;

		public const string dllName = "OopsAllVoid.dll";

		public const string bundleName = "oavassetbundle";

		public static void Init()
		{
			AssetBundle = AssetBundle.LoadFromFile(OopsAllVoid.PInfo.Location.Replace("OopsAllVoid.dll", "oavassetbundle"));
			if ((Object)(object)AssetBundle == (Object)null)
			{
				Log.LogInfo("Failed to load AssetBundle!");
			}
		}
	}
}