Decompiled source of Glitnir DeepNort v1.1.8

plugins/GlitnirFarm.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("GlitnirFarm")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GlitnirFarm")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e1da477d-c14c-4355-be8f-c043e789791a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GlitnirFarm;

[BepInPlugin("Glitnir.GlitnirFarm", "GlitnirFarm", "0.0.1")]
public class GlitnirFarm : BaseUnityPlugin
{
	public static ConfigEntry<KeyboardShortcut> MassActionHotkey { get; private set; }

	public static ConfigEntry<KeyboardShortcut> ControllerPickupHotkey { get; private set; }

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

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

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

	public static bool IgnoreStamina { get; private set; }

	public static bool IgnoreDurability { get; private set; }

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

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

	public void Awake()
	{
		//IL_001b: 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)
		MassActionHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "MassActionHotkey", new KeyboardShortcut((KeyCode)304, Array.Empty<KeyCode>()), "Mass activation hotkey for multi-pickup/multi-plant.");
		ControllerPickupHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "ControllerPickupHotkey", new KeyboardShortcut((KeyCode)334, Array.Empty<KeyCode>()), "Mass activation hotkey for multi-pickup/multi-plant for controller.");
		MassInteractRange = ((BaseUnityPlugin)this).Config.Bind<float>("Pickup", "MassInteractRange", 5f, "Range of auto-pickup.");
		PlantGridWidth = ((BaseUnityPlugin)this).Config.Bind<int>("PlantGrid", "PlantGridWidth", 5, "Grid width of auto-plant. Recommend odd-number, default is '5' so (5x5).");
		PlantGridLength = ((BaseUnityPlugin)this).Config.Bind<int>("PlantGrid", "PlantGridLength", 5, "Grid length of auto-plant. Recommend odd-number, default is '5' so (5x5).");
		IgnoreStamina = false;
		IgnoreDurability = false;
		GridAnchorWidth = ((BaseUnityPlugin)this).Config.Bind<bool>("PlantGrid", "GridAnchorWidth", true, "Planting grid anchor point (width). Default is 'enabled' so the grid will extend left and right from the crosshairs. Disable to set the anchor to the side of the grid. Disable both anchors to set to corner.");
		GridAnchorLength = ((BaseUnityPlugin)this).Config.Bind<bool>("PlantGrid", "GridAnchorLength", true, "Planting grid anchor point (length). Default is 'enabled' so the grid will extend forward and backward from the crosshairs. Disable to set the anchor to the side of the grid. Disable both anchors to set to corner.");
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
	}
}
[HarmonyPatch]
public static class MassPickup
{
	private static FieldInfo m_interactMaskField = AccessTools.Field(typeof(Player), "m_interactMask");

	private static MethodInfo _ExtractMethod = AccessTools.Method(typeof(Beehive), "Extract", (Type[])null, (Type[])null);

	[HarmonyPatch(typeof(Player), "Interact")]
	public static void Prefix(Player __instance, GameObject go, bool hold, bool alt)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		if (((Character)__instance).InAttack() || ((Character)__instance).InDodge() || hold)
		{
			return;
		}
		KeyboardShortcut value = GlitnirFarm.ControllerPickupHotkey.Value;
		if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
		{
			value = GlitnirFarm.MassActionHotkey.Value;
			if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
			{
				return;
			}
		}
		Interactable componentInParent = go.GetComponentInParent<Interactable>();
		Pickable val = (Pickable)(object)((componentInParent is Pickable) ? componentInParent : null);
		if (val != null)
		{
			int num = (int)m_interactMaskField.GetValue(__instance);
			Collider[] array = Physics.OverlapSphere(go.transform.position, GlitnirFarm.MassInteractRange.Value, num);
			Collider[] array2 = array;
			foreach (Collider val2 in array2)
			{
				object obj;
				if (val2 == null)
				{
					obj = null;
				}
				else
				{
					GameObject gameObject = ((Component)val2).gameObject;
					obj = ((gameObject != null) ? gameObject.GetComponentInParent<Pickable>() : null);
				}
				Pickable val3 = (Pickable)obj;
				if (val3 != null && (Object)(object)val3 != (Object)(object)val && ((Object)val3.m_itemPrefab).name == ((Object)val.m_itemPrefab).name)
				{
					val3.Interact((Humanoid)(object)__instance, false, alt);
				}
			}
			return;
		}
		Beehive val4 = (Beehive)(object)((componentInParent is Beehive) ? componentInParent : null);
		if (val4 == null)
		{
			return;
		}
		int num2 = (int)m_interactMaskField.GetValue(__instance);
		Collider[] array3 = Physics.OverlapSphere(go.transform.position, GlitnirFarm.MassInteractRange.Value, num2);
		Collider[] array4 = array3;
		foreach (Collider val5 in array4)
		{
			object obj2;
			if (val5 == null)
			{
				obj2 = null;
			}
			else
			{
				GameObject gameObject2 = ((Component)val5).gameObject;
				obj2 = ((gameObject2 != null) ? gameObject2.GetComponentInParent<Beehive>() : null);
			}
			Beehive val6 = (Beehive)obj2;
			if (val6 != null && (Object)(object)val6 != (Object)(object)val4 && PrivateArea.CheckAccess(((Component)val6).transform.position, 0f, true, false))
			{
				_ExtractMethod.Invoke(val6, null);
			}
		}
	}
}
[HarmonyPatch]
public static class MassPlant
{
	private static readonly FieldInfo m_noPlacementCostField = AccessTools.Field(typeof(Player), "m_noPlacementCost");

	private static readonly FieldInfo m_placementGhostField = AccessTools.Field(typeof(Player), "m_placementGhost");

	private static readonly FieldInfo m_buildPiecesField = AccessTools.Field(typeof(Player), "m_buildPieces");

	private static readonly MethodInfo _GetRightItemMethod = AccessTools.Method(typeof(Humanoid), "GetRightItem", (Type[])null, (Type[])null);

	private static Vector3 placedPosition;

	private static Quaternion placedRotation;

	private static Piece placedPiece;

	private static bool placeSuccessful = false;

	private static int? massFarmingRotation = null;

	private static readonly int _plantSpaceMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid" });

	private static GameObject[] _placementGhosts = (GameObject[])(object)new GameObject[1];

	private static readonly Piece _fakeResourcePiece;

	private static bool IsHotKeyPressed
	{
		get
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = GlitnirFarm.ControllerPickupHotkey.Value;
			int result;
			if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
			{
				value = GlitnirFarm.MassActionHotkey.Value;
				result = (Input.GetKey(((KeyboardShortcut)(ref value)).MainKey) ? 1 : 0);
			}
			else
			{
				result = 1;
			}
			return (byte)result != 0;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(Player), "PlacePiece")]
	public static void PlacePiecePrefix(int ___m_placeRotation)
	{
		if (IsHotKeyPressed)
		{
			int? num = massFarmingRotation;
			if (!num.HasValue)
			{
				massFarmingRotation = ___m_placeRotation;
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Player), "PlacePiece")]
	public static void PlacePiecePostfix(Player __instance, ref bool __result, Piece piece, ref int ___m_placeRotation)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		placeSuccessful = __result;
		if (__result)
		{
			GameObject val = (GameObject)m_placementGhostField.GetValue(__instance);
			placedPosition = val.transform.position;
			placedRotation = val.transform.rotation;
			placedPiece = piece;
		}
		if (IsHotKeyPressed)
		{
			___m_placeRotation = massFarmingRotation.Value;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(Player), "UpdatePlacement")]
	public static void UpdatePlacementPrefix(bool takeInput, float dt, ref int ___m_placeRotation)
	{
		placeSuccessful = false;
		if (IsHotKeyPressed && massFarmingRotation.HasValue)
		{
			___m_placeRotation = massFarmingRotation.Value;
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Player), "UpdatePlacement")]
	public static void UpdatePlacementPostfix(Player __instance, bool takeInput, float dt, int ___m_placeRotation)
	{
		//IL_0062: 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_0089: 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)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: 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_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		if (IsHotKeyPressed)
		{
			massFarmingRotation = ___m_placeRotation;
		}
		if (!placeSuccessful)
		{
			return;
		}
		Plant component = ((Component)placedPiece).gameObject.GetComponent<Plant>();
		if (!Object.op_Implicit((Object)(object)component) || !IsHotKeyPressed)
		{
			return;
		}
		Heightmap val = Heightmap.FindHeightmap(placedPosition);
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		foreach (Vector3 item in BuildPlantingGridPositions(placedPosition, component, placedRotation))
		{
			if ((placedPiece.m_cultivatedGroundOnly && !val.IsCultivated(item)) || placedPosition == item)
			{
				continue;
			}
			object? obj = _GetRightItemMethod.Invoke(__instance, Array.Empty<object>());
			ItemData val2 = (ItemData)((obj is ItemData) ? obj : null);
			if (val2 == null)
			{
				continue;
			}
			if (!GlitnirFarm.IgnoreStamina && !((Character)__instance).HaveStamina(val2.m_shared.m_attack.m_attackStamina))
			{
				Hud.instance.StaminaBarUppgradeFlash();
				break;
			}
			if (!(bool)m_noPlacementCostField.GetValue(__instance) && !__instance.HaveRequirements(placedPiece, (RequirementMode)0))
			{
				break;
			}
			if (!HasGrowSpace(item, ((Component)placedPiece).gameObject))
			{
				continue;
			}
			GameObject val3 = Object.Instantiate<GameObject>(((Component)placedPiece).gameObject, item, placedRotation);
			Piece component2 = val3.GetComponent<Piece>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.SetCreator(__instance.GetPlayerID());
			}
			placedPiece.m_placeEffect.Create(item, placedRotation, val3.transform, 1f, -1);
			Game.instance.IncrementPlayerStat((PlayerStatType)2, 1f);
			__instance.ConsumeResources(placedPiece.m_resources, 0, -1);
			if (!GlitnirFarm.IgnoreStamina)
			{
				((Character)__instance).UseStamina(val2.m_shared.m_attack.m_attackStamina, false);
			}
			if (!GlitnirFarm.IgnoreDurability && val2.m_shared.m_useDurability)
			{
				val2.m_durability -= val2.m_shared.m_useDurabilityDrain;
				if (val2.m_durability <= 0f)
				{
					break;
				}
			}
		}
	}

	private static List<Vector3> BuildPlantingGridPositions(Vector3 originPos, Plant placedPlant, Quaternion rotation)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: 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_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		float num = placedPlant.m_growRadius * 2f;
		List<Vector3> list = new List<Vector3>(GlitnirFarm.PlantGridWidth.Value * GlitnirFarm.PlantGridLength.Value);
		Vector3 val = rotation * Vector3.left * num;
		Vector3 val2 = rotation * Vector3.forward * num;
		Vector3 val3 = originPos;
		if (GlitnirFarm.GridAnchorLength.Value)
		{
			val3 -= val2 * (float)(GlitnirFarm.PlantGridLength.Value / 2);
		}
		if (GlitnirFarm.GridAnchorWidth.Value)
		{
			val3 -= val * (float)(GlitnirFarm.PlantGridWidth.Value / 2);
		}
		for (int i = 0; i < GlitnirFarm.PlantGridLength.Value; i++)
		{
			Vector3 val4 = val3;
			for (int j = 0; j < GlitnirFarm.PlantGridWidth.Value; j++)
			{
				val4.y = ZoneSystem.instance.GetGroundHeight(val4);
				list.Add(val4);
				val4 += val;
			}
			val3 += val2;
		}
		return list;
	}

	private static bool HasGrowSpace(Vector3 newPos, GameObject go)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		Plant component = go.GetComponent<Plant>();
		if (component != null)
		{
			Collider[] array = Physics.OverlapSphere(newPos, component.m_growRadius, _plantSpaceMask);
			return array.Length == 0;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(Player), "SetupPlacementGhost")]
	public static void SetupPlacementGhostPrefix(Player __instance, int ___m_placeRotation)
	{
		if (IsHotKeyPressed)
		{
			int? num = massFarmingRotation;
			if (!num.HasValue)
			{
				massFarmingRotation = ___m_placeRotation;
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Player), "SetupPlacementGhost")]
	public static void SetupPlacementGhostPostfix(Player __instance, ref int ___m_placeRotation)
	{
		if (IsHotKeyPressed && massFarmingRotation.HasValue)
		{
			___m_placeRotation = massFarmingRotation.Value;
		}
		DestroyGhosts();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Player), "UpdatePlacementGhost")]
	public static void UpdatePlacementGhostPostfix(Player __instance, bool flashGuardStone)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_003e: 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_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: 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_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: 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)
		GameObject val = (GameObject)m_placementGhostField.GetValue(__instance);
		if (!Object.op_Implicit((Object)(object)val) || !val.activeSelf)
		{
			SetGhostsActive(active: false);
			return;
		}
		KeyboardShortcut value = GlitnirFarm.ControllerPickupHotkey.Value;
		if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
		{
			value = GlitnirFarm.MassActionHotkey.Value;
			if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
			{
				SetGhostsActive(active: false);
				return;
			}
		}
		Plant component = val.GetComponent<Plant>();
		if (!Object.op_Implicit((Object)(object)component))
		{
			SetGhostsActive(active: false);
			return;
		}
		if (!EnsureGhostsBuilt(__instance))
		{
			SetGhostsActive(active: false);
			return;
		}
		Requirement val2 = ((IEnumerable<Requirement>)val.GetComponent<Piece>().m_resources).FirstOrDefault((Func<Requirement, bool>)((Requirement r) => Object.op_Implicit((Object)(object)r.m_resItem) && r.m_amount > 0));
		_fakeResourcePiece.m_resources[0].m_resItem = val2.m_resItem;
		_fakeResourcePiece.m_resources[0].m_amount = val2.m_amount;
		float num = __instance.GetStamina();
		object? obj = _GetRightItemMethod.Invoke(__instance, Array.Empty<object>());
		ItemData val3 = (ItemData)((obj is ItemData) ? obj : null);
		if (val3 == null)
		{
			return;
		}
		Heightmap val4 = Heightmap.FindHeightmap(val.transform.position);
		List<Vector3> list = BuildPlantingGridPositions(val.transform.position, component, val.transform.rotation);
		for (int i = 0; i < _placementGhosts.Length; i++)
		{
			Vector3 val5 = list[i];
			if (val.transform.position == val5)
			{
				_placementGhosts[i].SetActive(false);
				continue;
			}
			Requirement obj2 = _fakeResourcePiece.m_resources[0];
			obj2.m_amount += val2.m_amount;
			_placementGhosts[i].transform.position = val5;
			_placementGhosts[i].transform.rotation = val.transform.rotation;
			_placementGhosts[i].SetActive(true);
			bool invalidPlacementHeightlight = false;
			if (val.GetComponent<Piece>().m_cultivatedGroundOnly && !val4.IsCultivated(val5))
			{
				invalidPlacementHeightlight = true;
			}
			else if (!HasGrowSpace(val5, val.gameObject))
			{
				invalidPlacementHeightlight = true;
			}
			else if (!GlitnirFarm.IgnoreStamina && num < val3.m_shared.m_attack.m_attackStamina)
			{
				Hud.instance.StaminaBarUppgradeFlash();
				invalidPlacementHeightlight = true;
			}
			else if (!(bool)m_noPlacementCostField.GetValue(__instance) && !__instance.HaveRequirements(_fakeResourcePiece, (RequirementMode)0))
			{
				invalidPlacementHeightlight = true;
			}
			num -= val3.m_shared.m_attack.m_attackStamina;
			_placementGhosts[i].GetComponent<Piece>().SetInvalidPlacementHeightlight(invalidPlacementHeightlight);
		}
	}

	private static bool EnsureGhostsBuilt(Player player)
	{
		int num = GlitnirFarm.PlantGridWidth.Value * GlitnirFarm.PlantGridLength.Value;
		if (!Object.op_Implicit((Object)(object)_placementGhosts[0]) || _placementGhosts.Length != num)
		{
			DestroyGhosts();
			if (_placementGhosts.Length != num)
			{
				_placementGhosts = (GameObject[])(object)new GameObject[num];
			}
			object? value = m_buildPiecesField.GetValue(player);
			PieceTable val = (PieceTable)((value is PieceTable) ? value : null);
			if (val != null)
			{
				GameObject selectedPrefab = val.GetSelectedPrefab();
				if (selectedPrefab != null)
				{
					if (selectedPrefab.GetComponent<Piece>().m_repairPiece)
					{
						return false;
					}
					for (int i = 0; i < _placementGhosts.Length; i++)
					{
						_placementGhosts[i] = SetupMyGhost(player, selectedPrefab);
					}
					goto IL_00e0;
				}
			}
			return false;
		}
		goto IL_00e0;
		IL_00e0:
		return true;
	}

	private static void DestroyGhosts()
	{
		for (int i = 0; i < _placementGhosts.Length; i++)
		{
			if (Object.op_Implicit((Object)(object)_placementGhosts[i]))
			{
				Object.Destroy((Object)(object)_placementGhosts[i]);
				_placementGhosts[i] = null;
			}
		}
	}

	private static void SetGhostsActive(bool active)
	{
		GameObject[] placementGhosts = _placementGhosts;
		foreach (GameObject val in placementGhosts)
		{
			if (val != null)
			{
				val.SetActive(active);
			}
		}
	}

	private static GameObject SetupMyGhost(Player player, GameObject prefab)
	{
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Expected O, but got Unknown
		ZNetView.m_forceDisableInit = true;
		GameObject val = Object.Instantiate<GameObject>(prefab);
		ZNetView.m_forceDisableInit = false;
		((Object)val).name = ((Object)prefab).name;
		Joint[] componentsInChildren = val.GetComponentsInChildren<Joint>();
		foreach (Joint val2 in componentsInChildren)
		{
			Object.Destroy((Object)(object)val2);
		}
		Rigidbody[] componentsInChildren2 = val.GetComponentsInChildren<Rigidbody>();
		foreach (Rigidbody val3 in componentsInChildren2)
		{
			Object.Destroy((Object)(object)val3);
		}
		int layer = LayerMask.NameToLayer("ghost");
		Transform[] componentsInChildren3 = val.GetComponentsInChildren<Transform>();
		foreach (Transform val4 in componentsInChildren3)
		{
			((Component)val4).gameObject.layer = layer;
		}
		TerrainModifier[] componentsInChildren4 = val.GetComponentsInChildren<TerrainModifier>();
		foreach (TerrainModifier val5 in componentsInChildren4)
		{
			Object.Destroy((Object)(object)val5);
		}
		GuidePoint[] componentsInChildren5 = val.GetComponentsInChildren<GuidePoint>();
		foreach (GuidePoint val6 in componentsInChildren5)
		{
			Object.Destroy((Object)(object)val6);
		}
		Light[] componentsInChildren6 = val.GetComponentsInChildren<Light>();
		foreach (Light val7 in componentsInChildren6)
		{
			Object.Destroy((Object)(object)val7);
		}
		Transform val8 = val.transform.Find("_GhostOnly");
		if (Object.op_Implicit((Object)(object)val8))
		{
			((Component)val8).gameObject.SetActive(true);
		}
		MeshRenderer[] componentsInChildren7 = val.GetComponentsInChildren<MeshRenderer>();
		foreach (MeshRenderer val9 in componentsInChildren7)
		{
			if (!((Object)(object)((Renderer)val9).sharedMaterial == (Object)null))
			{
				Material[] sharedMaterials = ((Renderer)val9).sharedMaterials;
				for (int num2 = 0; num2 < sharedMaterials.Length; num2++)
				{
					Material val10 = new Material(sharedMaterials[num2]);
					val10.SetFloat("_RippleDistance", 0f);
					val10.SetFloat("_ValueNoise", 0f);
					sharedMaterials[num2] = val10;
				}
				((Renderer)val9).sharedMaterials = sharedMaterials;
				((Renderer)val9).shadowCastingMode = (ShadowCastingMode)0;
			}
		}
		return val;
	}

	static MassPlant()
	{
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Expected O, but got Unknown
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Expected O, but got Unknown
		Piece val = new Piece();
		val.m_dlc = string.Empty;
		val.m_resources = (Requirement[])(object)new Requirement[1]
		{
			new Requirement()
		};
		_fakeResourcePiece = val;
	}
}

plugins/Intermission.dll

Decompiled 2 weeks 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;
		}
	}
}