Decompiled source of CustomName v0.0.0

CustomName.dll

Decompiled 4 months 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using UnityEngine;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;

[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.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("CustomName")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Template")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomName")]
[assembly: AssemblyTitle("CustomName")]
[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 CustomName
{
	internal static class MyPluginInfo
	{
		internal const string PLUGIN_GUID = "id107.customname";

		internal const string PLUGIN_NAME = "CustomName";

		internal const string PLUGIN_VERSION = "0.0.0";
	}
	[BepInPlugin("id107.customname", "CustomName", "0.0.0")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "id107.customname");
			Configs.Load(this);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin id107.customname is loaded!");
		}
	}
	internal class Configs
	{
		internal static ConfigEntry<string> name;

		internal static void Load(BepinPlugin plugin)
		{
			name = ((BaseUnityPlugin)plugin).Config.Bind<string>("CustomName", "Name", "", (ConfigDescription)null);
		}
	}
	internal class GUI : ModSettingsMenu
	{
		private string nameString = Configs.name.Value;

		public override string Name()
		{
			return "Custom Name";
		}

		public override void Draw()
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Player Name:", Array.Empty<GUILayoutOption>());
			nameString = GUILayout.TextField(nameString, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(80f) });
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Apply", Array.Empty<GUILayoutOption>()))
			{
				Configs.name.Value = nameString;
			}
			if (GUILayout.Button("Reset", Array.Empty<GUILayoutOption>()))
			{
				Configs.name.Value = "";
				nameString = "";
			}
			GUILayout.EndHorizontal();
			GUILayout.Label("", Array.Empty<GUILayoutOption>());
			GUILayout.Label("Restarting the game may be required for full effect", Array.Empty<GUILayoutOption>());
		}
	}
	[HarmonyPatch(typeof(SteamFriends))]
	internal class PlayerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("GetPersonaName")]
		private static void GetPersonaName(ref string __result)
		{
			if (!string.IsNullOrEmpty(Configs.name.Value))
			{
				__result = Configs.name.Value;
			}
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)3;

		public override string Author => "18107";

		public override string Description => "Allows the user to set a custom username";
	}
}