Decompiled source of LunarRitual v0.1.2

LunarRitual.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LunarRitual")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cdd403e90bd4637556af2e0de47367add492e067")]
[assembly: AssemblyProduct("LunarRitual")]
[assembly: AssemblyTitle("LunarRitual")]
[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 LunarRitual
{
	public static class RiskOfOptionsCompatibility
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void OptionsInit()
		{
			Log.Info("Risk of Options detected, adding options...");
			AddMainOptions();
			AddDebugOptions();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void AddMainOptions()
		{
			//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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(LunarRitual.shardChance, new StepSliderConfig
			{
				min = 0f,
				max = 100f,
				increment = 0.01f
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(LunarRitual.teamShards));
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void AddDebugOptions()
		{
			//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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0053: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(LunarRitual.shardMultiplier, new StepSliderConfig
			{
				min = 0f,
				max = 1f,
				increment = 0.01f
			}));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(LunarRitual.startingShards, new IntSliderConfig
			{
				min = 0,
				max = 100
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(LunarRitual.noShardDroplet));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(LunarRitual.resetShards));
		}
	}
	public static class GenesisShards
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Init <>9__9_0;

			public static hook_Start <>9__9_1;

			internal IEnumerator <InitializeGenesisShardPickup>b__9_0(orig_Init orig)
			{
				IEnumerator result = orig.Invoke();
				InitializePickupIndex();
				return result;
			}

			internal void <InitializeGenesisShardPickup>b__9_1(orig_Start orig, Run self)
			{
				GenesisShardMiscPickupDef.ClearProcessedPickups();
				orig.Invoke(self);
			}
		}

		private static readonly string ShardsSavePath = Path.Combine(Paths.ConfigPath, "genesis_shards.json");

		private static Dictionary<ulong, int> playerShards = new Dictionary<ulong, int>();

		public static PickupIndex GenesisShardPickupIndex = PickupIndex.none;

		public static GameObject genesisShardPrefab;

		private static bool isInitialized = false;

		public static MiscPickupDef GenesisShardPickupDef { get; private set; }

		public static void InitializeGenesisShardPickup()
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			if (isInitialized)
			{
				Log.Warning("[LunarRitual] GenesisShard already initialized, skipping...");
				return;
			}
			try
			{
				LanguageAPI.Add("GENESIS_SHARD_NAME", "Genesis Shard");
				LanguageAPI.Add("GENESIS_SHARD_PICKUP", "Genesis Shard");
				LanguageAPI.Add("GENESIS_SHARD_DESC", "A fragment of lunar energy. Collect shards to perform powerful rituals.");
				LanguageAPI.Add("GENESIS_SHARD_LORE", "The Genesis Shards are remnants of the Moon's power, scattered across the worlds.");
				GenesisShardPickupDef = (MiscPickupDef)(object)ScriptableObject.CreateInstance<GenesisShardMiscPickupDef>();
				((Object)GenesisShardPickupDef).name = "GenesisShard";
				GenesisShardPickupDef.nameToken = "GENESIS_SHARD_NAME";
				GenesisShardPickupDef.descriptionToken = "GENESIS_SHARD_DESC";
				ContentAddition.AddMiscPickupDef(GenesisShardPickupDef);
				object obj = <>c.<>9__9_0;
				if (obj == null)
				{
					hook_Init val = delegate(orig_Init orig)
					{
						IEnumerator result = orig.Invoke();
						InitializePickupIndex();
						return result;
					};
					<>c.<>9__9_0 = val;
					obj = (object)val;
				}
				PickupCatalog.Init += (hook_Init)obj;
				object obj2 = <>c.<>9__9_1;
				if (obj2 == null)
				{
					hook_Start val2 = delegate(orig_Start orig, Run self)
					{
						GenesisShardMiscPickupDef.ClearProcessedPickups();
						orig.Invoke(self);
					};
					<>c.<>9__9_1 = val2;
					obj2 = (object)val2;
				}
				Run.Start += (hook_Start)obj2;
				Log.Warning("[LunarRitual] GenesisShard MiscPickupDef registered via ContentAddition");
			}
			catch (Exception ex)
			{
				Log.Error("[LunarRitual] Failed to initialize GenesisShard MiscPickupDef: " + ex.Message);
				Log.Error("[LunarRitual] Stack trace: " + ex.StackTrace);
				return;
			}
			isInitialized = true;
			Log.Warning("[LunarRitual] GenesisShard initialized successfully");
		}

		public static void InitializePickupIndex()
		{
			//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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GenesisShardPickupDef == (Object)null)
			{
				Log.Error("[LunarRitual] Cannot initialize PickupIndex - GenesisShardPickupDef is null");
				return;
			}
			try
			{
				GenesisShardPickupIndex = PickupCatalog.FindPickupIndex(GenesisShardPickupDef.miscPickupIndex);
				if (GenesisShardPickupIndex != PickupIndex.none)
				{
					Log.Warning($"[LunarRitual] GenesisShard PickupIndex found: {GenesisShardPickupIndex}");
					UpdateGenesisShardPrefab();
				}
				else
				{
					Log.Error("[LunarRitual] Failed to find PickupIndex for GenesisShard");
				}
			}
			catch (Exception ex)
			{
				Log.Error("[LunarRitual] Exception while getting PickupIndex: " + ex.Message);
			}
		}

		public static void UpdateGenesisShardPrefab()
		{
			//IL_000a: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			Log.Warning("[LunarRitual] UpdateGenesisShardPrefab called");
			if (GenesisShardPickupIndex == PickupIndex.none)
			{
				Log.Error("[LunarRitual] Cannot update prefab - GenesisShardPickupIndex is not initialized");
				return;
			}
			try
			{
				PickupDef pickupDef = ((PickupIndex)(ref GenesisShardPickupIndex)).pickupDef;
				Log.Warning($"[LunarRitual] GenesisShardPickupDef found, name: {pickupDef.nameToken}, pickupIndex: {GenesisShardPickupIndex.value}");
				pickupDef.nameToken = "GENESIS_SHARD_NAME";
				pickupDef.interactContextToken = "Pick up Genesis Shard";
				pickupDef.baseColor = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)100, (byte)100, byte.MaxValue));
				pickupDef.darkColor = Color32.op_Implicit(new Color32((byte)180, (byte)50, (byte)50, byte.MaxValue));
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/LunarCoin/PickupLunarCoin.prefab").WaitForCompletion();
				if ((Object)(object)val != (Object)null)
				{
					Log.Warning("[LunarRitual] LunarCoin prefab loaded: " + ((Object)val).name);
					GameObject val2 = GetLunarCoinDropletDisplayPrefab();
					if (!Object.op_Implicit((Object)(object)val2))
					{
						Log.Error("[LunarRitual] Failed to resolve LunarCoin dropletDisplayPrefab, falling back to pickup prefab (may be buggy)");
						val2 = val;
					}
					genesisShardPrefab = CreateGenesisShardDisplayPrefab(val2);
					Log.Warning("[LunarRitual] GenesisShard display prefab created");
					Renderer[] componentsInChildren = genesisShardPrefab.GetComponentsInChildren<Renderer>(true);
					if (componentsInChildren != null && componentsInChildren.Length != 0)
					{
						Log.Warning($"[LunarRitual] Found {componentsInChildren.Length} Renderer(s), setting material on mesh renderers");
						Material val3 = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Common/VFX/matLunarCoinPlaceholder.mat").WaitForCompletion();
						if ((Object)(object)val3 != (Object)null)
						{
							Color val4 = default(Color);
							((Color)(ref val4))..ctor(1f, 0.4f, 0.4f, 1f);
							Renderer[] array = componentsInChildren;
							foreach (Renderer val5 in array)
							{
								if (Object.op_Implicit((Object)(object)val5) && (val5 is MeshRenderer || val5 is SkinnedMeshRenderer))
								{
									val5.sharedMaterial = val3;
									val5.sharedMaterial.SetColor("_Color", val4);
									val5.sharedMaterial.SetColor("_EmColor", new Color(1f, 0.2f, 0.2f, 1f));
								}
							}
							Log.Warning("[LunarRitual] Material set successfully");
						}
						else
						{
							Log.Error("[LunarRitual] Failed to load matLunarCoinPlaceholder material");
						}
					}
					else
					{
						Log.Error("[LunarRitual] No Renderer found in GenesisShard display prefab");
					}
					Light componentInChildren = genesisShardPrefab.GetComponentInChildren<Light>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.color = new Color(1f, 0.4f, 0.4f, 1f);
						Log.Warning("[LunarRitual] Light color set");
					}
					else
					{
						Log.Warning("[LunarRitual] Light component not found");
					}
					pickupDef.dropletDisplayPrefab = genesisShardPrefab;
					Log.Warning("[LunarRitual] Assigned GenesisShard dropletDisplayPrefab");
					Log.Warning("[LunarRitual] GenesisShard prefab created and assigned successfully");
				}
				else
				{
					Log.Error("[LunarRitual] Failed to load LunarCoin prefab");
				}
			}
			catch (Exception ex)
			{
				Log.Error("[LunarRitual] Exception while updating GenesisShard prefab: " + ex.Message);
				Log.Error("[LunarRitual] Stack trace: " + ex.StackTrace);
			}
		}

		private static GameObject CreateGenesisShardDisplayPrefab(GameObject lunarCoinPickupPrefab)
		{
			if (!Object.op_Implicit((Object)(object)lunarCoinPickupPrefab))
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(lunarCoinPickupPrefab);
			((Object)val).name = "GenesisShardDisplay";
			val.SetActive(true);
			GenericPickupController component = val.GetComponent<GenericPickupController>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Object.Destroy((Object)(object)component);
			}
			Rigidbody component2 = val.GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				Object.Destroy((Object)(object)component2);
			}
			Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>(true);
			if (componentsInChildren != null)
			{
				Collider[] array = componentsInChildren;
				foreach (Collider val2 in array)
				{
					if (Object.op_Implicit((Object)(object)val2))
					{
						Object.Destroy((Object)(object)val2);
					}
				}
			}
			SetLayerRecursive(val, LayerIndex.pickups.intVal);
			return val;
		}

		private static GameObject GetLunarCoinDropletDisplayPrefab()
		{
			//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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PickupIndex val = PickupCatalog.FindPickupIndex(MiscPickups.LunarCoin.miscPickupIndex);
				if (val != PickupIndex.none)
				{
					PickupDef pickupDef = ((PickupIndex)(ref val)).pickupDef;
					if (pickupDef != null && Object.op_Implicit((Object)(object)pickupDef.dropletDisplayPrefab))
					{
						return pickupDef.dropletDisplayPrefab;
					}
				}
			}
			catch (Exception ex)
			{
				Log.Error("[LunarRitual] Exception while resolving LunarCoin dropletDisplayPrefab: " + ex.Message);
			}
			return null;
		}

		private static void SetLayerRecursive(GameObject obj, int layer)
		{
			if (!Object.op_Implicit((Object)(object)obj))
			{
				return;
			}
			obj.layer = layer;
			Transform transform = obj.transform;
			for (int i = 0; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				if (Object.op_Implicit((Object)(object)child))
				{
					SetLayerRecursive(((Component)child).gameObject, layer);
				}
			}
		}

		public static void AddShards(ulong userId, int amount)
		{
			if (!playerShards.ContainsKey(userId))
			{
				playerShards[userId] = 0;
			}
			playerShards[userId] += amount;
			Log.Warning($"[LunarRitual] Added {amount} Genesis Shard(s) to user {userId}. Total: {playerShards[userId]}");
		}

		public static int GetShards(ulong userId)
		{
			if (!playerShards.ContainsKey(userId))
			{
				return 0;
			}
			return playerShards[userId];
		}

		public static void SetShards(ulong userId, int amount)
		{
			playerShards[userId] = amount;
			Log.Warning($"[LunarRitual] Set Genesis Shards for user {userId} to {amount}");
		}

		public static void RemoveShards(ulong userId, int amount)
		{
			if (playerShards.ContainsKey(userId))
			{
				playerShards[userId] = Math.Max(0, playerShards[userId] - amount);
				Log.Warning($"[LunarRitual] Removed {amount} Genesis Shard(s) from user {userId}. Total: {playerShards[userId]}");
			}
		}

		public static void LoadShards()
		{
			if (!File.Exists(ShardsSavePath))
			{
				Log.Warning("[LunarRitual] No existing Genesis Shards save file found. Starting with 0 shards.");
				return;
			}
			try
			{
				playerShards = JsonConvert.DeserializeObject<Dictionary<ulong, int>>(File.ReadAllText(ShardsSavePath));
				Log.Warning($"[LunarRitual] Loaded Genesis Shards for {playerShards.Count} player(s)");
			}
			catch (Exception ex)
			{
				Log.Error("[LunarRitual] Failed to load Genesis Shards: " + ex.Message);
			}
		}

		public static void SaveShards()
		{
			try
			{
				string contents = JsonConvert.SerializeObject((object)playerShards, (Formatting)1);
				File.WriteAllText(ShardsSavePath, contents);
				Log.Warning("[LunarRitual] Genesis Shards saved successfully");
			}
			catch (Exception ex)
			{
				Log.Error("[LunarRitual] Failed to save Genesis Shards: " + ex.Message);
			}
		}
	}
	public class GenesisShardMiscPickupDef : MiscPickupDef
	{
		public static void ClearProcessedPickups()
		{
		}

		public override void GrantPickup(ref GrantContext context)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			Log.Warning("[LunarRitual] GrantPickup called for Genesis Shard");
			Log.Warning("[LunarRitual] context.body: " + (((Object)(object)context.body != (Object)null) ? ((Object)context.body).name : "null"));
			Log.Warning($"[LunarRitual] context.pickupIndex: {((GrantContext)(ref context)).pickupIndex.value}");
			NetworkUser val = Util.LookUpBodyNetworkUser(context.body);
			if ((Object)(object)val != (Object)null)
			{
				ulong value = val.id.value;
				Log.Warning($"[LunarRitual] Genesis Shard collected by player {value} via GrantPickup");
				GenesisShards.AddShards(value, 1);
				GenesisShardsUI.RefreshUI();
			}
			else
			{
				Log.Error("[LunarRitual] GrantPickup: NetworkUser is null! context.body is null or invalid");
			}
		}
	}
	public class GenesisShardsUI : MonoBehaviour
	{
		private static GameObject uiObject;

		private static HGTextMeshProUGUI shardsText;

		private static Canvas canvas;

		private static bool initialized;

		public static void Initialize()
		{
			if (!initialized)
			{
				initialized = true;
				Run.onRunStartGlobal += OnRunStart;
				Run.onRunDestroyGlobal += OnRunDestroy;
				SceneDirector.onPostPopulateSceneServer += OnSceneLoaded;
			}
		}

		private static void OnSceneLoaded(SceneDirector director)
		{
			if ((Object)(object)uiObject == (Object)null)
			{
				CreateUI();
			}
		}

		private static void OnRunStart(Run run)
		{
			CreateUI();
		}

		private static void OnRunDestroy(Run run)
		{
			DestroyUI();
		}

		private static void CreateUI()
		{
			if (!((Object)(object)uiObject != (Object)null))
			{
				CreateStandaloneUI();
				UpdateShardsDisplay();
				Log.Info("[LunarRitual] Genesis Shards UI created");
			}
		}

		private static void CreateStandaloneUI()
		{
			//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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("GenesisShardsCanvas");
			canvas = val.AddComponent<Canvas>();
			canvas.renderMode = (RenderMode)0;
			canvas.sortingOrder = 100;
			val.AddComponent<CanvasScaler>();
			val.AddComponent<GraphicRaycaster>();
			uiObject = val;
			GameObject val2 = new GameObject("ShardsContainer");
			val2.transform.SetParent(uiObject.transform, false);
			RectTransform obj = val2.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(0f, 1f);
			obj.pivot = new Vector2(0f, 1f);
			obj.sizeDelta = new Vector2(300f, 60f);
			obj.anchoredPosition = new Vector2(10f, -10f);
			((Transform)obj).localRotation = Quaternion.identity;
			GameObject val3 = new GameObject("ShardsIcon");
			val3.transform.SetParent(val2.transform, false);
			val3.AddComponent<Image>().sprite = CreateShardIcon();
			RectTransform component = val3.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0.5f);
			component.anchorMax = new Vector2(0f, 0.5f);
			component.pivot = new Vector2(0f, 0.5f);
			component.sizeDelta = new Vector2(40f, 40f);
			component.anchoredPosition = new Vector2(0f, 0f);
			GameObject val4 = new GameObject("ShardsText");
			val4.transform.SetParent(val2.transform, false);
			shardsText = val4.AddComponent<HGTextMeshProUGUI>();
			((TMP_Text)shardsText).fontSize = 24f;
			((Graphic)shardsText).color = new Color(12f / 85f, 3f / 85f, 0.20784314f);
			((TMP_Text)shardsText).fontStyle = (FontStyles)1;
			((TMP_Text)shardsText).alignment = (TextAlignmentOptions)513;
			((TMP_Text)shardsText).verticalAlignment = (VerticalAlignmentOptions)512;
			if ((Object)(object)((TMP_Text)shardsText).font == (Object)null)
			{
				((TMP_Text)shardsText).font = Resources.Load<TMP_FontAsset>("fonts & materials/LiberationSans SDF");
			}
			RectTransform component2 = val4.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.pivot = new Vector2(0f, 0.5f);
			component2.sizeDelta = new Vector2(-50f, 40f);
			component2.anchoredPosition = new Vector2(50f, 0f);
			val2.SetActive(true);
			val3.SetActive(true);
			val4.SetActive(true);
			UpdateShardsDisplay();
			Log.Info("[LunarRitual] Genesis Shards UI created (standalone)");
		}

		private static Sprite CreateShardIcon()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(32, 32);
			Color[] array = (Color[])(object)new Color[1024];
			for (int i = 0; i < array.Length; i++)
			{
				int num = i % 32;
				int num2 = i / 32;
				float num3 = 16f;
				float num4 = 16f;
				float num5 = Mathf.Sqrt(((float)num - num3) * ((float)num - num3) + ((float)num2 - num4) * ((float)num2 - num4));
				if (num5 < 15f)
				{
					float num6 = 1f - num5 / 15f;
					array[i] = new Color(12f / 85f, 3f / 85f, 0.20784314f, num6);
				}
				else
				{
					array[i] = new Color(0f, 0f, 0f, 0f);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f));
		}

		public static void UpdateShardsDisplay()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)shardsText == (Object)null)
			{
				Log.Warning("[LunarRitual] UpdateShardsDisplay: shardsText is null");
				return;
			}
			ulong num = 0uL;
			if (NetworkUser.readOnlyLocalPlayersList.Count > 0)
			{
				num = NetworkUser.readOnlyLocalPlayersList[0].id.value;
				Log.Warning($"[LunarRitual] UpdateShardsDisplay: Local player steamId: {num}");
			}
			else
			{
				Log.Warning("[LunarRitual] UpdateShardsDisplay: No local players found");
			}
			int shards = GenesisShards.GetShards(num);
			((TMP_Text)shardsText).text = $"Genesis Shards: {shards}";
			Log.Warning($"[LunarRitual] UpdateShardsDisplay: Set text to 'Genesis Shards: {shards}'");
		}

		public static void RefreshUI()
		{
			if ((Object)(object)uiObject != (Object)null)
			{
				UpdateShardsDisplay();
			}
		}

		private static void DestroyUI()
		{
			if ((Object)(object)uiObject != (Object)null)
			{
				Object.Destroy((Object)(object)uiObject);
				uiObject = null;
				shardsText = null;
			}
			if ((Object)(object)canvas != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)canvas).gameObject);
				canvas = null;
			}
		}
	}
	public class Hooks
	{
		private class GenesisShardDropletVisualFix : MonoBehaviour
		{
			private static Material shardMat;

			private static bool triedLoadMat;

			private static GameObject meshTemplate;

			private static bool triedLoadTemplate;

			private Transform visualRoot;

			private MeshRenderer shardMeshRenderer;

			private void Awake()
			{
				EnsureMaterialLoaded();
				EnsureMeshTemplateLoaded();
				EnsureVisualChild();
				HideVanillaPickupDisplay();
			}

			private void LateUpdate()
			{
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				HideVanillaPickupDisplay();
				if ((Object)(object)visualRoot == (Object)null || (Object)(object)shardMeshRenderer == (Object)null)
				{
					EnsureVisualChild();
				}
				if ((Object)(object)shardMeshRenderer != (Object)null)
				{
					if (!((Renderer)shardMeshRenderer).enabled)
					{
						((Renderer)shardMeshRenderer).enabled = true;
					}
					if (!((Component)shardMeshRenderer).gameObject.activeSelf)
					{
						((Component)shardMeshRenderer).gameObject.SetActive(true);
					}
					if ((Object)(object)shardMat != (Object)null)
					{
						((Renderer)shardMeshRenderer).sharedMaterial = shardMat;
						Color val = default(Color);
						((Color)(ref val))..ctor(1f, 0.4f, 0.4f, 1f);
						((Renderer)shardMeshRenderer).sharedMaterial.SetColor("_Color", val);
						((Renderer)shardMeshRenderer).sharedMaterial.SetColor("_EmColor", new Color(1f, 0.2f, 0.2f, 1f));
					}
				}
			}

			private static void EnsureMaterialLoaded()
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				if (triedLoadMat)
				{
					return;
				}
				triedLoadMat = true;
				try
				{
					shardMat = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Common/VFX/matLunarCoinPlaceholder.mat").WaitForCompletion();
				}
				catch
				{
					shardMat = null;
				}
			}

			private static void EnsureMeshTemplateLoaded()
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				if (triedLoadTemplate)
				{
					return;
				}
				triedLoadTemplate = true;
				try
				{
					GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/LunarCoin/PickupLunarCoin.prefab").WaitForCompletion();
					if (!((Object)(object)val != (Object)null))
					{
						return;
					}
					Transform val2 = val.transform.Find("Coin5Mesh");
					if ((Object)(object)val2 != (Object)null)
					{
						meshTemplate = Object.Instantiate<GameObject>(((Component)val2).gameObject);
						((Object)meshTemplate).name = "GenesisShardMeshTemplate";
						meshTemplate.SetActive(false);
						Collider[] componentsInChildren = meshTemplate.GetComponentsInChildren<Collider>(true);
						for (int i = 0; i < componentsInChildren.Length; i++)
						{
							Object.Destroy((Object)(object)componentsInChildren[i]);
						}
						Object.DontDestroyOnLoad((Object)(object)meshTemplate);
					}
				}
				catch
				{
					meshTemplate = null;
				}
			}

			private void EnsureVisualChild()
			{
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Expected O, but got Unknown
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: 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)
				if (!((Object)(object)visualRoot != (Object)null))
				{
					Transform val = ((Component)this).transform.Find("GenesisShardVisual");
					if ((Object)(object)val != (Object)null)
					{
						visualRoot = val;
					}
					else if (!((Object)(object)meshTemplate == (Object)null))
					{
						GameObject val2 = new GameObject("GenesisShardVisual");
						val2.transform.SetParent(((Component)this).transform, false);
						val2.transform.localPosition = new Vector3(0f, 0.55f, 0f);
						val2.transform.localRotation = Quaternion.identity;
						val2.transform.localScale = Vector3.one;
						GameObject val3 = Object.Instantiate<GameObject>(meshTemplate, val2.transform);
						((Object)val3).name = "Coin5Mesh";
						val3.SetActive(true);
						visualRoot = val2.transform;
						shardMeshRenderer = val3.GetComponent<MeshRenderer>();
					}
				}
			}

			private void HideVanillaPickupDisplay()
			{
				Transform val = ((Component)this).transform.Find("PickupDisplay");
				if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeSelf)
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__CreateShardEffectPrefab;

			public static hook_Start <1>__InitializePlayers;

			public static hook_Awake <2>__OnPlayerAwake;

			public static hook_OnCharacterDeath <3>__OnCharacterDeath;

			public static hook_OnDestroy <4>__SaveShardsOnRunEnd;

			public static hook_OnInteractionBegin <5>__OnPickupInteractionBegin;

			public static hook_OnTriggerStay <6>__OnPickupTriggerStay;

			public static hook_Start <7>__OnGenericPickupControllerStart;
		}

		private static GameObject shardEffectPrefab;

		private static Dictionary<ulong, float> playerShardChance = new Dictionary<ulong, float>();

		public static void Init()
		{
			//IL_0010: 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_001b: Expected O, but got Unknown
			//IL_0030: 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_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			//IL_007b: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			object obj = <>O.<0>__CreateShardEffectPrefab;
			if (obj == null)
			{
				hook_Awake val = CreateShardEffectPrefab;
				<>O.<0>__CreateShardEffectPrefab = val;
				obj = (object)val;
			}
			Run.Awake += (hook_Awake)obj;
			object obj2 = <>O.<1>__InitializePlayers;
			if (obj2 == null)
			{
				hook_Start val2 = InitializePlayers;
				<>O.<1>__InitializePlayers = val2;
				obj2 = (object)val2;
			}
			Run.Start += (hook_Start)obj2;
			object obj3 = <>O.<2>__OnPlayerAwake;
			if (obj3 == null)
			{
				hook_Awake val3 = OnPlayerAwake;
				<>O.<2>__OnPlayerAwake = val3;
				obj3 = (object)val3;
			}
			PlayerCharacterMasterController.Awake += (hook_Awake)obj3;
			object obj4 = <>O.<3>__OnCharacterDeath;
			if (obj4 == null)
			{
				hook_OnCharacterDeath val4 = OnCharacterDeath;
				<>O.<3>__OnCharacterDeath = val4;
				obj4 = (object)val4;
			}
			GlobalEventManager.OnCharacterDeath += (hook_OnCharacterDeath)obj4;
			object obj5 = <>O.<4>__SaveShardsOnRunEnd;
			if (obj5 == null)
			{
				hook_OnDestroy val5 = SaveShardsOnRunEnd;
				<>O.<4>__SaveShardsOnRunEnd = val5;
				obj5 = (object)val5;
			}
			Run.OnDestroy += (hook_OnDestroy)obj5;
			object obj6 = <>O.<5>__OnPickupInteractionBegin;
			if (obj6 == null)
			{
				hook_OnInteractionBegin val6 = OnPickupInteractionBegin;
				<>O.<5>__OnPickupInteractionBegin = val6;
				obj6 = (object)val6;
			}
			GenericPickupController.OnInteractionBegin += (hook_OnInteractionBegin)obj6;
			object obj7 = <>O.<6>__OnPickupTriggerStay;
			if (obj7 == null)
			{
				hook_OnTriggerStay val7 = OnPickupTriggerStay;
				<>O.<6>__OnPickupTriggerStay = val7;
				obj7 = (object)val7;
			}
			GenericPickupController.OnTriggerStay += (hook_OnTriggerStay)obj7;
			object obj8 = <>O.<7>__OnGenericPickupControllerStart;
			if (obj8 == null)
			{
				hook_Start val8 = OnGenericPickupControllerStart;
				<>O.<7>__OnGenericPickupControllerStart = val8;
				obj8 = (object)val8;
			}
			GenericPickupController.Start += (hook_Start)obj8;
			Log.Warning("[LunarRitual] Hooks initialized");
		}

		private static void CreateShardEffectPrefab(orig_Awake orig, Run self)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			orig.Invoke(self);
			if ((Object)(object)shardEffectPrefab == (Object)null)
			{
				shardEffectPrefab = new GameObject("GenesisShardEffect");
				shardEffectPrefab.AddComponent<NetworkIdentity>();
				shardEffectPrefab.AddComponent<GenesisShardEffect>();
				Object.DontDestroyOnLoad((Object)(object)shardEffectPrefab);
				shardEffectPrefab.SetActive(false);
			}
			Log.Warning("[LunarRitual] Shard effect prefab created");
		}

		private static void InitializePlayers(orig_Start orig, Run self)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				orig.Invoke(self);
				return;
			}
			if (LunarRitual.resetShards.Value && NetworkUser.readOnlyInstancesList != null)
			{
				foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
				{
					GenesisShards.SetShards(readOnlyInstances.id.value, LunarRitual.startingShards.Value);
				}
			}
			orig.Invoke(self);
		}

		private static void OnPlayerAwake(orig_Awake orig, PlayerCharacterMasterController self)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			NetworkUser networkUser = self.networkUser;
			if ((Object)(object)networkUser != (Object)null)
			{
				ulong value = networkUser.id.value;
				if (!playerShardChance.ContainsKey(value))
				{
					playerShardChance[value] = LunarRitual.ShardChanceProbability;
				}
			}
		}

		private static void OnCharacterDeath(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, damageReport);
			if (!NetworkServer.active)
			{
				return;
			}
			Log.Warning("[LunarRitual] OnCharacterDeath called - checking if shard should drop");
			if (damageReport == null || (Object)(object)damageReport.attackerMaster == (Object)null)
			{
				Log.Warning("[LunarRitual] damageReport or attackerMaster is null");
				return;
			}
			CharacterMaster attackerMaster = damageReport.attackerMaster;
			CharacterBody body = attackerMaster.GetBody();
			TeamComponent val = ((body != null) ? ((Component)body).GetComponent<TeamComponent>() : null);
			if ((Object)(object)val == (Object)null || (int)val.teamIndex != 1)
			{
				Log.Warning("[LunarRitual] Attacker is not on player team");
				return;
			}
			CharacterBody body2 = attackerMaster.GetBody();
			Log.Warning("[LunarRitual] Attacker is player: " + (((body2 != null) ? body2.GetUserName() : null) ?? "Unknown"));
			PlayerCharacterMasterController playerCharacterMasterController = attackerMaster.playerCharacterMasterController;
			NetworkUser val2 = ((playerCharacterMasterController != null) ? playerCharacterMasterController.networkUser : null);
			if ((Object)(object)val2 == (Object)null)
			{
				Log.Warning("[LunarRitual] playerCharacterMasterController.networkUser is null, trying fallback");
				foreach (NetworkUser readOnlyLocalPlayers in NetworkUser.readOnlyLocalPlayersList)
				{
					if ((Object)(object)readOnlyLocalPlayers.master == (Object)(object)attackerMaster)
					{
						val2 = readOnlyLocalPlayers;
						break;
					}
				}
				if ((Object)(object)val2 == (Object)null)
				{
					Log.Warning("[LunarRitual] Could not find attackerUser");
					return;
				}
			}
			ulong value = val2.id.value;
			Log.Warning($"[LunarRitual] Attacker steamId: {value}");
			if (!playerShardChance.ContainsKey(value))
			{
				playerShardChance[value] = LunarRitual.ShardChanceProbability;
				Log.Warning($"[LunarRitual] Initial shard chance set to {LunarRitual.ShardChanceProbability:F3}");
			}
			float num = Random.Range(0f, 1f);
			Log.Warning($"[LunarRitual] Roll: {num:F3}, Chance: {playerShardChance[value]:F3}");
			if (num < playerShardChance[value])
			{
				Log.Warning("[LunarRitual] SHARD DROP TRIGGERED!");
				if (LunarRitual.noShardDroplet.Value)
				{
					Log.Warning("[LunarRitual] Using auto-collect mode (no droplet)");
					if (LunarRitual.teamShards.Value)
					{
						foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
						{
							NetworkUser networkUser = instance.networkUser;
							if ((Object)(object)networkUser != (Object)null)
							{
								ulong value2 = networkUser.id.value;
								GenesisShards.AddShards(value2, 1);
								Log.Warning($"[LunarRitual] Added 1 shard to player {value2}");
							}
						}
					}
					else
					{
						GenesisShards.AddShards(value, 1);
						Log.Warning($"[LunarRitual] Added 1 shard to attacker {value}");
					}
				}
				else
				{
					Log.Warning("[LunarRitual] Creating physical shard droplet");
					SpawnShardDroplet(damageReport);
					Log.Warning("[LunarRitual] Droplet created");
				}
				CharacterBody body3 = attackerMaster.GetBody();
				Log.Warning("[LunarRitual] Genesis Shard dropped by " + (((body3 != null) ? body3.GetUserName() : null) ?? "Unknown"));
				GenesisShardsUI.RefreshUI();
			}
			else
			{
				Log.Warning("[LunarRitual] Shard drop failed (roll was too high)");
			}
		}

		private static void SpawnShardDroplet(DamageReport damageReport)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0030: 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_003b: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			PickupIndex val = GenesisShards.GenesisShardPickupIndex;
			if (val == PickupIndex.none && (Object)(object)GenesisShards.GenesisShardPickupDef != (Object)null)
			{
				try
				{
					val = (GenesisShards.GenesisShardPickupIndex = PickupCatalog.FindPickupIndex(GenesisShards.GenesisShardPickupDef.miscPickupIndex));
					Log.Warning($"[LunarRitual] Dynamically initialized GenesisShardPickupIndex: {val}");
					if (val == PickupIndex.none)
					{
						Log.Error("[LunarRitual] Failed to find PickupIndex for GenesisShard dynamically");
						return;
					}
				}
				catch (Exception ex)
				{
					Log.Error("[LunarRitual] Exception while getting PickupIndex: " + ex.Message);
					return;
				}
			}
			if (val == PickupIndex.none)
			{
				Log.Error("[LunarRitual] GenesisShardPickupIndex is not initialized and GenesisShardPickupDef is null!");
				return;
			}
			if ((Object)(object)GenesisShards.genesisShardPrefab == (Object)null)
			{
				Log.Warning("[LunarRitual] genesisShardPrefab is null, calling UpdateGenesisShardPrefab");
				GenesisShards.UpdateGenesisShardPrefab();
				if ((Object)(object)GenesisShards.genesisShardPrefab == (Object)null)
				{
					Log.Error("[LunarRitual] genesisShardPrefab is still null after UpdateGenesisShardPrefab!");
					return;
				}
			}
			Vector3 val2 = damageReport.victimBody.corePosition + Vector3.up * 3f;
			Vector3 insideUnitSphere = Random.insideUnitSphere;
			insideUnitSphere.y = 0f;
			if (((Vector3)(ref insideUnitSphere)).sqrMagnitude > 0.0001f)
			{
				((Vector3)(ref insideUnitSphere)).Normalize();
			}
			Vector3 val3 = Vector3.up * 10f + insideUnitSphere * Random.Range(2f, 6f);
			PickupDropletController.CreatePickupDroplet(val, val2, val3);
			Log.Warning($"[LunarRitual] Genesis Shard droplet created at {val2}");
		}

		private static void OnGenericPickupControllerStart(orig_Start orig, GenericPickupController self)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			try
			{
				if (!((Object)(object)self == (Object)null) && !(self.pickupIndex != GenesisShards.GenesisShardPickupIndex) && !Object.op_Implicit((Object)(object)((Component)self).gameObject.GetComponent<GenesisShardDropletVisualFix>()))
				{
					((Component)self).gameObject.AddComponent<GenesisShardDropletVisualFix>();
				}
			}
			catch (Exception ex)
			{
				Log.Error("[LunarRitual] Failed to attach GenesisShard visual fix: " + ex.Message);
			}
		}

		private static void SetLayerRecursive(GameObject obj, int layer)
		{
			if (!Object.op_Implicit((Object)(object)obj))
			{
				return;
			}
			obj.layer = layer;
			Transform transform = obj.transform;
			for (int i = 0; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				if (Object.op_Implicit((Object)(object)child))
				{
					SetLayerRecursive(((Component)child).gameObject, layer);
				}
			}
		}

		private static void OnPickupInteractionBegin(orig_OnInteractionBegin orig, GenericPickupController self, Interactor activator)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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)
			Log.Warning($"[LunarRitual] OnPickupInteractionBegin called - pickupIndex: {self.pickupIndex.value}, GenesisShardPickupIndex: {GenesisShards.GenesisShardPickupIndex.value}");
			Log.Warning($"[LunarRitual] Is Genesis Shard: {self.pickupIndex == GenesisShards.GenesisShardPickupIndex}");
			Log.Warning(string.Format("[LunarRitual] NetworkServer.active: {0}, self.gameObject: {1}", NetworkServer.active, ((Object)(object)((Component)self).gameObject != (Object)null) ? "exists" : "null"));
			orig.Invoke(self, activator);
			if (self.pickupIndex == GenesisShards.GenesisShardPickupIndex)
			{
				Log.Warning("[LunarRitual] Genesis Shard interaction begin detected, destroying object");
				if (NetworkServer.active && (Object)(object)((Component)self).gameObject != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)self).gameObject);
					Log.Warning("[LunarRitual] Genesis Shard object destroyed");
				}
				else
				{
					Log.Error($"[LunarRitual] Cannot destroy Genesis Shard - NetworkServer.active: {NetworkServer.active}, gameObject exists: {(Object)(object)((Component)self).gameObject != (Object)null}");
				}
			}
		}

		private static void OnPickupTriggerStay(orig_OnTriggerStay orig, GenericPickupController self, Collider other)
		{
			//IL_000a: 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)
			if (!((Object)(object)self != (Object)null) || !(self.pickupIndex == GenesisShards.GenesisShardPickupIndex))
			{
				orig.Invoke(self, other);
			}
		}

		private static void SaveShardsOnRunEnd(orig_OnDestroy orig, Run self)
		{
			GenesisShards.SaveShards();
			playerShardChance.Clear();
			orig.Invoke(self);
		}
	}
	public class GenesisShardEffect : MonoBehaviour
	{
		private float duration = 2f;

		private float radius = 2f;

		private ParticleSystem particleSystem;

		private Light light;

		public void Initialize(float enemyRadius)
		{
			radius = enemyRadius * 2f;
			CreateParticleSystem();
			CreateLight();
		}

		private void CreateParticleSystem()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00c8: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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)
			//IL_0127: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ShardParticles");
			val.transform.SetParent(((Component)this).transform, false);
			particleSystem = val.AddComponent<ParticleSystem>();
			MainModule main = particleSystem.main;
			((MainModule)(ref main)).duration = duration;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(duration);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(3f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.5f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.8f, 0.2f, 1f, 1f));
			((MainModule)(ref main)).maxParticles = 50;
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.5f);
			EmissionModule emission = particleSystem.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
			{
				new Burst(0f, (short)20)
			});
			ShapeModule shape = particleSystem.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = radius * 0.5f;
			ColorOverLifetimeModule colorOverLifetime = particleSystem.colorOverLifetime;
			Gradient val2 = new Gradient();
			val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(new Color(0.8f, 0.2f, 1f), 0f),
				new GradientColorKey(new Color(0.5f, 0.1f, 0.8f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2);
		}

		private void CreateLight()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ShardLight");
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.position = Vector3.zero;
			light = val.AddComponent<Light>();
			light.type = (LightType)2;
			light.color = new Color(0.8f, 0.2f, 1f);
			light.range = radius * 3f;
			light.intensity = 2f;
		}

		private void Update()
		{
			if ((Object)(object)light != (Object)null)
			{
				light.intensity = Mathf.Lerp(2f, 0f, Time.deltaTime / duration);
			}
		}
	}
	public class GenesisShardMarker : MonoBehaviour
	{
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("LunarRitual.LunarRitual", "LunarRitual", "0.1.1")]
	public class LunarRitual : BaseUnityPlugin
	{
		public const string PluginGUID = "LunarRitual.LunarRitual";

		public const string PluginAuthor = "LunarRitual";

		public const string PluginName = "LunarRitual";

		public const string PluginVersion = "0.1.1";

		public static PluginInfo pluginInfo;

		public static ConfigEntry<float> shardChance { get; set; }

		public static ConfigEntry<float> shardMultiplier { get; set; }

		public static ConfigEntry<int> startingShards { get; set; }

		public static ConfigEntry<bool> teamShards { get; set; }

		public static ConfigEntry<bool> noShardDroplet { get; set; }

		public static ConfigEntry<bool> resetShards { get; set; }

		public static float ShardChanceProbability => Mathf.Clamp(shardChance.Value, 0f, 100f) / 100f;

		public void Awake()
		{
			pluginInfo = ((BaseUnityPlugin)this).Info;
			shardChance = ((BaseUnityPlugin)this).Config.Bind<float>("Genesis Shards", "Initial Shard Chance", 1f, "Chance for first genesis shard to be dropped (0-100%).");
			shardMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Debug", "Shard Chance Multiplier", 0.5f, "Value that chance is multiplied by after a shard is dropped (0-1).");
			startingShards = ((BaseUnityPlugin)this).Config.Bind<int>("Debug", "Starting Shards", 0, "Shards that each player has at the start of a run, if 'Reset Shards Each Run' is enabled.");
			teamShards = ((BaseUnityPlugin)this).Config.Bind<bool>("Genesis Shards", "Distribute Shards", false, "All allies receive a genesis shard when one is dropped.");
			noShardDroplet = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "No Shard Droplets", false, "Enemies emit a genesis shard effect instead of the regular droplet that is manually picked up.");
			resetShards = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Reset Shards Each Run", false, "Genesis shards are reset at the start of a run to the value determined by 'Starting Shards'.");
			if (shardChance.Value > 100f)
			{
				shardChance.Value = 100f;
			}
			Log.Init(((BaseUnityPlugin)this).Logger);
			GenesisShards.InitializeGenesisShardPickup();
			GenesisShards.LoadShards();
			Hooks.Init();
			GenesisShardsUI.Initialize();
			RitualMenu.Initialize();
			if (RiskOfOptionsCompatibility.enabled)
			{
				RiskOfOptionsCompatibility.OptionsInit();
			}
			Log.Info("[LunarRitual] loaded successfully!");
		}

		public void OnDestroy()
		{
			GenesisShards.SaveShards();
		}
	}
	public static class RitualMenu
	{
		private class StageStartBootstrap : MonoBehaviour
		{
			private float remaining;

			public void BeginTryShow()
			{
				remaining = 8f;
				((Behaviour)this).enabled = true;
			}

			private void Awake()
			{
				((Behaviour)this).enabled = false;
			}

			private void Update()
			{
				if (shownThisRun)
				{
					((Behaviour)this).enabled = false;
					return;
				}
				remaining -= Time.unscaledDeltaTime;
				if (remaining <= 0f)
				{
					((Behaviour)this).enabled = false;
				}
				else
				{
					CreateAndShowIfNeeded();
				}
			}
		}

		private class DelayedInvoker : MonoBehaviour
		{
			private float t;

			private Action action;

			public void Init(float delay, Action action)
			{
				t = delay;
				this.action = action;
			}

			private void Update()
			{
				t -= Time.unscaledDeltaTime;
				if (t > 0f)
				{
					return;
				}
				try
				{
					action?.Invoke();
				}
				finally
				{
					Object.Destroy((Object)(object)this);
				}
			}
		}

		private enum OfferingTier : byte
		{
			Small,
			Medium,
			Grand
		}

		private struct RitualOfEssenceRequest : INetMessage, ISerializableObject
		{
			public NetworkInstanceId networkUserNetId;

			public OfferingTier tier;

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(networkUserNetId);
				writer.Write((byte)tier);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0002: 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)
				networkUserNetId = reader.ReadNetworkId();
				tier = (OfferingTier)reader.ReadByte();
			}

			public void OnReceived()
			{
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0210: 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_0215: Invalid comparison between Unknown and I4
				//IL_021e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0228: Unknown result type (might be due to invalid IL or missing references)
				Log.Info($"[LunarRitual] RitualOfEssenceRequest.OnReceived. NetworkServer.active={NetworkServer.active}, netId={((NetworkInstanceId)(ref networkUserNetId)).Value}, tier={tier}");
				if (!NetworkServer.active)
				{
					Log.Warning("[LunarRitual] OnReceived ignored: not server");
					return;
				}
				GameObject val = NetworkServer.FindLocalObject(networkUserNetId);
				if (!Object.op_Implicit((Object)(object)val))
				{
					Log.Warning("[LunarRitual] OnReceived: FindLocalObject returned null (bad netId?)");
					return;
				}
				NetworkUser component = val.GetComponent<NetworkUser>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					Log.Warning("[LunarRitual] OnReceived: NetworkUser component missing on object");
					return;
				}
				ulong value = component.id.value;
				if (serverConsumedThisRun.Contains(value))
				{
					Log.Info($"[LunarRitual] OnReceived: ritual already consumed this run. steamId={value}");
					return;
				}
				int num = tier switch
				{
					OfferingTier.Small => SmallCost, 
					OfferingTier.Medium => MediumCost, 
					OfferingTier.Grand => GrandCost, 
					_ => 0, 
				};
				if (num <= 0)
				{
					Log.Warning("[LunarRitual] OnReceived: cost <= 0 (invalid tier)");
					return;
				}
				int shards = GenesisShards.GetShards(value);
				if (shards < num)
				{
					Log.Info($"[LunarRitual] OnReceived: not enough shards. steamId={value} shards={shards} cost={num}");
					return;
				}
				CharacterMaster master = component.master;
				if (!Object.op_Implicit((Object)(object)master) || (Object)(object)master.inventory == (Object)null)
				{
					Log.Warning("[LunarRitual] OnReceived: user.master or inventory is null");
					return;
				}
				int num2 = tier switch
				{
					OfferingTier.Small => 1, 
					OfferingTier.Medium => 1, 
					OfferingTier.Grand => 1, 
					_ => 0, 
				};
				int num3 = tier switch
				{
					OfferingTier.Small => 5, 
					OfferingTier.Medium => 5, 
					OfferingTier.Grand => 2, 
					_ => 0, 
				};
				if (num2 <= 0 || num3 < num2)
				{
					return;
				}
				int num4 = (((Object)(object)Run.instance != (Object)null) ? Run.instance.treasureRng.RangeInt(num2, num3 + 1) : Random.Range(num2, num3 + 1));
				List<ItemIndex> list = new List<ItemIndex>();
				for (int i = 0; i < num4; i++)
				{
					ItemIndex val2 = RitualOfEssenceServerRollItem(tier);
					if ((int)val2 != -1)
					{
						master.inventory.GiveItem(val2, 1);
						list.Add(val2);
					}
				}
				if (list.Count == 0)
				{
					Log.Warning("[LunarRitual] OnReceived: failed to roll any items");
					return;
				}
				Log.Info(string.Format("[LunarRitual] OnReceived: granting {0} items ({1}) cost={2} steamId={3}", list.Count, string.Join(", ", list), num, value));
				GenesisShards.RemoveShards(value, num);
				serverConsumedThisRun.Add(value);
				GenesisShards.SaveShards();
				GenesisShardsUI.RefreshUI();
			}
		}

		private struct RitualOfEgoRequest : INetMessage, ISerializableObject
		{
			public NetworkInstanceId networkUserNetId;

			public OfferingTier tier;

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(networkUserNetId);
				writer.Write((byte)tier);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0002: 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)
				networkUserNetId = reader.ReadNetworkId();
				tier = (OfferingTier)reader.ReadByte();
			}

			public void OnReceived()
			{
				//IL_003d: 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)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Invalid comparison between Unknown and I4
				//IL_01f1: 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)
				Log.Info($"[LunarRitual] RitualOfEgoRequest.OnReceived. NetworkServer.active={NetworkServer.active}, netId={((NetworkInstanceId)(ref networkUserNetId)).Value}, tier={tier}");
				if (!NetworkServer.active)
				{
					return;
				}
				GameObject val = NetworkServer.FindLocalObject(networkUserNetId);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				NetworkUser component = val.GetComponent<NetworkUser>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				ulong value = component.id.value;
				if (serverConsumedThisRun.Contains(value))
				{
					Log.Info($"[LunarRitual] Ego: ritual already consumed this run. steamId={value}");
					return;
				}
				int num = tier switch
				{
					OfferingTier.Small => SmallCost, 
					OfferingTier.Medium => MediumCost, 
					OfferingTier.Grand => GrandCost, 
					_ => 0, 
				};
				if (num <= 0)
				{
					return;
				}
				int shards = GenesisShards.GetShards(value);
				if (shards < num)
				{
					Log.Info($"[LunarRitual] Ego: not enough shards. steamId={value} shards={shards} cost={num}");
					return;
				}
				CharacterMaster master = component.master;
				if (!Object.op_Implicit((Object)(object)master) || (Object)(object)master.inventory == (Object)null)
				{
					return;
				}
				ItemIndex val2 = ItemCatalog.FindItemIndex("LunarSun");
				if ((int)val2 != -1)
				{
					int num2 = tier switch
					{
						OfferingTier.Small => 1, 
						OfferingTier.Medium => 4, 
						OfferingTier.Grand => 7, 
						_ => 0, 
					};
					int num3 = tier switch
					{
						OfferingTier.Small => 3, 
						OfferingTier.Medium => 6, 
						OfferingTier.Grand => 10, 
						_ => 0, 
					};
					if (num2 > 0 && num3 >= num2)
					{
						int num4 = (((Object)(object)Run.instance != (Object)null) ? Run.instance.treasureRng.RangeInt(num2, num3 + 1) : Random.Range(num2, num3 + 1));
						Log.Info($"[LunarRitual] Ego: granting {num4}x {val2} cost={num} steamId={value}");
						GenesisShards.RemoveShards(value, num);
						master.inventory.GiveItem(val2, num4);
						serverConsumedThisRun.Add(value);
						GenesisShards.SaveShards();
						GenesisShardsUI.RefreshUI();
					}
				}
			}
		}

		private struct RitualOfLightnessRequest : INetMessage, ISerializableObject
		{
			public NetworkInstanceId networkUserNetId;

			public OfferingTier tier;

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(networkUserNetId);
				writer.Write((byte)tier);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0002: 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)
				networkUserNetId = reader.ReadNetworkId();
				tier = (OfferingTier)reader.ReadByte();
			}

			public void OnReceived()
			{
				//IL_003d: 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)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Invalid comparison between Unknown and I4
				//IL_01f1: 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)
				Log.Info($"[LunarRitual] RitualOfLightnessRequest.OnReceived. NetworkServer.active={NetworkServer.active}, netId={((NetworkInstanceId)(ref networkUserNetId)).Value}, tier={tier}");
				if (!NetworkServer.active)
				{
					return;
				}
				GameObject val = NetworkServer.FindLocalObject(networkUserNetId);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				NetworkUser component = val.GetComponent<NetworkUser>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				ulong value = component.id.value;
				if (serverConsumedThisRun.Contains(value))
				{
					Log.Info($"[LunarRitual] Lightness: ritual already consumed this run. steamId={value}");
					return;
				}
				int num = tier switch
				{
					OfferingTier.Small => SmallCost, 
					OfferingTier.Medium => MediumCost, 
					OfferingTier.Grand => GrandCost, 
					_ => 0, 
				};
				if (num <= 0)
				{
					return;
				}
				int shards = GenesisShards.GetShards(value);
				if (shards < num)
				{
					Log.Info($"[LunarRitual] Lightness: not enough shards. steamId={value} shards={shards} cost={num}");
					return;
				}
				CharacterMaster master = component.master;
				if (!Object.op_Implicit((Object)(object)master) || (Object)(object)master.inventory == (Object)null)
				{
					return;
				}
				ItemIndex val2 = ItemCatalog.FindItemIndex("Feather");
				if ((int)val2 != -1)
				{
					int num2 = tier switch
					{
						OfferingTier.Small => 2, 
						OfferingTier.Medium => 4, 
						OfferingTier.Grand => 6, 
						_ => 0, 
					};
					int num3 = tier switch
					{
						OfferingTier.Small => 3, 
						OfferingTier.Medium => 5, 
						OfferingTier.Grand => 10, 
						_ => 0, 
					};
					if (num2 > 0 && num3 >= num2)
					{
						int num4 = (((Object)(object)Run.instance != (Object)null) ? Run.instance.treasureRng.RangeInt(num2, num3 + 1) : Random.Range(num2, num3 + 1));
						Log.Info($"[LunarRitual] Lightness: granting {num4}x {val2} cost={num} steamId={value}");
						GenesisShards.RemoveShards(value, num);
						master.inventory.GiveItem(val2, num4);
						serverConsumedThisRun.Add(value);
						GenesisShards.SaveShards();
						GenesisShardsUI.RefreshUI();
					}
				}
			}
		}

		private struct RitualOfBlessingRequest : INetMessage, ISerializableObject
		{
			public NetworkInstanceId networkUserNetId;

			public OfferingTier tier;

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(networkUserNetId);
				writer.Write((byte)tier);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0002: 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)
				networkUserNetId = reader.ReadNetworkId();
				tier = (OfferingTier)reader.ReadByte();
			}

			public void OnReceived()
			{
				//IL_003d: 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)
				Log.Info($"[LunarRitual] RitualOfBlessingRequest.OnReceived. NetworkServer.active={NetworkServer.active}, netId={((NetworkInstanceId)(ref networkUserNetId)).Value}, tier={tier}");
				if (!NetworkServer.active)
				{
					return;
				}
				GameObject val = NetworkServer.FindLocalObject(networkUserNetId);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				NetworkUser component = val.GetComponent<NetworkUser>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				ulong value = component.id.value;
				if (serverConsumedThisRun.Contains(value))
				{
					Log.Info($"[LunarRitual] Blessing: ritual already consumed this run. steamId={value}");
					return;
				}
				int num = tier switch
				{
					OfferingTier.Small => SmallCost, 
					OfferingTier.Medium => MediumCost, 
					OfferingTier.Grand => GrandCost, 
					_ => 0, 
				};
				if (num <= 0)
				{
					return;
				}
				int shards = GenesisShards.GetShards(value);
				if (shards < num)
				{
					Log.Info($"[LunarRitual] Blessing: not enough shards. steamId={value} shards={shards} cost={num}");
					return;
				}
				CharacterMaster master = component.master;
				if (Object.op_Implicit((Object)(object)master) && !((Object)(object)master.inventory == (Object)null))
				{
					CharacterBody body = master.GetBody();
					if (Object.op_Implicit((Object)(object)body))
					{
						float num2 = tier switch
						{
							OfferingTier.Small => 5f, 
							OfferingTier.Medium => 15f, 
							OfferingTier.Grand => 25f, 
							_ => 0f, 
						};
						float num3 = tier switch
						{
							OfferingTier.Small => 1f, 
							OfferingTier.Medium => 2f, 
							OfferingTier.Grand => 3f, 
							_ => 0f, 
						};
						float num4 = tier switch
						{
							OfferingTier.Small => 5f, 
							OfferingTier.Medium => 15f, 
							OfferingTier.Grand => 25f, 
							_ => 0f, 
						};
						float num5 = tier switch
						{
							OfferingTier.Small => 50f, 
							OfferingTier.Medium => 100f, 
							OfferingTier.Grand => 500f, 
							_ => 0f, 
						};
						float num6 = tier switch
						{
							OfferingTier.Small => 50f, 
							OfferingTier.Medium => 100f, 
							OfferingTier.Grand => 500f, 
							_ => 0f, 
						};
						body.baseDamage += num2;
						body.baseMoveSpeed += num3;
						body.baseRegen += num4;
						body.baseMaxHealth += num5;
						body.baseArmor += num6;
						body.RecalculateStats();
						Log.Info($"[LunarRitual] Blessing: applied bonuses - DMG+{num2} SPD+{num3} Regen+{num4} HP+{num5} Def+{num6} cost={num} steamId={value}");
						GenesisShards.RemoveShards(value, num);
						serverConsumedThisRun.Add(value);
						GenesisShards.SaveShards();
						GenesisShardsUI.RefreshUI();
					}
				}
			}
		}

		private struct RitualOfHeresyRequest : INetMessage, ISerializableObject
		{
			public NetworkInstanceId networkUserNetId;

			public OfferingTier tier;

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(networkUserNetId);
				writer.Write((byte)tier);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0002: 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)
				networkUserNetId = reader.ReadNetworkId();
				tier = (OfferingTier)reader.ReadByte();
			}

			public void OnReceived()
			{
				//IL_003d: 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)
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fa: Invalid comparison between Unknown and I4
				//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ff: Invalid comparison between Unknown and I4
				//IL_0201: Unknown result type (might be due to invalid IL or missing references)
				//IL_0204: Invalid comparison between Unknown and I4
				//IL_0206: Unknown result type (might be due to invalid IL or missing references)
				//IL_0209: Invalid comparison between Unknown and I4
				//IL_021d: Unknown result type (might be due to invalid IL or missing references)
				//IL_022d: Unknown result type (might be due to invalid IL or missing references)
				//IL_023d: Unknown result type (might be due to invalid IL or missing references)
				//IL_024d: Unknown result type (might be due to invalid IL or missing references)
				Log.Info($"[LunarRitual] RitualOfHeresyRequest.OnReceived. NetworkServer.active={NetworkServer.active}, netId={((NetworkInstanceId)(ref networkUserNetId)).Value}, tier={tier}");
				if (!NetworkServer.active)
				{
					return;
				}
				GameObject val = NetworkServer.FindLocalObject(networkUserNetId);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				NetworkUser component = val.GetComponent<NetworkUser>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				ulong value = component.id.value;
				if (serverConsumedThisRun.Contains(value))
				{
					Log.Info($"[LunarRitual] Heresy: ritual already consumed this run. steamId={value}");
					return;
				}
				int num = tier switch
				{
					OfferingTier.Small => SmallCost, 
					OfferingTier.Medium => MediumCost, 
					OfferingTier.Grand => GrandCost, 
					_ => 0, 
				};
				if (num <= 0)
				{
					return;
				}
				int shards = GenesisShards.GetShards(value);
				if (shards < num)
				{
					Log.Info($"[LunarRitual] Heresy: not enough shards. steamId={value} shards={shards} cost={num}");
					return;
				}
				CharacterMaster master = component.master;
				if (!Object.op_Implicit((Object)(object)master) || (Object)(object)master.inventory == (Object)null)
				{
					return;
				}
				int num2 = tier switch
				{
					OfferingTier.Small => 1, 
					OfferingTier.Medium => 2, 
					OfferingTier.Grand => 4, 
					_ => 0, 
				};
				int num3 = tier switch
				{
					OfferingTier.Small => 1, 
					OfferingTier.Medium => 3, 
					OfferingTier.Grand => 5, 
					_ => 0, 
				};
				if (num2 > 0 && num3 >= num2)
				{
					int num4 = (((Object)(object)Run.instance != (Object)null) ? Run.instance.treasureRng.RangeInt(num2, num3 + 1) : Random.Range(num2, num3 + 1));
					ItemIndex val2 = ItemCatalog.FindItemIndex("LunarPrimaryReplacement");
					ItemIndex val3 = ItemCatalog.FindItemIndex("LunarSecondaryReplacement");
					ItemIndex val4 = ItemCatalog.FindItemIndex("LunarUtilityReplacement");
					ItemIndex val5 = ItemCatalog.FindItemIndex("LunarSpecialReplacement");
					if ((int)val2 == -1 || (int)val3 == -1 || (int)val4 == -1 || (int)val5 == -1)
					{
						Log.Warning("[LunarRitual] Heresy: one or more Heresy items not found in ItemCatalog");
						return;
					}
					master.inventory.GiveItem(val2, num4);
					master.inventory.GiveItem(val3, num4);
					master.inventory.GiveItem(val4, num4);
					master.inventory.GiveItem(val5, num4);
					Log.Info($"[LunarRitual] Heresy: granted {num4}x of all 4 Heresy items cost={num} steamId={value}");
					GenesisShards.RemoveShards(value, num);
					serverConsumedThisRun.Add(value);
					GenesisShards.SaveShards();
					GenesisShardsUI.RefreshUI();
				}
			}
		}

		private struct RitualOfSubjugationRequest : INetMessage, ISerializableObject
		{
			public NetworkInstanceId networkUserNetId;

			public OfferingTier tier;

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(networkUserNetId);
				writer.Write((byte)tier);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0002: 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)
				networkUserNetId = reader.ReadNetworkId();
				tier = (OfferingTier)reader.ReadByte();
			}

			public void OnReceived()
			{
				//IL_003d: 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)
				//IL_0162: Unknown result type (might be due to invalid IL or missing references)
				//IL_0167: Unknown result type (might be due to invalid IL or missing references)
				//IL_016e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_0175: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Invalid comparison between Unknown and I4
				//IL_017a: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Invalid comparison between Unknown and I4
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
				Log.Info($"[LunarRitual] RitualOfSubjugationRequest.OnReceived. NetworkServer.active={NetworkServer.active}, netId={((NetworkInstanceId)(ref networkUserNetId)).Value}, tier={tier}");
				if (!NetworkServer.active)
				{
					return;
				}
				GameObject val = NetworkServer.FindLocalObject(networkUserNetId);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				NetworkUser component = val.GetComponent<NetworkUser>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				ulong value = component.id.value;
				if (serverConsumedThisRun.Contains(value))
				{
					Log.Info($"[LunarRitual] Subjugation: ritual already consumed this run. steamId={value}");
					return;
				}
				int num = tier switch
				{
					OfferingTier.Small => SmallCost, 
					OfferingTier.Medium => MediumCost, 
					OfferingTier.Grand => GrandCost, 
					_ => 0, 
				};
				if (num <= 0)
				{
					return;
				}
				int shards = GenesisShards.GetShards(value);
				if (shards < num)
				{
					Log.Info($"[LunarRitual] Subjugation: not enough shards. steamId={value} shards={shards} cost={num}");
					return;
				}
				CharacterMaster master = component.master;
				if (!Object.op_Implicit((Object)(object)master) || (Object)(object)master.inventory == (Object)null)
				{
					return;
				}
				int num2 = tier switch
				{
					OfferingTier.Small => 1, 
					OfferingTier.Medium => 3, 
					OfferingTier.Grand => 4, 
					_ => 0, 
				};
				if (num2 > 0)
				{
					ItemIndex val2 = ItemCatalog.FindItemIndex("GhostOnKill");
					ItemIndex val3 = ItemCatalog.FindItemIndex("VoidMegaCrabItem");
					if ((int)val2 == -1 || (int)val3 == -1)
					{
						Log.Warning("[LunarRitual] Subjugation: one or more summoner items not found in ItemCatalog");
						return;
					}
					master.inventory.GiveItem(val2, num2);
					master.inventory.GiveItem(val3, num2);
					Log.Info($"[LunarRitual] Subjugation: granted {num2}x Happiest Mask and {num2}x Newly Hatched Zoea cost={num} steamId={value}");
					GenesisShards.RemoveShards(value, num);
					serverConsumedThisRun.Add(value);
					GenesisShards.SaveShards();
					GenesisShardsUI.RefreshUI();
				}
			}
		}

		private struct RitualOfGreedRequest : INetMessage, ISerializableObject
		{
			public NetworkInstanceId networkUserNetId;

			public OfferingTier tier;

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(networkUserNetId);
				writer.Write((byte)tier);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0002: 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)
				networkUserNetId = reader.ReadNetworkId();
				tier = (OfferingTier)reader.ReadByte();
			}

			public void OnReceived()
			{
				//IL_003d: 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)
				Log.Info($"[LunarRitual] RitualOfGreedRequest.OnReceived. NetworkServer.active={NetworkServer.active}, netId={((NetworkInstanceId)(ref networkUserNetId)).Value}, tier={tier}");
				if (!NetworkServer.active)
				{
					return;
				}
				GameObject val = NetworkServer.FindLocalObject(networkUserNetId);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				NetworkUser component = val.GetComponent<NetworkUser>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				ulong value = component.id.value;
				if (serverConsumedThisRun.Contains(value))
				{
					Log.Info($"[LunarRitual] Greed: ritual already consumed this run. steamId={value}");
					return;
				}
				int num = tier switch
				{
					OfferingTier.Small => SmallCost, 
					OfferingTier.Medium => MediumCost, 
					OfferingTier.Grand => GrandCost, 
					_ => 0, 
				};
				if (num <= 0)
				{
					return;
				}
				int shards = GenesisShards.GetShards(value);
				if (shards < num)
				{
					Log.Info($"[LunarRitual] Greed: not enough shards. steamId={value} shards={shards} cost={num}");
					return;
				}
				CharacterMaster master = component.master;
				if (Object.op_Implicit((Object)(object)master) && !((Object)(object)master.inventory == (Object)null))
				{
					int num2 = tier switch
					{
						OfferingTier.Small => 100, 
						OfferingTier.Medium => 500, 
						OfferingTier.Grand => 1000, 
						_ => 0, 
					};
					int num3 = tier switch
					{
						OfferingTier.Small => 200, 
						OfferingTier.Medium => 1000, 
						OfferingTier.Grand => 5000, 
						_ => 0, 
					};
					if (num2 > 0 && num3 >= num2)
					{
						int num4 = (((Object)(object)Run.instance != (Object)null) ? Run.instance.treasureRng.RangeInt(num2, num3 + 1) : Random.Range(num2, num3 + 1));
						master.GiveMoney((uint)num4);
						Log.Info($"[LunarRitual] Greed: granted {num4} gold cost={num} steamId={value}");
						GenesisShards.RemoveShards(value, num);
						serverConsumedThisRun.Add(value);
						GenesisShards.SaveShards();
						GenesisShardsUI.RefreshUI();
					}
				}
			}
		}

		private struct RitualOfHuntRequest : INetMessage, ISerializableObject
		{
			public NetworkInstanceId networkUserNetId;

			public OfferingTier tier;

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(networkUserNetId);
				writer.Write((byte)tier);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0002: 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)
				networkUserNetId = reader.ReadNetworkId();
				tier = (OfferingTier)reader.ReadByte();
			}

			public void OnReceived()
			{
				//IL_003d: 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)
				//IL_0162: Unknown result type (might be due to invalid IL or missing references)
				//IL_0167: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_016c: Invalid comparison between Unknown and I4
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				Log.Info($"[LunarRitual] RitualOfHuntRequest.OnReceived. NetworkServer.active={NetworkServer.active}, netId={((NetworkInstanceId)(ref networkUserNetId)).Value}, tier={tier}");
				if (!NetworkServer.active)
				{
					return;
				}
				GameObject val = NetworkServer.FindLocalObject(networkUserNetId);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				NetworkUser component = val.GetComponent<NetworkUser>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				ulong value = component.id.value;
				if (serverConsumedThisRun.Contains(value))
				{
					Log.Info($"[LunarRitual] Hunt: ritual already consumed this run. steamId={value}");
					return;
				}
				int num = tier switch
				{
					OfferingTier.Small => SmallCost, 
					OfferingTier.Medium => MediumCost, 
					OfferingTier.Grand => GrandCost, 
					_ => 0, 
				};
				if (num <= 0)
				{
					return;
				}
				int shards = GenesisShards.GetShards(value);
				if (shards < num)
				{
					Log.Info($"[LunarRitual] Hunt: not enough shards. steamId={value} shards={shards} cost={num}");
					return;
				}
				CharacterMaster master = component.master;
				if (!Object.op_Implicit((Object)(object)master) || (Object)(object)master.inventory == (Object)null)
				{
					return;
				}
				int num2 = tier switch
				{
					OfferingTier.Small => 1, 
					OfferingTier.Medium => 3, 
					OfferingTier.Grand => 5, 
					_ => 0, 
				};
				if (num2 > 0)
				{
					ItemIndex val2 = ItemCatalog.FindItemIndex("HeadHunter");
					if ((int)val2 == -1)
					{
						Log.Warning("[LunarRitual] Hunt: Wake of Vultures item not found in ItemCatalog");
						return;
					}
					master.inventory.GiveItem(val2, num2);
					Log.Info($"[LunarRitual] Hunt: granted {num2}x Wake of Vultures cost={num} steamId={value}");
					GenesisShards.RemoveShards(value, num);
					serverConsumedThisRun.Add(value);
					GenesisShards.SaveShards();
					GenesisShardsUI.RefreshUI();
				}
			}
		}

		private enum RitualType : byte
		{
			Essence,
			Ego,
			Lightness,
			Blessing,
			Heresy,
			Subjugation,
			Greed,
			Hunt
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static Action<Run> <0>__OnRunStart;

			public static Action<Run> <1>__OnRunDestroy;

			public static Action<Stage> <2>__OnStageStartGlobal;

			public static UnityAction <3>__Close;

			public static Action <4>__RefreshShardsText;
		}

		private static bool initialized;

		private static bool shownThisRun;

		private static readonly HashSet<ulong> serverConsumedThisRun = new HashSet<ulong>();

		private static GameObject uiRoot;

		private static GameObject bootstrapObj;

		private static StageStartBootstrap bootstrap;

		private static HGTextMeshProUGUI shardsText;

		private static HGTextMeshProUGUI ritualTitleText;

		private static HGTextMeshProUGUI ritualDescText;

		private static Button smallBtn;

		private static Button mediumBtn;

		private static Button grandBtn;

		private static Canvas canvas;

		private static readonly int SmallCost = 1;

		private static readonly int MediumCost = 5;

		private static readonly int GrandCost = 10;

		private static ExplicitPickupDropTable tier1DropTable;

		private static ExplicitPickupDropTable tier2DropTable;

		private static ExplicitPickupDropTable tier3DropTable;

		private static RitualType selectedRitual = RitualType.Essence;

		public static void Initialize()
		{
			if (!initialized)
			{
				initialized = true;
				NetworkingAPI.RegisterMessageType<RitualOfEssenceRequest>();
				NetworkingAPI.RegisterMessageType<RitualOfEgoRequest>();
				NetworkingAPI.RegisterMessageType<RitualOfLightnessRequest>();
				NetworkingAPI.RegisterMessageType<RitualOfBlessingRequest>();
				NetworkingAPI.RegisterMessageType<RitualOfHeresyRequest>();
				NetworkingAPI.RegisterMessageType<RitualOfSubjugationRequest>();
				NetworkingAPI.RegisterMessageType<RitualOfGreedRequest>();
				NetworkingAPI.RegisterMessageType<RitualOfHuntRequest>();
				Log.Info("[LunarRitual] RitualMenu initialized + message registered");
				EnsureBootstrap();
				Run.onRunStartGlobal += OnRunStart;
				Run.onRunDestroyGlobal += OnRunDestroy;
				Stage.onStageStartGlobal += OnStageStartGlobal;
			}
		}

		private static void OnRunStart(Run run)
		{
			shownThisRun = false;
			if (NetworkServer.active)
			{
				serverConsumedThisRun.Clear();
			}
		}

		private static void OnRunDestroy(Run run)
		{
			shownThisRun = false;
			if (NetworkServer.active)
			{
				serverConsumedThisRun.Clear();
			}
			DestroyUI();
		}

		private static void OnStageStartGlobal(Stage stage)
		{
			if (!shownThisRun && !((Object)(object)Run.instance == (Object)null) && Run.instance.stageClearCount == 0)
			{
				EnsureBootstrap();
				bootstrap.BeginTryShow();
			}
		}

		private static void EnsureBootstrap()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if ((Object)(object)bootstrap != (Object)null)
			{
				return;
			}
			if ((Object)(object)bootstrapObj != (Object)null)
			{
				bootstrap = bootstrapObj.GetComponent<StageStartBootstrap>();
				if ((Object)(object)bootstrap != (Object)null)
				{
					return;
				}
			}
			bootstrapObj = new GameObject("LunarRitual_RitualMenuBootstrap");
			Object.DontDestroyOnLoad((Object)(object)bootstrapObj);
			bootstrap = bootstrapObj.AddComponent<StageStartBootstrap>();
		}

		private static void CreateAndShowIfNeeded()
		{
			if (!shownThisRun && NetworkUser.readOnlyLocalPlayersList != null && NetworkUser.readOnlyLocalPlayersList.Count > 0)
			{
				NetworkUser val = NetworkUser.readOnlyLocalPlayersList[0];
				if (!((Object)(object)val == (Object)null) && Object.op_Implicit((Object)(object)val.master) && !((Object)(object)val.master.GetBody() == (Object)null))
				{
					shownThisRun = true;
					CreateUI();
					RefreshShardsText();
				}
			}
		}

		private static void CreateUI()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_007c: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: 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_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: 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_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: 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_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Unknown result type (might be due to invalid IL or missing references)
			//IL_068e: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: