Decompiled source of VoidFieldsFIXED v1.0.2

VoidFieldsFIXED.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("VoidFieldsFIXED")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VoidFieldsFIXED")]
[assembly: AssemblyTitle("VoidFieldsFIXED")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 VoidFieldsFIXED
{
	[BepInPlugin("Blank", "VoidFieldsFIXED", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		private static SceneDef originalSceneDef;

		private static SceneType originalSceneType;

		private static bool isVoidFieldsActive;

		private Harmony _harmony;

		public void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			_harmony.Patch((MethodBase)typeof(SceneCatalog).GetMethod("OnActiveSceneChanged", BindingFlags.Static | BindingFlags.NonPublic), (HarmonyMethod)null, new HarmonyMethod(typeof(Main), "OnSceneChanged", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void OnSceneChanged(Scene oldScene, Scene newScene)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				SceneDef sceneDefFromSceneName = SceneCatalog.GetSceneDefFromSceneName(((Scene)(ref newScene)).name);
				if ((Object)(object)sceneDefFromSceneName != (Object)null && sceneDefFromSceneName.cachedName.Equals("arena", StringComparison.OrdinalIgnoreCase))
				{
					originalSceneDef = sceneDefFromSceneName;
					originalSceneType = sceneDefFromSceneName.sceneType;
					sceneDefFromSceneName.sceneType = (SceneType)5;
					isVoidFieldsActive = true;
					Debug.Log((object)$"Void Fields entered. Changed sceneType to: {sceneDefFromSceneName.sceneType}");
				}
				else if (isVoidFieldsActive && (Object)(object)originalSceneDef != (Object)null)
				{
					originalSceneDef.sceneType = originalSceneType;
					isVoidFieldsActive = false;
					Debug.Log((object)$"Void Fields exited. Restored sceneType to: {originalSceneType}");
				}
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Error in scene change handler: {arg}");
			}
		}
	}
}
namespace ExamplePlugin
{
	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);
		}
	}
}