Decompiled source of PeakPresets v1.0.1

PeakPresets.dll

Decompiled 12 minutes ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[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 PeakPresets
{
	public static class Loc
	{
		public static bool IsUkrainian => (int)LocalizedText.CURRENT_LANGUAGE == 8;

		public static string T(string uk, string en)
		{
			if (!IsUkrainian)
			{
				return en;
			}
			return uk;
		}
	}
	[HarmonyPatch(typeof(PauseMenuMainPage), "Start")]
	public static class PauseMenuMainPage_Start_Patch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__0_0;

			internal void <Postfix>b__0_0()
			{
				if ((Object)(object)PresetsWindow.Instance != (Object)null)
				{
					PresetsWindow.Instance.Toggle();
				}
			}
		}

		private static void Postfix(PauseMenuMainPage __instance)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				object? value = AccessTools.Field(typeof(PauseMenuMainPage), "m_settingsButton").GetValue(__instance);
				Button val = (Button)((value is Button) ? value : null);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Transform parent = ((Component)val).transform.parent;
				if ((Object)(object)parent.Find("PeakPresetsButton") != (Object)null)
				{
					return;
				}
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				GameObject val2 = new GameObject("PeakPresetsButton", new Type[1] { typeof(RectTransform) });
				val2.transform.SetParent(parent, false);
				RectTransform component2 = val2.GetComponent<RectTransform>();
				component2.sizeDelta = component.sizeDelta;
				component2.anchorMin = component.anchorMin;
				component2.anchorMax = component.anchorMax;
				component2.pivot = component.pivot;
				((Transform)component2).localScale = ((Transform)component).localScale;
				Image val3 = val2.AddComponent<Image>();
				Image component3 = ((Component)val).GetComponent<Image>();
				if ((Object)(object)component3 != (Object)null)
				{
					val3.sprite = component3.sprite;
				}
				val3.type = (Type)1;
				((Graphic)val3).color = new Color(0.25f, 0.55f, 0.6f);
				ButtonClickedEvent onClick = val2.AddComponent<Button>().onClick;
				object obj = <>c.<>9__0_0;
				if (obj == null)
				{
					UnityAction val4 = delegate
					{
						if ((Object)(object)PresetsWindow.Instance != (Object)null)
						{
							PresetsWindow.Instance.Toggle();
						}
					};
					<>c.<>9__0_0 = val4;
					obj = (object)val4;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
				GameObject val5 = new GameObject("Text", new Type[1] { typeof(RectTransform) });
				val5.transform.SetParent(val2.transform, false);
				RectTransform component4 = val5.GetComponent<RectTransform>();
				component4.anchorMin = Vector2.zero;
				component4.anchorMax = Vector2.one;
				component4.offsetMin = Vector2.zero;
				component4.offsetMax = Vector2.zero;
				Text text = val5.AddComponent<Text>();
				Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
				if ((Object)(object)builtinResource == (Object)null)
				{
					builtinResource = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
				}
				text.font = builtinResource;
				text.fontSize = 20;
				text.alignment = (TextAnchor)4;
				((Graphic)text).color = Color.white;
				text.text = Loc.T("ПРЕСЕТИ", "PRESETS");
				LocalizedText.OnLangugageChanged = (Action)Delegate.Combine(LocalizedText.OnLangugageChanged, (Action)delegate
				{
					if ((Object)(object)text != (Object)null)
					{
						text.text = Loc.T("ПРЕСЕТИ", "PRESETS");
					}
				});
				val2.transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex() + 1);
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakPresets] Failed to inject pause menu button: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(PauseMenuHandler), "Update")]
	public static class PauseMenuHandler_Update_Patch
	{
		private static bool Prefix()
		{
			if ((Object)(object)PresetsWindow.Instance != (Object)null && PresetsWindow.Instance.IsOpen)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PassportManager), "Initialize")]
	public static class PassportManager_Initialize_Patch
	{
		private static void Postfix(PassportManager __instance)
		{
			PassportButtonInjector.EnsureButton(__instance);
		}
	}
	[HarmonyPatch(typeof(PassportManager), "ToggleOpen")]
	public static class PassportManager_ToggleOpen_Patch
	{
		private static void Postfix(PassportManager __instance)
		{
			PassportButtonInjector.EnsureButton(__instance);
		}
	}
	public static class PassportButtonInjector
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__0_0;

			internal void <EnsureButton>b__0_0()
			{
				if ((Object)(object)PresetsWindow.Instance != (Object)null)
				{
					PresetsWindow.Instance.Toggle();
				}
			}
		}

		public static void EnsureButton(PassportManager pm)
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00f7: 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)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Expected O, but got Unknown
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)pm == (Object)null)
				{
					return;
				}
				Transform val = null;
				if ((Object)(object)pm.nameText != (Object)null)
				{
					val = ((TMP_Text)pm.nameText).transform.parent;
				}
				if ((Object)(object)val == (Object)null && pm.buttons != null && pm.buttons.Length != 0 && (Object)(object)pm.buttons[0] != (Object)null)
				{
					val = ((Component)pm.buttons[0]).transform.parent;
				}
				if ((Object)(object)val == (Object)null && (Object)(object)pm.uiObject != (Object)null)
				{
					val = pm.uiObject.transform;
				}
				if ((Object)(object)val == (Object)null || (Object)(object)val.Find("PeakPresetsPassportButton") != (Object)null)
				{
					return;
				}
				GameObject val2 = new GameObject("PeakPresetsPassportButton", new Type[1] { typeof(RectTransform) });
				val2.transform.SetParent(val, false);
				RectTransform component = val2.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(1f, 1f);
				component.anchorMax = new Vector2(1f, 1f);
				component.pivot = new Vector2(1f, 1f);
				component.anchoredPosition = new Vector2(-10f, -70f);
				component.sizeDelta = new Vector2(150f, 40f);
				((Graphic)val2.AddComponent<Image>()).color = new Color(0.25f, 0.55f, 0.6f, 0.95f);
				ButtonClickedEvent onClick = val2.AddComponent<Button>().onClick;
				object obj = <>c.<>9__0_0;
				if (obj == null)
				{
					UnityAction val3 = delegate
					{
						if ((Object)(object)PresetsWindow.Instance != (Object)null)
						{
							PresetsWindow.Instance.Toggle();
						}
					};
					<>c.<>9__0_0 = val3;
					obj = (object)val3;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
				GameObject val4 = new GameObject("Text", new Type[1] { typeof(RectTransform) });
				val4.transform.SetParent(val2.transform, false);
				RectTransform component2 = val4.GetComponent<RectTransform>();
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				component2.offsetMin = Vector2.zero;
				component2.offsetMax = Vector2.zero;
				Text text = val4.AddComponent<Text>();
				Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
				if ((Object)(object)builtinResource == (Object)null)
				{
					builtinResource = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
				}
				text.font = builtinResource;
				text.fontSize = 16;
				text.alignment = (TextAnchor)4;
				((Graphic)text).color = Color.white;
				text.text = Loc.T("Пресети", "Presets");
				LocalizedText.OnLangugageChanged = (Action)Delegate.Combine(LocalizedText.OnLangugageChanged, (Action)delegate
				{
					if ((Object)(object)text != (Object)null)
					{
						text.text = Loc.T("Пресети", "Presets");
					}
				});
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakPresets] Failed to inject passport button: " + ex));
			}
		}
	}
	[BepInPlugin("kiberzuzka.peak.presets", "PeakPresets", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "kiberzuzka.peak.presets";

		public const string PluginName = "PeakPresets";

		public const string PluginVersion = "1.0.0";

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[PeakPresets] Loading v1.0.0...");
			_harmony = new Harmony("kiberzuzka.peak.presets");
			_harmony.PatchAll();
			GameObject val = new GameObject("PeakPresetsRunner");
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<PresetsWindow>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[PeakPresets] Loaded.");
		}
	}
	[Serializable]
	public class PresetSlot
	{
		public string name = "";

		public bool hasData;

		public int skin;

		public int accessory;

		public int eyes;

		public int mouth;

		public int outfit;

		public int hat;

		public int sash;

		public string photoBase64 = "";
	}
	[Serializable]
	public class PresetSaveFile
	{
		public PresetSlot[] slots;
	}
	public static class PresetStorage
	{
		public const int SlotCount = 20;

		private static string SaveDir => Path.Combine(Application.persistentDataPath, "PeakPresets");

		private static string SaveFilePath => Path.Combine(SaveDir, "presets.json");

		public static PresetSaveFile Load()
		{
			try
			{
				if (File.Exists(SaveFilePath))
				{
					PresetSaveFile presetSaveFile = JsonUtility.FromJson<PresetSaveFile>(File.ReadAllText(SaveFilePath));
					if (presetSaveFile != null && presetSaveFile.slots != null && presetSaveFile.slots.Length == 20)
					{
						return presetSaveFile;
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakPresets] Failed to load presets: " + ex));
			}
			return CreateEmpty();
		}

		public static void Save(PresetSaveFile data)
		{
			try
			{
				if (!Directory.Exists(SaveDir))
				{
					Directory.CreateDirectory(SaveDir);
				}
				string contents = JsonUtility.ToJson((object)data, true);
				File.WriteAllText(SaveFilePath, contents);
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakPresets] Failed to save presets: " + ex));
			}
		}

		public static PresetSaveFile CreateEmpty()
		{
			PresetSaveFile presetSaveFile = new PresetSaveFile
			{
				slots = new PresetSlot[20]
			};
			for (int i = 0; i < 20; i++)
			{
				presetSaveFile.slots[i] = new PresetSlot();
			}
			return presetSaveFile;
		}
	}
	public class PresetsWindow : MonoBehaviour
	{
		private class SlotUI
		{
			public GameObject root;

			public RawImage photo;

			public Image emptyBg;

			public Text nameText;

			public InputField nameInput;

			public Button saveButton;

			public Button loadButton;

			public Text saveText;

			public Text loadText;

			public Texture2D photoTexture;
		}

		private const int Columns = 5;

		private const int Rows = 4;

		private const int NameCharLimit = 16;

		private PresetSaveFile _data;

		private GameObject _canvasRoot;

		private GameObject _panel;

		private SlotUI[] _slotUis;

		private Text _titleText;

		private Text _backText;

		private Text _statusText;

		private Coroutine _statusRoutine;

		private bool _built;

		private Font _font;

		private Sprite _uiSprite;

		public static PresetsWindow Instance { get; private set; }

		public bool IsOpen
		{
			get
			{
				if ((Object)(object)_canvasRoot != (Object)null)
				{
					return _canvasRoot.activeSelf;
				}
				return false;
			}
		}

		private void Awake()
		{
			Instance = this;
			_data = PresetStorage.Load();
			LocalizedText.OnLangugageChanged = (Action)Delegate.Combine(LocalizedText.OnLangugageChanged, new Action(RefreshLanguage));
		}

		private void OnDestroy()
		{
			LocalizedText.OnLangugageChanged = (Action)Delegate.Remove(LocalizedText.OnLangugageChanged, new Action(RefreshLanguage));
		}

		private void RefreshLanguage()
		{
			if (!_built)
			{
				return;
			}
			if ((Object)(object)_titleText != (Object)null)
			{
				_titleText.text = Loc.T("ПРЕСЕТИ", "PRESETS");
			}
			if ((Object)(object)_backText != (Object)null)
			{
				_backText.text = Loc.T("Назад", "Back");
			}
			for (int i = 0; i < 20; i++)
			{
				SlotUI slotUI = _slotUis[i];
				if (slotUI != null)
				{
					if ((Object)(object)slotUI.saveText != (Object)null)
					{
						slotUI.saveText.text = Loc.T("Сейв", "Save");
					}
					if ((Object)(object)slotUI.loadText != (Object)null)
					{
						slotUI.loadText.text = Loc.T("Луд", "Load");
					}
					RefreshSlot(i);
				}
			}
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)287))
			{
				Toggle();
			}
			else if ((Object)(object)_canvasRoot != (Object)null && _canvasRoot.activeSelf && Input.GetKeyDown((KeyCode)27))
			{
				Close();
			}
		}

		public void Toggle()
		{
			if (IsOpen)
			{
				Close();
			}
			else
			{
				Open();
			}
		}

		public void Open()
		{
			if (!_built)
			{
				BuildUI();
			}
			_canvasRoot.SetActive(true);
			RefreshAllSlots();
		}

		public void Close()
		{
			if ((Object)(object)_canvasRoot != (Object)null)
			{
				_canvasRoot.SetActive(false);
			}
		}

		private Font GetFont()
		{
			if ((Object)(object)_font != (Object)null)
			{
				return _font;
			}
			_font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			if ((Object)(object)_font == (Object)null)
			{
				_font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
			}
			return _font;
		}

		private Sprite GetUiSprite()
		{
			if ((Object)(object)_uiSprite != (Object)null)
			{
				return _uiSprite;
			}
			_uiSprite = Resources.GetBuiltinResource<Sprite>("UISprite.psd");
			return _uiSprite;
		}

		private void BuildUI()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Expected O, but got Unknown
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Expected O, but got Unknown
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			_built = true;
			_canvasRoot = new GameObject("PeakPresets_Canvas");
			Object.DontDestroyOnLoad((Object)(object)_canvasRoot);
			Canvas obj = _canvasRoot.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 5000;
			CanvasScaler obj2 = _canvasRoot.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			_canvasRoot.AddComponent<GraphicRaycaster>();
			GameObject val = CreatePanel(_canvasRoot.transform, "Dim", new Color(0f, 0f, 0f, 0.65f));
			StretchFull(val.GetComponent<RectTransform>());
			Button obj3 = val.AddComponent<Button>();
			((Selectable)obj3).transition = (Transition)0;
			((UnityEvent)obj3.onClick).AddListener(new UnityAction(Close));
			_panel = CreatePanel(_canvasRoot.transform, "Panel", new Color(0.12f, 0.12f, 0.14f, 0.97f));
			RectTransform component = _panel.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(1150f, 780f);
			component.anchoredPosition = Vector2.zero;
			GameObject val2 = CreateButton(_panel.transform, "BackButton", Loc.T("Назад", "Back"), new Color(0.85f, 0.4f, 0.15f));
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 1f);
			component2.anchorMax = new Vector2(0f, 1f);
			component2.pivot = new Vector2(0f, 1f);
			component2.anchoredPosition = new Vector2(24f, -24f);
			component2.sizeDelta = new Vector2(140f, 50f);
			((UnityEvent)val2.GetComponent<Button>().onClick).AddListener(new UnityAction(Close));
			_backText = val2.GetComponentInChildren<Text>();
			GameObject val3 = CreateText(_panel.transform, "Title", Loc.T("ПРЕСЕТИ", "PRESETS"), 34, (TextAnchor)4);
			_titleText = val3.GetComponent<Text>();
			RectTransform component3 = val3.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0.5f, 1f);
			component3.anchorMax = new Vector2(0.5f, 1f);
			component3.pivot = new Vector2(0.5f, 1f);
			component3.anchoredPosition = new Vector2(0f, -30f);
			component3.sizeDelta = new Vector2(500f, 50f);
			GameObject val4 = new GameObject("Grid", new Type[1] { typeof(RectTransform) });
			val4.transform.SetParent(_panel.transform, false);
			RectTransform component4 = val4.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0.5f, 0.5f);
			component4.anchorMax = new Vector2(0.5f, 0.5f);
			component4.pivot = new Vector2(0.5f, 0.5f);
			component4.anchoredPosition = new Vector2(0f, -20f);
			component4.sizeDelta = new Vector2(1080f, 660f);
			GridLayoutGroup obj4 = val4.AddComponent<GridLayoutGroup>();
			obj4.cellSize = new Vector2(196f, 150f);
			obj4.spacing = new Vector2(14f, 14f);
			obj4.constraint = (Constraint)1;
			obj4.constraintCount = 5;
			((LayoutGroup)obj4).childAlignment = (TextAnchor)1;
			_slotUis = new SlotUI[20];
			for (int i = 0; i < 20; i++)
			{
				_slotUis[i] = BuildSlot(val4.transform, i);
			}
			GameObject val5 = CreateText(_panel.transform, "Status", "", 18, (TextAnchor)4);
			_statusText = val5.GetComponent<Text>();
			RectTransform component5 = val5.GetComponent<RectTransform>();
			component5.anchorMin = new Vector2(0.5f, 0f);
			component5.anchorMax = new Vector2(0.5f, 0f);
			component5.pivot = new Vector2(0.5f, 0f);
			component5.anchoredPosition = new Vector2(0f, 14f);
			component5.sizeDelta = new Vector2(900f, 30f);
		}

		private void SetStatus(string message, bool isError)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_statusText == (Object)null))
			{
				_statusText.text = message;
				((Graphic)_statusText).color = (isError ? new Color(1f, 0.45f, 0.4f) : new Color(0.55f, 1f, 0.55f));
				if (_statusRoutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(_statusRoutine);
				}
				_statusRoutine = ((MonoBehaviour)this).StartCoroutine(ClearStatusAfterDelay());
			}
		}

		private IEnumerator ClearStatusAfterDelay()
		{
			yield return (object)new WaitForSeconds(3f);
			if ((Object)(object)_statusText != (Object)null)
			{
				_statusText.text = "";
			}
		}

		private SlotUI BuildSlot(Transform parent, int index)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_007e: 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: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Expected O, but got Unknown
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Expected O, but got Unknown
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Expected O, but got Unknown
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Expected O, but got Unknown
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Expected O, but got Unknown
			SlotUI slotUI = new SlotUI();
			GameObject val = new GameObject("Slot_" + index, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			slotUI.root = val;
			Image obj = val.AddComponent<Image>();
			obj.sprite = GetUiSprite();
			obj.type = (Type)1;
			((Graphic)obj).color = new Color(0.22f, 0.22f, 0.25f, 1f);
			GameObject val2 = new GameObject("Photo", new Type[1] { typeof(RectTransform) });
			val2.transform.SetParent(val.transform, false);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.1f, 0.35f);
			component.anchorMax = new Vector2(0.9f, 0.98f);
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			slotUI.photo = val2.AddComponent<RawImage>();
			((Graphic)slotUI.photo).color = Color.white;
			((Component)slotUI.photo).gameObject.SetActive(false);
			GameObject val3 = new GameObject("Empty", new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent(val.transform, false);
			RectTransform component2 = val3.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0.1f, 0.35f);
			component2.anchorMax = new Vector2(0.9f, 0.98f);
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			slotUI.emptyBg = val3.AddComponent<Image>();
			((Graphic)slotUI.emptyBg).color = new Color(0.16f, 0.16f, 0.18f, 1f);
			GameObject val4 = new GameObject("Name", new Type[1] { typeof(RectTransform) });
			val4.transform.SetParent(val.transform, false);
			RectTransform component3 = val4.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 0.19f);
			component3.anchorMax = new Vector2(1f, 0.35f);
			component3.offsetMin = Vector2.zero;
			component3.offsetMax = Vector2.zero;
			slotUI.nameText = val4.AddComponent<Text>();
			slotUI.nameText.font = GetFont();
			slotUI.nameText.fontSize = 16;
			slotUI.nameText.alignment = (TextAnchor)4;
			((Graphic)slotUI.nameText).color = Color.white;
			slotUI.nameText.text = Loc.T("Пресет ", "Preset ") + (index + 1);
			Button obj2 = val4.AddComponent<Button>();
			((Selectable)obj2).transition = (Transition)0;
			int capturedIndex = index;
			((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate
			{
				StartRename(capturedIndex);
			});
			GameObject val5 = new GameObject("NameInput", new Type[1] { typeof(RectTransform) });
			val5.transform.SetParent(val.transform, false);
			RectTransform component4 = val5.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 0.19f);
			component4.anchorMax = new Vector2(1f, 0.35f);
			component4.offsetMin = Vector2.zero;
			component4.offsetMax = Vector2.zero;
			((Graphic)val5.AddComponent<Image>()).color = new Color(0.05f, 0.05f, 0.05f, 1f);
			GameObject val6 = new GameObject("Text", new Type[1] { typeof(RectTransform) });
			val6.transform.SetParent(val5.transform, false);
			StretchFull(val6.GetComponent<RectTransform>());
			Text val7 = val6.AddComponent<Text>();
			val7.font = GetFont();
			val7.fontSize = 16;
			((Graphic)val7).color = Color.white;
			val7.alignment = (TextAnchor)4;
			slotUI.nameInput = val5.AddComponent<InputField>();
			slotUI.nameInput.textComponent = val7;
			slotUI.nameInput.characterLimit = 16;
			((UnityEvent<string>)(object)slotUI.nameInput.onEndEdit).AddListener((UnityAction<string>)delegate(string newName)
			{
				EndRename(capturedIndex, newName);
			});
			val5.SetActive(false);
			slotUI.saveButton = CreateSmallButton(val.transform, "SaveBtn", Loc.T("Сейв", "Save"), new Color(0.2f, 0.55f, 0.85f), new Vector2(0f, 0f), new Vector2(0.5f, 0.19f));
			((UnityEvent)slotUI.saveButton.onClick).AddListener((UnityAction)delegate
			{
				OnSaveClicked(capturedIndex);
			});
			slotUI.saveText = ((Component)slotUI.saveButton).GetComponentInChildren<Text>();
			slotUI.loadButton = CreateSmallButton(val.transform, "LoadBtn", Loc.T("Луд", "Load"), new Color(0.2f, 0.7f, 0.35f), new Vector2(0.5f, 0f), new Vector2(1f, 0.19f));
			((UnityEvent)slotUI.loadButton.onClick).AddListener((UnityAction)delegate
			{
				OnLoadClicked(capturedIndex);
			});
			slotUI.loadText = ((Component)slotUI.loadButton).GetComponentInChildren<Text>();
			return slotUI;
		}

		private Button CreateSmallButton(Transform parent, string name, string text, Color color, Vector2 anchorMin, Vector2 anchorMax)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_005c: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = anchorMin;
			component.anchorMax = anchorMax;
			component.offsetMin = new Vector2(2f, 2f);
			component.offsetMax = new Vector2(-2f, -2f);
			Image obj = val.AddComponent<Image>();
			obj.sprite = GetUiSprite();
			obj.type = (Type)1;
			((Graphic)obj).color = color;
			Button val2 = val.AddComponent<Button>();
			ColorBlock colors = ((Selectable)val2).colors;
			((ColorBlock)(ref colors)).highlightedColor = color * 1.15f;
			((ColorBlock)(ref colors)).pressedColor = color * 0.8f;
			((Selectable)val2).colors = colors;
			GameObject val3 = new GameObject("Text", new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent(val.transform, false);
			StretchFull(val3.GetComponent<RectTransform>());
			Text obj2 = val3.AddComponent<Text>();
			obj2.font = GetFont();
			obj2.fontSize = 14;
			obj2.alignment = (TextAnchor)4;
			((Graphic)obj2).color = Color.white;
			obj2.text = text;
			return val2;
		}

		private GameObject CreatePanel(Transform parent, string name, Color color)
		{
			//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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			((Graphic)val.AddComponent<Image>()).color = color;
			return val;
		}

		private GameObject CreateButton(Transform parent, string name, string text, Color color)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			Image obj = val.AddComponent<Image>();
			obj.sprite = GetUiSprite();
			obj.type = (Type)1;
			((Graphic)obj).color = color;
			val.AddComponent<Button>();
			GameObject val2 = new GameObject("Text", new Type[1] { typeof(RectTransform) });
			val2.transform.SetParent(val.transform, false);
			StretchFull(val2.GetComponent<RectTransform>());
			Text obj2 = val2.AddComponent<Text>();
			obj2.font = GetFont();
			obj2.fontSize = 18;
			obj2.alignment = (TextAnchor)4;
			((Graphic)obj2).color = Color.white;
			obj2.text = text;
			return val;
		}

		private GameObject CreateText(Transform parent, string name, string text, int fontSize, TextAnchor anchor)
		{
			//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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			Text obj = val.AddComponent<Text>();
			obj.font = GetFont();
			obj.fontSize = fontSize;
			obj.alignment = anchor;
			((Graphic)obj).color = Color.white;
			obj.text = text;
			return val;
		}

		private void StretchFull(RectTransform rect)
		{
			//IL_0001: 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_0017: 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)
			rect.anchorMin = Vector2.zero;
			rect.anchorMax = Vector2.one;
			rect.offsetMin = Vector2.zero;
			rect.offsetMax = Vector2.zero;
		}

		private void RefreshAllSlots()
		{
			for (int i = 0; i < 20; i++)
			{
				RefreshSlot(i);
			}
		}

		private void RefreshSlot(int index)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			PresetSlot presetSlot = _data.slots[index];
			SlotUI slotUI = _slotUis[index];
			if (slotUI == null)
			{
				return;
			}
			slotUI.nameText.text = (string.IsNullOrEmpty(presetSlot.name) ? (Loc.T("Пресет ", "Preset ") + (index + 1)) : presetSlot.name);
			((Component)slotUI.loadButton).gameObject.SetActive(presetSlot.hasData);
			((Component)slotUI.emptyBg).gameObject.SetActive(!presetSlot.hasData);
			((Component)slotUI.photo).gameObject.SetActive(false);
			if (!presetSlot.hasData || string.IsNullOrEmpty(presetSlot.photoBase64))
			{
				return;
			}
			try
			{
				byte[] array = Convert.FromBase64String(presetSlot.photoBase64);
				if ((Object)(object)slotUI.photoTexture == (Object)null)
				{
					slotUI.photoTexture = new Texture2D(2, 2, (TextureFormat)4, false);
				}
				ImageConversion.LoadImage(slotUI.photoTexture, array);
				slotUI.photo.texture = (Texture)(object)slotUI.photoTexture;
				((Component)slotUI.photo).gameObject.SetActive(true);
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakPresets] Failed to decode preset photo: " + ex));
			}
		}

		private void StartRename(int index)
		{
			SlotUI obj = _slotUis[index];
			PresetSlot presetSlot = _data.slots[index];
			Transform obj2 = ((Component)obj.nameInput).transform.parent.Find("NameInput");
			if (obj2 != null)
			{
				((Component)obj2).gameObject.SetActive(true);
			}
			((Component)obj.nameInput).gameObject.SetActive(true);
			obj.nameInput.text = presetSlot.name;
			((Selectable)obj.nameInput).Select();
			obj.nameInput.ActivateInputField();
		}

		private void EndRename(int index, string newName)
		{
			SlotUI obj = _slotUis[index];
			_data.slots[index].name = (string.IsNullOrWhiteSpace(newName) ? "" : newName.Trim());
			((Component)obj.nameInput).gameObject.SetActive(false);
			PresetStorage.Save(_data);
			RefreshSlot(index);
		}

		private void OnLoadClicked(int index)
		{
			PresetSlot presetSlot = _data.slots[index];
			if (!presetSlot.hasData)
			{
				return;
			}
			try
			{
				CharacterCustomization.SetCharacterSkinColor(presetSlot.skin);
				CharacterCustomization.SetCharacterEyes(presetSlot.eyes);
				CharacterCustomization.SetCharacterMouth(presetSlot.mouth);
				CharacterCustomization.SetCharacterAccessory(presetSlot.accessory);
				CharacterCustomization.SetCharacterOutfit(presetSlot.outfit);
				CharacterCustomization.SetCharacterHat(presetSlot.hat);
				CharacterCustomization.SetCharacterSash(presetSlot.sash);
				SetStatus(Loc.T("Завантажено!", "Loaded!"), isError: false);
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakPresets] Failed to apply preset: " + ex));
				SetStatus(Loc.T("Помилка завантаження (див. лог)", "Load failed (see log)"), isError: true);
			}
		}

		private CharacterCustomizationData GetCurrentCustomizationData()
		{
			try
			{
				PersistentPlayerDataService service = GameHandler.GetService<PersistentPlayerDataService>();
				if (service == null)
				{
					Debug.LogError((object)"[PeakPresets] PersistentPlayerDataService не найден (GameHandler.GetService вернул null).");
					return null;
				}
				Player localPlayer = PhotonNetwork.LocalPlayer;
				if (localPlayer == null)
				{
					Debug.LogError((object)"[PeakPresets] PhotonNetwork.LocalPlayer == null.");
					return null;
				}
				PersistentPlayerData playerData = service.GetPlayerData(localPlayer);
				if (playerData == null)
				{
					Debug.LogError((object)"[PeakPresets] GetPlayerData вернул null.");
					return null;
				}
				return playerData.customizationData;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakPresets] Failed to read current customization: " + ex));
				return null;
			}
		}

		private void OnSaveClicked(int index)
		{
			((MonoBehaviour)this).StartCoroutine(SaveSlotRoutine(index));
		}

		private IEnumerator SaveSlotRoutine(int index)
		{
			CharacterCustomizationData currentCustomizationData = GetCurrentCustomizationData();
			if (currentCustomizationData == null)
			{
				SetStatus(Loc.T("Помилка збереження (див. лог)", "Save failed (see log)"), isError: true);
				yield break;
			}
			PresetSlot obj = _data.slots[index];
			obj.hasData = true;
			obj.skin = currentCustomizationData.currentSkin;
			obj.accessory = currentCustomizationData.currentAccessory;
			obj.eyes = currentCustomizationData.currentEyes;
			obj.mouth = currentCustomizationData.currentMouth;
			obj.outfit = currentCustomizationData.currentOutfit;
			obj.hat = currentCustomizationData.currentHat;
			obj.sash = currentCustomizationData.currentSash;
			yield return CapturePreviewRoutine(index);
			PresetStorage.Save(_data);
			RefreshSlot(index);
			SetStatus(Loc.T("Збережено!", "Saved!"), isError: false);
		}

		private IEnumerator CapturePreviewRoutine(int index)
		{
			PassportManager pm = PassportManager.instance;
			if ((Object)(object)pm == (Object)null || (Object)(object)pm.dummy == (Object)null || (Object)(object)pm.dummyCamera == (Object)null)
			{
				Debug.LogWarning((object)"[PeakPresets] PassportManager.instance/dummy/dummyCamera недоступны — фото не сделано (данные всё равно сохранены). Открой паспорт хотя бы раз за игру, чтобы фото работало.");
				yield break;
			}
			bool uiWasActive = (Object)(object)pm.uiObject != (Object)null && pm.uiObject.activeSelf;
			bool dummyWasActive = ((Component)pm.dummy).gameObject.activeSelf;
			try
			{
				if ((Object)(object)pm.uiObject != (Object)null && !uiWasActive)
				{
					pm.uiObject.SetActive(true);
				}
				if (!dummyWasActive)
				{
					((Component)pm.dummy).gameObject.SetActive(true);
				}
				pm.dummy.UpdateDummy();
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakPresets] Failed to prep preview dummy: " + ex));
				RestoreDummyState(pm, uiWasActive, dummyWasActive);
				yield break;
			}
			yield return (object)new WaitForEndOfFrame();
			Texture2D val = null;
			RenderTexture val2 = null;
			RenderTexture targetTexture = pm.dummyCamera.targetTexture;
			RenderTexture active = RenderTexture.active;
			try
			{
				val2 = new RenderTexture(512, 512, 24);
				pm.dummyCamera.targetTexture = val2;
				pm.dummyCamera.Render();
				RenderTexture.active = val2;
				val = new Texture2D(512, 512, (TextureFormat)4, false);
				val.ReadPixels(new Rect(0f, 0f, 512f, 512f), 0, 0);
				val.Apply();
				byte[] inArray = ImageConversion.EncodeToPNG(val);
				_data.slots[index].photoBase64 = Convert.ToBase64String(inArray);
			}
			catch (Exception ex2)
			{
				Debug.LogError((object)("[PeakPresets] Failed to capture preview: " + ex2));
			}
			finally
			{
				pm.dummyCamera.targetTexture = targetTexture;
				RenderTexture.active = active;
				if ((Object)(object)val2 != (Object)null)
				{
					Object.Destroy((Object)(object)val2);
				}
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
				RestoreDummyState(pm, uiWasActive, dummyWasActive);
			}
		}

		private void RestoreDummyState(PassportManager pm, bool uiWasActive, bool dummyWasActive)
		{
			try
			{
				if (!dummyWasActive)
				{
					((Component)pm.dummy).gameObject.SetActive(false);
				}
				if ((Object)(object)pm.uiObject != (Object)null && !uiWasActive)
				{
					pm.uiObject.SetActive(false);
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakPresets] Failed to restore dummy state: " + ex));
			}
		}
	}
}