Decompiled source of MysteriousEggRoom v1.2.5

plugins/MeticulouslyRare-EggRoom/meticulouslyrare.eggroom.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using EggRoom;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("meticulouslyrare.eggroom")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("meticulouslyrare.eggroom")]
[assembly: AssemblyTitle("meticulouslyrare.eggroom")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
public class _DeltaruneModeController : MonoBehaviour
{
	public _EggRoomMain eggMain;

	public void Awake()
	{
		if ((Object)(object)eggMain == (Object)null)
		{
			eggMain = _EggRoomMain.Instance;
		}
		TeleportToEggRoom();
	}

	public void TeleportToEggRoom()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		if (!eggMain.goneIntoEggRoom)
		{
			Debug.Log((object)$"TeleportToEggRoom called. Player at {((Component)MonoSingleton<NewMovement>.Instance).transform.position}");
			eggMain.goneIntoEggRoom = true;
			GameObject val = new GameObject("exitPos");
			Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
			val.transform.position = position;
			eggMain.roomDoorAdd = ((Component)this).gameObject;
			eggMain.exitPos = val;
			eggMain.lastCalmMusic = MonoSingleton<MusicManager>.Instance.cleanTheme.clip;
			eggMain.lastCombatMusic = MonoSingleton<MusicManager>.Instance.battleTheme.clip;
			eggMain.lastBossMusic = MonoSingleton<MusicManager>.Instance.bossTheme.clip;
			eggMain.GenericTeleport(eggMain.enterPos);
			eggMain.OnEnterEggRoom();
		}
	}
}
public class _DeltaruneModeDoor : MonoBehaviour
{
	public float currentChance;

	public void Awake()
	{
		if ((Object)(object)Plugin.Instance != (Object)null)
		{
			currentChance = Plugin.Instance.deltaruneModeBaseTeleportChance;
		}
	}

	public bool CanTeleportToEggRoom()
	{
		return Random.Range(0f, 100f) < currentChance;
	}

	public void CallMe()
	{
		bool num = CanTeleportToEggRoom();
		if (num)
		{
			((Component)this).gameObject.AddComponent<_DeltaruneModeController>();
			Object.Destroy((Object)(object)this);
		}
		if (!num)
		{
			currentChance += Plugin.Instance.deltaruneModeBasePerOpenChanceAddition;
		}
	}
}
public class _EggRoomDoorAdd : MonoBehaviour
{
	public Door parentDoor;

	public _EggRoomMain eggMain;

	public void Awake()
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		if ((Object)(object)parentDoor == (Object)null)
		{
			parentDoor = ((Component)this).gameObject.GetComponentInParent<Door>();
		}
		if ((Object)(object)eggMain == (Object)null)
		{
			eggMain = _EggRoomMain.Instance;
		}
		if ((Object)(object)parentDoor != (Object)null && (Object)(object)eggMain != (Object)null)
		{
			parentDoor.onFullyOpened.AddListener(new UnityAction(TeleportToEggRoom));
		}
	}

	public void TeleportToEggRoom()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		if (!eggMain.goneIntoEggRoom)
		{
			Debug.Log((object)$"TeleportToEggRoom called. Player at {((Component)MonoSingleton<NewMovement>.Instance).transform.position}");
			eggMain.goneIntoEggRoom = true;
			GameObject val = new GameObject("exitPos");
			Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
			val.transform.position = position;
			eggMain.roomDoorAdd = ((Component)this).gameObject;
			eggMain.exitPos = val;
			eggMain.lastCalmMusic = MonoSingleton<MusicManager>.Instance.cleanTheme.clip;
			eggMain.lastCombatMusic = MonoSingleton<MusicManager>.Instance.battleTheme.clip;
			eggMain.lastBossMusic = MonoSingleton<MusicManager>.Instance.bossTheme.clip;
			eggMain.GenericTeleport(eggMain.enterPos);
			eggMain.OnEnterEggRoom();
		}
	}
}
public class _EggRoomMain : MonoBehaviour
{
	public ObjectActivator exitTrigger;

	public GameObject enterPos;

	public GameObject MODEL_MAN;

	[HideInInspector]
	public GameObject exitPos;

	public bool goneIntoEggRoom;

	[HideInInspector]
	public GameObject roomDoorAdd;

	public AudioClip lastCalmMusic;

	public AudioClip lastCombatMusic;

	public AudioClip lastBossMusic;

	public AudioClip eggRoomMusic;

	private bool previousFog;

	private FistControl fistControl;

	public bool holdingEgg;

	private bool gottenEgg;

	public static _EggRoomMain Instance { get; private set; }

	public void Update()
	{
		if ((Object)(object)fistControl == (Object)null)
		{
			fistControl = MonoSingleton<FistControl>.Instance;
		}
		if ((Object)(object)fistControl.heldObject != (Object)null && ((Object)fistControl.heldObject).name != "Egg Pickupable")
		{
			holdingEgg = false;
		}
		if ((Object)(object)fistControl.heldObject != (Object)null && ((Object)fistControl.heldObject).name == "Egg Pickupable")
		{
			holdingEgg = true;
		}
		if ((Object)(object)fistControl.heldObject == (Object)null)
		{
			holdingEgg = false;
		}
		if (holdingEgg && !gottenEgg)
		{
			MODEL_MAN.SetActive(false);
			gottenEgg = true;
		}
	}

	private void Awake()
	{
		if ((Object)(object)fistControl == (Object)null)
		{
			fistControl = MonoSingleton<FistControl>.Instance;
		}
		if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
		else
		{
			Instance = this;
		}
	}

	public void OnEnterEggRoom()
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		if ((Object)(object)eggRoomMusic != (Object)null)
		{
			MonoSingleton<MusicManager>.Instance.StopMusic();
			MonoSingleton<MusicManager>.Instance.cleanTheme.clip = eggRoomMusic;
			MonoSingleton<MusicManager>.Instance.battleTheme.clip = eggRoomMusic;
			MonoSingleton<MusicManager>.Instance.bossTheme.clip = eggRoomMusic;
			MonoSingleton<MusicManager>.Instance.cleanTheme.pitch = 1f;
			MonoSingleton<MusicManager>.Instance.battleTheme.pitch = 1f;
			MonoSingleton<MusicManager>.Instance.bossTheme.pitch = 1f;
			MonoSingleton<MusicManager>.Instance.StartMusic();
		}
		else
		{
			Debug.LogWarning((object)"Egg room music is not loaded.");
		}
		previousFog = RenderSettings.fog;
		RenderSettings.fog = false;
		MonoSingleton<StatsManager>.Instance.currentCheckPoint.onRestart.AddListener(new UnityAction(OnCheckpointReload));
	}

	public void OnExitEggRoom()
	{
		Object.Destroy((Object)(object)roomDoorAdd.gameObject);
		MonoSingleton<MusicManager>.Instance.StopMusic();
		MonoSingleton<MusicManager>.Instance.cleanTheme.clip = lastCalmMusic;
		MonoSingleton<MusicManager>.Instance.battleTheme.clip = lastCombatMusic;
		MonoSingleton<MusicManager>.Instance.bossTheme.clip = lastBossMusic;
		MonoSingleton<MusicManager>.Instance.cleanTheme.pitch = 1f;
		MonoSingleton<MusicManager>.Instance.battleTheme.pitch = 1f;
		MonoSingleton<MusicManager>.Instance.bossTheme.pitch = 1f;
		MonoSingleton<MusicManager>.Instance.StartMusic();
		RenderSettings.fog = previousFog;
		GenericTeleport(exitPos);
	}

	public void GenericTeleport(GameObject targetPos)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		NewMovement instance = MonoSingleton<NewMovement>.Instance;
		if (Object.op_Implicit((Object)(object)instance.ridingRocket))
		{
			instance.ridingRocket.PlayerRideEnd();
		}
		instance.StopMovement();
		instance.gc.heavyFall = false;
		((Component)instance).transform.position = targetPos.transform.position;
		((Component)instance).transform.rotation = targetPos.transform.rotation;
		instance.dodgeDirection = Vector3.forward;
	}

	private void OnDestroy()
	{
		if ((Object)(object)Instance == (Object)(object)this)
		{
			Instance = null;
		}
	}

	public void OnCheckpointReload()
	{
		Object.Destroy((Object)(object)roomDoorAdd.gameObject);
		MonoSingleton<MusicManager>.Instance.StopMusic();
		MonoSingleton<MusicManager>.Instance.cleanTheme.clip = lastCalmMusic;
		MonoSingleton<MusicManager>.Instance.battleTheme.clip = lastCombatMusic;
		MonoSingleton<MusicManager>.Instance.bossTheme.clip = lastBossMusic;
		MonoSingleton<MusicManager>.Instance.StartMusic();
		RenderSettings.fog = previousFog;
	}
}
namespace EggRoom
{
	[BepInPlugin("meticulouslyrare.EggRoom", "Mysterious Man's Room", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public enum mode
		{
			Standard,
			Deltarune
		}

		public static Plugin? Instance;

		public static string eggContent = Path.Combine(ModPath(), "EggContent");

		public bool isContentLoaded;

		public List<Door> currentLevelDoors = new List<Door>();

		public List<Door> currentDoorCandidates = new List<Door>();

		public string eggRoomHash = "5d293bcd90f9e5041b0846d3a3970b97";

		public string eggMusicHash = "67c1d91c51199fe44bc8d12dbba8479e";

		public PluginConfigurator config;

		public FloatField spawnChanceField;

		public EnumField<mode> modeField;

		public FloatField dtModeBaseTeleportChanceField;

		public FloatField dtModePerOpenChanceAdditionField;

		public BoolField modEnabledField;

		public bool modEnabled = true;

		public float behaviorSpawnChance = 5f;

		public float deltaruneModeBaseTeleportChance = 2f;

		public float deltaruneModeBasePerOpenChanceAddition;

		public mode currentMode;

		private static readonly HashSet<string> forbiddenDoors = new HashSet<string> { "DoorLeft", "DoorRight", "Halls Entrance" };

		public static string ModPath()
		{
			return Assembly.GetExecutingAssembly().Location.Substring(0, Assembly.GetExecutingAssembly().Location.LastIndexOf(Path.DirectorySeparatorChar));
		}

		private bool ShouldSpawnEggRoom()
		{
			if (modEnabled)
			{
				return Random.Range(0f, 100f) < behaviorSpawnChance;
			}
			return false;
		}

		private void Awake()
		{
			//IL_0049: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Expected O, but got Unknown
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Expected O, but got Unknown
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Expected O, but got Unknown
			Instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Egg Room loaded!");
			if (!isContentLoaded)
			{
				((MonoBehaviour)this).StartCoroutine(LoadCatalogAndBundle(forceReload: true));
				isContentLoaded = true;
			}
			SceneManager.sceneLoaded += OnSceneLoaded;
			new Harmony("meticulouslyrare.EggRoom").PatchAll();
			config = PluginConfigurator.Create("Mysterious Man's Room", "meticulouslyrare.EggRoom");
			new ConfigHeader(config.rootPanel, "Warning: Changing values require a level restart!", 25, (TextAlignmentOptions)514);
			modEnabledField = new BoolField(config.rootPanel, "Enable Mod", "meticulouslyrare.eggroom.enabled", true);
			modeField = new EnumField<mode>(config.rootPanel, "Mode", "meticulouslyrare.eggroom.mode", mode.Standard);
			ConfigPanel val = new ConfigPanel(config.rootPanel, "Standard Mode Options", "meticulouslyrare.eggroom.standard");
			ConfigPanel val2 = new ConfigPanel(config.rootPanel, "Deltarune Mode Options", "meticulouslyrare.eggroom.deltarune");
			spawnChanceField = new FloatField(val, "Behavior Spawn Chance", "meticulouslyrare.eggroom.spawnchance", 5f, 0f, 100f);
			dtModeBaseTeleportChanceField = new FloatField(val2, "Base Teleport Chance", "meticulouslyrare.eggroom.deltarune.baseteleportchance", 2f, 0f, 100f);
			dtModePerOpenChanceAdditionField = new FloatField(val2, "Per Open Chance Addition", "meticulouslyrare.eggroom.deltarune.peropenchanceaddition", 0f, 0f, 100f);
			modEnabled = modEnabledField.value;
			currentMode = modeField.value;
			behaviorSpawnChance = spawnChanceField.value;
			deltaruneModeBaseTeleportChance = dtModeBaseTeleportChanceField.value;
			deltaruneModeBasePerOpenChanceAddition = dtModePerOpenChanceAdditionField.value;
			modEnabled = modEnabledField.value;
			behaviorSpawnChance = spawnChanceField.value;
			modEnabledField.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
			{
				modEnabled = e.value;
			};
			spawnChanceField.onValueChange += (FloatValueChangeEventDelegate)delegate(FloatValueChangeEvent e)
			{
				behaviorSpawnChance = e.value;
			};
			modeField.onValueChange += delegate(EnumValueChangeEvent<mode> e)
			{
				currentMode = e.value;
			};
			dtModeBaseTeleportChanceField.onValueChange += (FloatValueChangeEventDelegate)delegate(FloatValueChangeEvent e)
			{
				deltaruneModeBaseTeleportChance = e.value;
			};
			dtModePerOpenChanceAdditionField.onValueChange += (FloatValueChangeEventDelegate)delegate(FloatValueChangeEvent e)
			{
				deltaruneModeBasePerOpenChanceAddition = e.value;
			};
		}

		private T[] FindAllInstances<T>() where T : Object
		{
			return Resources.FindObjectsOfTypeAll<T>();
		}

		private void SaveCatalogKeysToFile()
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (object item in Addressables.ResourceLocators.SelectMany((IResourceLocator locator) => locator.Keys))
			{
				stringBuilder.AppendLine(item.ToString());
			}
			string text = Path.Combine(ModPath(), "catalogInfo.txt");
			try
			{
				File.WriteAllText(text, stringBuilder.ToString());
				Debug.Log((object)("Catalog keys saved to: " + text));
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Failed to save catalog keys: " + ex.Message));
			}
		}

		public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			modEnabled = modEnabledField.value;
			currentMode = modeField.value;
			behaviorSpawnChance = spawnChanceField.value;
			deltaruneModeBaseTeleportChance = dtModeBaseTeleportChanceField.value;
			deltaruneModeBasePerOpenChanceAddition = dtModePerOpenChanceAdditionField.value;
			((MonoBehaviour)this).StartCoroutine(SetupDoors());
		}

		private IEnumerator DeltaruneMode()
		{
			AsyncOperationHandle<GameObject> handle = Addressables.InstantiateAsync((object)eggRoomHash, (Transform)null, false, true);
			yield return handle;
			Debug.LogError((object)"== IN DELTARUNE MODE ==");
			Debug.LogError((object)$"Instantiate status: {handle.Status}");
			if ((int)handle.Status != 1)
			{
				Debug.LogError((object)"Instantiate failed.");
				Debug.LogException(handle.OperationException);
				yield break;
			}
			_ = handle.Result;
			Debug.LogError((object)"Instantiate succeeded.");
			foreach (Door currentDoorCandidate in currentDoorCandidates)
			{
				GameObject val = new GameObject("_DeltaruneModeEggRoomDoorAdd");
				Debug.LogError((object)("Added eggAdd to candidate: " + ((Object)currentDoorCandidate).name));
				val.transform.SetParent(((Component)currentDoorCandidate).transform, false);
				_DeltaruneModeDoor deltaruneModeDoor = val.AddComponent<_DeltaruneModeDoor>();
				currentDoorCandidate.onFullyOpened.AddListener(new UnityAction(deltaruneModeDoor.CallMe));
			}
		}

		private IEnumerator SetupDoors()
		{
			yield return null;
			currentLevelDoors.Clear();
			currentDoorCandidates.Clear();
			Door[] collection = Object.FindObjectsByType<Door>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			currentLevelDoors.AddRange(collection);
			foreach (Door currentLevelDoor in currentLevelDoors)
			{
				Debug.LogError((object)("Door found: " + ((Object)currentLevelDoor).name));
				if (forbiddenDoors.Contains(((Object)currentLevelDoor).name))
				{
					Debug.LogError((object)("Skipping forbidden door: " + ((Object)currentLevelDoor).name));
					continue;
				}
				GameObject[] activatedRooms = currentLevelDoor.activatedRooms;
				if (((activatedRooms != null && activatedRooms.Length != 0) ? 1 : 0) <= (false ? 1 : 0))
				{
					GameObject[] deactivatedRooms = currentLevelDoor.deactivatedRooms;
					if (((deactivatedRooms != null && deactivatedRooms.Length != 0) ? 1 : 0) <= (false ? 1 : 0))
					{
						continue;
					}
				}
				Debug.LogError((object)("Candidate: " + ((Object)currentLevelDoor).name));
				currentDoorCandidates.Add(currentLevelDoor);
			}
			Debug.LogError((object)$"Candidates: {currentDoorCandidates.Count}");
			if (currentDoorCandidates.Count == 0)
			{
				Debug.LogError((object)"No valid door candidates.");
				yield break;
			}
			if (currentMode != mode.Standard)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(DeltaruneMode());
				yield break;
			}
			bool flag = ShouldSpawnEggRoom();
			Debug.LogError((object)$"ShouldSpawn = {flag}");
			if (flag)
			{
				Debug.LogError((object)"Starting instantiate...");
				AsyncOperationHandle<GameObject> handle = Addressables.InstantiateAsync((object)eggRoomHash, (Transform)null, false, true);
				yield return handle;
				Debug.LogError((object)$"Instantiate status: {handle.Status}");
				if ((int)handle.Status != 1)
				{
					Debug.LogError((object)"Instantiate failed.");
					Debug.LogException(handle.OperationException);
					yield break;
				}
				_ = handle.Result;
				Debug.LogError((object)"Instantiate succeeded.");
				int index = Random.Range(0, currentDoorCandidates.Count);
				Door val = currentDoorCandidates[index];
				Debug.LogError((object)("Door chosen: " + ((Object)val).name));
				GameObject val2 = new GameObject("_EggRoomDoorAdd");
				val2.transform.SetParent(((Component)val).transform, false);
				val2.AddComponent<_EggRoomDoorAdd>().parentDoor = val;
				Debug.LogError((object)"Finished SetupDoors.");
			}
		}

		private IEnumerator LoadCatalogAndBundle(bool forceReload)
		{
			string text = Path.Combine(eggContent, "catalog.json");
			string text2 = Path.Combine(eggContent, "patched_catalog.json");
			if (!File.Exists(text))
			{
				Debug.LogError((object)("Catalog file not found at: " + text));
				yield break;
			}
			try
			{
				JObject val = JObject.Parse(File.ReadAllText(text));
				string text3 = "{AngryLevelLoader.Plugin.tempFolderPath}";
				string newValue = "{EggRoom.Plugin.eggContent}";
				JToken val2 = ((JToken)val).SelectToken("m_InternalIds");
				if (val2 != null && (int)val2.Type == 2)
				{
					JArray val3 = (JArray)val2;
					for (int i = 0; i < ((JContainer)val3).Count; i++)
					{
						string text4 = ((object)val3[i]).ToString();
						if (text4.Contains(text3))
						{
							val3[i] = JToken.op_Implicit(text4.Replace(text3, newValue));
						}
					}
				}
				File.WriteAllText(text2, ((JToken)val).ToString((Formatting)1, Array.Empty<JsonConverter>()));
				Debug.Log((object)"Patched catalog created successfully.");
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Error while patching catalog: " + ex.Message));
				yield break;
			}
			AsyncOperationHandle<IResourceLocator> addressableHandle = Addressables.LoadContentCatalogAsync(text2, false, (string)null);
			yield return (object)new WaitUntil((Func<bool>)(() => addressableHandle.IsDone || (int)addressableHandle.Status == 2));
			if ((int)addressableHandle.Status == 1)
			{
				Debug.Log((object)"Patched catalog loaded successfully.");
				SaveCatalogKeysToFile();
			}
			else
			{
				Debug.LogError((object)$"Failed to load patched catalog: {addressableHandle.OperationException}");
			}
		}
	}
	[HarmonyPatch(typeof(FinalRank))]
	public class FinalRankEggPatch
	{
		private static bool eggRewardedThisRun = false;

		private static string lastProcessedScene = "";

		[HarmonyPatch("SetInfo")]
		[HarmonyPostfix]
		public static void SetInfoPostfix(FinalRank __instance)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_EggRoomMain.Instance == (Object)null || !Plugin.Instance.modEnabled)
			{
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (lastProcessedScene != name)
			{
				lastProcessedScene = name;
				eggRewardedThisRun = false;
			}
			if ((Object)(object)_EggRoomMain.Instance != (Object)null && _EggRoomMain.Instance.holdingEgg)
			{
				if ((Object)(object)__instance.extraInfo != (Object)null)
				{
					TMP_Text extraInfo = __instance.extraInfo;
					extraInfo.text += "+ <color=#FF00FF>CARRIED THE EGG</color> (<color=orange>+1,000P</color>)\n";
				}
				if (!eggRewardedThisRun)
				{
					__instance.AddPoints(1000);
					eggRewardedThisRun = true;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}