Decompiled source of Goldfinger Costume v1.0.0

BepInEx\plugins\GoldfingerCostume\GoldfingerCostume.dll

Decompiled 9 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.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using ModelReplacement;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("GoldfingerCostume")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Goldfinger Costume")]
[assembly: AssemblyTitle("GoldfingerCostume")]
[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 EuclidMC.GoldfingerCostume
{
	public static class PluginInfo
	{
		public const string GUID = "euclidmc.goldfingercostume";

		public const string NAME = "Goldfinger Costume";

		public const string SUIT = "Goldfinger";

		public const string PREFAB = "GoldfingerPrefab";

		public const string BUNDLE = "goldfingercostume";

		public const string VERSION = "1.0.0";
	}
	public class CostumeReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			return Assets.LoadPrefab("GoldfingerPrefab");
		}
	}
	[BepInPlugin("euclidmc.goldfingercostume", "Goldfinger Costume", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		public static ConfigEntry<bool> Enabled;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Costume", "Enabled", true, "Replace the player model when wearing the Goldfinger suit. Turning this off leaves the suit on the rack as a plain coloured suit.");
			if (!Enabled.Value)
			{
				Log.LogInfo((object)"Goldfinger Costume disabled by config; not registering.");
				return;
			}
			if (!Assets.Populate())
			{
				Log.LogError((object)"AssetBundle 'goldfingercostume' failed to load; costume not registered. Ensure the bundle sits next to this dll.");
				return;
			}
			ModelReplacementAPI.RegisterSuitModelReplacement("Goldfinger", typeof(CostumeReplacement));
			Log.LogInfo((object)"Goldfinger Costume 1.0.0 loaded.");
		}
	}
	public static class Assets
	{
		public static AssetBundle MainAssetBundle;

		public static bool Populate()
		{
			if ((Object)(object)MainAssetBundle != (Object)null)
			{
				return true;
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "goldfingercostume");
			if (!File.Exists(text))
			{
				Plugin.Log.LogError((object)("AssetBundle not found at '" + text + "'."));
				return false;
			}
			try
			{
				MainAssetBundle = AssetBundle.LoadFromFile(text);
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"AssetBundle load threw: {arg}");
				return false;
			}
			return (Object)(object)MainAssetBundle != (Object)null;
		}

		public static GameObject LoadPrefab(string name)
		{
			GameObject obj = (((Object)(object)MainAssetBundle != (Object)null) ? MainAssetBundle.LoadAsset<GameObject>(name) : null);
			if ((Object)(object)obj == (Object)null)
			{
				string text = (((Object)(object)MainAssetBundle != (Object)null) ? string.Join(", ", MainAssetBundle.GetAllAssetNames()) : "<bundle not loaded>");
				Plugin.Log.LogError((object)("Prefab '" + name + "' not found in bundle. Bundle contains: " + text));
			}
			return obj;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}