Decompiled source of BuddyFix v1.0.0

BuddyFix.dll

Decompiled 5 hours ago
using System;
using System.Diagnostics;
using System.IO;
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 HG.Reflection;
using Logger;
using Microsoft.CodeAnalysis;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2.ContentManagement;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BuddyFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+73a8c59d599d2022b3d5d405c25040f0ad5790a7")]
[assembly: AssemblyProduct("BuddyFix")]
[assembly: AssemblyTitle("BuddyFix")]
[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 Logger
{
	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);
		}
	}
}
namespace BuddyFix
{
	[BepInPlugin("Onyx.BuddyFix", "BuddyFix", "1.0.0")]
	public sealed class BuddyFix : BaseUnityPlugin
	{
		public const string PluginGUID = "Onyx.BuddyFix";

		public const string PluginAuthor = "Onyx";

		public const string PluginName = "BuddyFix";

		public const string PluginVersion = "1.0.0";

		public static BuddyFix Instance;

		public static ConfigEntry<string> BuddyName { get; set; }

		public void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			Instance = SingletonHelper.Assign<BuddyFix>(Instance, this);
			Options.Init();
			AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC3_FriendUnit.FriendUnitBody_prefab), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				Transform val2 = x.Result.transform.Find("ModelBase/mdlDefectiveUnit (1)/Hitbox");
				if (Object.op_Implicit((Object)(object)val2))
				{
					val2.localPosition = new Vector3(0f, -1f, 0.1f);
					val2.localScale = new Vector3(2.5f, 2.5f, 2.5f);
				}
				LanguageAPI.AddOverlay("FRIENDUNIT_BODY_NAME", BuddyName.Value);
			};
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal static class Options
	{
		public static bool IsEnabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		public static void Init()
		{
			BuddyFix.BuddyName = ((BaseUnityPlugin)BuddyFix.Instance).Config.Bind<string>("General", "Best Buddy Name", "Best Buddy", "Change his name to whatever you want");
			if (IsEnabled)
			{
				RiskOfOptionsConfig();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void RiskOfOptionsConfig()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(BuddyFix.BuddyName, true), "Onyx.BuddyFix", "BuddyFix");
			ModSettingsManager.SetModDescription("Options for BuddyFix", "Onyx.BuddyFix", "BuddyFix");
			FileInfo fileInfo = null;
			DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
			do
			{
				FileInfo[] files = directoryInfo.GetFiles("icon.png", SearchOption.TopDirectoryOnly);
				if (files != null && files.Length != 0)
				{
					fileInfo = files[0];
					break;
				}
				directoryInfo = directoryInfo.Parent;
			}
			while (directoryInfo != null && directoryInfo.Exists && !string.Equals(directoryInfo.Name, "plugins", StringComparison.OrdinalIgnoreCase));
			if (fileInfo != null)
			{
				Texture2D val = new Texture2D(256, 256);
				if (ImageConversion.LoadImage(val, File.ReadAllBytes(fileInfo.FullName)))
				{
					Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
					((Object)val2).name = "BuddyFixIcon";
					ModSettingsManager.SetModIcon(val2, "Onyx.BuddyFix", "BuddyFix");
				}
			}
		}
	}
}