Decompiled source of MithrixWispFix v1.0.0

plugins/MithrixWispFix/MithrixWispFix.dll

Decompiled 5 days 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 System.Text;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using R2API.Utils;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MithrixWispFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+843ece454286c498f556dfbc9567dc0142eb310c")]
[assembly: AssemblyProduct("MithrixWispFix")]
[assembly: AssemblyTitle("MithrixWispFix")]
[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 MithrixWispFix
{
	internal static class Log
	{
		private static readonly StringBuilder _sharedStringBuilder;

		private static readonly int _cachedCallerPathPrefixLength;

		private static ManualLogSource _logSource;

		static Log()
		{
			_sharedStringBuilder = new StringBuilder(256);
			_cachedCallerPathPrefixLength = getCallerPathPrefixLength("D:\\Git\\RoR2\\MithrixWispFix\\MithrixWispFix\\Log.cs");
			static int getCallerPathPrefixLength([CallerFilePath] string callerPath = null)
			{
				int num = callerPath.LastIndexOf("MithrixWispFix\\");
				if (num >= 0)
				{
					return num + "MithrixWispFix\\".Length;
				}
				Debug.LogError((object)"[MithrixWispFix] Logger failed to determine caller path prefix length");
				return 0;
			}
		}

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

		private static StringBuilder AppendCallerPrefix(this StringBuilder stringBuilder, string callerPath, string callerMemberName, int callerLineNumber)
		{
			return stringBuilder.Append(callerPath, _cachedCallerPathPrefixLength, callerPath.Length - _cachedCallerPathPrefixLength).Append(':').Append(callerLineNumber)
				.Append(" (")
				.Append(callerMemberName)
				.Append("):");
		}

		private static StringBuilder buildCallerLogString(string callerPath, string callerMemberName, int callerLineNumber, object data)
		{
			return _sharedStringBuilder.Clear().AppendCallerPrefix(callerPath, callerMemberName, callerLineNumber).Append(' ')
				.Append(data);
		}

		[Conditional("DEBUG")]
		internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogDebug((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[Conditional("DEBUG")]
		internal static void Debug_NoCallerPrefix(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}

		internal static void LogType(LogLevel level, object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if ((level & 0x20) == 0)
			{
				_logSource.Log(level, (object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void LogType_NoCallerPrefix(LogLevel level, object data)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if ((level & 0x20) == 0)
			{
				_logSource.Log(level, data);
			}
		}
	}
	[BepInPlugin("Gorakh.MithrixWispFix", "MithrixWispFix", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MithrixWispFixPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Gorakh.MithrixWispFix";

		public const string PluginAuthor = "Gorakh";

		public const string PluginName = "MithrixWispFix";

		public const string PluginVersion = "1.0.0";

		private static MithrixWispFixPlugin _instance;

		internal static MithrixWispFixPlugin Instance => _instance;

		private void Awake()
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			SingletonHelper.Assign<MithrixWispFixPlugin>(ref _instance, this);
			Log.Init(((BaseUnityPlugin)this).Logger);
			SceneCatalog.onMostRecentSceneDefChanged += SceneCatalog_onMostRecentSceneDefChanged;
			stopwatch.Stop();
			Log.Message_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalMilliseconds:F0}ms");
		}

		private void OnDestroy()
		{
			SingletonHelper.Unassign<MithrixWispFixPlugin>(ref _instance, this);
		}

		private static void SceneCatalog_onMostRecentSceneDefChanged(SceneDef sceneDef)
		{
			if (sceneDef.cachedName == "moon2")
			{
				fixPhase2WispSpawnPosition();
			}
		}

		private static void fixPhase2WispSpawnPosition()
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			SceneInfo instance = SceneInfo.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				Log.Error("No SceneInfo instance", "D:\\Git\\RoR2\\MithrixWispFix\\MithrixWispFix\\MithrixWispFixPlugin.cs", "fixPhase2WispSpawnPosition", 52);
				return;
			}
			Transform val = ((Component)instance).transform.Find("BrotherMissionController");
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.Error("Failed to find BrotherMissionController object", "D:\\Git\\RoR2\\MithrixWispFix\\MithrixWispFix\\MithrixWispFixPlugin.cs", "fixPhase2WispSpawnPosition", 59);
				return;
			}
			ChildLocator component = ((Component)val).GetComponent<ChildLocator>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				Log.Error($"{val} is missing ChildLocator component", "D:\\Git\\RoR2\\MithrixWispFix\\MithrixWispFix\\MithrixWispFixPlugin.cs", "fixPhase2WispSpawnPosition", 66);
				return;
			}
			Transform val2 = component.FindChild("Phase2");
			if (!Object.op_Implicit((Object)(object)val2))
			{
				Log.Error("Failed to find phase 2 root", "D:\\Git\\RoR2\\MithrixWispFix\\MithrixWispFix\\MithrixWispFixPlugin.cs", "fixPhase2WispSpawnPosition", 73);
				return;
			}
			Transform val3 = val2.Find("Lunar Wisp Spawn, 1");
			if (!Object.op_Implicit((Object)(object)val3))
			{
				Log.Error("Failed to find wisp spawn point", "D:\\Git\\RoR2\\MithrixWispFix\\MithrixWispFix\\MithrixWispFixPlugin.cs", "fixPhase2WispSpawnPosition", 80);
			}
			else
			{
				val3.position = new Vector3(-94.6326f, 498.4218f, -85.32126f);
			}
		}
	}
}