Decompiled source of WeaponWheel2 v2.1.0

WeaponWheelSelect.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using InControl;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WeaponWheelSelect")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WeaponWheelSelect")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("57445610-0892-47c3-be16-453172104123")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace WeaponWheelSelect;

public static class WeaponWheelSelectController
{
	[HarmonyPatch(typeof(GameUIRoot), "HandleMetalGearGunSelect")]
	private class WeaponWheelPatch
	{
		private static bool Prefix(GameUIRoot __instance, PlayerController targetPlayer, int numToL, ref IEnumerator __result)
		{
			if (!OptionalGunfig.WheelEnabled())
			{
				return true;
			}
			__result = HandleWeaponWheelSelect(targetPlayer, numToL);
			return false;
		}
	}

	private const int _SEGMENT_SIZE = 201;

	internal static Shader radialShader;

	private static RadialSegment[] segments;

	private static dfLabel ammoLabel;

	private static bool weaponWheelActive;

	public static void Init()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		string text = (((int)Application.platform == 13) ? "linux" : (((int)Application.platform == 1) ? "osx" : "windows"));
		AssetBundle val = LoadAssetBundleFromResource("WeaponWheelSelect.AssetBundles.wwshaders-" + text);
		radialShader = val.LoadAsset<Shader>("assets/weaponwheel.shader");
	}

	private static AssetBundle LoadAssetBundleFromResource(string filePath)
	{
		using (Stream stream = Assembly.GetCallingAssembly().GetManifestResourceStream(filePath))
		{
			if (stream != null)
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				return AssetBundle.LoadFromMemory(array);
			}
		}
		ETGModConsole.Log((object)("No bytes found in " + filePath), false);
		return null;
	}

	private static Vector2 GetCenteredMousePosition()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: 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)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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)
		Vector2 mousePosition = BraveInput.GetInstanceForPlayer(0).MousePosition;
		mousePosition.y = (float)Screen.height - mousePosition.y;
		Vector2 val = mousePosition;
		Rect safeArea = Screen.safeArea;
		return val - ((Rect)(ref safeArea)).center;
	}

	private static void CleanUpWeaponWheel(PlayerController targetPlayer, GameUIAmmoController ammoController)
	{
		RadialSegment[] array = segments;
		foreach (RadialSegment radialSegment in array)
		{
			radialSegment.Destroy();
		}
		if ((Object)(object)ammoLabel != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)ammoLabel).gameObject);
			ammoLabel = null;
		}
		Pixelator.Instance.fade = 1f;
		BraveTime.ClearMultiplier(((Component)GameUIRoot.Instance).gameObject);
		targetPlayer.ClearInputOverride("metal gear");
		GameUIRoot.Instance.m_metalGearGunSelectActive = false;
		((dfControl)ammoController.GunAmmoCountLabel).IsVisible = true;
		weaponWheelActive = false;
	}

	private static string FormatWeaponText(Gun gun, bool showAmmo, bool showName)
	{
		if (showAmmo && showName)
		{
			string text = (gun.InfiniteAmmo ? "[sprite \"infinite-big\"]" : $"{gun.ammo}/{gun.AdjustedMaxAmmo}");
			return text + "\n" + ((PickupObject)gun).EncounterNameOrDisplayName;
		}
		if (showAmmo)
		{
			return gun.InfiniteAmmo ? "[sprite \"infinite-big\"]" : $"{gun.ammo}/{gun.AdjustedMaxAmmo}";
		}
		return showName ? ((PickupObject)gun).EncounterNameOrDisplayName : "";
	}

	private static IEnumerator HandleWeaponWheelSelect(PlayerController targetPlayer, int numToL)
	{
		if (weaponWheelActive)
		{
			yield break;
		}
		weaponWheelActive = true;
		GameUIRoot UIRoot = GameUIRoot.Instance;
		dfGUIManager GUIManager = UIRoot.m_manager;
		GameUIAmmoController ammoController = UIRoot.ammoControllers[0];
		if ((int)GameManager.Instance.CurrentGameType == 1)
		{
			ammoController = UIRoot.ammoControllers[targetPlayer.IsPrimaryPlayer ? 1 : 0];
		}
		BraveInput inputInstance = BraveInput.GetInstanceForPlayer(targetPlayer.PlayerIDX);
		while (ammoController.IsFlipping)
		{
			if (!((OneAxisInputControl)inputInstance.ActiveActions.GunQuickEquipAction).IsPressed && !targetPlayer.ForceMetalGearMenu)
			{
				targetPlayer.DoQuickEquip();
				yield break;
			}
			yield return null;
		}
		if ((int)GameManager.Instance.CurrentGameType == 1)
		{
			UIRoot.ToggleItemPanels(false);
		}
		UIRoot.ClearGunName(targetPlayer.IsPrimaryPlayer);
		targetPlayer.SetInputOverride("metal gear");
		BraveTime.RegisterTimeScaleMultiplier(0.05f, ((Component)UIRoot).gameObject);
		UIRoot.m_metalGearGunSelectActive = true;
		Tribool gunSelectPhase = Tribool.Unready;
		List<Gun> playerGuns = targetPlayer.inventory.AllGuns;
		if (playerGuns.Count <= 1)
		{
			UIRoot.m_metalGearGunSelectActive = false;
			yield break;
		}
		float totalTimeMetalGeared = 0f;
		Pixelator.Instance.FadeColor = Color.black;
		float ignoreStickTimer = 0f;
		Vector2 mousePosition = GetCenteredMousePosition();
		Vector2 lastMousePosition = mousePosition;
		ammoLabel = new GameObject("WeaponWheelSelectLabel").AddComponent<dfLabel>();
		float cachedGuiScale = 0f;
		int hoveredIndex = 0;
		int numGuns = 0;
		bool showAmmo = OptionalGunfig.AmmoEnabled();
		bool showName = OptionalGunfig.NameEnabled();
		bool smallLabel = showAmmo && !showName;
		int labelHeight = (smallLabel ? 64 : 192);
		while (UIRoot.m_metalGearGunSelectActive)
		{
			Pixelator.Instance.fade = Mathf.Lerp(1f, 0.5f, totalTimeMetalGeared * 8f);
			if ((!((OneAxisInputControl)inputInstance.ActiveActions.GunQuickEquipAction).IsPressed && !GameManager.Instance.PrimaryPlayer.ForceMetalGearMenu) || GameManager.IsBossIntro || GameManager.Instance.IsPaused || GameManager.Instance.IsLoadingLevel)
			{
				UIRoot.m_metalGearGunSelectActive = false;
				break;
			}
			if (gunSelectPhase == Tribool.Unready)
			{
				UIRoot.GunventoryFolded = false;
				yield return null;
				numGuns = playerGuns.Count;
				segments = new RadialSegment[numGuns];
				hoveredIndex = Mathf.Clamp(playerGuns.IndexOf(((GameActor)targetPlayer).CurrentGun), 0, numGuns - 1);
				int gap = ((numGuns <= 20) ? ((numGuns > 15) ? 2 : ((numGuns > 10) ? 5 : 10)) : 0);
				float dfScale = GameUIUtility.GetCurrentTK2D_DFScale(GUIManager);
				float angle = 360f / (float)numGuns;
				bool useColor = OptionalGunfig.ColorEnabled();
				for (int i = 0; i < numGuns; i++)
				{
					float rotation = (float)i * angle;
					RadialSegment segment = new RadialSegment(201f, angle - (float)gap, rotation, useColor, i == hoveredIndex && OptionalGunfig.HighlightEnabled());
					segments[i] = segment;
					segment.AssignGun(playerGuns[i], dfScale);
					segment.SetHovered(i == hoveredIndex);
				}
				((Component)ammoLabel).transform.parent = ((Component)GUIManager).transform;
				((dfControl)ammoLabel).Size = new Vector2(256f, (float)labelHeight);
				dfLabel obj = ammoLabel;
				obj.TextScale *= 3f;
				ammoLabel.TextAlignment = (TextAlignment)1;
				ammoLabel.BackgroundColor = Color32.op_Implicit(Vector3Extensions.WithAlpha(Color.blue, 0.5f));
				ammoLabel.ProcessMarkup = true;
				ammoLabel.ColorizeSymbols = false;
				ammoLabel.WordWrap = true;
				ammoLabel.Text = FormatWeaponText(((GameActor)targetPlayer).CurrentGun, showAmmo, showName);
				((dfControl)ammoLabel).Anchor = (dfAnchorStyle)192;
				if (!smallLabel)
				{
					dfLabel obj2 = ammoLabel;
					((dfControl)obj2).Position = ((dfControl)obj2).Position + new Vector3(0f, -32f, 0f);
				}
				gunSelectPhase = Tribool.Ready;
			}
			if (numGuns != playerGuns.Count)
			{
				CleanUpWeaponWheel(targetPlayer, ammoController);
				yield break;
			}
			GungeonActions currentActions = inputInstance.ActiveActions;
			InputDevice currentDevice = ((PlayerActionSet)currentActions).Device;
			bool gunUp = inputInstance.IsKeyboardAndMouse(true) && ((OneAxisInputControl)currentActions.GunUpAction).WasPressed;
			bool gunDown = inputInstance.IsKeyboardAndMouse(true) && ((OneAxisInputControl)currentActions.GunDownAction).WasPressed;
			int targetIndex2 = hoveredIndex;
			mousePosition = GetCenteredMousePosition();
			Vector2 val = lastMousePosition - mousePosition;
			if (((Vector2)(ref val)).sqrMagnitude >= 16f)
			{
				float segmentWidth = GUIManager.UIScale * 0.375f * 201f;
				if (((Vector2)(ref mousePosition)).magnitude > segmentWidth)
				{
					float mouseAngle = BraveMathCollege.ClampAngle360(Mathf.Atan2(mousePosition.y, 0f - mousePosition.x) * 57.29578f);
					targetIndex2 = Mathf.FloorToInt(0.5f + (float)segments.Length * mouseAngle / 360f);
				}
				lastMousePosition = mousePosition;
			}
			else
			{
				targetIndex2 -= (gunUp ? 1 : (gunDown ? (-1) : 0));
			}
			if (!gunUp && !gunDown && currentDevice != null && (!inputInstance.IsKeyboardAndMouse(true) || GameManager.Options.AllowMoveKeysToChangeGuns))
			{
				bool dpadUp = ((OneAxisInputControl)currentDevice.DPadRight).WasPressedRepeating || ((OneAxisInputControl)currentDevice.DPadUp).WasPressedRepeating;
				bool dpadDown = ((OneAxisInputControl)currentDevice.DPadLeft).WasPressedRepeating || ((OneAxisInputControl)currentDevice.DPadDown).WasPressedRepeating;
				if (dpadUp || dpadDown)
				{
					ignoreStickTimer = 0.25f;
					targetIndex2 += (dpadDown ? 1 : (-1));
				}
				else if (ignoreStickTimer <= 0f && Vector2.Distance(Vector2.zero, currentDevice.LeftStick.Value) >= 0.4f)
				{
					float anglePerSegment = 360f / (float)segments.Length;
					targetIndex2 = Mathf.FloorToInt((0f - currentDevice.LeftStick.Angle + 270f) / anglePerSegment + 0.5f);
				}
			}
			targetIndex2 = (targetIndex2 + segments.Length) % segments.Length;
			if (hoveredIndex != targetIndex2)
			{
				segments[hoveredIndex].SetHovered(hovered: false);
				segments[targetIndex2].SetHovered(hovered: true);
				hoveredIndex = targetIndex2;
				ammoLabel.Text = FormatWeaponText(playerGuns[targetIndex2], showAmmo, showName);
			}
			float newGuiScale = GUIManager.PixelsToUnits();
			if (newGuiScale != cachedGuiScale)
			{
				cachedGuiScale = newGuiScale;
				float dfScale2 = GameUIUtility.GetCurrentTK2D_DFScale(GUIManager);
				RadialSegment[] array = segments;
				foreach (RadialSegment seg in array)
				{
					seg.Rescale(newGuiScale, dfScale2);
				}
			}
			UIRoot.GunventoryFolded = true;
			yield return null;
			ignoreStickTimer = Mathf.Max(0f, ignoreStickTimer - GameManager.INVARIANT_DELTA_TIME);
			totalTimeMetalGeared += GameManager.INVARIANT_DELTA_TIME;
		}
		if (targetPlayer.inventory.AllGuns.Count != 0)
		{
			targetPlayer.CacheQuickEquipGun();
			targetPlayer.ChangeToGunSlot(hoveredIndex, false);
			ammoController.SuppressNextGunFlip = false;
		}
		else
		{
			UIRoot.TemporarilyShowGunName(targetPlayer.IsPrimaryPlayer);
		}
		if (totalTimeMetalGeared < 0.005f)
		{
			targetPlayer.DoQuickEquip();
		}
		CleanUpWeaponWheel(targetPlayer, ammoController);
	}
}
internal class RadialSegment
{
	internal const float SEG_SCALE = 0.375f;

	private static readonly Color innerColor = Vector3Extensions.WithAlpha(Color.black, 0.5f);

	private static readonly Color currentColor = Vector3Extensions.WithAlpha(Color.white, 0.15f);

	private Transform container;

	private MeshRenderer renderer;

	private Transform gunContainer;

	private tk2dClippedSprite gunSprite;

	private float resolution;

	private Vector3 basePos;

	private Color hoveredOutlineColor;

	private Color unhoveredOutlineColor;

	internal RadialSegment(float size, float angle, float rotation, bool useColor, bool current)
	{
		//IL_0019: 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_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_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Expected O, but got Unknown
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		dfGUIManager manager = GameUIRoot.Instance.m_manager;
		container = new GameObject("SegmentContainer").transform;
		container.parent = ((Component)manager).transform;
		container.localPosition = Vector3.zero;
		container.SetAsFirstSibling();
		float num = (0f - rotation - 90f) * ((float)Math.PI / 180f);
		basePos = new Vector3(0.375f * Mathf.Sin(num), 0.375f * Mathf.Cos(num));
		resolution = size;
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
		val.transform.parent = container;
		val.transform.localScale = Vector2.op_Implicit(manager.PixelsToUnits() * 3f * size * Vector2.one);
		val.transform.localPosition = Vector3.zero;
		if (useColor)
		{
			hoveredOutlineColor = HSBColor.ToColor(new HSBColor(rotation / 360f, 0.75f, 0.95f));
			unhoveredOutlineColor = HSBColor.ToColor(new HSBColor(rotation / 360f, 0.25f, 0.25f));
		}
		else
		{
			hoveredOutlineColor = Color.white;
			unhoveredOutlineColor = new Color(32f / 85f, 32f / 85f, 0.39607844f);
		}
		Material val2 = new Material(WeaponWheelSelectController.radialShader);
		val2.SetFloat("_Resolution", size);
		val2.SetFloat("_Angle", angle);
		val2.SetFloat("_Rotation", rotation);
		val2.SetColor("_Color", current ? currentColor : innerColor);
		val2.SetColor("_OutlineColor", unhoveredOutlineColor);
		val2.SetFloat("_OutlineWidth", 1f);
		val2.SetFloat("_LowBound", 0.25f);
		val2.SetFloat("_HighBound", 0.5f);
		renderer = val.GetComponent<MeshRenderer>();
		((Renderer)renderer).material = val2;
		((Renderer)renderer).sortingOrder = 1;
		GameObjectExtensions.SetLayerRecursively(((Component)container).gameObject, LayerMask.NameToLayer("GUI"));
	}

	internal void AssignGun(Gun gun, float dfScale)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		tk2dBaseSprite sprite = gun.GetSprite();
		gunContainer = new GameObject("GunContainer").transform;
		gunContainer.parent = container;
		GameObject val = new GameObject("SomeGun");
		val.transform.parent = gunContainer;
		gunSprite = tk2dBaseSprite.AddComponent<tk2dClippedSprite>(val, sprite.Collection, sprite.spriteId);
		((tk2dBaseSprite)gunSprite).scale = dfScale * Vector3.one;
		((tk2dBaseSprite)gunSprite).ignoresTiltworldDepth = true;
		((BraveBehaviour)gunSprite).renderer.material.shader = ShaderCache.Acquire("tk2d/BlendVertexColorFadeRange");
		((BraveBehaviour)gunSprite).transform.localPosition = GameUIRoot.Instance.ammoControllers[0].GetOffsetVectorForGun(gun, false);
		if (gun.CurrentAmmo == 0)
		{
			((BraveBehaviour)gunSprite).renderer.material.SetFloat("_Saturation", 0f);
			tk2dSprite component = ((GameObject)Object.Instantiate(BraveResources.Load("Global Prefabs/NoAmmoIcon", ".prefab"))).GetComponent<tk2dSprite>();
			((BraveBehaviour)component).transform.parent = gunContainer;
			((tk2dBaseSprite)component).HeightOffGround = 2f;
			((BraveBehaviour)component).transform.position = Vector3.zero;
			((tk2dBaseSprite)component).scale = ((tk2dBaseSprite)gunSprite).scale;
			((tk2dBaseSprite)component).ignoresTiltworldDepth = true;
		}
		GameObjectExtensions.SetLayerRecursively(((Component)gunContainer).gameObject, LayerMask.NameToLayer("GUI"));
	}

	internal void Rescale(float guiScale, float dfScale)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = guiScale * 3f * resolution * Vector2.one;
		((Component)renderer).transform.localScale = Vector2.op_Implicit(val);
		((tk2dBaseSprite)gunSprite).scale = dfScale * Vector3.one;
		gunContainer.localPosition = val.x * basePos;
	}

	internal void Destroy()
	{
		Object.Destroy((Object)(object)((Component)container).gameObject);
	}

	internal void SetHovered(bool hovered)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		((Renderer)renderer).material.SetColor("_OutlineColor", hovered ? hoveredOutlineColor : unhoveredOutlineColor);
	}
}
internal static class OptionalGunfig
{
	private const string GUNFIG_MOD_ENABLED = "Enable Weapon Wheel";

	private const string GUNFIG_USE_COLOR = "Use Colors";

	private const string GUNFIG_HIGHLIGHT = "Use Different Background Color for Current Gun";

	private const string GUNFIG_SHOW_AMMO = "Display Gun Ammo";

	private const string GUNFIG_SHOW_NAME = "Display Gun Name";

	private static readonly Color GunmetalBlue = new Color(0.533f, 0.533f, 0.733f, 1f);

	internal static Func<bool> WheelEnabled = DefaultTrue;

	internal static Func<bool> ColorEnabled = DefaultFalse;

	internal static Func<bool> HighlightEnabled = DefaultFalse;

	internal static Func<bool> AmmoEnabled = DefaultTrue;

	internal static Func<bool> NameEnabled = DefaultFalse;

	private static Func<string, bool> GunfigEnabled = null;

	private static bool DefaultFalse()
	{
		return false;
	}

	private static bool DefaultTrue()
	{
		return true;
	}

	private static bool WheelEnabledGunfig()
	{
		return GunfigEnabled("Enable Weapon Wheel");
	}

	private static bool ColorEnabledGunfig()
	{
		return GunfigEnabled("Use Colors");
	}

	private static bool HighlightEnabledGunfig()
	{
		return GunfigEnabled("Use Different Background Color for Current Gun");
	}

	private static bool AmmoEnabledGunfig()
	{
		return GunfigEnabled("Display Gun Ammo");
	}

	private static bool NameEnabledGunfig()
	{
		return GunfigEnabled("Display Gun Name");
	}

	internal static void Init()
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			if (assembly.FullName.Contains("Gunfig"))
			{
				Type type = assembly.GetType("Gunfiguration.Gunfig");
				string text = (string)assembly.GetType("Gunfiguration.GunfigHelpers").GetMethod("WithColor").Invoke(null, new object[2] { "Weapon Wheel Select", GunmetalBlue });
				object obj = type.GetMethod("Get").Invoke(null, new object[1] { text });
				MethodInfo method = type.GetMethod("AddToggle");
				method.Invoke(obj, new object[5] { "Enable Weapon Wheel", true, null, null, 1 });
				method.Invoke(obj, new object[5] { "Use Colors", false, null, null, 1 });
				method.Invoke(obj, new object[5] { "Use Different Background Color for Current Gun", false, null, null, 1 });
				method.Invoke(obj, new object[5] { "Display Gun Ammo", true, null, null, 1 });
				method.Invoke(obj, new object[5] { "Display Gun Name", false, null, null, 1 });
				GunfigEnabled = (Func<string, bool>)Delegate.CreateDelegate(typeof(Func<string, bool>), obj, type.GetMethod("Enabled"));
				WheelEnabled = WheelEnabledGunfig;
				ColorEnabled = ColorEnabledGunfig;
				HighlightEnabled = HighlightEnabledGunfig;
				AmmoEnabled = AmmoEnabledGunfig;
				NameEnabled = NameEnabledGunfig;
				break;
			}
		}
	}
}
[BepInPlugin("pretzel.etg.weaponwheel", "Weapon Wheel Select", "2.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Module : BaseUnityPlugin
{
	public const string MOD_GUID = "pretzel.etg.weaponwheel";

	public const string MOD_NAME = "Weapon Wheel Select";

	public const string MOD_VERSION = "2.1.0";

	public void Start()
	{
		ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
	}

	public void GMStart(GameManager manager)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			OptionalGunfig.Init();
			new Harmony("pretzel.etg.weaponwheel").PatchAll();
			WeaponWheelSelectController.Init();
			ETGModConsole.Log((object)"<color=#8888BB>Weapon Wheel Select v2.1.0 started successfully!</color>", false);
		}
		catch (Exception arg)
		{
			ETGModConsole.Log((object)string.Format("<color=#FF0000>{0} v{1} failed to initialize!\n{2}</color>", "Weapon Wheel Select", "2.1.0", arg), false);
		}
	}
}