Decompiled source of BetterVoidFields v1.0.0

BetterVoidFields.dll

Decompiled 10 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using EntityStates.Missions.Arena.NullWard;
using Microsoft.CodeAnalysis;
using On.EntityStates.Missions.Arena.NullWard;
using On.RoR2;
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("BetterVoidFields")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterVoidFields")]
[assembly: AssemblyTitle("BetterVoidFields")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace BetterVoidFields
{
	[BepInPlugin("com.Moffein.BetterVoidFields", "BetterVoidFields", "1.0.0")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class BetterVoidFields : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_PopulateScene <>9__9_0;

			internal void <RemoveInteractables>b__9_0(orig_PopulateScene orig, SceneDirector self)
			{
				if ((Object)(object)SceneCatalog.GetSceneDefForCurrentScene() == (Object)(object)voidFieldsSceneDef)
				{
					self.interactableCredit = 0;
				}
				orig.Invoke(self);
			}
		}

		private static SceneDef voidFieldsSceneDef = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/Base/arena/arena.asset").WaitForCompletion();

		public static ConfigEntry<bool> removeInteractables;

		public static ConfigEntry<bool> holdoutsAreCylinders;

		public static ConfigEntry<bool> shortenWaves;

		public static ConfigEntry<bool> removeSotsBloat;

		public static ConfigEntry<float> expandHoldoutRadius;

		public static ConfigEntry<float> holdoutDuration;

		private void Awake()
		{
			ReadConfig();
			RemoveInteractables();
			ChangeHoldoutDuration();
			ChangeHoldoutRadius();
			HoldoutsAreCylinders();
			ShortenWaves();
			RemoveSotsBloat();
		}

		private void ReadConfig()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_002c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0060: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_0094: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00c4: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_00f4: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_0124: Expected O, but got Unknown
			removeInteractables = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Remove Interactables"), true, new ConfigDescription("Remove interactables from Void Fields, like how it used to work pre-SotV.", (AcceptableValueBase)null, Array.Empty<object>()));
			holdoutDuration = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Settings", "Charge Duration"), 60f, new ConfigDescription("How long it takes to charge a Cell Vent.", (AcceptableValueBase)null, Array.Empty<object>()));
			expandHoldoutRadius = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Settings", "Holdout Radius"), 30f, new ConfigDescription("Size of the Cell Vent radius. 15m is Vanilla.", (AcceptableValueBase)null, Array.Empty<object>()));
			holdoutsAreCylinders = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Holdouts are Cylinders"), false, new ConfigDescription("Makes the holdout shape a cylinder.", (AcceptableValueBase)null, Array.Empty<object>()));
			shortenWaves = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Less Waves"), true, new ConfigDescription("Lowers wave count from 9 to 5.", (AcceptableValueBase)null, Array.Empty<object>()));
			removeSotsBloat = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Remove SotS Bloat Mechanics"), true, new ConfigDescription("Removes SotS Void Fields changes.", (AcceptableValueBase)null, Array.Empty<object>()));
		}

		private void RemoveInteractables()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			if (!removeInteractables.Value)
			{
				return;
			}
			object obj = <>c.<>9__9_0;
			if (obj == null)
			{
				hook_PopulateScene val = delegate(orig_PopulateScene orig, SceneDirector self)
				{
					if ((Object)(object)SceneCatalog.GetSceneDefForCurrentScene() == (Object)(object)voidFieldsSceneDef)
					{
						self.interactableCredit = 0;
					}
					orig.Invoke(self);
				};
				<>c.<>9__9_0 = val;
				obj = (object)val;
			}
			SceneDirector.PopulateScene += (hook_PopulateScene)obj;
		}

		private void ChangeHoldoutDuration()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"8a6a0189c5090eb4bab48bd10e3074ea").WaitForCompletion();
			val.GetComponent<HoldoutZoneController>().baseChargeDuration = holdoutDuration.Value;
		}

		private void ChangeHoldoutRadius()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			NullWardBaseState.OnEnter += new hook_OnEnter(NullWardBaseState_OnEnter);
		}

		private void NullWardBaseState_OnEnter(orig_OnEnter orig, NullWardBaseState self)
		{
			orig.Invoke(self);
			NullWardBaseState.wardRadiusOn = expandHoldoutRadius.Value;
		}

		private void HoldoutsAreCylinders()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (holdoutsAreCylinders.Value)
			{
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"8a6a0189c5090eb4bab48bd10e3074ea").WaitForCompletion();
				val.GetComponent<HoldoutZoneController>().holdoutZoneShape = (HoldoutZoneShape)1;
			}
		}

		private void ShortenWaves()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			if (shortenWaves.Value)
			{
				ArenaMissionController.Awake += new hook_Awake(SetRoundsAndOverrideRewards);
				ArenaMissionController.BeginRound += new hook_BeginRound(AugmentBeginRound);
				ArenaMissionController.AddMonsterType += new hook_AddMonsterType(PreventOnRound5);
			}
		}

		private void RemoveSotsBloat()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if (removeSotsBloat.Value)
			{
				ArenaMissionController.UpdateFogDamageVoidFieldsDamageMultiplier += new hook_UpdateFogDamageVoidFieldsDamageMultiplier(ArenaMissionController_UpdateFogDamageVoidFieldsDamageMultiplier);
				Active.HandlePenalties += new hook_HandlePenalties(Active_HandlePenalties);
			}
		}

		private void ArenaMissionController_UpdateFogDamageVoidFieldsDamageMultiplier(orig_UpdateFogDamageVoidFieldsDamageMultiplier orig, ArenaMissionController self, int voidFieldsDamageMultiplier)
		{
		}

		private void Active_HandlePenalties(orig_HandlePenalties orig, Active self, ref float percentOfPlayersInRadius)
		{
			self.timeSincePreviousItemPunishment = 0f;
			orig.Invoke(self, ref percentOfPlayersInRadius);
		}

		private void PreventOnRound5(orig_AddMonsterType orig, ArenaMissionController self)
		{
			if (self.currentRound != 5)
			{
				orig.Invoke(self);
			}
		}

		private void AugmentBeginRound(orig_BeginRound orig, ArenaMissionController self)
		{
			if (NetworkServer.active)
			{
				switch (self.currentRound)
				{
				case 0:
					self.AddItemStack();
					break;
				case 1:
					self.AddMonsterType();
					break;
				case 2:
					self.AddItemStack();
					break;
				case 3:
					self.AddMonsterType();
					break;
				case 4:
					self.AddItemStack();
					break;
				}
			}
			orig.Invoke(self);
		}

		private void SetRoundsAndOverrideRewards(orig_Awake orig, ArenaMissionController self)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			self.totalRoundsMax = 5;
			for (int i = 0; i < 5 && i < self.playerRewardOrder.Length; i++)
			{
				switch (i)
				{
				case 0:
					self.playerRewardOrder[i] = Addressables.LoadAssetAsync<PickupDropTable>((object)"RoR2/Base/Common/dtTier1Item.asset").WaitForCompletion();
					break;
				case 1:
					self.playerRewardOrder[i] = Addressables.LoadAssetAsync<PickupDropTable>((object)"RoR2/Base/Common/dtTier1Item.asset").WaitForCompletion();
					break;
				case 2:
					self.playerRewardOrder[i] = Addressables.LoadAssetAsync<PickupDropTable>((object)"RoR2/Base/Common/dtTier2Item.asset").WaitForCompletion();
					break;
				case 3:
					self.playerRewardOrder[i] = Addressables.LoadAssetAsync<PickupDropTable>((object)"RoR2/Base/Common/dtTier2Item.asset").WaitForCompletion();
					break;
				case 4:
					self.playerRewardOrder[i] = Addressables.LoadAssetAsync<PickupDropTable>((object)"RoR2/Base/Common/dtTier3Item.asset").WaitForCompletion();
					break;
				}
			}
		}
	}
}