Decompiled source of PEAKTrails v1.1.3

plugins/com.github.darmuh.PEAKTrails.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
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 UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using pworld.Scripts.Extensions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("darmuh")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion("1.1.3+3d8827df7ad667fdeec0a566ac5f82a203750122")]
[assembly: AssemblyProduct("com.github.darmuh.PEAKTrails")]
[assembly: AssemblyTitle("PEAKTrails")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.3.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PEAKTrails
{
	internal class Misc
	{
		[CompilerGenerated]
		private sealed class <TransitionHideColor>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public TrailRenderer trail;

			public Character __instance;

			private float <start>5__2;

			private float <end>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TransitionHideColor>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					trailsActive.Remove(trail);
					<start>5__2 = trail.startColor.a;
					<end>5__3 = trail.endColor.a;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!Patching.PlayerVisualUpdatePatch.ShowTrails && trail.startColor.a > 0f)
				{
					Color playerColor = __instance.refs.customization.PlayerColor;
					trail.startColor = new Color(playerColor.r, playerColor.g, playerColor.b, <start>5__2);
					trail.endColor = new Color(playerColor.r, playerColor.g, playerColor.b, <end>5__3);
					<start>5__2 -= Time.deltaTime;
					<end>5__3 -= Time.deltaTime;
					if (<end>5__3 < 0f)
					{
						<end>5__3 = 0f;
					}
					if (<start>5__2 < 0f)
					{
						<start>5__2 = 0f;
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <TransitionShowColor>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public TrailRenderer trail;

			public Character __instance;

			public float end;

			public float start;

			private float <currentStart>5__2;

			private float <currentEnd>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TransitionShowColor>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (trailsActive.Contains(trail))
					{
						return false;
					}
					trailsActive.Add(trail);
					<currentStart>5__2 = trail.startColor.a;
					<currentEnd>5__3 = trail.endColor.a;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (Patching.PlayerVisualUpdatePatch.ShowTrails && trail.startColor.a < start)
				{
					Color playerColor = __instance.refs.customization.PlayerColor;
					<currentStart>5__2 += Time.deltaTime;
					<currentEnd>5__3 += Time.deltaTime;
					if (<currentEnd>5__3 > end)
					{
						<currentEnd>5__3 = end;
					}
					if (<currentStart>5__2 > start)
					{
						<currentStart>5__2 = start;
					}
					trail.startColor = new Color(playerColor.r, playerColor.g, playerColor.b, <currentStart>5__2);
					trail.endColor = new Color(playerColor.r, playerColor.g, playerColor.b, <currentEnd>5__3);
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal static List<TrailRenderer> trailsActive = new List<TrailRenderer>();

		[IteratorStateMachine(typeof(<TransitionShowColor>d__1))]
		internal static IEnumerator TransitionShowColor(TrailRenderer trail, Character __instance, float start, float end)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TransitionShowColor>d__1(0)
			{
				trail = trail,
				__instance = __instance,
				start = start,
				end = end
			};
		}

		[IteratorStateMachine(typeof(<TransitionHideColor>d__2))]
		internal static IEnumerator TransitionHideColor(TrailRenderer trail, Character __instance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TransitionHideColor>d__2(0)
			{
				trail = trail,
				__instance = __instance
			};
		}

		internal static string GetEmoteFrom(Patching.TrailAction action)
		{
			return action switch
			{
				Patching.TrailAction.DanceEmote => "A_Scout_Emote_Dance1", 
				Patching.TrailAction.NoNoEmote => "A_Scout_Emote_Nono", 
				Patching.TrailAction.SaluteEmote => "A_Scout_Emote_Salute", 
				Patching.TrailAction.ThinkEmote => "A_Scout_Emote_Think", 
				Patching.TrailAction.ThumbsUpEmote => "A_Scout_Emote_ThumbsUp", 
				Patching.TrailAction.CrossedArmsEmote => "A_Scout_Emote_CrossedArms", 
				Patching.TrailAction.PlayDeadEmote => "A_Scout_Emote_Flex", 
				Patching.TrailAction.ShrugEmote => "A_Scout_Emote_Shrug", 
				_ => "NoValidEmotesDetected", 
			};
		}
	}
	internal class ModConfig
	{
		internal static ConfigEntry<float> TrailLength { get; private set; }

		internal static ConfigEntry<float> TrailStartWidth { get; private set; }

		internal static ConfigEntry<float> TrailEndWidth { get; private set; }

		internal static ConfigEntry<float> TrailStartAlpha { get; private set; }

		internal static ConfigEntry<float> TrailEndAlpha { get; private set; }

		internal static ConfigEntry<bool> ShowLocalTrail { get; private set; }

		internal static ConfigEntry<Patching.ShowTrailSetting> VisibilitySetting { get; private set; }

		internal static ConfigEntry<string> ToggleKey { get; set; }

		internal static ConfigEntry<float> TogglePressDelay { get; private set; }

		internal static ConfigEntry<Patching.TrailAction> ToggleAction { get; private set; }

		internal static ConfigEntry<Patching.TrailItem> ToggleItem { get; private set; }

		internal static void Init(ConfigFile config)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			TrailLength = config.Bind<float>("General", "Trail Length", 360f, new ConfigDescription("This sets the length of the trail in seconds. The end of the trail will fade/disappear\nThe maximum value for this config item is 30 minutes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 1800f), Array.Empty<object>()));
			TrailStartWidth = config.Bind<float>("General", "Trail Start Width", 0.22f, new ConfigDescription("This sets the width of the trail line itself", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			TrailEndWidth = config.Bind<float>("General", "Trail End Width", 0f, new ConfigDescription("This sets the width of the trail line itself", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			TrailStartAlpha = config.Bind<float>("General", "Trail Start Alpha", 0.65f, new ConfigDescription("This sets the transparency of the start of the trail", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>()));
			TrailEndAlpha = config.Bind<float>("General", "Trail End Alpha", 0.25f, new ConfigDescription("This sets the transparency of the end of the trail.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>()));
			ShowLocalTrail = config.Bind<bool>("General", "Show Self Trail", true, "If disabled, will not render a trail for yourself (local client)");
			VisibilitySetting = config.Bind<Patching.ShowTrailSetting>("General", "Visbility Setting", Patching.ShowTrailSetting.ToggleKey, "Determines how trail visibility will be handled.\r\nAlwaysOn means the trail will always be visible.\r\nToggleKey means the trail can be toggled on/off with a keybind.\r\nOnActionShow means the trail will only be visible when a player is performing a specific action.\r\nOnActionHide means the trail will always be visible except when a player is performing a specific action.\r\nOnHoldItem means the trail will be visible while holding a specific item.\r\nOnItemUseButton means the trail will be visible when a player is pressing the primary or secondary use buttons while holding a specific item.");
			TogglePressDelay = config.Bind<float>("Controls", "Visibility Press Delay", 0.2f, new ConfigDescription("This sets the amount of time additional key presses will not affect trail visbility after the Visibility Toggle Key has been pressed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
			ToggleAction = config.Bind<Patching.TrailAction>("Controls", "Visibility Toggle Action", Patching.TrailAction.Reach, "When Visibility Setting is set to OnAction, this action will be used to display player trails");
			ToggleItem = config.Bind<Patching.TrailItem>("Controls", "Visibility Toggle Item", Patching.TrailItem.Guidebook, "When Visibility Setting is set to OnHoldItem OR OnItemUsed, this item will be used to display player trails");
		}
	}
	internal class Patching
	{
		internal enum ShowTrailSetting
		{
			AlwaysOn,
			ToggleKey,
			OnActionShow,
			OnActionHide,
			OnHoldItem,
			OnItemUseButton
		}

		internal enum TrailAction
		{
			Reach,
			Crouch,
			SaluteEmote,
			ThumbsUpEmote,
			NoNoEmote,
			ThinkEmote,
			PlayDeadEmote,
			ShrugEmote,
			CrossedArmsEmote,
			DanceEmote
		}

		internal enum TrailItem
		{
			Binoculars,
			BingBong,
			Bugle,
			Coconut,
			Conch,
			Compass,
			Flare,
			Guidebook,
			Lantern
		}

		[HarmonyPatch(typeof(Character), "Update")]
		internal class PlayerVisualUpdatePatch
		{
			internal static bool ShowTrails;

			internal static float UpdateDelay;

			private static void Postfix(Character __instance)
			{
				if (__instance.isBot)
				{
					return;
				}
				if (__instance.IsLocal)
				{
					UpdateLocalTrailControls(__instance);
				}
				TrailRenderer val = TryGetTrailRenderer(__instance);
				if (!((Behaviour)__instance.data).enabled || __instance.data.dead || (__instance.IsLocal && !ModConfig.ShowLocalTrail.Value))
				{
					val.emitting = false;
					return;
				}
				if (!val.emitting)
				{
					val.emitting = true;
				}
				UpdateTrailColor(__instance, val);
			}

			private static void UpdateLocalTrailControls(Character __instance)
			{
				if (ModConfig.VisibilitySetting.Value == ShowTrailSetting.AlwaysOn)
				{
					AlwaysOn();
				}
				else if (ModConfig.VisibilitySetting.Value == ShowTrailSetting.ToggleKey)
				{
					KeyListener();
				}
				else if (ActionSettings(ModConfig.VisibilitySetting.Value))
				{
					ActionListener(__instance);
				}
				else
				{
					ItemListener(__instance);
				}
			}

			private static bool ActionSettings(ShowTrailSetting setting)
			{
				if (setting == ShowTrailSetting.OnActionHide || setting == ShowTrailSetting.OnActionShow)
				{
					return true;
				}
				return false;
			}

			private static void AlwaysOn()
			{
				if (!ShowTrails)
				{
					ShowTrails = true;
				}
			}

			private static void ActionListener(Character __instance)
			{
				if (ModConfig.VisibilitySetting.Value == ShowTrailSetting.OnActionShow)
				{
					ShowTrails = ActionShowTrail(__instance);
				}
				else
				{
					ShowTrails = !ActionShowTrail(__instance);
				}
			}

			private static bool ActionShowTrail(Character __instance)
			{
				if (ModConfig.ToggleAction.Value == TrailAction.Reach)
				{
					return __instance.data.isReaching;
				}
				if (ModConfig.ToggleAction.Value == TrailAction.Crouch)
				{
					return __instance.data.isCrouching;
				}
				string emoteFrom = Misc.GetEmoteFrom(ModConfig.ToggleAction.Value);
				return PExt.IsPlaying(__instance.refs.animator, emoteFrom, 0);
			}

			private static void ItemListener(Character __instance)
			{
				Item currentItem = __instance.data.currentItem;
				if ((Object)(object)currentItem == (Object)null)
				{
					ShowTrails = false;
				}
				else if (IsValidItem(currentItem))
				{
					if (ModConfig.VisibilitySetting.Value == ShowTrailSetting.OnHoldItem)
					{
						ShowTrails = true;
					}
					else
					{
						ShowTrails = CharacterInput.action_usePrimary.IsPressed() || CharacterInput.action_useSecondary.IsPressed();
					}
				}
				else
				{
					ShowTrails = false;
				}
			}

			private static bool IsValidItem(Item item)
			{
				Item item2 = item;
				if ((Object)(object)item2 == (Object)null)
				{
					return false;
				}
				return ValidItems.Any((string x) => item2.UIData.itemName.Contains(x, StringComparison.InvariantCultureIgnoreCase) && ModConfig.ToggleItem.Value == (TrailItem)ValidItems.IndexOf(x));
			}

			private static void KeyListener()
			{
				if (ModConfig.VisibilitySetting.Value == ShowTrailSetting.ToggleKey)
				{
					if (UpdateDelay > 0f)
					{
						UpdateDelay -= Time.deltaTime;
					}
					if (Plugin.ToggleView.IsPressed() && UpdateDelay <= 0f)
					{
						ShowTrails = !ShowTrails;
						UpdateDelay = ModConfig.TogglePressDelay.Value;
						Plugin.Log.LogMessage((object)$"Trail toggled to [ {ShowTrails} ]");
					}
				}
			}

			private static void UpdateTrailColor(Character __instance, TrailRenderer trail)
			{
				if (ShowTrails)
				{
					((MonoBehaviour)__instance).StartCoroutine(Misc.TransitionShowColor(trail, __instance, ModConfig.TrailStartAlpha.Value, ModConfig.TrailEndAlpha.Value));
				}
				else
				{
					((MonoBehaviour)__instance).StartCoroutine(Misc.TransitionHideColor(trail, __instance));
				}
			}

			private static TrailRenderer TryGetTrailRenderer(Character __instance)
			{
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Expected O, but got Unknown
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				TrailRenderer val = default(TrailRenderer);
				if (!((Component)__instance.refs.animationPositionTransform).gameObject.TryGetComponent<TrailRenderer>(ref val))
				{
					val = ((Component)__instance.refs.animationPositionTransform).gameObject.AddComponent<TrailRenderer>();
					Color playerColor = __instance.refs.customization.PlayerColor;
					val.startColor = new Color(playerColor.r, playerColor.g, playerColor.b, ModConfig.TrailStartAlpha.Value);
					val.endColor = new Color(playerColor.g, playerColor.b, playerColor.a, ModConfig.TrailEndAlpha.Value);
					Plugin.Log.LogDebug((object)"Trail created!");
				}
				((Renderer)val).material = new Material(Shader.Find("Sprites/Default"));
				val.time = ModConfig.TrailLength.Value;
				val.startWidth = ModConfig.TrailStartWidth.Value;
				val.endWidth = ModConfig.TrailEndWidth.Value;
				return val;
			}
		}

		internal static readonly List<string> ValidItems = new List<string>(9) { "Binoculars", "Bing Bong", "Bugle", "Coconut", "Conch", "Compass", "Flare", "Guidebook", "Lantern" };
	}
	[BepInPlugin("com.github.darmuh.PEAKTrails", "PEAKTrails", "1.1.3")]
	public class Plugin : BaseUnityPlugin
	{
		internal static InputAction ToggleView = new InputAction("Toggle Trail", (InputActionType)0, (string)null, (string)null, (string)null, (string)null);

		internal static string LastBinding = string.Empty;

		public const string Id = "com.github.darmuh.PEAKTrails";

		internal static ManualLogSource Log { get; private set; } = null;


		public static string Name => "PEAKTrails";

		public static string Version => "1.1.3";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			ModConfig.Init(((BaseUnityPlugin)this).Config);
			((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			Log.LogInfo((object)("Plugin " + Name + " is loaded with version " + Version + "!"));
		}

		private void Start()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			ModConfig.ToggleKey = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "Visibility Toggle Key", "/Keyboard/t", new ConfigDescription("When Visbility Setting is set to ToggleKey, this key will be used to toggle the trail visibility.\nSet this to a valid unity control string.\nA listing of possible control strings is generated on game launch.", (AcceptableValueBase)(object)new AcceptableValueList<string>(GenerateValidConfigValues().ToArray()), Array.Empty<object>()));
			InputActionSetupExtensions.AddBinding(ToggleView, ModConfig.ToggleKey.Value, (string)null, (string)null, (string)null);
			LastBinding = ModConfig.ToggleKey.Value;
			ToggleView.Enable();
			CollectionExtensions.AddItem<InputAction>((IEnumerable<InputAction>)InputSystem.actions, ToggleView);
		}

		private void OnSettingChanged(object sender, SettingChangedEventArgs settingChangedArg)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (settingChangedArg.ChangedSetting != null && settingChangedArg.ChangedSetting == ModConfig.ToggleKey)
			{
				BindingSyntax val = InputActionSetupExtensions.ChangeBindingWithPath(ToggleView, LastBinding);
				((BindingSyntax)(ref val)).Erase();
				InputActionSetupExtensions.AddBinding(ToggleView, ModConfig.ToggleKey.Value, (string)null, (string)null, (string)null);
				LastBinding = ModConfig.ToggleKey.Value;
			}
		}

		private static List<string> GenerateValidConfigValues()
		{
			//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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			List<string> source = new List<string>(1) { "/Keyboard/anyKey" };
			Enumerator<InputDevice> enumerator = InputSystem.devices.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					InputDevice current = enumerator.Current;
					if (current == null)
					{
						continue;
					}
					Enumerator<InputControl> enumerator2 = current.allControls.GetEnumerator();
					try
					{
						while (enumerator2.MoveNext())
						{
							InputControl control = enumerator2.Current;
							if (!source.Any((string d) => d.Equals(control.path, StringComparison.InvariantCultureIgnoreCase)))
							{
								list.Add(control.path);
							}
						}
					}
					finally
					{
						((IDisposable)enumerator2).Dispose();
					}
				}
				return list;
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ConstantExpectedAttribute : Attribute
	{
		public object? Min { get; set; }

		public object? Max { get; set; }
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class OverloadResolutionPriorityAttribute : Attribute
	{
		public int Priority { get; }

		public OverloadResolutionPriorityAttribute(int priority)
		{
			Priority = priority;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ParamCollectionAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}