Decompiled source of DRAKENFJORD LoadingScreensV2 v2.0.0

plugins/Intermission.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComfyLib;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Intermission")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Intermission")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("746fb90c-3d18-4ef5-8e0f-6ac9ca2b36fe")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.7.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Intermission
{
	public static class CustomAssets
	{
		private static readonly Dictionary<string, Sprite> _loadingImageCache = new Dictionary<string, Sprite>();

		private static int _loadingImageIndex = -1;

		public static List<string> LoadingTips { get; } = new List<string>();


		public static List<string> LoadingImageFiles { get; } = new List<string>();


		public static void Initialize(string pluginDir)
		{
			LoadingTips.Clear();
			LoadingTips.AddRange(ReadLoadingTips(Path.Combine(pluginDir, "tips.txt")));
			LoadingImageFiles.Clear();
			LoadingImageFiles.AddRange(ReadLoadingImageFiles(pluginDir, ".png"));
			LoadingImageFiles.AddRange(ReadLoadingImageFiles(pluginDir, ".jpg"));
		}

		public static IEnumerable<string> ReadLoadingTips(string path)
		{
			if (File.Exists(path))
			{
				string[] array = File.ReadAllLines(path);
				Intermission.LogInfo($"Found {array.Length} custom tips in file: {path}");
				return array;
			}
			Intermission.LogInfo("Creating new empty custom tips file: " + path);
			Directory.CreateDirectory(Path.GetDirectoryName(path));
			File.Create(path);
			return Array.Empty<string>();
		}

		public static IEnumerable<string> ReadLoadingImageFiles(string path, string extension)
		{
			Directory.CreateDirectory(Path.GetDirectoryName(path));
			string[] files = Directory.GetFiles(path, "*" + extension, SearchOption.TopDirectoryOnly);
			Intermission.LogInfo($"Found {files.Length} custom loading images ({extension}) in directory: {path}");
			return files;
		}

		public static Sprite ReadLoadingImage(string imageFile)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (_loadingImageCache.TryGetValue(imageFile, out var value))
			{
				return value;
			}
			if (!File.Exists(imageFile))
			{
				Intermission.LogError("Could not find custom loading image: " + imageFile);
				return null;
			}
			Texture2D val = new Texture2D(1, 1);
			val.SetName<Texture2D>("intermission.texture-" + Path.GetFileName(imageFile));
			ImageConversion.LoadImage(val, File.ReadAllBytes(imageFile));
			value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero, 1f);
			value.SetName<Sprite>("intermission.sprite-" + Path.GetFileName(imageFile));
			_loadingImageCache[imageFile] = value;
			return value;
		}

		public static bool GetRandomLoadingTip(out string tipText)
		{
			if (LoadingTips.Count > 0)
			{
				tipText = LoadingTips[Random.Range(0, LoadingTips.Count)];
				return true;
			}
			tipText = null;
			return false;
		}

		public static bool GetRandomLoadingImage(out Sprite loadingImageSprite)
		{
			if (LoadingImageFiles.Count > 0)
			{
				if (_loadingImageIndex < 0 || _loadingImageIndex >= LoadingImageFiles.Count)
				{
					LoadingImageFiles.Sort(RandomStringComparer.Instance);
					_loadingImageIndex = 0;
				}
				loadingImageSprite = ReadLoadingImage(LoadingImageFiles[_loadingImageIndex]);
				_loadingImageIndex++;
				return Object.op_Implicit((Object)(object)loadingImageSprite);
			}
			loadingImageSprite = null;
			return false;
		}
	}
	public static class ImageScaleUtils
	{
		private static Coroutine _scaleLerpCoroutine;

		public static IEnumerator ScaleLerp(Transform transform, Vector3 startScale, Vector3 endScale, float lerpDuration)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			transform.localScale = startScale;
			float timeElapsed = 0f;
			while (timeElapsed < lerpDuration)
			{
				float num = timeElapsed / lerpDuration;
				num = num * num * (3f - 2f * num);
				transform.localScale = Vector3.Lerp(startScale, endScale, num);
				timeElapsed += Time.deltaTime;
				yield return null;
			}
			transform.localScale = endScale;
		}

		public static void ScaleLerpLoadingImage(this MonoBehaviour component, Image loadingImage)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (_scaleLerpCoroutine != null)
			{
				component.StopCoroutine(_scaleLerpCoroutine);
				_scaleLerpCoroutine = null;
			}
			if (PluginConfig.LoadingImageUseScaleLerp.Value && Object.op_Implicit((Object)(object)loadingImage))
			{
				_scaleLerpCoroutine = component.StartCoroutine(ScaleLerp(((Component)loadingImage).transform, Vector3.one, Vector3.one * PluginConfig.LoadingImageScaleLerpEndScale.Value, PluginConfig.LoadingImageScaleLerpDuration.Value));
			}
		}
	}
	public static class HudUtils
	{
		private static TMP_Text _cachedTipText;

		private static Image _cachedLoadingImage;

		private static Image _cachedLoadingBackground;

		private static Transform _cachedPanelSeparator;

		public static void SetLoadingImage(Image loadingImage)
		{
			if (Object.op_Implicit((Object)(object)loadingImage) && CustomAssets.GetRandomLoadingImage(out var loadingImageSprite))
			{
				loadingImage.SetSprite(loadingImageSprite);
			}
		}

		public static void SetLoadingTip(TMP_Text tipText)
		{
			if (Object.op_Implicit((Object)(object)tipText) && CustomAssets.GetRandomLoadingTip(out var tipText2))
			{
				tipText.SetText(tipText2);
			}
		}

		public static void SetupLoadingImage(Image loadingImage = null)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)loadingImage))
			{
				_cachedLoadingImage = loadingImage;
			}
			else if (Object.op_Implicit((Object)(object)_cachedLoadingImage))
			{
				loadingImage = _cachedLoadingImage;
			}
			else
			{
				Intermission.LogError("Could not find a LoadingImage to setup!");
			}
			loadingImage.SetType((Type)0).SetColor(PluginConfig.LoadingImageBaseColor.Value).SetPreserveAspect(preserveAspect: true);
		}

		public static void SetupLoadingBackground(Transform parentTransform)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_cachedLoadingBackground))
			{
				_cachedLoadingBackground = new GameObject("Background", new Type[1] { typeof(RectTransform) }).AddComponent<Image>();
			}
			((Component)_cachedLoadingBackground).transform.SetParent(parentTransform, false);
			((Component)_cachedLoadingBackground).transform.SetAsFirstSibling();
			((Component)_cachedLoadingBackground).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one)
				.SetPivot(new Vector2(0.5f, 0.5f))
				.SetPosition(Vector2.zero)
				.SetSizeDelta(Vector2.zero);
			SetupLoadingBackground();
		}

		public static void SetupLoadingBackground(Image loadingBackground = null)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)loadingBackground))
			{
				_cachedLoadingBackground = loadingBackground;
			}
			else if (Object.op_Implicit((Object)(object)_cachedLoadingBackground))
			{
				loadingBackground = _cachedLoadingBackground;
			}
			else
			{
				Intermission.LogError("Could not find a LoadingBackground to setup!");
			}
			loadingBackground.Ref<Image>()?.SetType((Type)0).SetColor(PluginConfig.LoadingScreenBackgroundColor.Value);
		}

		public static void SetupPanelSeparator(Transform panelSeparator = null)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)panelSeparator))
			{
				_cachedPanelSeparator = panelSeparator;
			}
			else if (Object.op_Implicit((Object)(object)_cachedPanelSeparator))
			{
				panelSeparator = _cachedPanelSeparator;
			}
			else
			{
				Intermission.LogError("Could not find a PanelSeparator to setup!");
			}
			((Component)panelSeparator).gameObject.SetActive(PluginConfig.LoadingScreenShowPanelSeparator.Value);
			((Component)panelSeparator).GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0f)).SetAnchorMax(new Vector2(0.5f, 0f))
				.SetPosition(PluginConfig.LoadingScreenPanelSeparatorPosition.Value);
		}

		public static void SetupTipText(TMP_Text tipText = null)
		{
			//IL_0055: 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_0070: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)tipText))
			{
				_cachedTipText = tipText;
			}
			else if (Object.op_Implicit((Object)(object)_cachedTipText))
			{
				tipText = _cachedTipText;
			}
			else
			{
				Intermission.LogError("Could not find a TipText to setup!");
			}
			tipText.SetAlignment<TMP_Text>((TextAlignmentOptions)258).SetTextWrappingMode<TMP_Text>((TextWrappingModes)1).SetFontSize<TMP_Text>((float)PluginConfig.LoadingTipTextFontSize.Value)
				.SetColor<TMP_Text>(PluginConfig.LoadingTipTextColor.Value);
			((Component)tipText).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.right)
				.SetPosition(PluginConfig.LoadingTipTextPosition.Value)
				.SetSizeDelta(new Vector2(-50f, 78f));
		}
	}
	public sealed class RandomStringComparer : Comparer<string>
	{
		public static readonly RandomStringComparer Instance = new RandomStringComparer();

		public override int Compare(string x, string y)
		{
			return Random.Range(-1, 2);
		}
	}
	[BepInPlugin("redseiko.valheim.intermission", "Intermission", "1.7.0")]
	public sealed class Intermission : BaseUnityPlugin
	{
		public const string PluginGuid = "redseiko.valheim.intermission";

		public const string PluginName = "Intermission";

		public const string PluginVersion = "1.7.0";

		private static ManualLogSource _logger;

		private void Awake()
		{
			_logger = ((BaseUnityPlugin)this).Logger;
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			if (PluginConfig.IsModEnabled.Value)
			{
				CustomAssets.Initialize(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath), "Intermission"));
				Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.intermission");
			}
		}

		public static void LogInfo(object obj)
		{
			_logger.LogInfo((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}");
		}

		public static void LogError(object obj)
		{
			_logger.LogError((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}");
		}
	}
	[HarmonyPatch(typeof(FejdStartup))]
	internal static class FejdStartupPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostfix(ref FejdStartup __instance)
		{
			Image component = ((Component)__instance.m_loading.transform.Find("Bkg")).GetComponent<Image>();
			TMP_Text component2 = ((Component)__instance.m_loading.transform.Find("Text")).GetComponent<TMP_Text>();
			TMP_Text val = Object.Instantiate<TMP_Text>(component2, __instance.m_loading.transform);
			((Object)val).name = ((Object)component2).name;
			Object.Destroy((Object)(object)((Component)component2).gameObject);
			Transform panelSeparator = Object.Instantiate<Transform>(__instance.m_menuList.transform.Find("ornament"), __instance.m_loading.transform);
			HudUtils.SetupTipText(val);
			HudUtils.SetupLoadingBackground(((Component)component).transform.parent);
			HudUtils.SetupLoadingImage(component);
			HudUtils.SetupPanelSeparator(panelSeparator);
			HudUtils.SetLoadingTip(val);
			HudUtils.SetLoadingImage(component);
		}
	}
	[HarmonyPatch(typeof(Hud))]
	internal static class HudPatch
	{
		private static bool _loadingScreenState;

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostfix(ref Hud __instance)
		{
			Transform obj = __instance.m_loadingProgress.transform.Find("panel_separator");
			HudUtils.SetupTipText(__instance.m_loadingTip);
			HudUtils.SetupLoadingImage(__instance.m_loadingImage);
			HudUtils.SetupPanelSeparator(obj);
			HudUtils.SetLoadingTip(__instance.m_loadingTip);
			HudUtils.SetLoadingImage(__instance.m_loadingImage);
			Transform obj2 = __instance.m_loadingProgress.transform.Find("TopFade").Ref<Transform>();
			if (obj2 != null)
			{
				((Component)obj2).gameObject.SetActive(false);
			}
			Transform obj3 = __instance.m_loadingProgress.transform.Find("BottomFade").Ref<Transform>();
			if (obj3 != null)
			{
				((Component)obj3).gameObject.SetActive(false);
			}
			Transform obj4 = __instance.m_loadingProgress.transform.Find("text_darken").Ref<Transform>();
			if (obj4 != null)
			{
				((Component)obj4).gameObject.SetActive(false);
			}
			__instance.m_teleportingProgress = __instance.m_loadingProgress;
			HudUtils.SetupLoadingBackground(((Component)((Component)__instance).transform.Find("LoadingBlack/Bkg")).GetComponent<Image>());
			Transform val = ((Component)__instance).transform.Find("LoadingBlack");
			((Component)__instance.m_loadingImage).transform.SetParent(val, false);
			__instance.m_loadingTip.transform.SetParent(val, false);
			obj.SetParent(val, false);
		}

		[HarmonyPrefix]
		[HarmonyPatch("UpdateBlackScreen")]
		private static void UpdateBlackScreenPrefix(ref Hud __instance)
		{
			_loadingScreenState = ((Component)__instance.m_loadingImage).gameObject.activeInHierarchy;
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateBlackScreen")]
		private static void UpdateBlackScreenPostfix(Hud __instance)
		{
			if (!_loadingScreenState && ((Component)__instance.m_loadingScreen).gameObject.activeInHierarchy)
			{
				HudUtils.SetLoadingImage(__instance.m_loadingImage);
				HudUtils.SetLoadingTip(__instance.m_loadingTip);
				((MonoBehaviour)(object)__instance).ScaleLerpLoadingImage(__instance.m_loadingImage);
			}
		}
	}
	public static class PluginConfig
	{
		public static ConfigEntry<bool> IsModEnabled { get; private set; }

		public static ConfigEntry<bool> SceneLoaderUseLoadingImages { get; private set; }

		public static ConfigEntry<bool> SceneLoaderShowProgressText { get; private set; }

		public static ConfigEntry<bool> SceneLoaderCenterProgressIndicator { get; private set; }

		public static ConfigEntry<Vector2> SceneLoaderProgressIndicatorOffset { get; private set; }

		public static ConfigEntry<Color> LoadingImageBaseColor { get; private set; }

		public static ConfigEntry<bool> LoadingImageUseScaleLerp { get; private set; }

		public static ConfigEntry<float> LoadingImageScaleLerpEndScale { get; private set; }

		public static ConfigEntry<float> LoadingImageScaleLerpDuration { get; private set; }

		public static ConfigEntry<Color> LoadingScreenBackgroundColor { get; private set; }

		public static ConfigEntry<bool> LoadingScreenShowPanelSeparator { get; private set; }

		public static ConfigEntry<Vector2> LoadingScreenPanelSeparatorPosition { get; private set; }

		public static ConfigEntry<Vector2> LoadingTipTextPosition { get; private set; }

		public static ConfigEntry<int> LoadingTipTextFontSize { get; private set; }

		public static ConfigEntry<Color> LoadingTipTextColor { get; private set; }

		public static void BindConfig(ConfigFile config)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod (restart required).");
			SceneLoaderUseLoadingImages = config.BindInOrder("SceneLoader", "useLoadingImages", defaultValue: true, "If set, will use custom loading images on the initial SceneLoader scene.");
			SceneLoaderShowProgressText = config.BindInOrder("SceneLoader", "showProgressText", defaultValue: true, "If set, will show loading progress text on the initial SceneLoader scene.");
			SceneLoaderCenterProgressIndicator = config.BindInOrder("SceneLoader", "centerProgressIndicator", defaultValue: true, "If set, will center the loading progress indicator (instead of being on the lower-right).");
			SceneLoaderProgressIndicatorOffset = config.BindInOrder<Vector2>("SceneLoader", "progressIndicatorOffset", new Vector2(0f, 200f), "When centerProgressIndicator is true, this is used to offset from the bottom center.");
			LoadingImageBaseColor = config.BindInOrder<Color>("LoadingImage.Image", "baseColor", Color.white, "The base color to apply to the loading image.");
			LoadingImageBaseColor.SettingChanged += OnLoadingImageConfigChanged;
			LoadingImageUseScaleLerp = config.BindInOrder("LoadingImage.ScaleLerp", "useScaleLerp", defaultValue: true, "If true, performs a scale lerp animation on the loading image.");
			LoadingImageScaleLerpEndScale = config.BindInOrder("LoadingImage.ScaleLerp", "lerpEndScale", 1.05f, "Image.scale ending factor for the scale lerp animation.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 1.5f));
			LoadingImageScaleLerpDuration = config.BindInOrder("LoadingImage.ScaleLerp", "lerpDuration", 15f, "Duration for the scale lerp animation.");
			LoadingTipTextPosition = config.BindInOrder<Vector2>("LoadingTip.Text", "textPosition", new Vector2(0f, 90f), "LoadingTip.Text.position value.");
			LoadingTipTextPosition.SettingChanged += OnLoadingTipConfigChanged;
			LoadingTipTextFontSize = config.BindInOrder("LoadingTip.Text", "textFontSize", 24, "LoadingTip.Text.fontSize value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 64));
			LoadingTipTextFontSize.SettingChanged += OnLoadingTipConfigChanged;
			LoadingTipTextColor = config.BindInOrder<Color>("LoadingTip.Text", "textColor", Color.white, "LoadingTip.Text.color value.");
			LoadingTipTextColor.SettingChanged += OnLoadingTipConfigChanged;
			LoadingScreenBackgroundColor = config.BindInOrder<Color>("LoadingScreen.Background", "backgroundColor", Color.black, "Color to use for the loading screen background.");
			LoadingScreenBackgroundColor.SettingChanged += OnLoadingBackgroundConfigChanged;
			LoadingScreenShowPanelSeparator = config.BindInOrder("LoadingScreen.PanelSeparator", "showPanelSeparator", defaultValue: true, "Show the panel separator image on the loading screen.");
			LoadingScreenShowPanelSeparator.SettingChanged += OnPanelSeparatorConfigChanged;
			LoadingScreenPanelSeparatorPosition = config.BindInOrder<Vector2>("LoadingScreen.PanelSeparator", "panelSeparatorPosition", new Vector2(0f, 150f), "The position of the panel separator image on the loading screen.");
			LoadingScreenPanelSeparatorPosition.SettingChanged += OnPanelSeparatorConfigChanged;
		}

		private static void OnLoadingImageConfigChanged(object sender, EventArgs args)
		{
			HudUtils.SetupLoadingImage();
		}

		private static void OnLoadingTipConfigChanged(object sender, EventArgs args)
		{
			HudUtils.SetupTipText();
		}

		private static void OnLoadingBackgroundConfigChanged(object sender, EventArgs args)
		{
			HudUtils.SetupLoadingBackground();
		}

		private static void OnPanelSeparatorConfigChanged(object sender, EventArgs args)
		{
			HudUtils.SetupPanelSeparator();
		}
	}
	[HarmonyPatch(typeof(SceneLoader))]
	internal static class SceneLoaderPatch
	{
		private static Image _loadingImage;

		private static TMP_Text _loadingText;

		private static float _startTime;

		private static float _lastImageTime;

		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void StartPrefix(SceneLoader __instance)
		{
			_loadingImage = ((Component)__instance.gameLogo.transform.parent.Find("Bkg")).GetComponent<Image>();
			if (PluginConfig.SceneLoaderUseLoadingImages.Value && CustomAssets.LoadingImageFiles.Count > 0)
			{
				__instance._showLogos = false;
				__instance._showSaveNotification = false;
				__instance._showHealthWarning = false;
				HudUtils.SetupLoadingBackground(((Component)_loadingImage).transform.parent);
				HudUtils.SetupLoadingImage(_loadingImage);
				HudUtils.SetLoadingImage(_loadingImage);
				((MonoBehaviour)(object)__instance).ScaleLerpLoadingImage(_loadingImage);
				__instance.gameLogo = ((Component)_loadingImage).gameObject;
			}
			if (PluginConfig.SceneLoaderShowProgressText.Value)
			{
				_loadingText = Object.Instantiate<TMP_Text>(((Component)__instance.savingNotification).GetComponentInChildren<TMP_Text>(), ((Component)_loadingImage).transform.parent);
				HudUtils.SetupTipText(_loadingText);
				HudUtils.SetLoadingTip(_loadingText);
			}
			if (PluginConfig.SceneLoaderCenterProgressIndicator.Value)
			{
				SetupLoadingIndicator(LoadingIndicator.s_instance);
			}
			_startTime = Time.time;
			_lastImageTime = _startTime;
		}

		private static void SetupLoadingIndicator(LoadingIndicator indicator)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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)
			indicator.m_showProgressIndicator = true;
			RectTransform component = ((Component)((Component)indicator).transform).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0f);
			component.anchorMax = new Vector2(0.5f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.anchoredPosition = PluginConfig.SceneLoaderProgressIndicatorOffset.Value;
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void UpdatePostfix(SceneLoader __instance)
		{
			float time = Time.time;
			if (PluginConfig.SceneLoaderUseLoadingImages.Value && time - _lastImageTime >= 10f)
			{
				_lastImageTime = time;
				HudUtils.SetLoadingImage(_loadingImage);
				((MonoBehaviour)(object)__instance).ScaleLerpLoadingImage(_loadingImage);
			}
			if (PluginConfig.SceneLoaderShowProgressText.Value && Object.op_Implicit((Object)(object)_loadingText))
			{
				_loadingText.text = $"<b>{__instance._fakeProgress * 100f:F0}%</b>\n<size=-4>({time - _startTime:F1}s)</size>";
			}
		}
	}
}
namespace ComfyLib
{
	public static class CanvasGroupExtensions
	{
		public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha)
		{
			canvasGroup.alpha = alpha;
			return canvasGroup;
		}

		public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts)
		{
			canvasGroup.blocksRaycasts = blocksRaycasts;
			return canvasGroup;
		}
	}
	public static class ColorExtensions
	{
		public static Color SetAlpha(this Color color, float alpha)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			color.a = alpha;
			return color;
		}
	}
	public static class ContentSizeFitterExtensions
	{
		public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			fitter.horizontalFit = fitMode;
			return fitter;
		}

		public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			fitter.verticalFit = fitMode;
			return fitter;
		}
	}
	public static class LayoutGroupExtensions
	{
		public static T SetChildAlignment<T>(this T layoutGroup, TextAnchor alignment) where T : HorizontalOrVerticalLayoutGroup
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((LayoutGroup)(object)layoutGroup).childAlignment = alignment;
			return layoutGroup;
		}

		public static T SetChildControl<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value;
			}
			if (height.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value;
			}
			return layoutGroup;
		}

		public static T SetChildForceExpand<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value;
			}
			if (height.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value;
			}
			return layoutGroup;
		}

		public static T SetPadding<T>(this T layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) where T : HorizontalOrVerticalLayoutGroup
		{
			if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue)
			{
				throw new ArgumentException("Value for left, right, top or bottom must be provided.");
			}
			if (left.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.left = left.Value;
			}
			if (right.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.right = right.Value;
			}
			if (top.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.top = top.Value;
			}
			if (bottom.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.bottom = bottom.Value;
			}
			return layoutGroup;
		}

		public static T SetSpacing<T>(this T layoutGroup, float spacing) where T : HorizontalOrVerticalLayoutGroup
		{
			((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing;
			return layoutGroup;
		}
	}
	public static class ImageExtensions
	{
		public static Image SetColor(this Image image, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)image).color = color;
			return image;
		}

		public static Image SetFillAmount(this Image image, float amount)
		{
			image.fillAmount = amount;
			return image;
		}

		public static Image SetFillCenter(this Image image, bool fillCenter)
		{
			image.fillCenter = fillCenter;
			return image;
		}

		public static Image SetFillMethod(this Image image, FillMethod fillMethod)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			image.fillMethod = fillMethod;
			return image;
		}

		public static Image SetFillOrigin(this Image image, OriginHorizontal origin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			image.fillOrigin = (int)origin;
			return image;
		}

		public static Image SetFillOrigin(this Image image, OriginVertical origin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			image.fillOrigin = (int)origin;
			return image;
		}

		public static Image SetMaskable(this Image image, bool maskable)
		{
			((MaskableGraphic)image).maskable = maskable;
			return image;
		}

		public static Image SetMaterial(this Image image, Material material)
		{
			((Graphic)image).material = material;
			return image;
		}

		public static Image SetPixelsPerUnitMultiplier(this Image image, float pixelsPerUnitMultiplier)
		{
			image.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier;
			return image;
		}

		public static Image SetPreserveAspect(this Image image, bool preserveAspect)
		{
			image.preserveAspect = preserveAspect;
			return image;
		}

		public static Image SetRaycastTarget(this Image image, bool raycastTarget)
		{
			((Graphic)image).raycastTarget = raycastTarget;
			return image;
		}

		public static Image SetSprite(this Image image, Sprite sprite)
		{
			image.sprite = sprite;
			return image;
		}

		public static Image SetType(this Image image, Type type)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			image.type = type;
			return image;
		}
	}
	public static class LayoutElementExtensions
	{
		public static LayoutElement SetFlexible(this LayoutElement layoutElement, float? width = null, float? height = null)
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				layoutElement.flexibleWidth = width.Value;
			}
			if (height.HasValue)
			{
				layoutElement.flexibleHeight = height.Value;
			}
			return layoutElement;
		}

		public static LayoutElement SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout)
		{
			layoutElement.ignoreLayout = ignoreLayout;
			return layoutElement;
		}

		public static LayoutElement SetMinimum(this LayoutElement layoutElement, float? width = null, float? height = null)
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				layoutElement.minWidth = width.Value;
			}
			if (height.HasValue)
			{
				layoutElement.minHeight = height.Value;
			}
			return layoutElement;
		}

		public static LayoutElement SetPreferred(this LayoutElement layoutElement, float? width = null, float? height = null)
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				layoutElement.preferredWidth = width.Value;
			}
			if (height.HasValue)
			{
				layoutElement.preferredHeight = height.Value;
			}
			return layoutElement;
		}
	}
	public static class RectMask2DExtensions
	{
		public static RectMask2D SetSoftness(this RectMask2D rectMask2d, Vector2Int softness)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectMask2d.softness = softness;
			return rectMask2d;
		}
	}
	public static class RectTransformExtensions
	{
		public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMin = anchorMin;
			return rectTransform;
		}

		public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMax = anchorMax;
			return rectTransform;
		}

		public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.pivot = pivot;
			return rectTransform;
		}

		public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition = position;
			return rectTransform;
		}

		public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.sizeDelta = sizeDelta;
			return rectTransform;
		}
	}
	public static class ScrollbarExtensions
	{
		public static T SetDirection<T>(this T scrollbar, Direction direction) where T : Scrollbar
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Scrollbar)scrollbar).direction = direction;
			return scrollbar;
		}

		public static T SetHandleRect<T>(this T scrollbar, RectTransform handleRect) where T : Scrollbar
		{
			((Scrollbar)scrollbar).handleRect = handleRect;
			return scrollbar;
		}
	}
	public static class SelectableExtensions
	{
		public static T SetColors<T>(this T selectable, ColorBlock colors) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)selectable).colors = colors;
			return selectable;
		}

		public static T SetImage<T>(this T selectable, Image image) where T : Selectable
		{
			((Selectable)selectable).image = image;
			return selectable;
		}

		public static T SetInteractable<T>(this T selectable, bool interactable) where T : Selectable
		{
			((Selectable)selectable).interactable = interactable;
			return selectable;
		}

		public static T SetSpriteState<T>(this T selectable, SpriteState spriteState) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)selectable).spriteState = spriteState;
			return selectable;
		}

		public static T SetTargetGraphic<T>(this T selectable, Graphic graphic) where T : Selectable
		{
			((Selectable)selectable).targetGraphic = graphic;
			return selectable;
		}

		public static T SetTransition<T>(this T selectable, Transition transition) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)selectable).transition = transition;
			return selectable;
		}

		public static T SetNavigationMode<T>(this T selectable, Mode mode) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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)
			Navigation navigation = ((Selectable)selectable).navigation;
			((Navigation)(ref navigation)).mode = mode;
			((Selectable)selectable).navigation = navigation;
			return selectable;
		}
	}
	public static class SliderExtensions
	{
		public static T SetDirection<T>(this T slider, Direction direction) where T : Slider
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Slider)slider).direction = direction;
			return slider;
		}

		public static T SetFillRect<T>(this T slider, RectTransform fillRect) where T : Slider
		{
			((Slider)slider).fillRect = fillRect;
			return slider;
		}

		public static T SetHandleRect<T>(this T slider, RectTransform handleRect) where T : Slider
		{
			((Slider)slider).handleRect = handleRect;
			return slider;
		}

		public static T SetMaxValue<T>(this T slider, float maxValue) where T : Slider
		{
			((Slider)slider).maxValue = maxValue;
			return slider;
		}

		public static T SetMinValue<T>(this T slider, float minValue) where T : Slider
		{
			((Slider)slider).minValue = minValue;
			return slider;
		}

		public static T SetWholeNumbers<T>(this T slider, bool wholeNumbers) where T : Slider
		{
			((Slider)slider).wholeNumbers = wholeNumbers;
			return slider;
		}
	}
	public static class ScrollRectExtensions
	{
		public static T SetContent<T>(this T scrollRect, RectTransform content) where T : ScrollRect
		{
			((ScrollRect)scrollRect).content = content;
			return scrollRect;
		}

		public static T SetHorizontal<T>(this T scrollRect, bool horizontal) where T : ScrollRect
		{
			((ScrollRect)scrollRect).horizontal = horizontal;
			return scrollRect;
		}

		public static T SetMovementType<T>(this T scrollRect, MovementType movementType) where T : ScrollRect
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ScrollRect)scrollRect).movementType = movementType;
			return scrollRect;
		}

		public static T SetScrollSensitivity<T>(this T scrollRect, float sensitivity) where T : ScrollRect
		{
			((ScrollRect)scrollRect).scrollSensitivity = sensitivity;
			return scrollRect;
		}

		public static T SetVertical<T>(this T scrollRect, bool vertical) where T : ScrollRect
		{
			((ScrollRect)scrollRect).vertical = vertical;
			return scrollRect;
		}

		public static T SetVerticalScrollbar<T>(this T scrollRect, Scrollbar verticalScrollbar) where T : ScrollRect
		{
			((ScrollRect)scrollRect).verticalScrollbar = verticalScrollbar;
			return scrollRect;
		}

		public static T SetVerticalScrollPosition<T>(this T scrollRect, float position) where T : ScrollRect
		{
			((ScrollRect)scrollRect).verticalNormalizedPosition = position;
			return scrollRect;
		}

		public static T SetVerticalScrollbarVisibility<T>(this T scrollRect, ScrollbarVisibility visibility) where T : ScrollRect
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ScrollRect)scrollRect).verticalScrollbarVisibility = visibility;
			return scrollRect;
		}

		public static T SetViewport<T>(this T scrollRect, RectTransform viewport) where T : ScrollRect
		{
			((ScrollRect)scrollRect).viewport = viewport;
			return scrollRect;
		}
	}
	public static class TextMeshProExtensions
	{
		public static T SetAlignment<T>(this T tmpText, TextAlignmentOptions alignment) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).alignment = alignment;
			return tmpText;
		}

		public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)(object)tmpText).color = color;
			return tmpText;
		}

		public static T SetEnableAutoSizing<T>(this T tmpText, bool enableAutoSizing) where T : TMP_Text
		{
			((TMP_Text)tmpText).enableAutoSizing = enableAutoSizing;
			return tmpText;
		}

		public static T SetFont<T>(this T tmpText, TMP_FontAsset font) where T : TMP_Text
		{
			((TMP_Text)tmpText).font = font;
			return tmpText;
		}

		public static T SetFontSize<T>(this T tmpText, float fontSize) where T : TMP_Text
		{
			((TMP_Text)tmpText).fontSize = fontSize;
			return tmpText;
		}

		public static T SetFontMaterial<T>(this T tmpText, Material fontMaterial) where T : TMP_Text
		{
			((TMP_Text)tmpText).fontMaterial = fontMaterial;
			return tmpText;
		}

		public static T SetMargin<T>(this T tmpText, Vector4 margin) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).margin = margin;
			return tmpText;
		}

		public static T SetOverflowMode<T>(this T tmpText, TextOverflowModes overflowMode) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).overflowMode = overflowMode;
			return tmpText;
		}

		public static T SetRichText<T>(this T tmpText, bool richText) where T : TMP_Text
		{
			((TMP_Text)tmpText).richText = richText;
			return tmpText;
		}

		public static T SetTextWrappingMode<T>(this T tmpText, TextWrappingModes textWrappingMode) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).textWrappingMode = textWrappingMode;
			return tmpText;
		}
	}
	public static class Texture2DExtensions
	{
		public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Texture)texture).filterMode = filterMode;
			return texture;
		}

		public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Texture)texture).wrapMode = wrapMode;
			return texture;
		}
	}
	public static class ToggleExtensions
	{
		public static T SetGraphic<T>(this T toggle, Graphic graphic) where T : Toggle
		{
			((Toggle)toggle).graphic = graphic;
			return toggle;
		}

		public static T SetToggleTransition<T>(this T toggle, ToggleTransition toggleTransition) where T : Toggle
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Toggle)toggle).toggleTransition = toggleTransition;
			return toggle;
		}
	}
	public static class ConfigFileExtensions
	{
		internal sealed class ConfigurationManagerAttributes
		{
			public Action<ConfigEntryBase> CustomDrawer;

			public bool? Browsable;

			public bool? HideDefaultButton;

			public bool? HideSettingName;

			public bool? IsAdvanced;

			public int? Order;

			public bool? ReadOnly;
		}

		private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>();

		private static int GetSettingOrder(string section)
		{
			if (!_sectionToSettingOrder.TryGetValue(section, out var value))
			{
				value = 0;
			}
			_sectionToSettingOrder[section] = value - 1;
			return value;
		}

		public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = browsable,
					CustomDrawer = null,
					HideDefaultButton = hideDefaultButton,
					HideSettingName = hideSettingName,
					IsAdvanced = isAdvanced,
					Order = GetSettingOrder(section),
					ReadOnly = readOnly
				}
			}));
		}

		public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = browsable,
					CustomDrawer = customDrawer,
					HideDefaultButton = hideDefaultButton,
					HideSettingName = hideSettingName,
					IsAdvanced = isAdvanced,
					Order = GetSettingOrder(section),
					ReadOnly = readOnly
				}
			}));
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler)
		{
			configEntry.SettingChanged += delegate
			{
				settingChangedHandler();
			};
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}
	}
	public static class ObjectExtensions
	{
		public static T FirstByNameOrThrow<T>(this IEnumerable<T> unityObjects, string name) where T : Object
		{
			foreach (T unityObject in unityObjects)
			{
				if (((Object)unityObject).name == name)
				{
					return unityObject;
				}
			}
			throw new InvalidOperationException($"Could not find Unity object of type {typeof(T)} with name: {name}");
		}

		public static T Ref<T>(this T unityObject) where T : Object
		{
			if (!Object.op_Implicit((Object)(object)unityObject))
			{
				return default(T);
			}
			return unityObject;
		}

		public static T SetName<T>(this T unityObject, string name) where T : Object
		{
			((Object)unityObject).name = name;
			return unityObject;
		}
	}
}