Decompiled source of LicensePlate v1.3.0

LicensePlate.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComfyLib;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LicensePlate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LicensePlate")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("89477657-8729-4e5e-995e-4d58fa20b25b")]
[assembly: AssemblyFileVersion("1.3.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.0.0")]
[module: UnverifiableCode]
namespace ComfyLib
{
	public static class ConfigFileExtensions
	{
		internal sealed class ConfigurationManagerAttributes
		{
			public Action<ConfigEntryBase> CustomDrawer;

			public bool? Browsable;

			public bool? HideDefaultButton;

			public int? Order;
		}

		private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>();

		private static int GetSettingOrder(string section)
		{
			if (!_sectionToSettingOrder.TryGetValue(section, out var value))
			{
				value = 0;
			}
			_sectionToSettingOrder[section] = value - 1;
			return value;
		}

		public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = GetSettingOrder(section)
				}
			}));
		}

		public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = browsable,
					CustomDrawer = customDrawer,
					HideDefaultButton = hideDefaultButton,
					Order = GetSettingOrder(section)
				}
			}));
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler)
		{
			configEntry.SettingChanged += delegate
			{
				settingChangedHandler();
			};
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}
	}
	public static class ObjectExtensions
	{
		public static T Ref<T>(this T o) where T : Object
		{
			if (!Object.op_Implicit((Object)(object)o))
			{
				return default(T);
			}
			return o;
		}
	}
}
namespace LicensePlate
{
	public sealed class ShipName : MonoBehaviour, TextReceiver
	{
		private ZNetView _netView;

		private NpcText _npcText;

		private ShipControlls _shipControlls;

		private Ship _ship;

		private string _shipName = string.Empty;

		private string _shipNameCache = string.Empty;

		private void Awake()
		{
			_shipControlls = ((Component)this).GetComponent<ShipControlls>();
			_ship = _shipControlls.Ref<ShipControlls>()?.m_ship;
			_netView = _shipControlls.Ref<ShipControlls>()?.m_nview;
			if (Object.op_Implicit((Object)(object)_shipControlls) && Object.op_Implicit((Object)(object)_ship) && Object.op_Implicit((Object)(object)_netView) && _netView.IsValid())
			{
				((MonoBehaviour)this).InvokeRepeating("UpdateShipName", 0f, 1f);
			}
		}

		private void UpdateShipName()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_netView) || !_netView.IsValid() || !Object.op_Implicit((Object)(object)_ship) || !PluginConfig.IsModEnabled.Value || !PluginConfig.ShowShipNames.Value)
			{
				ClearNpcText();
				((MonoBehaviour)this).CancelInvoke("UpdateShipName");
				return;
			}
			if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				ClearNpcText();
				return;
			}
			_shipName = _netView.m_zdo.GetString(LicensePlate.ShipLicensePlateHashCode, string.Empty);
			float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)this).gameObject.transform.position);
			if (Object.op_Implicit((Object)(object)_npcText?.m_gui) && _shipName.Length > 0 && num > PluginConfig.ShipNameMinimumDistance.Value)
			{
				UpdateNpcTextValue(_shipName);
				return;
			}
			ClearNpcText();
			if (_shipName.Length > 0 && Object.op_Implicit((Object)(object)Player.m_localPlayer) && num > PluginConfig.ShipNameMinimumDistance.Value && num < PluginConfig.ShipNameCutoffDistance.Value)
			{
				SetNpcText(_shipName);
			}
		}

		private void ClearNpcText()
		{
			if (_npcText != null)
			{
				Chat.m_instance.ClearNpcText(_npcText);
				_npcText = null;
			}
		}

		private void SetNpcText(string shipName)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Chat.m_instance.SetNpcText(((Component)_ship).gameObject, PluginConfig.ShipNameDisplayOffset.Value, PluginConfig.ShipNameCutoffDistance.Value, PluginConfig.ShipNameTimeToLive.Value, string.Empty, GetSanitizedShipName(shipName), false);
			_shipNameCache = shipName;
			_npcText = Chat.m_instance.FindNpcText(((Component)_ship).gameObject);
			if (Object.op_Implicit((Object)(object)_npcText?.m_gui))
			{
				CustomizeNpcText();
			}
		}

		public void UpdateNpcTextValue(string shipName)
		{
			if (!(shipName == _shipNameCache))
			{
				_shipNameCache = shipName;
				((TMP_Text)_npcText.m_textField).text = GetSanitizedShipName(shipName);
			}
		}

		private string GetSanitizedShipName(string shipName)
		{
			if (shipName.Length > 64)
			{
				shipName = shipName.Substring(0, 64);
			}
			if (PluginConfig.ShipNameStripHtmlTags.Value)
			{
				shipName = LicensePlate.HtmlTagsRegex.Replace(shipName, string.Empty);
			}
			return shipName;
		}

		private void CustomizeNpcText()
		{
			((TMP_Text)_npcText.m_textField).enableAutoSizing = false;
			((TMP_Text)_npcText.m_textField).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)_npcText.m_textField).overflowMode = (TextOverflowModes)0;
			((TMP_Text)_npcText.m_textField).fontSize = PluginConfig.ShipNameFontSize.Value;
			((TMP_Text)_npcText.m_textField).fontSizeMax = 64f;
			CustomizeNpcTextBackground(((Component)_npcText.m_gui.transform.Find("Image")).gameObject);
		}

		private void CustomizeNpcTextBackground(GameObject background)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			background.GetComponent<RectTransform>().SetSizeWithCurrentAnchors((Axis)1, 60f);
			Image component = background.GetComponent<Image>();
			Color color = ((Graphic)component).color;
			color.a = 0.5f;
			((Graphic)component).color = color;
		}

		public string GetText()
		{
			if (!Object.op_Implicit((Object)(object)_netView) || !_netView.IsValid())
			{
				return string.Empty;
			}
			return _netView.m_zdo.GetString(LicensePlate.ShipLicensePlateHashCode, string.Empty);
		}

		public void SetText(string text)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_netView) && _netView.IsValid() && Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				LicensePlate.LogInfo($"Setting Ship ({_netView.m_zdo.m_uid}) name to: {text}");
				_netView.m_zdo.Set(LicensePlate.ShipLicensePlateHashCode, text);
				_netView.m_zdo.Set(LicensePlate.LicensePlateLastSetByHashCode, Player.m_localPlayer.GetPlayerID());
				UpdateShipName();
			}
		}
	}
	public sealed class VagonName : MonoBehaviour, TextReceiver
	{
		private ZNetView _netView;

		private NpcText _npcText;

		private Vagon _vagon;

		private string _vagonName = string.Empty;

		private string _vagonNameCache = string.Empty;

		private void Awake()
		{
			_vagon = ((Component)this).GetComponent<Vagon>();
			_netView = ((Component)this).GetComponent<ZNetView>();
			if (Object.op_Implicit((Object)(object)_vagon) && Object.op_Implicit((Object)(object)_netView) && _netView.IsValid())
			{
				((MonoBehaviour)this).InvokeRepeating("UpdateVagonName", 0f, 1f);
			}
		}

		private void UpdateVagonName()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_netView) || !_netView.IsValid() || !PluginConfig.IsModEnabled.Value || !PluginConfig.ShowCartNames.Value)
			{
				ClearNpcText();
				((MonoBehaviour)this).CancelInvoke("UpdateVagonName");
				return;
			}
			if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				ClearNpcText();
				return;
			}
			_vagonName = _netView.m_zdo.GetString(LicensePlate.VagonLicensePlateHashCode, string.Empty);
			float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position + _vagon.m_attachOffset, _vagon.m_attachPoint.position);
			if (Object.op_Implicit((Object)(object)_npcText?.m_gui) && _vagonName.Length > 0 && num > PluginConfig.CartNameMinimumDistance.Value)
			{
				UpdateNpcTextValue(_vagonName);
				return;
			}
			ClearNpcText();
			if (_vagonName.Length > 0 && Object.op_Implicit((Object)(object)Player.m_localPlayer) && num > PluginConfig.CartNameMinimumDistance.Value && num < PluginConfig.CartNameCutoffDistance.Value)
			{
				SetNpcText(_vagonName);
			}
		}

		private void ClearNpcText()
		{
			if (_npcText != null)
			{
				Chat.m_instance.ClearNpcText(_npcText);
				_npcText = null;
			}
			_vagonNameCache = string.Empty;
		}

		private void SetNpcText(string vagonName)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Chat.m_instance.SetNpcText(((Component)this).gameObject, PluginConfig.CartNameDisplayOffset.Value, PluginConfig.CartNameCutoffDistance.Value, PluginConfig.CartNameTimeToLive.Value, string.Empty, GetSanitizedVagonName(vagonName), false);
			_vagonNameCache = vagonName;
			_npcText = Chat.m_instance.FindNpcText(((Component)this).gameObject);
			if (Object.op_Implicit((Object)(object)_npcText?.m_gui))
			{
				CustomizeNpcText();
			}
		}

		private void UpdateNpcTextValue(string vagonName)
		{
			if (!(vagonName == _vagonNameCache))
			{
				_vagonNameCache = vagonName;
				((TMP_Text)_npcText.m_textField).text = GetSanitizedVagonName(vagonName);
			}
		}

		private string GetSanitizedVagonName(string vagonName)
		{
			if (vagonName.Length > 64)
			{
				vagonName = vagonName.Substring(0, 64);
			}
			if (PluginConfig.CartNameStripHtmlTags.Value)
			{
				vagonName = LicensePlate.HtmlTagsRegex.Replace(vagonName, string.Empty);
			}
			return vagonName;
		}

		private void CustomizeNpcText()
		{
			((TMP_Text)_npcText.m_textField).enableAutoSizing = false;
			((TMP_Text)_npcText.m_textField).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)_npcText.m_textField).overflowMode = (TextOverflowModes)0;
			((TMP_Text)_npcText.m_textField).fontSize = PluginConfig.CartNameFontSize.Value;
			((TMP_Text)_npcText.m_textField).fontSizeMax = 64f;
			CustomizeNpcTextBackground(((Component)_npcText.m_gui.transform.Find("Image")).gameObject);
		}

		private void CustomizeNpcTextBackground(GameObject background)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			background.GetComponent<RectTransform>().SetSizeWithCurrentAnchors((Axis)1, 60f);
			Image component = background.GetComponent<Image>();
			Color color = ((Graphic)component).color;
			color.a = 0.5f;
			((Graphic)component).color = color;
		}

		public string GetText()
		{
			if (!Object.op_Implicit((Object)(object)_netView) || !_netView.IsValid())
			{
				return string.Empty;
			}
			return _netView.m_zdo.GetString(LicensePlate.VagonLicensePlateHashCode, string.Empty);
		}

		public void SetText(string text)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_netView) && _netView.IsValid() && Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				LicensePlate.LogInfo($"Setting Vagon ({_netView.m_zdo.m_uid}) name to: {text}");
				_netView.m_zdo.Set(LicensePlate.VagonLicensePlateHashCode, text);
				_netView.m_zdo.Set(LicensePlate.LicensePlateLastSetByHashCode, Player.m_localPlayer.GetPlayerID());
				UpdateVagonName();
			}
		}
	}
	[BepInPlugin("redseiko.valheim.licenseplate", "LicensePlate", "1.3.0")]
	public sealed class LicensePlate : BaseUnityPlugin
	{
		public const string PluginGuid = "redseiko.valheim.licenseplate";

		public const string PluginName = "LicensePlate";

		public const string PluginVersion = "1.3.0";

		public static readonly int ShipLicensePlateHashCode = StringExtensionMethods.GetStableHashCode("ShipLicensePlate");

		public static readonly int VagonLicensePlateHashCode = StringExtensionMethods.GetStableHashCode("VagonLicensePlate");

		public static readonly int LicensePlateLastSetByHashCode = StringExtensionMethods.GetStableHashCode("LicensePlateLastSetBy");

		public static readonly Regex HtmlTagsRegex = new Regex("<.*?>");

		private static ManualLogSource _logger;

		private Harmony _harmony;

		private void Awake()
		{
			_logger = ((BaseUnityPlugin)this).Logger;
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.licenseplate");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		public static void LogInfo(object obj)
		{
			_logger.LogInfo((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}");
		}

		public static void LogError(object obj)
		{
			_logger.LogError((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}");
		}
	}
	[HarmonyPatch(typeof(ShipControlls))]
	internal static class ShipControllsPatch
	{
		private static readonly Lazy<string> _renameText = new Lazy<string>(() => Localization.m_instance.Localize("\n[<color=yellow><b>$KEY_AltPlace + $KEY_Use</b></color>] $hud_rename"));

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostfix(ref ShipControlls __instance)
		{
			if (PluginConfig.IsModEnabled.Value && PluginConfig.ShowShipNames.Value)
			{
				((Component)__instance).gameObject.AddComponent<ShipName>();
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("Interact")]
		private static IEnumerable<CodeInstruction> InteractTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
			{
				new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Character), "GetStandingOnShip", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShipControlls), "m_ship"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Object), "op_Inequality", (Type[])null, (Type[])null), (string)null)
			}).Advance(5).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_3, (object)null),
				Transpilers.EmitDelegate<Func<bool, ShipControlls, bool, bool>>((Func<bool, ShipControlls, bool, bool>)StandingOnShipInequalityDelegate)
			})
				.InstructionEnumeration();
		}

		private static bool StandingOnShipInequalityDelegate(bool isNotEqual, ShipControlls shipControls, bool alt)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			ShipName shipName = default(ShipName);
			if (!isNotEqual && alt && PluginConfig.IsModEnabled.Value && PluginConfig.ShowShipNames.Value && PrivateArea.CheckAccess(((Component)shipControls).transform.position, 0f, true, false) && Object.op_Implicit((Object)(object)shipControls.m_nview) && shipControls.m_nview.IsValid() && shipControls.m_nview.IsOwner() && ((Component)shipControls).TryGetComponent<ShipName>(ref shipName))
			{
				TextInput.m_instance.RequestText((TextReceiver)(object)shipName, "$hud_rename", 64);
				return true;
			}
			return isNotEqual;
		}

		[HarmonyPostfix]
		[HarmonyPatch("GetHoverText")]
		private static void GetHoverTextPostfix(ref ShipControlls __instance, ref string __result)
		{
			if (PluginConfig.IsModEnabled.Value && PluginConfig.ShowShipNames.Value && Object.op_Implicit((Object)(object)__instance.m_nview) && __instance.m_nview.IsValid() && Object.op_Implicit((Object)(object)Player.m_localPlayer) && __instance.InUseDistance((Humanoid)(object)Player.m_localPlayer))
			{
				__result += _renameText.Value;
			}
		}
	}
	[HarmonyPatch(typeof(Vagon))]
	internal static class VagonPatch
	{
		private static readonly Lazy<string> _renameText = new Lazy<string>(() => Localization.m_instance.Localize("\n[<color=yellow><b>$KEY_AltPlace + $KEY_Use</b></color>] $hud_rename"));

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostfix(ref Vagon __instance)
		{
			if (PluginConfig.IsModEnabled.Value && PluginConfig.ShowCartNames.Value)
			{
				((Component)__instance).gameObject.AddComponent<VagonName>();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("Interact")]
		private static bool InteractPrefix(ref Vagon __instance, ref bool __result, bool hold, bool alt)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			VagonName vagonName = default(VagonName);
			if (alt && PluginConfig.IsModEnabled.Value && PluginConfig.ShowCartNames.Value && PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, true, false) && Object.op_Implicit((Object)(object)__instance.m_nview) && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner() && ((Component)__instance).TryGetComponent<VagonName>(ref vagonName))
			{
				TextInput.m_instance.RequestText((TextReceiver)(object)vagonName, "$hud_rename", 64);
				__result = true;
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("GetHoverText")]
		private static void GetHoverTextPostfix(ref Vagon __instance, ref string __result)
		{
			if (PluginConfig.IsModEnabled.Value && PluginConfig.ShowCartNames.Value && Object.op_Implicit((Object)(object)__instance.m_nview) && __instance.m_nview.IsValid())
			{
				__result += _renameText.Value;
			}
		}
	}
	public static class PluginConfig
	{
		public static ConfigEntry<bool> IsModEnabled { get; private set; }

		public static ConfigEntry<bool> ShowShipNames { get; private set; }

		public static ConfigEntry<float> ShipNameMinimumDistance { get; private set; }

		public static ConfigEntry<float> ShipNameCutoffDistance { get; private set; }

		public static ConfigEntry<Vector3> ShipNameDisplayOffset { get; private set; }

		public static ConfigEntry<float> ShipNameTimeToLive { get; private set; }

		public static ConfigEntry<int> ShipNameFontSize { get; private set; }

		public static ConfigEntry<bool> ShipNameStripHtmlTags { get; private set; }

		public static ConfigEntry<bool> ShowCartNames { get; private set; }

		public static ConfigEntry<float> CartNameMinimumDistance { get; private set; }

		public static ConfigEntry<float> CartNameCutoffDistance { get; private set; }

		public static ConfigEntry<Vector3> CartNameDisplayOffset { get; private set; }

		public static ConfigEntry<float> CartNameTimeToLive { get; private set; }

		public static ConfigEntry<int> CartNameFontSize { get; private set; }

		public static ConfigEntry<bool> CartNameStripHtmlTags { get; private set; }

		public static void BindConfig(ConfigFile config)
		{
			IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod.");
			BindShipNameConfig(config);
			BindCartNameConfig(config);
		}

		private static void BindShipNameConfig(ConfigFile config)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			ShowShipNames = config.BindInOrder("ShipName", "showShipNames", defaultValue: true, "Show custom names over ships.");
			ShipNameMinimumDistance = config.BindInOrder("ShipName", "shipNameMinimumDistance", 0f, "Minimum distance for custom ship names to appear/disappear. Must be less than cutoff distance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f));
			ShipNameMinimumDistance.OnSettingChanged<float>(ValidateShipNameMinimumDistance);
			ShipNameCutoffDistance = config.BindInOrder("ShipName", "shipNameCutoffDistance", 25f, "Cutoff distance for custom ship names to appear/disappear.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 40f));
			ShipNameCutoffDistance.OnSettingChanged<float>(ValidateShipNameMinimumDistance);
			ShipNameDisplayOffset = config.BindInOrder<Vector3>("ShipName", "shipNameDisplayOffset", Vector3.up, "Display offset for custom ship names.");
			ShipNameTimeToLive = config.BindInOrder("ShipName", "shipNameTimeToLive", 60f, "Time (in seconds) for a custom ship name to be displayed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f));
			ShipNameFontSize = config.BindInOrder("ShipName", "shipNameFontSize", 20, "Font size for custom ship names.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 64));
			ShipNameStripHtmlTags = config.BindInOrder("ShipName", "shipNameStripHtmlTags", defaultValue: false, "If true, html tags will be stripped from custom ship names when they are displayed.");
			static void ValidateShipNameMinimumDistance()
			{
				ShipNameMinimumDistance.Value = Mathf.Min(ShipNameMinimumDistance.Value, ShipNameCutoffDistance.Value);
			}
		}

		private static void BindCartNameConfig(ConfigFile config)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			ShowCartNames = config.BindInOrder("CartName", "showCartNames", defaultValue: true, "Show custom names over carts.");
			CartNameMinimumDistance = config.BindInOrder("CartName", "cartNameMinimumDistance", 0f, "Minimum distance for custom cart names to appear/disappear. Must be less than cutoff distance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f));
			CartNameMinimumDistance.OnSettingChanged<float>(ValidateCartNameMinimumDistance);
			CartNameCutoffDistance = config.BindInOrder("CartName", "cartNameCutoffDistance", 10f, "Cutoff distance for custom cart names to appear/disappear.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 25f));
			CartNameCutoffDistance.OnSettingChanged<float>(ValidateCartNameMinimumDistance);
			CartNameDisplayOffset = config.BindInOrder<Vector3>("CartName", "cartNameDisplayOffset", Vector3.up, "Display offset for custom cart names.");
			CartNameTimeToLive = config.BindInOrder("CartName", "cartNameTimeToLive", 60f, "Time (in seconds) for a custom cart name to be displayed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f));
			CartNameFontSize = config.BindInOrder("CartName", "cartNameFontSize", 20, "Font size for custom cart names.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 64));
			CartNameStripHtmlTags = config.BindInOrder("CartName", "cartNameStripHtmlTags", defaultValue: false, "If true, html tags will be stripped from custom cart names when they are displayed.");
			static void ValidateCartNameMinimumDistance()
			{
				CartNameMinimumDistance.Value = Mathf.Min(CartNameMinimumDistance.Value, CartNameCutoffDistance.Value);
			}
		}
	}
}