Decompiled source of BerryGodsBlessing v0.1.0

BerryGodsBlessing.dll

Decompiled 3 days 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.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using SuperFantasyKingdom;
using SuperFantasyKingdom.Spawner;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BerryGodsBlessing")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BerryGodsBlessing")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("20c3324d-c6ee-4fd1-aea6-b44b7856ee29")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("AWSSDK.CognitoIdentity")]
[assembly: IgnoresAccessChecksTo("AWSSDK.CognitoSync")]
[assembly: IgnoresAccessChecksTo("AWSSDK.Core")]
[assembly: IgnoresAccessChecksTo("AWSSDK.Kinesis")]
[assembly: IgnoresAccessChecksTo("AWSSDK.SecurityToken")]
[assembly: IgnoresAccessChecksTo("com.games-farm.platforms.wingdk.public.runtime")]
[assembly: IgnoresAccessChecksTo("com.rlabrecque.steamworks.net")]
[assembly: IgnoresAccessChecksTo("FMODUnity")]
[assembly: IgnoresAccessChecksTo("FMODUnityResonance")]
[assembly: IgnoresAccessChecksTo("GalaxyCSharp")]
[assembly: IgnoresAccessChecksTo("GamesFarm.Platforms.WinGDK.Private.Core")]
[assembly: IgnoresAccessChecksTo("GamesFarm.Platforms.WinGDK.Private.Runtime")]
[assembly: IgnoresAccessChecksTo("I18N.CJK")]
[assembly: IgnoresAccessChecksTo("I18N")]
[assembly: IgnoresAccessChecksTo("I18N.MidEast")]
[assembly: IgnoresAccessChecksTo("I18N.Other")]
[assembly: IgnoresAccessChecksTo("I18N.Rare")]
[assembly: IgnoresAccessChecksTo("I18N.West")]
[assembly: IgnoresAccessChecksTo("Mono.Security")]
[assembly: IgnoresAccessChecksTo("netstandard")]
[assembly: IgnoresAccessChecksTo("Newtonsoft.Json")]
[assembly: IgnoresAccessChecksTo("PrimeTween.Runtime")]
[assembly: IgnoresAccessChecksTo("Textus.SerializeReferenceUI")]
[assembly: IgnoresAccessChecksTo("UniTask.Addressables")]
[assembly: IgnoresAccessChecksTo("UniTask")]
[assembly: IgnoresAccessChecksTo("UniTask.DOTween")]
[assembly: IgnoresAccessChecksTo("UniTask.Linq")]
[assembly: IgnoresAccessChecksTo("UniTask.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.2D.Animation.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.Common.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.IK.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.PixelPerfect")]
[assembly: IgnoresAccessChecksTo("Unity.2D.SpriteShape.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.Tilemap.Extras")]
[assembly: IgnoresAccessChecksTo("Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.001")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")]
[assembly: IgnoresAccessChecksTo("Unity.Localization")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Microsoft.GDK")]
[assembly: IgnoresAccessChecksTo("Unity.Microsoft.GDK.Tools")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipeline.Universal.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Shaders")]
[assembly: IgnoresAccessChecksTo("Unity.ResourceManager")]
[assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AccessibilityModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AndroidJNIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AnimationModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AssetBundleModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AudioModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClothModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClusterInputModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClusterRendererModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CoreModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CrashReportingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.DirectorModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine")]
[assembly: IgnoresAccessChecksTo("UnityEngine.DSPGraphModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GameCenterModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GridModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.HotReloadModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ImageConversionModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.IMGUIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.InputLegacyModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.InputModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.JSONSerializeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.LocalizationModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ParticleSystemModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PerformanceReportingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.Physics2DModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PhysicsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ProfilerModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ScreenCaptureModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SharedInternalsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpriteMaskModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpriteShapeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.StreamingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SubstanceModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SubsystemsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TerrainModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TerrainPhysicsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreFontEngineModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreTextEngineModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextRenderingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TilemapModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TLSModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIElementsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIElementsNativeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UmbraModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UNETModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsCommonModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityConnectModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityCurlModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityTestProtocolModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAssetBundleModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAudioModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestTextureModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestWWWModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VehiclesModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VFXModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VideoModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VirtualTexturingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VRModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.WindModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XRModule")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 BerryGodsBlessing
{
	[BepInPlugin("com.low.berrygodsblessing", "Berry God's Blessing", "0.1.0")]
	public class BerryGodPlugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <DelayedBlessingCheck>d__5 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public BerryGodPlugin <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DelayedBlessingCheck>d__5(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected O, but got Unknown
				int num = <>1__state;
				BerryGodPlugin berryGodPlugin = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					berryGodPlugin.currentBerryCount = berryGodPlugin.CountBerries();
					float num2 = Mathf.InverseLerp(10f, 100f, (float)berryGodPlugin.currentBerryCount);
					float num3 = Mathf.Lerp(0.01f, 0.5f, num2);
					((BaseUnityPlugin)berryGodPlugin).Logger.LogInfo((object)$"Berry count = {berryGodPlugin.currentBerryCount}, Blessing chance = {num3 * 100f}%");
					float num4 = (float)berryGodPlugin.rng.NextDouble();
					((BaseUnityPlugin)berryGodPlugin).Logger.LogInfo((object)$"Roll = {num4}");
					if (num4 <= num3)
					{
						IBlessing blessing = berryGodPlugin.RollRandomBlessing();
						((BaseUnityPlugin)berryGodPlugin).Logger.LogInfo((object)("A blessing has occurred! The gods grant: " + blessing.Name));
						berryGodPlugin.ApplyBlessing(blessing);
					}
					else
					{
						((BaseUnityPlugin)berryGodPlugin).Logger.LogInfo((object)"No blessing occurred this time.");
					}
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitForDialogueToClose>d__6 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Action onClose;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitForDialogueToClose>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
				}
				GameObject val = GameObject.Find("Canvas/Dialogues");
				if ((Object)(object)val == (Object)null || !val.activeInHierarchy)
				{
					onClose?.Invoke();
					return false;
				}
				<>2__current = null;
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private int currentBerryCount;

		private Random rng = new Random();

		private void EnsureHideManagerGameObjectDisabled()
		{
			try
			{
				string path = Path.Combine(Paths.ConfigPath, "BepInEx.cfg");
				if (!File.Exists(path))
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"BepInEx.cfg not found — cannot verify HideManagerGameObject.");
					return;
				}
				string[] array = File.ReadAllLines(path);
				bool flag = false;
				for (int i = 0; i < array.Length; i++)
				{
					if (array[i].Trim().StartsWith("HideManagerGameObject") && !array[i].Contains("true"))
					{
						array[i] = "HideManagerGameObject = true";
						flag = true;
					}
				}
				if (flag)
				{
					File.WriteAllLines(path, array);
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched BepInEx.cfg → HideManagerGameObject = true");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"HideManagerGameObject already set to true.");
				}
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to update BepInEx.cfg: {arg}");
			}
		}

		private void Awake()
		{
			EnsureHideManagerGameObjectDisabled();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Berry God's Blessing loaded.");
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name == "GameScene")
			{
				((MonoBehaviour)this).StartCoroutine(DelayedBlessingCheck());
			}
		}

		[IteratorStateMachine(typeof(<DelayedBlessingCheck>d__5))]
		private IEnumerator DelayedBlessingCheck()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DelayedBlessingCheck>d__5(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<WaitForDialogueToClose>d__6))]
		private IEnumerator WaitForDialogueToClose(Action onClose)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForDialogueToClose>d__6(0)
			{
				onClose = onClose
			};
		}

		public void OpenDialogue(string dialogueText)
		{
			DialogueManager instance = DialogueManager.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"DialogueManager.Instance is null");
			}
			GameManager.Instance.StartForcedPause(true);
			UIManager.Instance.DisplaySkipControls();
			Actor actor = instance.GetActor((Actors)1);
			instance.dialogueBox.Init(dialogueText, actor, true, true);
			((MonoBehaviour)this).StartCoroutine(WaitForDialogueToClose(delegate
			{
				GameManager.Instance.EndForcedPause(true);
				UIManager.Instance.HideSkipControls();
			}));
		}

		private int CountBerries()
		{
			ResourceDepositBerry[] array = Object.FindObjectsOfType<ResourceDepositBerry>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Found {array.Length} berries");
			return array.Length;
		}

		private IBlessing RollRandomBlessing()
		{
			List<IBlessing> list = BlessingList.All.Where((IBlessing b) => b.CanApply()).ToList();
			if (list.Count == 0)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"No eligible blessings! All conditions failed.");
				return null;
			}
			int index = rng.Next(list.Count);
			return list[index];
		}

		private void ApplyBlessing(IBlessing blessing)
		{
			if (blessing == null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Blessing was null — no valid blessings available.");
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Applying blessing: " + blessing.Name));
			OpenDialogue(blessing.Message);
			_ = DroppedShardSpawner.Instance;
			blessing.Apply();
		}
	}
	public interface IBlessing
	{
		string Name { get; }

		string Message { get; }

		void Apply();

		bool CanApply();
	}
	public class Blessing<T> : IBlessing
	{
		public string name;

		public string message;

		public T requiredType;

		public Action onApply;

		public Func<bool> condition;

		public string Name => name;

		public Type TargetType => typeof(T);

		public string Message => message;

		public Blessing(string name, string message, Action onApply = null, Func<bool> condition = null)
		{
			this.name = name;
			this.message = message;
			this.onApply = onApply;
			this.condition = condition;
		}

		public void Apply()
		{
			onApply();
		}

		public bool CanApply()
		{
			if (condition != null)
			{
				return condition();
			}
			return true;
		}
	}
	public static class BlessingList
	{
		public static Blessing<DroppedShardSpawner> GoldBlessing = new Blessing<DroppedShardSpawner>("Gold", "The berry gods have blessed your kingdom with a golden bounty. Some of your bushes have sprouted golden berries.", delegate
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			DroppedShardSpawner.Instance.Spawn(new Vector3(0f, 0f, 0f), 10, (ResourceType)15);
		});

		public static Blessing<DroppedShardSpawner> FaithBlessing = new Blessing<DroppedShardSpawner>("Faith", "The berry gods have blessed your kingdom with their holy gaze. Your kingdom's faith has been bolstered.", delegate
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			DroppedShardSpawner.Instance.Spawn(new Vector3(0f, 0f, 0f), 10, (ResourceType)13);
		});

		public static Blessing<WallManager> WallBlessing = new Blessing<WallManager>("Wall", "The berry gods have blessed your kingdom with fortifications. Vines have sprouted from the earth entertwining with your walls.", delegate
		{
			WallManager.Instance.AddToHitpointMultiplier(0.1f);
		}, () => WallManager.Instance.m_MaxHitpoints > 0f);

		private static List<IBlessing> _all;

		public static List<IBlessing> All
		{
			get
			{
				if (_all == null)
				{
					_all = (from f in typeof(BlessingList).GetFields(BindingFlags.Static | BindingFlags.Public)
						where typeof(IBlessing).IsAssignableFrom(f.FieldType)
						select (IBlessing)f.GetValue(null)).ToList();
				}
				return _all;
			}
		}

		public static IBlessing GetByName(string name)
		{
			return All.FirstOrDefault((IBlessing b) => b.Name == name);
		}
	}
	public class PopupManager : MonoBehaviour
	{
		private static PopupManager instance;

		private GameObject popupRoot;

		private Text popupText;

		public static void Show(string message)
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = CreatePopupManager();
			}
			instance.ShowPopup(message);
		}

		private static PopupManager CreatePopupManager()
		{
			//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_0010: Expected O, but got Unknown
			GameObject val = new GameObject("PopupManager");
			Object.DontDestroyOnLoad((Object)val);
			return val.AddComponent<PopupManager>();
		}

		private void ShowPopup(string message)
		{
			EnsurePopupUICreated();
			popupText.text = message;
			popupRoot.SetActive(true);
		}

		private void EnsurePopupUICreated()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Expected O, but got Unknown
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Expected O, but got Unknown
			if ((Object)(object)popupRoot != (Object)null)
			{
				return;
			}
			GameObject val = GameObject.Find("Canvas");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)"[PopupManager] Could not find Canvas!");
				return;
			}
			popupRoot = new GameObject("BlessingPopup");
			popupRoot.transform.SetParent(val.transform, false);
			popupRoot.AddComponent<CanvasRenderer>();
			((Graphic)popupRoot.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f);
			RectTransform component = popupRoot.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			GameObject val2 = new GameObject("Panel");
			val2.transform.SetParent(popupRoot.transform, false);
			((Graphic)val2.AddComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 0.9f);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.sizeDelta = new Vector2(360f, 200f);
			component2.anchorMin = new Vector2(0.5f, 0.5f);
			component2.anchorMax = new Vector2(0.5f, 0.5f);
			component2.anchoredPosition = Vector2.zero;
			GameObject val3 = new GameObject("Message");
			val3.transform.SetParent(val2.transform, false);
			popupText = val3.AddComponent<Text>();
			popupText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			popupText.fontSize = 14;
			((Graphic)popupText).color = Color.white;
			popupText.alignment = (TextAnchor)4;
			popupText.horizontalOverflow = (HorizontalWrapMode)0;
			RectTransform component3 = val3.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0.1f, 0.25f);
			component3.anchorMax = new Vector2(0.9f, 0.85f);
			component3.offsetMin = Vector2.zero;
			component3.offsetMax = Vector2.zero;
			GameObject val4 = new GameObject("CloseButton");
			val4.transform.SetParent(val2.transform, false);
			Button obj = val4.AddComponent<Button>();
			((Graphic)val4.AddComponent<Image>()).color = new Color(0.3f, 0.3f, 0.3f);
			Text obj2 = new GameObject("Text").AddComponent<Text>();
			((Component)obj2).transform.SetParent(val4.transform, false);
			obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			obj2.fontSize = 20;
			((Graphic)obj2).color = Color.white;
			obj2.text = "Close";
			obj2.alignment = (TextAnchor)4;
			RectTransform component4 = val4.GetComponent<RectTransform>();
			component4.sizeDelta = new Vector2(120f, 50f);
			component4.anchorMin = new Vector2(0.5f, 0.1f);
			component4.anchorMax = new Vector2(0.5f, 0.1f);
			component4.anchoredPosition = Vector2.zero;
			RectTransform component5 = ((Component)obj2).GetComponent<RectTransform>();
			component5.anchorMin = Vector2.zero;
			component5.anchorMax = Vector2.one;
			component5.offsetMin = Vector2.zero;
			component5.offsetMax = Vector2.zero;
			((UnityEvent)obj.onClick).AddListener((UnityAction)delegate
			{
				popupRoot.SetActive(false);
			});
			popupRoot.SetActive(false);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}