Decompiled source of BetterVoidProgression v1.0.0

BetterVoidProgression.dll

Decompiled 4 hours 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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.VoidCamp;
using Microsoft.CodeAnalysis;
using On.EntityStates.VoidCamp;
using On.RoR2;
using RoR2;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
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("BetterVoidProgression")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f480bf53f32266ef723654d1e8cd26c0b293f94a")]
[assembly: AssemblyProduct("BetterVoidProgression")]
[assembly: AssemblyTitle("BetterVoidProgression")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 BetterVoidProgression
{
	public static class Assets
	{
		public static SceneDef voidRaidSceneDef = Addressables.LoadAssetAsync<SceneDef>((object)RoR2_DLC1_voidraid.voidraid_asset).WaitForCompletion();

		public static SceneDef voidStageSceneDef = Addressables.LoadAssetAsync<SceneDef>((object)RoR2_DLC1_voidstage.voidstage_asset).WaitForCompletion();

		public static InteractableSpawnCard voidPortalSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)RoR2_DLC1_PortalVoid.iscVoidPortal_asset).WaitForCompletion();

		public static GameObject nullPortalPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_PortalArena.PortalArena_prefab).WaitForCompletion();
	}
	[BepInPlugin("mwmw.BetterVoidProgression", "BetterVoidProgression", "1.0.0")]
	public class BetterVoidProgression : BaseUnityPlugin
	{
		public const string PluginGUID = "mwmw.BetterVoidProgression";

		public const string PluginAuthor = "mwmw";

		public const string PluginName = "BetterVoidProgression";

		public const string PluginVersion = "1.0.0";

		public static ConfigFile config;

		private static bool hasCompletedVoidStage;

		private static bool dirtyStageClearCount;

		private static PortalSpawner cachedVoidPortalSpawner;

		public void Awake()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			config = ((BaseUnityPlugin)this).Config;
			Run.onRunStartGlobal += delegate
			{
				hasCompletedVoidStage = false;
			};
			Run.AdvanceStage += new hook_AdvanceStage(UpdateStageClearCount);
			Deactivate.OnEnter += new hook_OnEnter(RollPlorb);
			VoidStageMissionController.OnBatteryActivated += new hook_OnBatteryActivated(SetExits);
			BazaarController.Awake += new hook_Awake(ModifyVoidSeerWeight);
			TeleporterInteraction.Awake += new hook_Awake(ModifyVoidPortalSpawner);
		}

		private void ModifyVoidPortalSpawner(orig_Awake orig, TeleporterInteraction self)
		{
			orig.Invoke(self);
			TryEnsureVoidPortalSpawner(self);
			if (Object.op_Implicit((Object)(object)cachedVoidPortalSpawner) && !hasCompletedVoidStage)
			{
				cachedVoidPortalSpawner.bannedEventFlag = string.Empty;
			}
		}

		private void UpdateStageClearCount(orig_AdvanceStage orig, Run self, SceneDef nextScene)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			if (dirtyStageClearCount)
			{
				if ((Object)(object)nextScene != (Object)(object)Assets.voidRaidSceneDef && ((int)nextScene.sceneType == 1 || (int)nextScene.sceneType == 5) && !nextScene.preventStageAdvanceCounter)
				{
					self.stageClearCount--;
				}
				dirtyStageClearCount = false;
			}
			orig.Invoke(self, nextScene);
		}

		private void ModifyVoidSeerWeight(orig_Awake orig, BazaarController 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!NetworkServer.active)
			{
				return;
			}
			for (int i = 0; i < self.seerSceneOverrides.Length; i++)
			{
				if ((Object)(object)self.seerSceneOverrides[i].sceneDef == (Object)(object)Assets.voidStageSceneDef)
				{
					SeerSceneOverride val = self.seerSceneOverrides[i];
					if (!hasCompletedVoidStage)
					{
						val.overrideChance = 0.15f;
						val.bannedEventFlag = string.Empty;
					}
					else
					{
						val.overrideChance = 0f;
					}
					self.seerSceneOverrides[i] = val;
					break;
				}
			}
		}

		private void SetExits(orig_OnBatteryActivated orig, VoidStageMissionController self)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Invalid comparison between Unknown and I4
			orig.Invoke(self);
			if (!hasCompletedVoidStage && self._numBatteriesActivated >= self._numBatteriesSpawned && Object.op_Implicit((Object)(object)self.portalRoot))
			{
				GameObject val = Object.Instantiate<GameObject>(Assets.nullPortalPrefab);
				val.transform.eulerAngles = new Vector3(-0f, 120f, 0f);
				val.transform.position = new Vector3(-10f, 28.56f, -18f);
				NetworkServer.Spawn(val);
				hasCompletedVoidStage = true;
				dirtyStageClearCount = true;
				if ((int)Run.instance.selectedDifficulty >= 3 && Object.op_Implicit((Object)(object)self.voidPortal))
				{
					NetworkServer.Destroy(self.voidPortal);
				}
			}
		}

		private void RollPlorb(orig_OnEnter orig, Deactivate self)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			orig.Invoke(self);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)Run.instance) && Run.instance.stageClearCount > 0 && ((int)Run.instance.selectedDifficulty < 3 || !hasCompletedVoidStage))
			{
				float num = 0f;
				switch (Stage.instance.sceneDef.cachedName)
				{
				case "ancientloft":
				case "sulfurpools":
				case "snowyforest":
					num = 1f;
					break;
				case "goolake":
				case "skymeadow":
				case "frozenwall":
				case "shipgraveyard":
				case "dampcavesimple":
				case "golemplains":
				case "golemplains2":
				case "lakes":
				case "lakesnight":
					num = 1f - 1f / Mathf.Pow(1.58f, (float)(Run.instance.stageClearCount + 1));
					break;
				case "blackbeach":
				case "blackbeach2":
				case "foggyswamp":
				case "rootjungle":
				case "wispgraveyard":
				case "helminthroost":
					num = 1f - 1.5f / (float)(Run.instance.stageClearCount + 1);
					break;
				}
				float value = Random.value;
				if (value < num)
				{
					TrySpawnPlorb();
				}
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void TryEnsureVoidPortalSpawner(TeleporterInteraction teleporterInstance)
		{
			if (!Object.op_Implicit((Object)(object)cachedVoidPortalSpawner) && Object.op_Implicit((Object)(object)teleporterInstance))
			{
				cachedVoidPortalSpawner = ((IEnumerable<PortalSpawner>)((Component)teleporterInstance).GetComponents<PortalSpawner>()).FirstOrDefault((Func<PortalSpawner, bool>)((PortalSpawner x) => (Object)(object)x.portalSpawnCard == (Object)(object)Assets.voidPortalSpawnCard));
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void TrySpawnPlorb()
		{
			//IL_0051: 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_006b: Expected O, but got Unknown
			TryEnsureVoidPortalSpawner(TeleporterInteraction.instance);
			if (Object.op_Implicit((Object)(object)cachedVoidPortalSpawner) && !cachedVoidPortalSpawner.NetworkwillSpawn)
			{
				cachedVoidPortalSpawner.NetworkwillSpawn = true;
				if (!string.IsNullOrEmpty(cachedVoidPortalSpawner.spawnPreviewMessageToken))
				{
					Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
					{
						baseToken = cachedVoidPortalSpawner.spawnPreviewMessageToken
					});
				}
				if (Object.op_Implicit((Object)(object)cachedVoidPortalSpawner.previewChild))
				{
					cachedVoidPortalSpawner.previewChild.SetActive(true);
				}
			}
		}
	}
	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);
		}
	}
	public class Options
	{
		private static bool? _rooEnabled;

		public static bool rooEnabled
		{
			get
			{
				if (!_rooEnabled.HasValue)
				{
					_rooEnabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
				}
				return _rooEnabled.Value;
			}
		}

		public static void Init()
		{
			if (rooEnabled)
			{
				RoOInit();
			}
		}

		private static void RoOInit()
		{
		}

		public static void OnLoadFinished()
		{
		}
	}
}