Decompiled source of LemurianFix v1.0.1

plugins/LemurianFix/LemurianFix.dll

Decompiled 6 months ago
using System;
using System.Collections;
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.Logging;
using LemurianFix.Content;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("LemurianFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+646e5678562717b5a8c68de3d290c1401171dd73")]
[assembly: AssemblyProduct("LemurianFix")]
[assembly: AssemblyTitle("LemurianFix")]
[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 LemurianFix
{
	[BepInPlugin("Gorakh.LemurianFix", "LemurianFix", "1.0.1")]
	public class LemurianFixPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Gorakh.LemurianFix";

		public const string PluginAuthor = "Gorakh";

		public const string PluginName = "LemurianFix";

		public const string PluginVersion = "1.0.1";

		internal static LemurianFixPlugin Instance { get; private set; }

		internal ContentPackProvider ContentPackProvider { get; private set; }

		private void Awake()
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			Log.Init(((BaseUnityPlugin)this).Logger);
			Instance = SingletonHelper.Assign<LemurianFixPlugin>(Instance, this);
			ContentPackProvider = new ContentPackProvider();
			ContentPackProvider.Register();
			stopwatch.Stop();
			Log.Info_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
		}

		private void OnDestroy()
		{
			Instance = SingletonHelper.Unassign<LemurianFixPlugin>(Instance, this);
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("LemurianFix\\");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "LemurianFix\\".Length);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

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

		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)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		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)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		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)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		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)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}
namespace LemurianFix.Content
{
	internal class ContentPackProvider : IContentPackProvider
	{
		private readonly ContentPack _contentPack = new ContentPack();

		public string identifier { get; } = "Gorakh.LemurianFix";


		internal ContentPackProvider()
		{
		}//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown


		internal void Register()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)delegate(AddContentPackProviderDelegate addContentPackProvider)
			{
				addContentPackProvider.Invoke((IContentPackProvider)(object)this);
			};
		}

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			_contentPack.identifier = identifier;
			AsyncOperationHandle<GameObject> lemurianBodyLoad = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Lemurian/LemurianBody.prefab");
			while (!lemurianBodyLoad.IsDone)
			{
				args.ReportProgress(Util.Remap(lemurianBodyLoad.PercentComplete, 0f, 1f, 0f, 0.5f));
				yield return 0;
			}
			AsyncOperationHandle<GameObject> devotedLemurianMasterLoad = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/CU8/LemurianEgg/DevotedLemurianMaster.prefab");
			while (!devotedLemurianMasterLoad.IsDone)
			{
				args.ReportProgress(Util.Remap(devotedLemurianMasterLoad.PercentComplete, 0f, 1f, 1f, 1f));
				yield return 0;
			}
			GameObject result = lemurianBodyLoad.Result;
			GameObject result2 = devotedLemurianMasterLoad.Result;
			GameObject val = PrefabAPI.InstantiateClone(result, "DevotedLemurianBody", true);
			DeathRewards val2 = default(DeathRewards);
			if (val.TryGetComponent<DeathRewards>(ref val2))
			{
				val2.logUnlockableDef = null;
			}
			_contentPack.bodyPrefabs.Add((GameObject[])(object)new GameObject[1] { val });
			result2.GetComponent<CharacterMaster>().bodyPrefab = val;
			CharacterBody component = result.GetComponent<CharacterBody>();
			component.bodyFlags = (BodyFlags)(component.bodyFlags & -4097);
			args.ReportProgress(1f);
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			ContentPack.Copy(_contentPack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			yield break;
		}
	}
}