Decompiled source of Yap Yap Shop v1.0.0

BepInEx/plugins/Empress-YapYapShop/EmpressYapYapShop.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Empress_ShopLoaderAPI;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.Networking;
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("Omniscye")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmpressYapYapShop")]
[assembly: AssemblyTitle("EmpressYapYapShop")]
[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 Empress.REPO.YapYapShop
{
	public sealed class EmpressYapYapAmbience : MonoBehaviour
	{
		private AudioSource _music;

		private AudioSource _ambience;

		private void Start()
		{
			if ((Object)(object)YapYapAssets.Music != (Object)null)
			{
				_music = ((Component)this).gameObject.AddComponent<AudioSource>();
				_music.clip = YapYapAssets.Music;
				_music.loop = true;
				_music.spatialBlend = 0f;
				_music.volume = 0.32f;
				_music.Play();
			}
			if ((Object)(object)YapYapAssets.Ambience != (Object)null)
			{
				_ambience = ((Component)this).gameObject.AddComponent<AudioSource>();
				_ambience.clip = YapYapAssets.Ambience;
				_ambience.loop = true;
				_ambience.spatialBlend = 0f;
				_ambience.volume = 0.5f;
				_ambience.Play();
			}
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)_music))
			{
				_music.Stop();
			}
			if (Object.op_Implicit((Object)(object)_ambience))
			{
				_ambience.Stop();
			}
		}
	}
	public sealed class EmpressYapYapPortal : MonoBehaviour, IOnEventCallback
	{
		private const byte PortalEvent = 144;

		private const float InteractionDistance = 3.5f;

		private const float CountdownSeconds = 10f;

		private const float PortalVolume = 0.2f;

		private bool _sequenceRunning;

		private AudioSource _audio;

		private Text _hudText;

		private void OnEnable()
		{
			PhotonNetwork.AddCallbackTarget((object)this);
		}

		private void OnDisable()
		{
			PhotonNetwork.RemoveCallbackTarget((object)this);
		}

		private void Start()
		{
			_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
			_audio.spatialBlend = 1f;
			_audio.minDistance = 2f;
			_audio.maxDistance = 30f;
			_audio.volume = 0.2f;
			BuildHudText();
		}

		private void Update()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			if (_sequenceRunning || !Object.op_Implicit((Object)(object)PlayerAvatar.instance))
			{
				return;
			}
			if (Vector3.Distance(((Component)this).transform.position, ((Component)PlayerAvatar.instance).transform.position) > 3.5f)
			{
				if (Object.op_Implicit((Object)(object)_hudText) && _hudText.text.StartsWith("[E]"))
				{
					_hudText.text = "";
				}
				return;
			}
			if (Object.op_Implicit((Object)(object)_hudText))
			{
				_hudText.text = "[E] Leave the shop";
			}
			if (InputManager.instance.KeyDown((InputKey)2) || Input.GetKeyDown((KeyCode)101))
			{
				if (PhotonNetwork.InRoom)
				{
					PhotonNetwork.RaiseEvent((byte)144, (object)null, new RaiseEventOptions
					{
						Receivers = (ReceiverGroup)0
					}, SendOptions.SendReliable);
				}
				BeginSequence();
			}
		}

		public void OnEvent(EventData photonEvent)
		{
			if (photonEvent.Code == 144 && !((Object)(object)this != (Object)(object)Object.FindObjectOfType<EmpressYapYapPortal>()))
			{
				BeginSequence();
			}
		}

		private void BeginSequence()
		{
			if (!_sequenceRunning)
			{
				_sequenceRunning = true;
				((MonoBehaviour)this).StartCoroutine(RunSequence());
			}
		}

		private IEnumerator RunSequence()
		{
			if ((Object)(object)YapYapAssets.PortalStart != (Object)null)
			{
				_audio.PlayOneShot(YapYapAssets.PortalStart);
			}
			if ((Object)(object)YapYapAssets.PortalLoop != (Object)null)
			{
				_audio.clip = YapYapAssets.PortalLoop;
				_audio.loop = true;
				_audio.Play();
			}
			float remaining = 10f;
			while (remaining > 0f)
			{
				if (Object.op_Implicit((Object)(object)_hudText))
				{
					_hudText.text = "The portal hums... leaving in " + Mathf.CeilToInt(remaining);
				}
				remaining -= Time.deltaTime;
				yield return null;
			}
			_audio.loop = false;
			_audio.Stop();
			if ((Object)(object)YapYapAssets.PortalEnd != (Object)null)
			{
				_audio.PlayOneShot(YapYapAssets.PortalEnd);
			}
			if (Object.op_Implicit((Object)(object)_hudText))
			{
				_hudText.text = "";
			}
			yield return (object)new WaitForSeconds(1.5f);
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)0);
			}
		}

		private void BuildHudText()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_008b: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			Transform val = (Object.op_Implicit((Object)(object)HUDCanvas.instance) ? ((Component)HUDCanvas.instance).transform : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				GameObject val2 = new GameObject("YapYapPortalText");
				val2.transform.SetParent(val, false);
				_hudText = val2.AddComponent<Text>();
				Font font = ((Resources.FindObjectsOfTypeAll<Font>().Length != 0) ? Resources.FindObjectsOfTypeAll<Font>()[0] : Font.CreateDynamicFontFromOSFont("Arial", 16));
				_hudText.font = font;
				((Graphic)_hudText).color = new Color(0.75f, 0.95f, 1f, 0.95f);
				_hudText.alignment = (TextAnchor)4;
				_hudText.fontSize = 24;
				RectTransform component = val2.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(0.2f, 0.13f);
				component.anchorMax = new Vector2(0.8f, 0.22f);
				Vector2 offsetMin = (component.offsetMax = Vector2.zero);
				component.offsetMin = offsetMin;
				_hudText.text = "";
			}
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)_hudText))
			{
				Object.Destroy((Object)(object)((Component)_hudText).gameObject);
			}
		}
	}
	[BepInPlugin("Empress.REPO.YapYapShop", "Empress YapYap Shop", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class EmpressYapYapShopPlugin : BaseUnityPlugin
	{
		internal const string PluginGuid = "Empress.REPO.YapYapShop";

		internal const string PluginName = "Empress YapYap Shop";

		internal const string PluginVersion = "1.0.0";

		internal const string ShopResourcePath = "Empress/YapYapShop";

		private static readonly Color NightAmbient = new Color(0.05f, 0.065f, 0.11f, 1f);

		private static readonly Color NightFog = new Color(0.012f, 0.02f, 0.05f, 1f);

		private static readonly Vector3 StandsFarOffset = new Vector3(500f, 0f, 500f);

		private static readonly Vector3 StartRoomLocalOffset = new Vector3(-500f, 0f, -500f);

		private static readonly Vector3 TruckLocalInRoom = new Vector3(-16f, 0f, 10f);

		private static readonly Vector3 NpcLocalTarget = new Vector3(-5.5f, -0.02f, 5.5f);

		private static readonly Vector3 SpawnLocalTarget = new Vector3(-1.5f, 0.05f, 2.5f);

		private static readonly FieldRef<PrefabRef, string> PrefabNameRef = AccessTools.FieldRefAccess<PrefabRef, string>("prefabName");

		private static readonly FieldRef<PrefabRef, string> ResourcePathRef = AccessTools.FieldRefAccess<PrefabRef, string>("resourcePath");

		private GameObject _hubVisualPrefab;

		private bool _registered;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			string text = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty;
			string text2 = Path.Combine(text, "empressyapyapshop");
			AssetBundle val = AssetBundle.LoadFromFile(text2);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("YapYap Shop bundle missing at " + text2));
				return;
			}
			_hubVisualPrefab = val.LoadAsset<GameObject>("EmpressYapYapHub");
			if ((Object)(object)_hubVisualPrefab == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"EmpressYapYapHub prefab missing from bundle.");
				return;
			}
			new Harmony("Empress.REPO.YapYapShop").Patch((MethodBase)AccessTools.Method(typeof(ShopLoaderPlugin), "ApplyShopLevelsToGame", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(EmpressYapYapShopPlugin), "ApplyNightLook", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			((MonoBehaviour)this).StartCoroutine(YapYapAssets.LoadAll(text));
			((MonoBehaviour)this).StartCoroutine(BuildWhenReady());
		}

		private IEnumerator BuildWhenReady()
		{
			while (!_registered)
			{
				RunManager instance = RunManager.instance;
				if ((Object)(object)instance != (Object)null && instance.levelShop != null && instance.levelShop.Count > 0)
				{
					TryBuildAndRegister(instance);
					if (_registered)
					{
						break;
					}
				}
				yield return (object)new WaitForSeconds(1f);
			}
		}

		private void TryBuildAndRegister(RunManager rm)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00e4: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: 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_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			Level val = PickShopLevel(rm);
			if ((Object)(object)val == (Object)null)
			{
				Log.LogWarning((object)"YapYap Shop found no vanilla shop level yet.");
				return;
			}
			GameObject val2 = LoadModulePrefab(val);
			GameObject val3 = LoadStartRoomPrefab(val);
			if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
			{
				Log.LogError((object)("YapYap Shop could not resolve vanilla shop prefabs (stands=" + ((Object)(object)val2 != (Object)null) + " startRoom=" + ((Object)(object)val3 != (Object)null) + ")."));
				_registered = true;
				return;
			}
			GameObject val4 = new GameObject("EmpressYapYapShopHolder");
			val4.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)val4);
			GameObject val5 = Object.Instantiate<GameObject>(val2, val4.transform);
			((Object)val5).name = "Module - Shop - N - EmpressYapYap";
			foreach (Transform item in val5.transform)
			{
				item.localPosition += StandsFarOffset;
			}
			GameObject val7 = Object.Instantiate<GameObject>(val3, val5.transform);
			((Object)val7).name = "Empress Truck Room";
			val7.transform.localPosition = StartRoomLocalOffset;
			val7.transform.localRotation = Quaternion.identity;
			TrimStartRoomFloors(val7.transform);
			RemoveDirectionalLights(val7.transform);
			GameObject obj = Object.Instantiate<GameObject>(_hubVisualPrefab, val5.transform);
			((Object)obj).name = "Empress YapYap Hub";
			obj.transform.localPosition = NpcLocalTarget;
			obj.transform.localRotation = Quaternion.identity;
			ClampHubLights(obj.transform);
			MoveRoomVolumeToHub(val7.transform, val5.transform);
			RemoveLevelPoints(val7.transform);
			Transform val8 = FindDeep(obj.transform, "NpcShopKeeper");
			if ((Object)(object)val8 != (Object)null)
			{
				((Component)val8).gameObject.AddComponent<YapYapTalker>();
			}
			else
			{
				Log.LogWarning((object)"YapYap Shop hub has no NpcShopKeeper, talker skipped.");
			}
			Vector3 localPosition = SpawnLocalTarget;
			Vector3 faceLocalTarget = NpcLocalTarget;
			if ((Object)(object)val8 != (Object)null)
			{
				localPosition = val5.transform.InverseTransformPoint(val8.position + val8.forward * 4f);
				localPosition.y = 0.05f;
				faceLocalTarget = val5.transform.InverseTransformPoint(val8.position);
			}
			MovePieceToHub(val7.transform, "Spawn Points", val5.transform, localPosition, hasFaceTarget: true, faceLocalTarget, Vector3.one);
			TagHubSurfaces(obj.transform);
			obj.AddComponent<EmpressYapYapAmbience>();
			Transform val9 = FindDeep(obj.transform, "HubBasementPortal");
			if ((Object)(object)val9 != (Object)null)
			{
				((Component)val9).gameObject.AddComponent<EmpressYapYapPortal>();
			}
			else
			{
				Log.LogWarning((object)"YapYap Shop hub has no HubBasementPortal, exit portal skipped.");
			}
			val5.SetActive(true);
			ShopAPI.RegisterShop(val5, "Empress/YapYapShop");
			_registered = true;
		}

		private static Level PickShopLevel(RunManager rm)
		{
			List<Level> list = rm.levelShop.Where((Level level) => (Object)(object)level != (Object)null && level.StartRooms != null && level.StartRooms.Count > 0).ToList();
			if (list.Count == 0)
			{
				return null;
			}
			return ((IEnumerable<Level>)list).FirstOrDefault((Func<Level, bool>)((Level level) => ((Object)level).name.Contains("Forest") && !((Object)level).name.Contains("Dead"))) ?? list[0];
		}

		private static GameObject LoadModulePrefab(Level shopLevel)
		{
			List<PrefabRef> list = new List<PrefabRef>();
			if (shopLevel.ModulesNormal1 != null)
			{
				list.AddRange(shopLevel.ModulesNormal1);
			}
			if (shopLevel.ModulesNormal2 != null)
			{
				list.AddRange(shopLevel.ModulesNormal2);
			}
			if (shopLevel.ModulesNormal3 != null)
			{
				list.AddRange(shopLevel.ModulesNormal3);
			}
			return LoadPrefab(((IEnumerable<PrefabRef>)list).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef r) => r != null && (PrefabNameRef.Invoke(r) ?? string.Empty).Contains("Center Extract"))) ?? ((IEnumerable<PrefabRef>)list).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef r) => r != null)));
		}

		private static GameObject LoadStartRoomPrefab(Level shopLevel)
		{
			return LoadPrefab(((IEnumerable<PrefabRef>)shopLevel.StartRooms).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef r) => r != null)));
		}

		private static GameObject LoadPrefab(PrefabRef reference)
		{
			if (reference == null)
			{
				return null;
			}
			string text = ResourcePathRef.Invoke(reference);
			if (string.IsNullOrEmpty(text))
			{
				text = PrefabNameRef.Invoke(reference);
			}
			if (string.IsNullOrEmpty(text))
			{
				return null;
			}
			GameObject obj = Resources.Load<GameObject>(text);
			if ((Object)(object)obj == (Object)null)
			{
				Log.LogError((object)("YapYap Shop failed to load resource '" + text + "'."));
			}
			return obj;
		}

		private static void MovePieceToHub(Transform startRoom, string pieceName, Transform moduleRoot, Vector3 localPosition, bool hasFaceTarget, Vector3 faceLocalTarget, Vector3 scaleMultiplier)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			Transform val = FindDeep(startRoom, pieceName);
			if ((Object)(object)val == (Object)null)
			{
				Log.LogWarning((object)("YapYap Shop could not find '" + pieceName + "' to move into the hub."));
				return;
			}
			val.SetParent(moduleRoot, false);
			val.localPosition = localPosition;
			val.localScale = Vector3.Scale(val.localScale, scaleMultiplier);
			val.localRotation = Quaternion.identity;
			if (hasFaceTarget)
			{
				Vector3 val2 = faceLocalTarget - localPosition;
				val2.y = 0f;
				if (((Vector3)(ref val2)).sqrMagnitude > 0.01f)
				{
					val.localRotation = Quaternion.LookRotation(((Vector3)(ref val2)).normalized);
				}
			}
		}

		public static void ApplyNightLook()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			if (!(AccessTools.Field(typeof(ShopLoaderPlugin), "RegisteredShops").GetValue(null) is IEnumerable enumerable))
			{
				return;
			}
			foreach (object item in enumerable)
			{
				if (item != null && !((string)AccessTools.Field(item.GetType(), "ResourcePath").GetValue(item) != "Empress/YapYapShop"))
				{
					Level val = (Level)AccessTools.Field(item.GetType(), "Level").GetValue(item);
					if (!((Object)(object)val == (Object)null))
					{
						val.FogColor = NightFog;
						val.FogStartDistance = 6f;
						val.FogEndDistance = 130f;
						val.AmbientColor = NightAmbient;
					}
				}
			}
		}

		private static void ClampHubLights(Transform hub)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			Light[] componentsInChildren = ((Component)hub).GetComponentsInChildren<Light>(true);
			foreach (Light val in componentsInChildren)
			{
				if ((int)val.type == 1)
				{
					Object.Destroy((Object)(object)val);
					continue;
				}
				val.intensity = Mathf.Min(val.intensity, 1.4f);
				val.range = Mathf.Min(val.range, 14f);
			}
		}

		private static void RemoveDirectionalLights(Transform startRoom)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			Light[] componentsInChildren = ((Component)startRoom).GetComponentsInChildren<Light>(true);
			foreach (Light val in componentsInChildren)
			{
				if ((int)val.type == 1)
				{
					Object.Destroy((Object)(object)val);
				}
			}
		}

		private static void RemoveLevelPoints(Transform startRoom)
		{
			Transform[] componentsInChildren = ((Component)startRoom).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && (((Object)val).name.StartsWith("Level Point") || ((Object)val).name.StartsWith("Level Path Point")))
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
		}

		private static void TagHubSurfaces(Transform hub)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			int num2 = 0;
			Collider[] componentsInChildren = ((Component)hub).GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				GameObject gameObject = ((Component)componentsInChildren[i]).gameObject;
				string text = ((Object)gameObject).name.ToLowerInvariant();
				Type type;
				if (text.Contains("terrain") || text.Contains("ground") || text.Contains("grass"))
				{
					type = (Type)10;
					num++;
				}
				else
				{
					if (!text.Contains("stone") && !text.Contains("rock") && !text.Contains("peak"))
					{
						continue;
					}
					type = (Type)4;
					num2++;
				}
				MaterialSurface val = gameObject.GetComponent<MaterialSurface>();
				if ((Object)(object)val == (Object)null)
				{
					val = gameObject.AddComponent<MaterialSurface>();
				}
				val.Type = type;
			}
		}

		private static void MoveRoomVolumeToHub(Transform startRoom, Transform moduleRoot)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform item in ((IEnumerable)startRoom).Cast<Transform>().ToList())
			{
				if (((Object)item).name.StartsWith("Room Volume"))
				{
					MovePieceToHub(startRoom, ((Object)item).name, moduleRoot, new Vector3(0f, 2f, 0f), hasFaceTarget: false, Vector3.zero, new Vector3(8f, 3f, 8f));
					return;
				}
			}
			Log.LogWarning((object)"YapYap Shop found no room volume in the start room.");
		}

		private static void TrimStartRoomFloors(Transform startRoom)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			Transform val = null;
			foreach (Transform item in startRoom)
			{
				Transform val2 = item;
				if (((Object)val2).name.StartsWith("FLOOR"))
				{
					val = val2;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Vector3 truckLocalInRoom = TruckLocalInRoom;
			foreach (Transform item2 in ((IEnumerable)val).Cast<Transform>().ToList())
			{
				if (((Object)item2).name.StartsWith("FAR FLOOR"))
				{
					Object.Destroy((Object)(object)((Component)item2).gameObject);
					continue;
				}
				Vector3 val3 = item2.localPosition - truckLocalInRoom;
				val3.y = 0f;
				if (((Vector3)(ref val3)).magnitude > 32f)
				{
					Object.Destroy((Object)(object)((Component)item2).gameObject);
				}
			}
		}

		private static Transform FindDeep(Transform root, string targetName)
		{
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name == targetName)
				{
					return val;
				}
			}
			return null;
		}
	}
	internal static class YapYapAssets
	{
		internal static readonly List<AudioClip> Notice = new List<AudioClip>();

		internal static readonly List<AudioClip> Buy = new List<AudioClip>();

		internal static readonly List<AudioClip> SoldOut = new List<AudioClip>();

		internal static readonly List<AudioClip> Sell = new List<AudioClip>();

		internal static AudioClip PortalStart;

		internal static AudioClip PortalLoop;

		internal static AudioClip PortalEnd;

		internal static AudioClip Music;

		internal static AudioClip Ambience;

		internal static IEnumerator LoadAll(string pluginDirectory)
		{
			string text = Path.Combine(pluginDirectory, "audio");
			if (!Directory.Exists(text))
			{
				EmpressYapYapShopPlugin.Log.LogWarning((object)("YapYap Shop audio folder missing at " + text));
				yield break;
			}
			string[] files = Directory.GetFiles(text, "*.ogg");
			foreach (string text2 in files)
			{
				string fileName = Path.GetFileNameWithoutExtension(text2);
				UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip("file://" + text2, (AudioType)14);
				DownloadHandlerAudioClip val = (DownloadHandlerAudioClip)request.downloadHandler;
				val.streamAudio = false;
				val.compressed = false;
				yield return request.SendWebRequest();
				if ((int)request.result != 1)
				{
					EmpressYapYapShopPlugin.Log.LogWarning((object)("YapYap Shop failed to load audio " + fileName));
					continue;
				}
				AudioClip content = DownloadHandlerAudioClip.GetContent(request);
				if (!((Object)(object)content == (Object)null))
				{
					((Object)content).name = fileName;
					Sort(fileName, content);
				}
			}
		}

		private static void Sort(string fileName, AudioClip clip)
		{
			if (fileName.StartsWith("sfx_merchant_notice"))
			{
				Notice.Add(clip);
				return;
			}
			if (fileName.StartsWith("sfx_merchant_buy"))
			{
				Buy.Add(clip);
				return;
			}
			if (fileName.StartsWith("sfx_merchant_sold_out"))
			{
				SoldOut.Add(clip);
				return;
			}
			if (fileName.StartsWith("sfx_merchant_sell"))
			{
				Sell.Add(clip);
				return;
			}
			switch (fileName)
			{
			case "sfx_teleport_start":
				PortalStart = clip;
				break;
			case "sfx_teleport_activate_loop_a":
				PortalLoop = clip;
				break;
			case "sfx_teleport_end":
				PortalEnd = clip;
				break;
			case "yapyap_music":
				Music = clip;
				break;
			case "yapyap_ambience":
				Ambience = clip;
				break;
			}
		}

		internal static List<AudioClip> Category(int category)
		{
			return category switch
			{
				0 => Notice, 
				1 => Buy, 
				2 => SoldOut, 
				3 => Sell, 
				_ => Notice, 
			};
		}
	}
	public sealed class YapYapTalker : MonoBehaviour, IOnEventCallback
	{
		private const byte YapYapBuyEvent = 143;

		private const byte YapYapVoiceEvent = 145;

		private const float InteractionDistance = 3.5f;

		private const float RotationSpeed = 5f;

		private const float TextTypeSpeed = 0.045f;

		private static readonly List<string> DialogueLines = new List<string> { "Yap yap! Welcome to my little corner of the woods.", "Everything here fell off a cart. My cart. It is fine.", "The frogs are not for sale. They are staff.", "Buy something shiny before the fog eats it.", "I keep the good stuff behind the mask. And the counter.", "Coins in, treasures out. That is the whole deal, yap.", "The cabin? Do not ask about the cabin.", "You look like someone who loses grenades. Buy two.", "The portal in the rocks hums at night. I sell earplugs. Not really.", "Spend big and I will pretend I remember your name." };

		private AudioSource _audio;

		private bool _talking;

		private bool _shopOpen;

		private bool _armOpen;

		private bool _armBuy;

		private GameObject _panel;

		private Text _text;

		private Quaternion _restRotation;

		private Coroutine _typing;

		private List<Item> _shopItems = new List<Item>();

		private int _selectedIndex;

		private Transform _targetPlayer;

		private void OnEnable()
		{
			PhotonNetwork.AddCallbackTarget((object)this);
		}

		private void OnDisable()
		{
			PhotonNetwork.RemoveCallbackTarget((object)this);
		}

		private void Start()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			_restRotation = ((Component)this).transform.rotation;
			_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
			_audio.spatialBlend = 1f;
			_audio.minDistance = 1f;
			_audio.maxDistance = 10f;
			BuildUi();
			GenerateShopList();
		}

		private void GenerateShopList()
		{
			_shopItems.Clear();
			foreach (Item value in StatsManager.instance.itemDictionary.Values)
			{
				if (!value.disabled && value.physicalItem && value.value.valueMax > 0f)
				{
					_shopItems.Add(value);
				}
			}
			_shopItems = _shopItems.OrderBy((Item item) => item.value.valueMax).ToList();
		}

		private void Update()
		{
			//IL_0014: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (!_talking)
			{
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, _restRotation, Time.deltaTime * 5f);
			}
			if (!Object.op_Implicit((Object)(object)PlayerAvatar.instance))
			{
				return;
			}
			if (Vector3.Distance(((Component)this).transform.position, ((Component)PlayerAvatar.instance).transform.position) <= 3.5f)
			{
				if (!_talking)
				{
					if (InputManager.instance.KeyDown((InputKey)2) || Input.GetKeyDown((KeyCode)101))
					{
						StartTalk();
					}
				}
				else if (!_shopOpen)
				{
					if (!_armOpen)
					{
						if (!ConfirmKeyHeld())
						{
							_armOpen = true;
						}
					}
					else if (Input.GetKeyDown((KeyCode)101) || Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
					{
						OpenShop();
						return;
					}
				}
			}
			else if (_talking)
			{
				EndTalk();
			}
			if (_talking)
			{
				HoldPlayer();
				if (_shopOpen)
				{
					UpdateShopInput();
				}
			}
		}

		private void UpdateShopInput()
		{
			if (Input.GetKeyDown((KeyCode)273) || Input.GetKeyDown((KeyCode)119))
			{
				_selectedIndex--;
				if (_selectedIndex < 0)
				{
					_selectedIndex = _shopItems.Count - 1;
				}
				UpdateShopUi();
			}
			if (Input.GetKeyDown((KeyCode)274) || Input.GetKeyDown((KeyCode)115))
			{
				_selectedIndex++;
				if (_selectedIndex >= _shopItems.Count)
				{
					_selectedIndex = 0;
				}
				UpdateShopUi();
			}
			if (!_armBuy)
			{
				if (!ConfirmKeyHeld())
				{
					_armBuy = true;
				}
			}
			else if (Input.GetKeyDown((KeyCode)101) || Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
			{
				BuyItem();
			}
			if (Input.GetKeyDown((KeyCode)27) || InputManager.instance.KeyDown((InputKey)18))
			{
				EndTalk();
			}
		}

		private static bool ConfirmKeyHeld()
		{
			if (!Input.GetKey((KeyCode)101) && !Input.GetKey((KeyCode)13))
			{
				return Input.GetKey((KeyCode)271);
			}
			return true;
		}

		private int GetPrice(Item item)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Invalid comparison between Unknown and I4
			float num = item.value.valueMax / 1000f * 4f;
			if (Object.op_Implicit((Object)(object)ShopManager.instance))
			{
				if ((int)item.itemType == 3)
				{
					num = ShopManager.instance.UpgradeValueGet(num, item);
				}
				else if ((int)item.itemType == 8)
				{
					num = ShopManager.instance.HealthPackValueGet(num);
				}
				else if ((int)item.itemType == 5)
				{
					num = ShopManager.instance.CrystalValueGet(num);
				}
			}
			return Mathf.CeilToInt(num);
		}

		private void BuyItem()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (_shopItems.Count == 0)
			{
				return;
			}
			Item val = _shopItems[_selectedIndex];
			int price = GetPrice(val);
			int num = SemiFunc.StatGetRunCurrency();
			if (num < price)
			{
				PlayVoice(2);
				return;
			}
			PlayVoice(1);
			if (PhotonNetwork.IsMasterClient || !PhotonNetwork.IsConnected)
			{
				SemiFunc.StatSetRunCurrency(num - price);
				StatsManager.instance.ItemPurchase(((Object)val).name);
			}
			else
			{
				object[] array = new object[2]
				{
					price,
					((Object)val).name
				};
				RaiseEventOptions val2 = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)2
				};
				PhotonNetwork.RaiseEvent((byte)143, (object)array, val2, SendOptions.SendReliable);
			}
			UpdateShopUi();
		}

		public void OnEvent(EventData photonEvent)
		{
			if ((photonEvent.Code != 143 && photonEvent.Code != 145) || (Object)(object)this != (Object)(object)Object.FindObjectOfType<YapYapTalker>())
			{
				return;
			}
			if (photonEvent.Code == 145)
			{
				object[] array = (object[])photonEvent.CustomData;
				PlayVoiceLocal((int)array[0], (int)array[1]);
			}
			else if (PhotonNetwork.IsMasterClient)
			{
				object[] obj = (object[])photonEvent.CustomData;
				int num = (int)obj[0];
				string text = (string)obj[1];
				int num2 = SemiFunc.StatGetRunCurrency();
				if (num2 >= num)
				{
					SemiFunc.StatSetRunCurrency(num2 - num);
					StatsManager.instance.ItemPurchase(text);
				}
			}
		}

		private void PlayVoice(int category)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			List<AudioClip> list = YapYapAssets.Category(category);
			if (list.Count != 0)
			{
				int num = Random.Range(0, list.Count);
				PlayVoiceLocal(category, num);
				if (PhotonNetwork.InRoom)
				{
					object[] array = new object[2] { category, num };
					PhotonNetwork.RaiseEvent((byte)145, (object)array, new RaiseEventOptions
					{
						Receivers = (ReceiverGroup)0
					}, SendOptions.SendReliable);
				}
			}
		}

		private void PlayVoiceLocal(int category, int index)
		{
			List<AudioClip> list = YapYapAssets.Category(category);
			if (list.Count != 0 && !((Object)(object)_audio == (Object)null))
			{
				if (index < 0 || index >= list.Count)
				{
					index = 0;
				}
				_audio.PlayOneShot(list[index]);
			}
		}

		private void UpdateShopUi()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_text))
			{
				return;
			}
			RectTransform component = _panel.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.1f, 0.1f);
			component.anchorMax = new Vector2(0.9f, 0.8f);
			string text = "<size=20><b>YAPYAP'S SHOP</b></size>\n\n";
			int num = 9;
			int num2 = 0;
			int num3 = _shopItems.Count;
			if (_shopItems.Count > num)
			{
				num2 = _selectedIndex - num / 2;
				if (num2 < 0)
				{
					num2 = 0;
				}
				if (num2 + num > _shopItems.Count)
				{
					num2 = _shopItems.Count - num;
				}
				num3 = num2 + num;
			}
			for (int i = num2; i < num3; i++)
			{
				Item val = _shopItems[i];
				string text2 = ((i == _selectedIndex) ? "> <color=green>" : "  ");
				string text3 = ((i == _selectedIndex) ? "</color>" : "");
				text = text + text2 + val.itemName + " - $" + GetPrice(val) + text3 + "\n";
			}
			text = text + "\n<b>Money: $" + SemiFunc.StatGetRunCurrency() + "</b>\n[E] Buy  [Esc] Exit";
			_text.text = text;
		}

		private void OpenShop()
		{
			if (_typing != null)
			{
				((MonoBehaviour)this).StopCoroutine(_typing);
			}
			_shopOpen = true;
			_selectedIndex = 0;
			_armBuy = false;
			PlayVoice(3);
			UpdateShopUi();
		}

		private void HoldPlayer()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)PlayerController.instance))
			{
				PlayerController.instance.InputDisable(0.1f);
				PlayerController.instance.rb.velocity = Vector3.zero;
			}
			if (Object.op_Implicit((Object)(object)_targetPlayer))
			{
				Vector3 position = _targetPlayer.position;
				position.y = ((Component)this).transform.position.y;
				Vector3 val = position - ((Component)this).transform.position;
				if (val != Vector3.zero)
				{
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(val), Time.deltaTime * 5f);
				}
			}
		}

		private void StartTalk()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			_talking = true;
			_shopOpen = false;
			_armOpen = false;
			if (Object.op_Implicit((Object)(object)PlayerAvatar.instance))
			{
				_targetPlayer = ((Component)PlayerAvatar.instance).transform;
			}
			RectTransform component = _panel.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.1f, 0.1f);
			component.anchorMax = new Vector2(0.9f, 0.3f);
			string line = DialogueLines[Random.Range(0, DialogueLines.Count)];
			_panel.SetActive(true);
			PlayVoice(0);
			if (_typing != null)
			{
				((MonoBehaviour)this).StopCoroutine(_typing);
			}
			_typing = ((MonoBehaviour)this).StartCoroutine(TypeLine(line));
		}

		private void EndTalk()
		{
			_talking = false;
			_shopOpen = false;
			_targetPlayer = null;
			if (Object.op_Implicit((Object)(object)_panel))
			{
				_panel.SetActive(false);
			}
			if (_typing != null)
			{
				((MonoBehaviour)this).StopCoroutine(_typing);
			}
			if (Object.op_Implicit((Object)(object)_text))
			{
				_text.text = "";
			}
		}

		private IEnumerator TypeLine(string line)
		{
			_text.text = "";
			foreach (char c in line)
			{
				Text text = _text;
				text.text += c;
				yield return (object)new WaitForSeconds(0.045f);
			}
		}

		private void BuildUi()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_0027: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: 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)
			Transform val = (Object.op_Implicit((Object)(object)HUDCanvas.instance) ? ((Component)HUDCanvas.instance).transform : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				GameObject val2 = new GameObject("YapYapDialogCanvas");
				Canvas obj = val2.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 999;
				val2.AddComponent<CanvasScaler>();
				val2.AddComponent<GraphicRaycaster>();
				val = val2.transform;
			}
			_panel = new GameObject("YapYapPanel");
			_panel.transform.SetParent(val, false);
			((Graphic)_panel.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.8f);
			RectTransform component = _panel.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.1f, 0.1f);
			component.anchorMax = new Vector2(0.9f, 0.3f);
			Vector2 offsetMin = (component.offsetMax = Vector2.zero);
			component.offsetMin = offsetMin;
			GameObject val3 = new GameObject("YapYapText");
			val3.transform.SetParent(_panel.transform, false);
			_text = val3.AddComponent<Text>();
			Font font = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name == "Arial")) ?? Resources.FindObjectsOfTypeAll<Font>().FirstOrDefault() ?? Font.CreateDynamicFontFromOSFont("Arial", 16);
			_text.font = font;
			((Graphic)_text).color = Color.white;
			_text.alignment = (TextAnchor)0;
			_text.resizeTextForBestFit = true;
			_text.resizeTextMinSize = 14;
			_text.resizeTextMaxSize = 35;
			_text.verticalOverflow = (VerticalWrapMode)0;
			RectTransform component2 = val3.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0.02f, 0.05f);
			component2.anchorMax = new Vector2(0.98f, 0.95f);
			offsetMin = (component2.offsetMax = Vector2.zero);
			component2.offsetMin = offsetMin;
			_panel.SetActive(false);
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)_panel))
			{
				Object.Destroy((Object)(object)_panel);
			}
		}
	}
}