Decompiled source of BetterSkinRolls v1.0.0

plugins/BetterSkinRolls/BetterSkinRolls.dll

Decompiled 6 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FishNet;
using FishNet.Connection;
using FishNet.Object;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BetterSkinRolls")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fdb61d4a6a68320d4b4ecb9720b294e58a133381")]
[assembly: AssemblyProduct("BetterSkinRolls")]
[assembly: AssemblyTitle("BetterSkinRolls")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 BetterSkinRolls
{
	[HarmonyPatch(typeof(PauseManager), "OnPause")]
	internal static class GameMenus
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__Refresh;

			public static UnityAction <1>__HidePanel;
		}

		private const string TabLabel = "Skin Rolls";

		private const string PanelTitle = "Better Skin Rolls";

		private static readonly FieldRef<PauseManager, GameObject> OptionsScreen = AccessTools.FieldRefAccess<PauseManager, GameObject>("_optionsScreen");

		private static readonly FieldInfo Instance = AccessTools.Field(typeof(PauseManager), "_instance");

		private static GameObject _panel;

		private static Toggle _self;

		private static Toggle _strike;

		private static TextMeshProUGUI _selfTitle;

		private static TextMeshProUGUI _selfHint;

		private static TextMeshProUGUI _strikeTitle;

		private static TextMeshProUGUI _strikeHint;

		private static bool _optionsFailed;

		private static bool _languageHooked;

		private static void Postfix()
		{
			object? obj = Instance?.GetValue(null);
			PauseManager val = (PauseManager)((obj is PauseManager) ? obj : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)_panel) && !_optionsFailed)
			{
				try
				{
					BuildOptionsTab(val);
				}
				catch (Exception arg)
				{
					_optionsFailed = true;
					Plugin.Log.LogError((object)$"Could not add the Options tab: {arg}");
				}
			}
			if (!_languageHooked)
			{
				_languageHooked = true;
				Strings.LanguageChanged += Refresh;
			}
			Refresh();
		}

		private static void BuildOptionsTab(PauseManager manager)
		{
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Expected O, but got Unknown
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Expected O, but got Unknown
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Expected O, but got Unknown
			GameObject obj = OptionsScreen.Invoke(manager);
			Transform options = ((obj != null) ? obj.transform : null);
			if (!Object.op_Implicit((Object)(object)options))
			{
				throw new InvalidOperationException("PauseManager._optionsScreen not found, the game was probably updated");
			}
			Transform val = options.Find("UpperButtonHolder");
			Transform val2 = FindChild(options, "GameplayDisplay");
			Transform val3 = (Object.op_Implicit((Object)(object)val) ? FindChild(val, "GameplayButton") : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3))
			{
				throw new InvalidOperationException("Options tabs or Gameplay panel not found, the game was probably updated");
			}
			GameObject val4 = CloneInactive(((Component)val2).gameObject, "BetterSkinRollsDisplay (To toggle)");
			Transform val5 = val4.transform.Find("Layout");
			TextMeshProUGUI val6 = (Object.op_Implicit((Object)(object)val5) ? ((Component)val5.GetChild(0)).GetComponent<TextMeshProUGUI>() : null);
			Transform val7 = null;
			if (Object.op_Implicit((Object)(object)val5))
			{
				foreach (Transform item in val5)
				{
					Transform val8 = item;
					if (Object.op_Implicit((Object)(object)((Component)val8).GetComponentInChildren<Toggle>(true)) && (!Object.op_Implicit((Object)(object)val7) || ((Object)val8).name.StartsWith("Nametags")))
					{
						val7 = val8;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)val6) || !Object.op_Implicit((Object)(object)val7))
			{
				throw new InvalidOperationException("Gameplay panel layout not as expected");
			}
			for (int num = val5.childCount - 1; num >= 0; num--)
			{
				Transform child = val5.GetChild(num);
				if ((Object)(object)child != (Object)(object)((TMP_Text)val6).transform && (Object)(object)child != (Object)(object)val7)
				{
					Object.DestroyImmediate((Object)(object)((Component)child).gameObject);
				}
			}
			((TMP_Text)val6).text = "Better Skin Rolls";
			_self = AddRow(val5, val7, Plugin.Enabled, out _selfTitle);
			_selfHint = AddHint(val5, val7, val5.childCount);
			_strike = AddRow(val5, val7, Plugin.StrikeCompletedPrizes, out _strikeTitle);
			_strikeHint = AddHint(val5, val7, val5.childCount);
			Object.DestroyImmediate((Object)(object)((Component)val7).gameObject);
			Place(val4, options, val2.GetSiblingIndex() + 1);
			val4.SetActive(false);
			_panel = val4;
			GameObject obj2 = CloneInactive(((Component)val3).gameObject, "BetterSkinRollsButton");
			Button component = obj2.GetComponent<Button>();
			component.onClick = new ButtonClickedEvent();
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				ShowPanel(options);
			});
			TextMeshProUGUI componentInChildren = obj2.GetComponentInChildren<TextMeshProUGUI>(true);
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				((TMP_Text)componentInChildren).text = "Skin Rolls";
			}
			Place(obj2, val, val.childCount);
			obj2.SetActive(true);
			Button[] componentsInChildren = ((Component)options).GetComponentsInChildren<Button>(true);
			foreach (Button val9 in componentsInChildren)
			{
				if ((Object)(object)val9 != (Object)(object)component && Object.op_Implicit((Object)(object)((Component)val9).transform.parent) && ((Object)((Component)val9).transform.parent).name.EndsWith("ButtonHolder") && ((Object)val9).name != "BackButton")
				{
					ButtonClickedEvent onClick = val9.onClick;
					object obj3 = <>O.<1>__HidePanel;
					if (obj3 == null)
					{
						UnityAction val10 = HidePanel;
						<>O.<1>__HidePanel = val10;
						obj3 = (object)val10;
					}
					((UnityEvent)onClick).AddListener((UnityAction)obj3);
				}
			}
			FitTabs(val);
		}

		private static void ShowPanel(Transform options)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)_panel))
			{
				return;
			}
			foreach (Transform option in options)
			{
				Transform val = option;
				if ((Object)(object)((Component)val).gameObject != (Object)(object)_panel && ((Object)val).name.Contains("Display"))
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
			_panel.SetActive(true);
			Refresh();
		}

		private static void HidePanel()
		{
			if (Object.op_Implicit((Object)(object)_panel))
			{
				_panel.SetActive(false);
			}
		}

		private static void FitTabs(Transform tabs)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0021: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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)
			RectTransform val = (RectTransform)tabs;
			HorizontalLayoutGroup component = ((Component)tabs).GetComponent<HorizontalLayoutGroup>();
			int num = 0;
			foreach (Transform tab in tabs)
			{
				if (((Component)tab).gameObject.activeSelf)
				{
					num++;
				}
			}
			if (num == 0)
			{
				return;
			}
			float num2 = (Object.op_Implicit((Object)(object)component) ? ((HorizontalOrVerticalLayoutGroup)component).spacing : 10f);
			Rect rect = val.rect;
			float num3 = (((Rect)(ref rect)).width - num2 * (float)(num - 1)) / (float)num;
			foreach (Transform tab2 in tabs)
			{
				Transform val2 = tab2;
				RectTransform val3 = (RectTransform)val2;
				val3.sizeDelta = new Vector2(num3, val3.sizeDelta.y);
				LayoutElement obj = ((Component)val2).GetComponent<LayoutElement>() ?? ((Component)val2).gameObject.AddComponent<LayoutElement>();
				obj.preferredWidth = num3;
				obj.minWidth = num3;
				TextMeshProUGUI[] componentsInChildren = ((Component)val2).GetComponentsInChildren<TextMeshProUGUI>(true);
				foreach (TextMeshProUGUI obj2 in componentsInChildren)
				{
					RectTransform rectTransform = ((TMP_Text)obj2).rectTransform;
					if (rectTransform.anchorMin.x == rectTransform.anchorMax.x && rectTransform.sizeDelta.x > num3 - 16f)
					{
						rectTransform.sizeDelta = new Vector2(num3 - 16f, rectTransform.sizeDelta.y);
					}
					AutoSize(obj2, 0.55f);
				}
			}
		}

		private static Toggle AddRow(Transform layout, Transform template, ConfigEntry<bool> entry, out TextMeshProUGUI title)
		{
			GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, layout, false);
			((Object)obj).name = "BetterSkinRolls_" + ((ConfigEntryBase)entry).Definition.Key.Replace(" ", "");
			obj.SetActive(true);
			return Wire(obj, entry, out title);
		}

		private static Toggle Wire(GameObject row, ConfigEntry<bool> entry, out TextMeshProUGUI title)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			Toggle componentInChildren = row.GetComponentInChildren<Toggle>(true);
			componentInChildren.onValueChanged = new ToggleEvent();
			componentInChildren.SetIsOnWithoutNotify(entry.Value);
			((UnityEvent<bool>)(object)componentInChildren.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
			{
				entry.Value = value;
			});
			title = row.GetComponentInChildren<TextMeshProUGUI>(true);
			if (Object.op_Implicit((Object)(object)title))
			{
				AutoSize(title, 0.6f);
			}
			return componentInChildren;
		}

		private static TextMeshProUGUI AddHint(Transform layout, Transform rowTemplate, int index)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_003d: 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)
			//IL_00a9: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CloneInactive(((Component)rowTemplate).gameObject, "BetterSkinRolls_Hint");
			RectTransform val2 = (RectTransform)val.transform;
			Toggle componentInChildren = val.GetComponentInChildren<Toggle>(true);
			TextMeshProUGUI val3 = null;
			foreach (Transform item in val.transform)
			{
				TextMeshProUGUI component = ((Component)item).GetComponent<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)component) && !Object.op_Implicit((Object)(object)val3))
				{
					val3 = component;
				}
			}
			if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)componentInChildren))
			{
				throw new InvalidOperationException("toggle row layout not as expected");
			}
			float num = EdgeX((RectTransform)((TMP_Text)val3).transform, right: false);
			float num2 = EdgeX((RectTransform)((Component)componentInChildren).transform, right: true);
			foreach (Transform item2 in val.transform)
			{
				Transform val4 = item2;
				if ((Object)(object)val4 != (Object)(object)((TMP_Text)val3).transform)
				{
					Object.DestroyImmediate((Object)(object)((Component)val4).gameObject);
				}
			}
			RectTransform rectTransform = ((TMP_Text)val3).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 0f);
			rectTransform.anchorMax = new Vector2(1f, 1f);
			rectTransform.pivot = new Vector2(0.5f, 0.5f);
			Rect rect = val2.rect;
			rectTransform.offsetMin = new Vector2(num - ((Rect)(ref rect)).xMin, 0f);
			rect = val2.rect;
			rectTransform.offsetMax = new Vector2(num2 - ((Rect)(ref rect)).xMax, 0f);
			((TMP_Text)val3).fontSize = 24f;
			((TMP_Text)val3).enableAutoSizing = true;
			((TMP_Text)val3).fontSizeMax = 24f;
			((TMP_Text)val3).fontSizeMin = 16f;
			((TMP_Text)val3).textWrappingMode = (TextWrappingModes)1;
			((TMP_Text)val3).alignment = (TextAlignmentOptions)257;
			Color color = ((Graphic)val3).color;
			color.a = 0.8f;
			((Graphic)val3).color = color;
			LayoutElement obj = val.GetComponent<LayoutElement>() ?? val.AddComponent<LayoutElement>();
			obj.preferredHeight = 56f;
			obj.minHeight = 56f;
			val2.sizeDelta = new Vector2(val2.sizeDelta.x, 56f);
			Place(val, layout, index);
			val.SetActive(true);
			return val3;
		}

		private static float EdgeX(RectTransform child, bool right)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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)
			Rect rect = child.rect;
			return ((Transform)child).localPosition.x + (right ? ((Rect)(ref rect)).xMax : ((Rect)(ref rect)).xMin) * ((Transform)child).localScale.x;
		}

		public static void Refresh()
		{
			try
			{
				SetTexts();
				if (Object.op_Implicit((Object)(object)_self))
				{
					_self.SetIsOnWithoutNotify(Plugin.Enabled.Value);
				}
				if (Object.op_Implicit((Object)(object)_strike))
				{
					_strike.SetIsOnWithoutNotify(Plugin.StrikeCompletedPrizes.Value);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not update the menus: " + ex.Message));
			}
		}

		private static void SetTexts()
		{
			if (Object.op_Implicit((Object)(object)_selfTitle))
			{
				((TMP_Text)_selfTitle).text = Strings.Get("SelfToggle");
			}
			if (Object.op_Implicit((Object)(object)_selfHint))
			{
				((TMP_Text)_selfHint).text = Strings.Get("SelfHint");
			}
			if (Object.op_Implicit((Object)(object)_strikeTitle))
			{
				((TMP_Text)_strikeTitle).text = Strings.Get("StrikeToggle");
			}
			if (Object.op_Implicit((Object)(object)_strikeHint))
			{
				((TMP_Text)_strikeHint).text = Strings.Get("StrikeHint");
			}
		}

		private static Transform FindChild(Transform parent, string prefix)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name.StartsWith(prefix))
				{
					return val;
				}
			}
			return null;
		}

		private static GameObject CloneInactive(GameObject template, string name)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			GameObject val = new GameObject("BetterSkinRolls_Holder");
			val.SetActive(false);
			GameObject val2 = Object.Instantiate<GameObject>(template, val.transform, false);
			((Object)val2).name = name;
			Component[] componentsInChildren = val2.GetComponentsInChildren<Component>(true);
			foreach (Component val3 in componentsInChildren)
			{
				if ((Object)(object)val3 != (Object)null && ((object)val3).GetType().Name.Contains("Localize"))
				{
					Object.DestroyImmediate((Object)(object)val3);
				}
			}
			val2.SetActive(false);
			val2.transform.SetParent((Transform)null, false);
			Object.Destroy((Object)(object)val);
			return val2;
		}

		private static void Place(GameObject go, Transform parent, int index)
		{
			go.transform.SetParent(parent, false);
			go.transform.SetSiblingIndex(Mathf.Clamp(index, 0, parent.childCount - 1));
		}

		private static void AutoSize(TextMeshProUGUI text, float minRatio)
		{
			float num = (((TMP_Text)text).enableAutoSizing ? ((TMP_Text)text).fontSizeMax : ((TMP_Text)text).fontSize);
			((TMP_Text)text).enableAutoSizing = true;
			((TMP_Text)text).fontSizeMax = num;
			((TMP_Text)text).fontSizeMin = Mathf.Max(12f, num * minRatio);
		}
	}
	internal static class LobbySync
	{
		public enum HostState
		{
			Vanilla,
			Modded
		}

		public const string Key = "BetterSkinRolls";

		private static CSteamID _lastLobby = CSteamID.Nil;

		private static string _lastMember;

		private static string _lastHost;

		public static void PublishNow()
		{
			Publish(force: true);
		}

		public static void Publish(bool force)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CSteamID currentLobbyID = SteamManager.CurrentLobbyID;
				if (currentLobbyID == CSteamID.Nil)
				{
					_lastLobby = CSteamID.Nil;
					return;
				}
				if (currentLobbyID != _lastLobby)
				{
					_lastLobby = currentLobbyID;
					_lastMember = (_lastHost = null);
				}
				string text = "off";
				if (Plugin.Enabled.Value)
				{
					HashSet<byte> hashSet = SkinProgress.LocalCompleted();
					text = ((hashSet == null) ? null : ("on:" + SkinProgress.Encode(hashSet)));
				}
				if (text != null && (force || text != _lastMember))
				{
					SteamMatchmaking.SetLobbyMemberData(currentLobbyID, "BetterSkinRolls", text);
					if (Plugin.LogRolls.Value && text != _lastMember)
					{
						Plugin.Log.LogInfo((object)("[lobby] shared with the host: " + ((text == "off") ? "Skip completed weapons is off" : ("completed weapons " + WheelLog.Names(SkinProgress.Decode(text.Substring(3)))))));
					}
					_lastMember = text;
				}
				if (InstanceFinder.IsServerStarted && (force || "on" != _lastHost) && SteamMatchmaking.SetLobbyData(currentLobbyID, "BetterSkinRolls", "on"))
				{
					if (Plugin.LogRolls.Value && _lastHost == null)
					{
						Plugin.Log.LogInfo((object)"[lobby] you host this lobby: marked it as having the mod");
					}
					_lastHost = "on";
				}
			}
			catch (Exception ex)
			{
				if (force)
				{
					Plugin.Log.LogWarning((object)("Could not update the lobby data: " + ex.Message));
				}
			}
		}

		public static HostState GetHostState()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CSteamID currentLobbyID = SteamManager.CurrentLobbyID;
				if (currentLobbyID == CSteamID.Nil)
				{
					return HostState.Vanilla;
				}
				string lobbyData = SteamMatchmaking.GetLobbyData(currentLobbyID, "BetterSkinRolls");
				if (lobbyData == "" || lobbyData == null)
				{
					return HostState.Vanilla;
				}
				return HostState.Modded;
			}
			catch
			{
				return HostState.Vanilla;
			}
		}

		public static HashSet<byte> GetMemberCompleted(ulong steamId)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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)
			try
			{
				CSteamID currentLobbyID = SteamManager.CurrentLobbyID;
				if (currentLobbyID == CSteamID.Nil || steamId == 0L)
				{
					return null;
				}
				string lobbyMemberData = SteamMatchmaking.GetLobbyMemberData(currentLobbyID, new CSteamID(steamId), "BetterSkinRolls");
				if (string.IsNullOrEmpty(lobbyMemberData) || !lobbyMemberData.StartsWith("on:"))
				{
					return null;
				}
				return SkinProgress.Decode(lobbyMemberData.Substring(3));
			}
			catch
			{
				return null;
			}
		}
	}
	internal static class Patches
	{
		internal static readonly FieldInfo MachineInstance = AccessTools.Field(typeof(SlotMachine), "_instance");

		private static readonly MethodInfo UpdatePrizesText = AccessTools.Method(typeof(SlotMachine), "UpdatePrizesText", (Type[])null, (Type[])null);

		public static void RefreshPrizes()
		{
			try
			{
				object? obj = MachineInstance?.GetValue(null);
				SlotMachine val = (SlotMachine)((obj is SlotMachine) ? obj : null);
				if (Object.op_Implicit((Object)(object)val) && UpdatePrizesText != null)
				{
					UpdatePrizesText.Invoke(val, null);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not refresh the prize list: " + ex.Message));
			}
		}

		internal static bool IsLocal(Player player)
		{
			if (Object.op_Implicit((Object)(object)player) && ((NetworkBehaviour)player).Owner != (NetworkConnection)null)
			{
				return ((NetworkBehaviour)player).Owner.IsLocalClient;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(SlotMachineManager), "RollRandom")]
	internal static class RollRandomPatch
	{
		internal struct Saved
		{
			public bool Active;

			public Item[] Items;

			public bool ExcludeBoat;
		}

		private static readonly MethodInfo SetAvailableItems = AccessTools.PropertySetter(typeof(SlotMachine), "AvailableItems");

		private static readonly MethodInfo SetExcludeBoat = AccessTools.PropertySetter(typeof(SlotMachine), "ExcludeBoat");

		private static HashSet<byte> CompletedFor(Player roller)
		{
			if (Patches.IsLocal(roller))
			{
				if (!Plugin.Enabled.Value)
				{
					return null;
				}
				return SkinProgress.LocalCompleted();
			}
			return LobbySync.GetMemberCompleted(roller.SteamID);
		}

		private static void Prefix(Player roller, out Saved __state)
		{
			__state = default(Saved);
			try
			{
				if (!Object.op_Implicit((Object)(object)roller) || SetAvailableItems == null || SetExcludeBoat == null)
				{
					return;
				}
				Item[] availableItems = SlotMachine.AvailableItems;
				if (availableItems == null)
				{
					return;
				}
				HashSet<byte> hashSet = CompletedFor(roller);
				if (Plugin.LogRolls.Value)
				{
					Plugin.Log.LogInfo((object)("[host] " + roller.SteamName + " (" + (Patches.IsLocal(roller) ? "you" : "other player") + ") rolls; completed weapons: " + ((hashSet == null) ? "unknown (no mod, or Skip completed weapons off)" : WheelLog.Names(hashSet))));
				}
				if (hashSet == null || hashSet.Count == 0)
				{
					return;
				}
				List<Item> list = new List<Item>();
				Item[] array = availableItems;
				foreach (Item val in array)
				{
					if (Object.op_Implicit((Object)(object)val) && !hashSet.Contains(val.ID))
					{
						list.Add(val);
					}
				}
				bool flag = SlotMachine.ExcludeBoat || hashSet.Contains(byte.MaxValue);
				if ((list.Count != availableItems.Length || flag != SlotMachine.ExcludeBoat) && !(list.Count == 0 && flag))
				{
					__state = new Saved
					{
						Active = true,
						Items = availableItems,
						ExcludeBoat = SlotMachine.ExcludeBoat
					};
					SetAvailableItems.Invoke(null, new object[1] { list.ToArray() });
					SetExcludeBoat.Invoke(null, new object[1] { flag });
					if (Plugin.LogRolls.Value)
					{
						Plugin.Log.LogInfo((object)("[host] filtered the wheel for " + roller.SteamName + ": skipping " + WheelLog.Names(hashSet) + ", " + string.Format("{0} item(s) left, boat {1}", list.Count, flag ? "excluded" : "kept")));
					}
				}
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Could not filter the roll: {arg}");
			}
		}

		private static Exception Finalizer(Exception __exception, Saved __state)
		{
			if (__state.Active)
			{
				try
				{
					SetAvailableItems.Invoke(null, new object[1] { __state.Items });
					SetExcludeBoat.Invoke(null, new object[1] { __state.ExcludeBoat });
				}
				catch (Exception arg)
				{
					Plugin.Log.LogError((object)$"Could not restore the prize pool: {arg}");
				}
			}
			return __exception;
		}
	}
	[HarmonyPatch(typeof(SlotMachine), "Roll")]
	internal static class RollPatch
	{
		private static void Prefix(Player roller, byte[] itemIDs, byte[] itemSkins)
		{
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Patches.IsLocal(roller) || InstanceFinder.IsServerStarted || !Plugin.Enabled.Value || itemIDs == null || itemSkins == null || LobbySync.GetHostState() != LobbySync.HostState.Vanilla)
				{
					return;
				}
				HashSet<byte> hashSet = SkinProgress.LocalCompleted();
				if (hashSet == null || hashSet.Count == 0)
				{
					return;
				}
				List<byte> list = new List<byte>();
				if (SlotMachine.AvailableItems != null)
				{
					Item[] availableItems = SlotMachine.AvailableItems;
					foreach (Item val in availableItems)
					{
						if (Object.op_Implicit((Object)(object)val) && !hashSet.Contains(val.ID))
						{
							list.Add(val.ID);
						}
					}
				}
				if (!SlotMachine.ExcludeBoat && !hashSet.Contains(byte.MaxValue))
				{
					list.Add(byte.MaxValue);
				}
				if (list.Count == 0)
				{
					return;
				}
				int num = 0;
				int num2 = Math.Min(itemIDs.Length, itemSkins.Length);
				for (int j = 0; j < num2; j++)
				{
					if (!hashSet.Contains(itemIDs[j]))
					{
						continue;
					}
					SkinPreset val2 = SkinProgress.PresetFor(itemIDs[j]);
					if (!Object.op_Implicit((Object)(object)val2) || itemSkins[j] >= val2.Skins.Count)
					{
						continue;
					}
					ItemSkin val3 = val2.Skins[itemSkins[j]];
					Rarity rarity = ((ItemSkin)(ref val3)).Rarity;
					if ((int)rarity != 0)
					{
						byte b = list[Random.Range(0, list.Count)];
						SkinPreset val4 = SkinProgress.PresetFor(b);
						if (Object.op_Implicit((Object)(object)val4))
						{
							itemIDs[j] = b;
							itemSkins[j] = val4.GetRandomSkinIndex(rarity);
							num++;
						}
					}
				}
				if (num > 0 && Plugin.LogRolls.Value)
				{
					Plugin.Log.LogInfo((object)($"Vanilla host, changed locally: {num} slot(s) of completed collections " + SkinProgress.Encode(hashSet)));
				}
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Could not change the roll locally: {arg}");
			}
		}

		private static void Postfix(Player roller, byte[] itemIDs, byte[] itemSkins, byte rolled)
		{
			if (!Plugin.LogRolls.Value)
			{
				return;
			}
			try
			{
				string text = (InstanceFinder.IsServerStarted ? "you are the host" : ("host has the mod: " + ((LobbySync.GetHostState() == LobbySync.HostState.Modded) ? "yes" : "no")));
				HashSet<byte> hashSet = SkinProgress.LocalCompleted();
				List<string> list = new List<string>();
				HashSet<byte> hashSet2 = new HashSet<byte>();
				int num = Math.Min(itemIDs.Length, itemSkins.Length);
				for (int i = 0; i < num; i++)
				{
					list.Add(WheelLog.Slot(itemIDs[i], itemSkins[i]));
					if (hashSet != null && hashSet.Contains(itemIDs[i]))
					{
						hashSet2.Add(itemIDs[i]);
					}
				}
				Plugin.Log.LogInfo((object)("[wheel] " + ((roller != null) ? roller.SteamName : null) + " rolled (" + (Patches.IsLocal(roller) ? "you" : "other player") + ", " + text + "). Prize: " + ((rolled < num) ? WheelLog.Slot(itemIDs[rolled], itemSkins[rolled]) : "?") + ". Your completed weapons on this wheel: " + ((hashSet2.Count == 0) ? "none" : WheelLog.Names(hashSet2)) + ". Slots: " + string.Join(" | ", list)));
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not log the wheel: " + ex.Message));
			}
		}
	}
	internal static class WheelLog
	{
		public static string Name(byte id)
		{
			if (id == byte.MaxValue)
			{
				return "Boat";
			}
			Item val = GameInfo.IDToItem(id);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return id.ToString();
			}
			return ((Object)val).name;
		}

		public static string Names(IEnumerable<byte> ids)
		{
			List<string> list = new List<string>();
			foreach (byte id in ids)
			{
				list.Add(Name(id));
			}
			if (list.Count != 0)
			{
				return string.Join(", ", list);
			}
			return "none";
		}

		public static string Slot(byte id, byte skin)
		{
			//IL_003b: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			SkinPreset val = SkinProgress.PresetFor(id);
			if (!Object.op_Implicit((Object)(object)val) || skin >= val.Skins.Count)
			{
				return $"{Name(id)} #{skin}";
			}
			ItemSkin val2 = val.Skins[skin];
			return $"{Name(id)} {((ItemSkin)(ref val2)).Name} ({((ItemSkin)(ref val2)).Rarity})";
		}
	}
	[HarmonyPatch(typeof(SlotMachine), "OnRollFinished")]
	internal static class OnRollFinishedPatch
	{
		private static readonly FieldInfo PlayerWhoRolled = AccessTools.Field(typeof(SlotMachine), "_playerWhoRolled");

		private static void Postfix()
		{
			try
			{
				object? obj = PlayerWhoRolled?.GetValue(null);
				if (Patches.IsLocal((Player)((obj is Player) ? obj : null)))
				{
					LobbySync.PublishNow();
					Patches.RefreshPrizes();
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not update after the roll: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(SlotMachine), "UpdatePrizesText")]
	internal static class UpdatePrizesTextPatch
	{
		private static readonly FieldRef<SlotMachine, TextMeshProUGUI> PrizesText = AccessTools.FieldRefAccess<SlotMachine, TextMeshProUGUI>("_prizesText");

		private static readonly FieldRef<SlotMachine, Item[]> Items = AccessTools.FieldRefAccess<SlotMachine, Item[]>("_availableItems");

		private static readonly FieldRef<SlotMachine, bool> ExcludeBoat = AccessTools.FieldRefAccess<SlotMachine, bool>("_excludeBoat");

		private static void Postfix(SlotMachine __instance)
		{
			try
			{
				if (!Plugin.Enabled.Value || !Plugin.StrikeCompletedPrizes.Value)
				{
					return;
				}
				HashSet<byte> hashSet = SkinProgress.LocalCompleted();
				if (hashSet == null || hashSet.Count == 0)
				{
					return;
				}
				TextMeshProUGUI val = PrizesText.Invoke(__instance);
				Item[] array = Items.Invoke(__instance);
				if (!Object.op_Implicit((Object)(object)val) || array == null)
				{
					return;
				}
				List<string> list = new List<string>();
				if (!ExcludeBoat.Invoke(__instance))
				{
					list.Add(Mark(LocalizationManager.BoatLocalized.GetLocalizedString(), hashSet.Contains(byte.MaxValue)));
				}
				Item[] array2 = array;
				foreach (Item val2 in array2)
				{
					if (Object.op_Implicit((Object)(object)val2))
					{
						list.Add(Mark(val2.GetName(), hashSet.Contains(val2.ID)));
					}
				}
				StringBuilder stringBuilder = new StringBuilder("<color=#FFEF4D><b>");
				stringBuilder.Append(LocalizationManager.PrizesLocalized.GetLocalizedString()).Append(":</color></b> ");
				stringBuilder.Append(string.Join(", ", list));
				((TMP_Text)val).text = stringBuilder.ToString();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not mark the completed prizes: " + ex.Message));
			}
		}

		private static string Mark(string name, bool completed)
		{
			if (!completed)
			{
				return name;
			}
			return "<s><alpha=#80>" + name + "<alpha=#FF></s>";
		}
	}
	[BepInPlugin("avidkaos.howtofish.betterskinrolls", "BetterSkinRolls", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "avidkaos.howtofish.betterskinrolls";

		public const string PluginName = "BetterSkinRolls";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> StrikeCompletedPrizes;

		internal static ConfigEntry<bool> LogRolls;

		private float _nextSync;

		private void Awake()
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Skip completed weapons: when you roll the slot machine, weapons whose obtainable skins you've all unlocked are left out of the wheel. Other weapons can still give repeats. If the host also has the mod, everyone in the lobby sees the same wheel; if not, only your screen shows the changed wheel and the others see the original roll. Also in Options > Skin Rolls.");
			StrikeCompletedPrizes = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Strike completed prizes", true, "Cross out completed weapons in the prize list: the slot machine's \"Prizes:\" list crosses out the weapons you've completed. Only you see the marks. Also in Options > Skin Rolls.");
			LogRolls = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Log rolls", false, "Log every roll this mod changes.");
			Enabled.SettingChanged += delegate
			{
				LobbySync.PublishNow();
				Patches.RefreshPrizes();
				GameMenus.Refresh();
			};
			StrikeCompletedPrizes.SettingChanged += delegate
			{
				Patches.RefreshPrizes();
				GameMenus.Refresh();
			};
			new Harmony("avidkaos.howtofish.betterskinrolls").PatchAll(typeof(Plugin).Assembly);
			Log.LogInfo((object)"BetterSkinRolls 1.0.0 loaded");
		}

		private void Update()
		{
			if (!(Time.unscaledTime < _nextSync))
			{
				_nextSync = Time.unscaledTime + 1f;
				LobbySync.Publish(force: false);
			}
		}
	}
	internal static class SkinProgress
	{
		public const byte BoatId = byte.MaxValue;

		private static readonly FieldInfo CurLocalSave = AccessTools.Field(typeof(SaveManager), "_curLocalSave");

		private static SkinPreset _boatPreset;

		public static SkinPreset PresetFor(byte id)
		{
			if (id != byte.MaxValue)
			{
				Item val = GameInfo.IDToItem(id);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return null;
				}
				return val.SkinPreset;
			}
			if (Object.op_Implicit((Object)(object)BoatManager.Boat))
			{
				return BoatManager.Boat.SkinPreset;
			}
			if (!Object.op_Implicit((Object)(object)_boatPreset))
			{
				Boat[] array = Resources.FindObjectsOfTypeAll<Boat>();
				foreach (Boat val2 in array)
				{
					if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.SkinPreset))
					{
						_boatPreset = val2.SkinPreset;
						break;
					}
				}
			}
			return _boatPreset;
		}

		public static HashSet<byte> LocalCompleted()
		{
			object? obj = CurLocalSave?.GetValue(null);
			LocalSaveObject val = (LocalSaveObject)((obj is LocalSaveObject) ? obj : null);
			if (val == null)
			{
				return null;
			}
			HashSet<byte> hashSet = new HashSet<byte>();
			Item[] itemWithSkinsforCommands = GameInfo.ItemWithSkinsforCommands;
			if (itemWithSkinsforCommands != null)
			{
				Item[] array = itemWithSkinsforCommands;
				foreach (Item val2 in array)
				{
					if (!Object.op_Implicit((Object)(object)val2))
					{
						continue;
					}
					List<byte> unlocked = null;
					if (val.UnlockedItemSkins != null)
					{
						foreach (SavedItemSkin unlockedItemSkin in val.UnlockedItemSkins)
						{
							if (unlockedItemSkin != null && unlockedItemSkin.ID == val2.ID)
							{
								unlocked = unlockedItemSkin.SkinsUnlocked;
								break;
							}
						}
					}
					if (IsComplete(val2.SkinPreset, unlocked))
					{
						hashSet.Add(val2.ID);
					}
				}
			}
			if (IsComplete(PresetFor(byte.MaxValue), val.UnlockedBoatSkins))
			{
				hashSet.Add(byte.MaxValue);
			}
			return hashSet;
		}

		private static bool IsComplete(SkinPreset preset, List<byte> unlocked)
		{
			//IL_001c: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)preset) || unlocked == null)
			{
				return false;
			}
			IReadOnlyList<ItemSkin> skins = preset.Skins;
			int num = 0;
			for (int i = 0; i < skins.Count; i++)
			{
				ItemSkin val = skins[i];
				if ((int)((ItemSkin)(ref val)).Rarity != 0)
				{
					num++;
					if (!unlocked.Contains((byte)i))
					{
						return false;
					}
				}
			}
			return num > 0;
		}

		public static string Encode(HashSet<byte> ids)
		{
			List<byte> list = new List<byte>(ids);
			list.Sort();
			return string.Join(",", list);
		}

		public static HashSet<byte> Decode(string csv)
		{
			HashSet<byte> hashSet = new HashSet<byte>();
			string[] array = csv.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < array.Length; i++)
			{
				if (byte.TryParse(array[i], out var result))
				{
					hashSet.Add(result);
				}
			}
			return hashSet;
		}
	}
	public static class Strings
	{
		public const string SelfToggle = "SelfToggle";

		public const string SelfHint = "SelfHint";

		public const string StrikeToggle = "StrikeToggle";

		public const string StrikeHint = "StrikeHint";

		private static bool _subscribed;

		private static readonly Dictionary<string, Dictionary<string, string>> Table = new Dictionary<string, Dictionary<string, string>>
		{
			["SelfToggle"] = new Dictionary<string, string>
			{
				["en"] = "Skip completed weapons",
				["zh-CN"] = "跳过已集齐的武器",
				["zh-TW"] = "跳過已集齊的武器",
				["fr"] = "Ignorer les armes complètes",
				["de"] = "Vollständige Waffen überspringen",
				["it"] = "Salta armi complete",
				["ja"] = "コンプリートした武器をスキップ",
				["ko"] = "완성한 무기 건너뛰기",
				["pl"] = "Pomijaj ukończone bronie",
				["pt-BR"] = "Pular armas completas",
				["ru"] = "Пропускать собранное оружие",
				["es-MX"] = "Omitir armas completas",
				["es-ES"] = "Omitir armas completas",
				["sv"] = "Hoppa över kompletta vapen",
				["tr"] = "Tamamlanan silahları atla",
				["uk"] = "Пропускати зібрану зброю"
			},
			["SelfHint"] = new Dictionary<string, string>
			{
				["en"] = "Your rolls leave out weapons whose skins you've all unlocked. If the host doesn't have the mod, only you see the changed wheel.",
				["zh-CN"] = "你转动时会排除皮肤已全部解锁的武器。如果房主没有此模组,只有你能看到修改后的转盘。",
				["zh-TW"] = "你轉動時會排除外觀已全部解鎖的武器。如果房主沒有此模組,只有你看得到修改後的轉輪。",
				["fr"] = "Vos tirages excluent les armes dont toutes les apparences sont débloquées. Si l'hôte n'a pas le mod, vous seul voyez la roue modifiée.",
				["de"] = "Deine Drehungen lassen Waffen aus, deren Skins du alle freigeschaltet hast. Hat der Host den Mod nicht, siehst nur du die geänderte Walze.",
				["it"] = "I tuoi giri escludono le armi con tutte le skin sbloccate. Se l'host non ha la mod, solo tu vedi la ruota modificata.",
				["ja"] = "スキンをすべて解放した武器は、あなたが回すときに除外されます。ホストがMODを入れていない場合、変更された結果はあなたにだけ表示されます。",
				["ko"] = "스킨을 모두 해금한 무기는 내가 돌릴 때 제외됩니다. 호스트에 모드가 없으면 바뀐 결과는 나에게만 보입니다.",
				["pl"] = "Twoje losowania pomijają bronie, których wszystkie skórki odblokowałeś. Jeśli host nie ma moda, zmienione losowanie widzisz tylko ty.",
				["pt-BR"] = "Seus giros deixam de fora armas com todos os visuais desbloqueados. Se o host não tiver o mod, só você vê a roleta alterada.",
				["ru"] = "Ваши прокруты пропускают оружие, у которого открыты все скины. Если у хоста нет мода, изменённый барабан видите только вы.",
				["es-MX"] = "Tus giros dejan fuera las armas con todos sus aspectos desbloqueados. Si el anfitrión no tiene el mod, solo tú ves la ruleta cambiada.",
				["es-ES"] = "Tus tiradas dejan fuera las armas con todos sus diseños desbloqueados. Si el anfitrión no tiene el mod, solo tú ves la ruleta cambiada.",
				["sv"] = "Dina snurr hoppar över vapen där du har låst upp alla skins. Om värden saknar modden ser bara du den ändrade snurren.",
				["tr"] = "Çevirişlerin, tüm kaplamalarının kilidini açtığın silahları dışarıda bırakır. Kurucuda mod yoksa değişen çarkı yalnızca sen görürsün.",
				["uk"] = "Ваші прокрути пропускають зброю, у якої відкриті всі скіни. Якщо в хоста немає мода, змінений барабан бачите лише ви."
			},
			["StrikeToggle"] = new Dictionary<string, string>
			{
				["en"] = "Cross out completed weapons in the prize list",
				["zh-CN"] = "在奖品列表中划掉已集齐的武器",
				["zh-TW"] = "在獎品列表中劃掉已集齊的武器",
				["fr"] = "Barrer les armes complètes dans la liste des prix",
				["de"] = "Vollständige Waffen in der Preisliste durchstreichen",
				["it"] = "Barra le armi complete nell'elenco dei premi",
				["ja"] = "景品リストでコンプリート済みの武器に取り消し線",
				["ko"] = "상품 목록에서 완성한 무기에 취소선",
				["pl"] = "Przekreślaj ukończone bronie na liście nagród",
				["pt-BR"] = "Riscar armas completas na lista de prêmios",
				["ru"] = "Зачёркивать собранное оружие в списке призов",
				["es-MX"] = "Tachar armas completas en la lista de premios",
				["es-ES"] = "Tachar armas completas en la lista de premios",
				["sv"] = "Stryk över kompletta vapen i prislistan",
				["tr"] = "Ödül listesinde tamamlanan silahların üstünü çiz",
				["uk"] = "Закреслювати зібрану зброю у списку призів"
			},
			["StrikeHint"] = new Dictionary<string, string>
			{
				["en"] = "The prize list on the slot machine crosses out the weapons you've completed. Only you see the marks.",
				["zh-CN"] = "老虎机上的奖品列表会划掉你已集齐的武器。只有你能看到这些标记。",
				["zh-TW"] = "拉霸機上的獎品列表會劃掉你已集齊的武器。只有你看得到這些標記。",
				["fr"] = "La liste des prix de la machine à sous barre les armes que vous avez complétées. Vous seul voyez ces marques.",
				["de"] = "Die Preisliste am Spielautomaten streicht deine vollständigen Waffen durch. Nur du siehst die Markierung.",
				["it"] = "L'elenco dei premi sulla slot machine barra le armi che hai completato. Solo tu vedi i segni.",
				["ja"] = "スロットマシンの景品リストで、コンプリート済みの武器に取り消し線が付きます。この印はあなたにだけ見えます。",
				["ko"] = "슬롯머신의 상품 목록에서 완성한 무기에 취소선이 그어집니다. 이 표시는 나에게만 보입니다.",
				["pl"] = "Lista nagród na automacie przekreśla bronie, które ukończyłeś. Tylko ty widzisz te oznaczenia.",
				["pt-BR"] = "A lista de prêmios da máquina risca as armas que você já completou. Só você vê essas marcas.",
				["ru"] = "Список призов на автомате зачёркивает собранное оружие. Эти отметки видите только вы.",
				["es-MX"] = "La lista de premios de la tragamonedas tacha las armas que completaste. Solo tú ves las marcas.",
				["es-ES"] = "La lista de premios de la tragaperras tacha las armas que has completado. Solo tú ves las marcas.",
				["sv"] = "Prislistan på spelautomaten stryker över vapnen du har gjort klara. Bara du ser markeringarna.",
				["tr"] = "Slot makinesindeki ödül listesi tamamladığın silahların üstünü çizer. Bu işaretleri yalnızca sen görürsün.",
				["uk"] = "Список призів на автоматі закреслює зібрану зброю. Ці позначки бачите лише ви."
			}
		};

		public static event Action LanguageChanged;

		public static string Get(string key, params object[] args)
		{
			EnsureSubscribed();
			if (!Table.TryGetValue(key, out var value))
			{
				return key;
			}
			string value2 = null;
			string text = CurrentCode();
			if (text != null && !value.TryGetValue(text, out value2))
			{
				string value3 = text.Split('-')[0];
				foreach (KeyValuePair<string, string> item in value)
				{
					if (item.Key.Split('-')[0].Equals(value3, StringComparison.OrdinalIgnoreCase))
					{
						value2 = item.Value;
						break;
					}
				}
			}
			if (value2 == null)
			{
				value2 = value["en"];
			}
			if (args.Length == 0)
			{
				return value2;
			}
			return string.Format(value2, args);
		}

		private static string CurrentCode()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Locale selectedLocale = LocalizationSettings.SelectedLocale;
				object obj;
				if (selectedLocale == null)
				{
					obj = null;
				}
				else
				{
					LocaleIdentifier identifier = selectedLocale.Identifier;
					obj = ((LocaleIdentifier)(ref identifier)).Code;
				}
				string text = (string)obj;
				if (string.IsNullOrEmpty(text))
				{
					return null;
				}
				string[] array = text.Split('-');
				return (array.Length == 2) ? (array[0].ToLowerInvariant() + "-" + array[1].ToUpperInvariant()) : text.ToLowerInvariant();
			}
			catch (Exception)
			{
				return null;
			}
		}

		private static void EnsureSubscribed()
		{
			if (_subscribed)
			{
				return;
			}
			try
			{
				LocalizationSettings.SelectedLocaleChanged += delegate
				{
					Strings.LanguageChanged?.Invoke();
				};
				_subscribed = true;
			}
			catch (Exception)
			{
			}
		}
	}
	internal static class PluginInfo
	{
		public const string Version = "1.0.0";
	}
}