Decompiled source of REPO Luck Gambling v4.5.5

EmptyChildMod.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using Steamworks;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("EmptyChildMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EmptyChildMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eb22faed-b405-4d38-9eb8-cae6b316dbed")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RepoLuckMod;

public static class LuckWeights
{
	public const float ENV_NARROW_HEAVY_ITEM = -5f;

	public const float ENV_OVERCHARGE_SOLO = -2f;

	public const float ENV_BENEFICIAL_MAP = 15f;

	public const float MON_DUCK_GRAB = -5f;

	public const float MON_BALLOON_POP = -2.5f;

	public const float MON_CC_LOOP = -25f;

	public const float MON_RUN_ENDER = -25f;

	public const float MON_EARLY_TIER3 = -10f;

	public const float MON_HATED_COMBO = -5f;

	public const float MON_SAFETY_KILL = 10f;

	public const float MON_SPAWN_NEAR_TRUCK = -10f;

	public const float PHY_PIT_DEATH = -15f;

	public const float PHY_LOST_VALUE_FACTOR = -0.5f;

	public const float PHY_DESTROYED_ITEM_FACTOR = -1f;

	public const float PHY_DESTROYED_MINIMUM = -0.5f;

	public const float PHY_DESTROYED_ENEMY_ITEM = -5f;

	public const float PHY_HEALED_THEN_DIED = -10f;

	public const float PHY_BROKE_CART = -15f;

	public const float PHY_CLEAN_RUN_BONUS = 10f;

	public const float MON_ANIMAL_CRATE = -5f;

	public const float MON_CHOMP_BOOK = -2f;

	public const float MON_FROG_TRAP = -2f;

	public const float MON_TRAP_RADIO = -2f;

	public const float MON_TRAP_TV = -2f;

	public const float MON_TRAP_GRAMOPHONE = -2f;

	public const float SOCIAL_HIDDEN_RESCUE = 25f;

	public const float ECO_BAD_LOOT = -5f;

	public const float ECO_TRAP_LOOT = -3f;

	public const float ECO_GOOD_LOOT = 4f;

	public const float ECO_EXTRACTION_SUCCESS = 10f;

	public const float ECO_FOUND_WEAPON = 10f;

	public const float ECO_FOUND_UPGRADE = 5f;

	public const float PHY_DESTROYED_WEAPON = -10f;

	public const float PHY_DESTROYED_DRONE = -5f;

	public const float MOD_TIER3_EARLY = -5f;

	public const float MOD_TIER2_EARLY = -2.5f;

	public const float MOD_TIER3_MID = -3f;

	public const float MOD_TIER2_MID = -1.5f;

	public const float MOD_TIER3_LATE = -1f;

	public const float MOD_TIER3_EXPECTED = 0.5f;
}
public class TrackedValuable
{
	public ValuableObject Valuable;

	public float LastKnownValue;

	public bool WasDestroyed;
}
[BepInPlugin("com.repo.luckmonitor", "R.E.P.O. Luck Monitor", "1.1.0")]
public class LuckMonitorPlugin : BaseUnityPlugin
{
	private enum EffectType
	{
		Money,
		PlayerStats,
		EnemyStats,
		SpawnEnemy,
		SpawnItem,
		ModuleRarity,
		LevelList
	}

	[HarmonyPatch(typeof(PhysGrabObject), "FixedUpdate")]
	public static class Patch_GoldenTouchOnTouch
	{
		private static FieldInfo _heldByLocalField = typeof(PhysGrabObject).GetField("heldByLocalPlayer", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo _dollarCurrentField = typeof(ValuableObject).GetField("dollarValueCurrent", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo _dollarOriginalField = typeof(ValuableObject).GetField("dollarValueOriginal", BindingFlags.Instance | BindingFlags.NonPublic);

		public static Material _cachedGoldMat;

		private static HashSet<int> _processedItems = new HashSet<int>();

		public static void Postfix(PhysGrabObject __instance)
		{
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			if (!GoldenTouchActive)
			{
				return;
			}
			int instanceID = ((Object)__instance).GetInstanceID();
			if (_processedItems.Contains(instanceID) || ((Object)((Component)__instance).gameObject).name.Contains("(GOLD)"))
			{
				return;
			}
			bool flag = false;
			if (_heldByLocalField != null)
			{
				flag = (bool)_heldByLocalField.GetValue(__instance);
			}
			if (!flag)
			{
				return;
			}
			ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			if ((Object)(object)_cachedGoldMat != (Object)null)
			{
				Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val in componentsInChildren)
				{
					if (!(val is ParticleSystemRenderer))
					{
						Material[] array = (Material[])(object)new Material[val.sharedMaterials.Length];
						for (int j = 0; j < array.Length; j++)
						{
							array[j] = _cachedGoldMat;
						}
						val.materials = array;
					}
				}
			}
			else
			{
				_cachedGoldMat = ((IEnumerable<Material>)Resources.FindObjectsOfTypeAll<Material>()).FirstOrDefault((Func<Material, bool>)((Material m) => ((Object)m).name.Contains("GoldTooth")));
			}
			if (_dollarCurrentField != null && _dollarOriginalField != null)
			{
				float num = (float)_dollarCurrentField.GetValue(component);
				float num2 = num * 2f;
				_dollarCurrentField.SetValue(component, num2);
				_dollarOriginalField.SetValue(component, num2);
			}
			if ((Object)(object)CameraGlitch.Instance != (Object)null)
			{
				CameraGlitch.Instance.PlayUpgrade();
			}
			GameDirector.instance.CameraImpact.ShakeDistance(2f, 0.5f, 3f, ((Component)__instance).transform.position, 0.1f);
			Transform[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren2)
			{
				if (((Object)val2).name.ToLower().Contains("particle"))
				{
					GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, ((Component)__instance).transform.position, Quaternion.identity);
					val3.SetActive(true);
					ParticleSystem component2 = val3.GetComponent<ParticleSystem>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.Play();
					}
					if ((Object)(object)val3.GetComponent<ItemUpgradeParticleEffects>() == (Object)null)
					{
						val3.AddComponent<ItemUpgradeParticleEffects>();
					}
				}
			}
			GameObject gameObject = ((Component)__instance).gameObject;
			((Object)gameObject).name = ((Object)gameObject).name + " (GOLD)";
			_processedItems.Add(instanceID);
			Debug.Log((object)("<color=gold>[Luck] Midas Transmuted: " + ((Object)((Component)__instance).gameObject).name + "!</color>"));
		}
	}

	[HarmonyPatch(typeof(PhysGrabObject), "Start")]
	public static class Patch_LightHandContinuous
	{
		public static void Postfix(PhysGrabObject __instance)
		{
			if (LightHandActive)
			{
				Rigidbody component = ((Component)__instance).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.mass *= 0.1f;
					component.drag = 0f;
				}
			}
		}
	}

	[HarmonyPatch(typeof(LuckMonitorPlugin))]
	public static class LuckPointEventPatches
	{
		[HarmonyPatch(typeof(PhysGrabObject), "Start")]
		public static class Patch_HeavyHandsContinuous
		{
			public static void Postfix(PhysGrabObject __instance)
			{
				if (IsHeavyHandsActive)
				{
					Rigidbody component = ((Component)__instance).GetComponent<Rigidbody>();
					if ((Object)(object)component != (Object)null)
					{
						component.mass *= 2f;
					}
				}
			}
		}

		[HarmonyPatch(typeof(PhysGrabObject), "Start")]
		public static class Patch_SizeMattersContinuous
		{
			public static void Postfix(PhysGrabObject __instance)
			{
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				if (!MidRangeEventActive)
				{
					return;
				}
				Collider[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Collider>();
				foreach (Collider val in componentsInChildren)
				{
					val.material = SlipperyMat;
				}
				if (IsValidForScaling(__instance))
				{
					float num = Random.Range(0.33f, 3f);
					Transform transform = ((Component)__instance).transform;
					transform.localScale *= num;
					Rigidbody component = ((Component)__instance).GetComponent<Rigidbody>();
					if ((Object)(object)component != (Object)null)
					{
						component.mass *= num;
					}
				}
			}

			private static bool IsValidForScaling(PhysGrabObject item)
			{
				if ((Object)(object)((Component)item).GetComponent<ValuableObject>() != (Object)null)
				{
					return true;
				}
				if ((Object)(object)((Component)item).GetComponent<ItemAttributes>() != (Object)null)
				{
					return true;
				}
				Transform[] componentsInChildren = ((Component)item).GetComponentsInChildren<Transform>(true);
				foreach (Transform val in componentsInChildren)
				{
					if (((Object)val).name.ToLower().Contains("hinge"))
					{
						return true;
					}
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(LevelGenerator), "Start")]
		public static class Patch_LevelReset
		{
			public static void Prefix()
			{
				LightHandActive = false;
				MidRangeEventActive = false;
				Debug.Log((object)"<color=white>[Luck System] Mid-Range Event Reset to OFF for new level.</color>");
			}
		}

		[HarmonyPatch(typeof(PlayerController), "Update")]
		public static class Patch_OrbNukeUpdate
		{
			public static void Postfix()
			{
				if (!NukeEnemyOrbsActive)
				{
					return;
				}
				MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>();
				MonoBehaviour[] array2 = array;
				foreach (MonoBehaviour val in array2)
				{
					if ((Object)(object)val == (Object)null || !(((object)val).GetType().Name == "Valuable"))
					{
						continue;
					}
					string name = ((Object)((Component)val).gameObject).name;
					Debug.Log((object)("[Luck Scanner] Found Valuable: " + name));
					if (name.ToLower().Contains("enemy") || name.ToLower().Contains("orb") || name.ToLower().Contains("point"))
					{
						Debug.Log((object)("<color=red>[Luck] DESTROYING: " + name + "</color>"));
						PhotonView component = ((Component)val).GetComponent<PhotonView>();
						if ((Object)(object)component != (Object)null && (component.IsMine || PhotonNetwork.IsMasterClient))
						{
							PhotonNetwork.Destroy(((Component)val).gameObject);
						}
						else
						{
							Object.Destroy((Object)(object)((Component)val).gameObject);
						}
					}
				}
			}
		}

		public static float LuckPercentage => ((Object)(object)Instance != (Object)null) ? Instance._levelLuck : 50f;

		[HarmonyPatch("UseLuckPoint")]
		[HarmonyPrefix]
		public static void UseLuckPoint_Prefix()
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(LuckMonitorPlugin), "_storedPointValues");
			if (fieldInfo == null || !(fieldInfo.GetValue(null) is List<float> list) || list.Count == 0)
			{
				return;
			}
			float num = list[0];
			float value = Random.value;
			bool flag = value < 0.8f;
			if (num <= 5f)
			{
				if (flag)
				{
					Log.LogInfo((object)$"[Luck Event] Point value {num}% <= 5%. (Roll: {value:F2}) Spawning Random Enemy!");
					SpawnRandomEnemy();
				}
				else
				{
					Log.LogInfo((object)$"[Luck Event] Point value {num}% <= 5%. (Roll: {value:F2}) Missed the 80% chance.");
				}
			}
			else if (num >= 95f)
			{
				if (flag)
				{
					Log.LogInfo((object)$"[Luck Event] Point value {num}% >= 95%. (Roll: {value:F2}) Spawning Surplus Valuable!");
					SpawnSurplusValuable();
				}
				else
				{
					Log.LogInfo((object)$"[Luck Event] Point value {num}% >= 95%. (Roll: {value:F2}) Missed the 80% chance.");
				}
			}
		}

		public static void TriggerGlobalSlip()
		{
			Collider[] array = Object.FindObjectsOfType<Collider>();
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				val.material = SlipperyMat;
			}
			if ((Object)(object)PlayerController.instance != (Object)null)
			{
				Collider[] componentsInChildren = ((Component)PlayerController.instance).GetComponentsInChildren<Collider>();
				foreach (Collider val2 in componentsInChildren)
				{
					val2.material = PlayerSuperSlip;
				}
			}
			EnemyRigidbody[] array3 = Object.FindObjectsOfType<EnemyRigidbody>();
			EnemyRigidbody[] array4 = array3;
			foreach (EnemyRigidbody val3 in array4)
			{
				val3.ColliderMaterialDefault = SlipperyMat;
				val3.ColliderMaterialStunned = SlipperyMat;
				val3.ColliderMaterialDisabled = SlipperyMat;
				val3.ColliderMaterialGrabbed = SlipperyMat;
				val3.ColliderMaterialJumping = SlipperyMat;
			}
			Debug.Log((object)"<color=cyan>[Luck Event] FRICTION REMOVED: World is now ice!</color>");
		}

		public static void TriggerSizeMatters()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			PhysGrabObject[] array = Object.FindObjectsOfType<PhysGrabObject>();
			int num = 0;
			PhysGrabObject[] array2 = array;
			foreach (PhysGrabObject val in array2)
			{
				if (IsValidForScaling(val))
				{
					float num2 = Random.Range(0.33f, 3f);
					Transform transform = ((Component)val).transform;
					transform.localScale *= num2;
					Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
					if ((Object)(object)component != (Object)null)
					{
						component.mass *= num2;
					}
					num++;
				}
			}
			Debug.Log((object)$"<color=magenta>[Luck Event] SIZE MATTERS: {num} objects warped!</color>");
		}

		private static bool IsValidForScaling(PhysGrabObject item)
		{
			if ((Object)(object)((Component)item).GetComponent<ValuableObject>() != (Object)null)
			{
				return true;
			}
			if ((Object)(object)((Component)item).GetComponent<ItemAttributes>() != (Object)null)
			{
				return true;
			}
			Transform[] componentsInChildren = ((Component)item).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name.ToLower().Contains("hinge"))
				{
					return true;
				}
			}
			return false;
		}

		public static void TriggerHeavyHands()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			IsHeavyHandsActive = true;
			PhysGrabObject[] array = Object.FindObjectsOfType<PhysGrabObject>();
			int num = 0;
			PhysGrabObject[] array2 = array;
			foreach (PhysGrabObject val in array2)
			{
				Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					if (!originalItemMasses.ContainsKey(val))
					{
						originalItemMasses.Add(val, component.mass);
					}
					component.mass *= 2.5f;
					num++;
				}
			}
			if ((Object)(object)PlayerController.instance != (Object)null)
			{
				SemiFunc.CameraShakeImpactDistance(((Component)PlayerController.instance).transform.position, 10f, 0.5f, 5f, 20f);
				Log.LogInfo((object)$"[Luck Event] HEAVY HANDS: {num} items are now 2.5x heavier!");
			}
		}

		private static void SpawnRandomEnemy()
		{
			//IL_005e: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			EnemySetup[] array = Resources.FindObjectsOfTypeAll<EnemySetup>();
			if (array != null && array.Length != 0)
			{
				EnemySetup val = array[Random.Range(0, array.Length)];
				if (!((Object)(object)val == (Object)null) && val.spawnObjects != null && val.spawnObjects.Count != 0)
				{
					Vector3 spawnPos = GetPlayerPosition() + Vector3.up * 1.5f;
					SpawnEnemySetupAt(val, spawnPos);
				}
			}
		}

		private static void SpawnSurplusValuable()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			string[] array = new string[9] { "Valuable Arctic Cryo Pod", "Valuable Arctic Server Rack", "Valuable Manor Golden Statue", "Valuable Manor Grandfather Clock", "Valuable Wizard Broom", "Valuable Wizard Troll Finger", "Valuable Manor Harp", "Valuable Manor Harp", "Valuable Wizard Dumgolfs Staff" };
			Vector3 val = GetPlayerPosition() + Vector3.up * 1.5f + ((Component)Camera.main).transform.forward * 2.5f;
			for (int i = 0; i < 30; i++)
			{
				string text = array[Random.Range(0, array.Length)];
				GameObject val2 = Resources.Load<GameObject>("Valuables/" + text);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				ValuableObject component = val2.GetComponent<ValuableObject>();
				if ((Object)(object)component != (Object)null && (Object)(object)component.valuePreset != (Object)null)
				{
					component.valuePreset.valueMin = 30000f;
					component.valuePreset.valueMax = 30000f;
				}
				GameObject val3 = Object.Instantiate<GameObject>(val2, val + Random.insideUnitSphere * 1.5f, Random.rotation);
				if (!((Object)(object)val3 != (Object)null))
				{
					continue;
				}
				PhotonView component2 = val3.GetComponent<PhotonView>();
				if ((Object)(object)component2 != (Object)null && PhotonNetwork.InRoom)
				{
					if (component2.ViewID == 0)
					{
						PhotonNetwork.AllocateViewID(component2);
					}
					component2.RPC("DollarValueSetRPC", (RpcTarget)1, new object[1] { 30000f });
				}
			}
			Log.LogInfo((object)"[Luck Event] 30 random high-value items spawned.");
		}

		private static bool SpawnEnemySetupAt(EnemySetup setup, Vector3 spawnPos)
		{
			//IL_0033: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			bool result = false;
			foreach (PrefabRef spawnObject in setup.spawnObjects)
			{
				if (spawnObject == null)
				{
					continue;
				}
				GameObject val = InstantiatePrefabRef(spawnObject.Prefab, spawnPos, Quaternion.identity);
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (PhotonNetwork.InRoom && !HasValidPhotonView(val))
				{
					Object.Destroy((Object)(object)val);
					continue;
				}
				result = true;
				EnemyParent component = val.GetComponent<EnemyParent>();
				if ((Object)(object)component != (Object)null)
				{
					Traverse val2 = Traverse.Create((object)component);
					val2.Field("SetupDone").SetValue((object)true);
					val2.Field("firstSpawnPointUsed").SetValue((object)true);
				}
				Enemy componentInChildren = val.GetComponentInChildren<Enemy>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.EnemyTeleported(spawnPos);
				}
			}
			return result;
		}

		private static GameObject InstantiatePrefabRef(GameObject prefab, Vector3 pos, Quaternion rot)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			if ((Object)(object)prefab == (Object)null)
			{
				return null;
			}
			try
			{
				if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient)
				{
					return PhotonNetwork.Instantiate(((Object)prefab).name, pos, rot, (byte)0, (object[])null);
				}
				return Object.Instantiate<GameObject>(prefab, pos, rot);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("[Luck Event] Spawn failed: " + ex.Message));
				return null;
			}
		}

		private static bool HasValidPhotonView(GameObject go)
		{
			return go.GetComponentsInChildren<PhotonView>(true)?.Any((PhotonView v) => (Object)(object)v != (Object)null && v.ViewID != 0) ?? false;
		}

		private static Vector3 GetPlayerPosition()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0040: 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)
			if ((Object)(object)PlayerController.instance != (Object)null)
			{
				return ((Component)PlayerController.instance).transform.position;
			}
			if ((Object)(object)Camera.main != (Object)null)
			{
				return ((Component)Camera.main).transform.position;
			}
			return Vector3.zero;
		}
	}

	[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
	public static class Patch_AbsoluteSpeedForce
	{
		[HarmonyPostfix]
		public static void Postfix(PlayerController __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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)
			if (IsEffectActive)
			{
				Traverse val = Traverse.Create((object)__instance);
				Vector3 value = val.Field("VelocityRelativeNew").GetValue<Vector3>();
				val.Field("VelocityRelativeNew").SetValue((object)(value * CurrentMultiplier));
			}
		}
	}

	[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
	public static class Patch_TemporaryLevelSpeed
	{
		[HarmonyPostfix]
		public static void Postfix(PlayerController __instance)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (ActiveMultiplier != 1f)
			{
				Traverse val = Traverse.Create((object)__instance);
				val.Field("MoveMultiplier").SetValue((object)ActiveMultiplier);
				val.Field("MoveMultiplierTimer").SetValue((object)1f);
				Vector3 value = val.Field("VelocityRelative").GetValue<Vector3>();
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(value.x * ActiveMultiplier, value.y, value.z * ActiveMultiplier);
				val.Field("VelocityRelative").SetValue((object)val2);
			}
		}
	}

	[HarmonyPatch(typeof(LevelGenerator), "GenerateDone")]
	public static class Patch_LuckVisualReset
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			ResetVisuals();
			Debug.Log((object)"[Luck Mod] Level visuals reset and initialized.");
		}
	}

	[HarmonyPatch(typeof(Enemy), "Update")]
	public static class Patch_EnemyForceActivation
	{
		public static void Postfix(Enemy __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			float levelLuck = Instance._levelLuck;
			if (levelLuck > 15f && levelLuck < 20f && (int)__instance.CurrentState == 1)
			{
				__instance.CurrentState = (EnemyState)2;
			}
		}
	}

	[HarmonyPatch(typeof(PlayerController), "Update")]
	public static class Patch_OrbNukeUpdate
	{
		public static void Postfix()
		{
			if (!NukeEnemyOrbsActive)
			{
				return;
			}
			MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>();
			MonoBehaviour[] array2 = array;
			foreach (MonoBehaviour val in array2)
			{
				if ((Object)(object)val == (Object)null || !(((object)val).GetType().Name == "Valuable"))
				{
					continue;
				}
				string name = ((Object)((Component)val).gameObject).name;
				Debug.Log((object)("[Luck Scanner] Found Valuable: " + name));
				if (name.ToLower().Contains("enemy") || name.ToLower().Contains("orb") || name.ToLower().Contains("point"))
				{
					Debug.Log((object)("<color=red>[Luck] DESTROYING: " + name + "</color>"));
					PhotonView component = ((Component)val).GetComponent<PhotonView>();
					if ((Object)(object)component != (Object)null && (component.IsMine || PhotonNetwork.IsMasterClient))
					{
						PhotonNetwork.Destroy(((Component)val).gameObject);
					}
					else
					{
						Object.Destroy((Object)(object)((Component)val).gameObject);
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
	public static class Patch_ResetLuckEvents
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			NukeEnemyOrbsActive = false;
			Debug.Log((object)"[Luck] Level transition: Resetting temporary luck events.");
		}
	}

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

		private object <>2__current;

		private ValuableObject[] <>s__1;

		private int <>s__2;

		private ValuableObject <val>5__3;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>s__1 = null;
			<val>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				_initialTotalMapValue = 0f;
				<>s__1 = Object.FindObjectsOfType<ValuableObject>();
				for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++)
				{
					<val>5__3 = <>s__1[<>s__2];
					if ((Object)(object)<val>5__3 != (Object)null)
					{
						_initialTotalMapValue += (float)_dollarValueField.GetValue(<val>5__3);
					}
					<val>5__3 = null;
				}
				<>s__1 = null;
				Log.LogInfo((object)$"[Luck] Map Value Calculated: ${_initialTotalMapValue}");
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				return false;
			}
		}

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

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

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

		private object <>2__current;

		private int <currentWallet>5__1;

		private bool <hasWeapon>5__2;

		private bool <hasBat>5__3;

		private ItemAttributes[] <items>5__4;

		private ItemAttributes[] <>s__5;

		private int <>s__6;

		private ItemAttributes <attr>5__7;

		private string <n>5__8;

		private int <cost>5__9;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<items>5__4 = null;
			<>s__5 = null;
			<attr>5__7 = null;
			<n>5__8 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<currentWallet>5__1 = SemiFunc.StatGetRunCurrency();
				<hasWeapon>5__2 = false;
				<hasBat>5__3 = false;
				<items>5__4 = Object.FindObjectsOfType<ItemAttributes>();
				<>s__5 = <items>5__4;
				for (<>s__6 = 0; <>s__6 < <>s__5.Length; <>s__6++)
				{
					<attr>5__7 = <>s__5[<>s__6];
					if (!((Object)(object)<attr>5__7 == (Object)null) && !((Object)(object)<attr>5__7.item == (Object)null))
					{
						<n>5__8 = ((Object)<attr>5__7.item).name.ToLower();
						<cost>5__9 = Traverse.Create((object)<attr>5__7).Field<int>("value").Value;
						if (<currentWallet>5__1 >= <cost>5__9)
						{
							if (<n>5__8.Contains("gun") || <n>5__8.Contains("tranq") || <n>5__8.Contains("shotgun") || <n>5__8.Contains("photon") || <n>5__8.Contains("blaster"))
							{
								<hasWeapon>5__2 = true;
							}
							if (<n>5__8.Contains("baseball") || <n>5__8.Contains("hammer"))
							{
								<hasBat>5__3 = true;
							}
						}
						<n>5__8 = null;
						<attr>5__7 = null;
					}
				}
				<>s__5 = null;
				if (<hasWeapon>5__2)
				{
					_foundWeaponThisLevel = true;
					_weaponlessLevels = 0;
					ModifyLuck(20f, "Good Weapon Stock");
				}
				else if (<hasBat>5__3)
				{
					_foundWeaponThisLevel = true;
					_weaponlessLevels = 0;
					ModifyLuck(8f, "Decent Weapon Stock");
				}
				else
				{
					ModifyLuck(-10f, "Bad Weapon Stock");
				}
				return false;
			}
		}

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

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

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

		private object <>2__current;

		private float <totalPenalty>5__1;

		private string <reason>5__2;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitUntil((Func<bool>)(() => (Object)(object)RoundDirector.instance != (Object)null && (int)_roundDirectorHaulGoalField.GetValue(RoundDirector.instance) > 0));
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(2f);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<>2__current = RecalculateTotalMapValue();
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				if (_badModuleSpawns > 0)
				{
					<totalPenalty>5__1 = 0f;
					<reason>5__2 = "";
					if (_currentLevelIndex <= 3)
					{
						<totalPenalty>5__1 = (float)_badModuleSpawns * -5f;
						<reason>5__2 = $"Bad Gen: {_badModuleSpawns} Hard Modules";
					}
					else if (_currentLevelIndex == 4)
					{
						<totalPenalty>5__1 = (float)_badModuleSpawns * -3f;
						<reason>5__2 = $"Rough Gen: {_badModuleSpawns} Hard Modules";
					}
					else
					{
						<totalPenalty>5__1 = (float)_badModuleSpawns * 0.5f;
						<reason>5__2 = $"Good Gen: {_badModuleSpawns} Hard Modules";
					}
					ModifyLuck(<totalPenalty>5__1, <reason>5__2);
					<reason>5__2 = null;
				}
				return false;
			}
		}

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

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

	public static LuckMonitorPlugin Instance;

	private static ManualLogSource Log;

	private static float _duckLuckCooldown = 0f;

	public static bool GoldenTouchActive = false;

	private float _logTimer = 0f;

	private float _updateTimer = 0f;

	private Texture2D _lensTexture;

	public static float CurrentMultiplier = 1f;

	public static bool IsEffectActive = false;

	private static Material _cachedGoldMat;

	private float _overallLuck = 50f;

	private float _levelLuck = 50f;

	private string _statusMessage = "Run Started";

	private static float _totalLuckSum = 0f;

	private static int _completedLevelsCount = 0;

	private static Dictionary<Light, float> originalLightIntensities = new Dictionary<Light, float>();

	private static int _luckPoints = 0;

	private static List<float> _storedPointValues = new List<float>();

	private static List<float> _luckChangesThisCycle = new List<float>();

	private static float originalFarClip;

	private static bool originalFogState;

	private static bool hasStoredOriginals = false;

	private static int _levelStartTotalHaul = 0;

	private static float _initialTotalMapValue = 0f;

	private static PhysicMaterial _slipperyMat;

	public static bool IsHeavyHandsActive = false;

	private static Dictionary<PhysGrabObject, float> originalItemMasses = new Dictionary<PhysGrabObject, float>();

	public static bool LightHandActive = false;

	private static bool IsInGameLevel = false;

	private static Level _lastLevel;

	private float _lastTextureUpdate;

	private static PhysicMaterial _playerSuperSlip;

	public static bool NukeEnemyOrbsActive = false;

	private static int _currentLevelIndex = 0;

	private static HashSet<string> _activeEnemies = new HashSet<string>();

	private static List<string> _levelEnemies = new List<string>();

	private static int _weaponlessLevels = 0;

	private static bool _foundWeaponThisLevel = false;

	private static bool _isHeadmanManor = false;

	private static int _badModuleSpawns = 0;

	private static HashSet<string> _deadPlayersProcessed = new HashSet<string>();

	private static List<TrackedValuable> _trackedValuables = new List<TrackedValuable>();

	private static float _totalLevelValue = 0f;

	private static bool _itemDestroyedThisLevel = false;

	private static bool _truckHealAnalyzed = false;

	private static bool _playerWasHealedByTruck = false;

	private static bool _hiddenRescueTriggered = false;

	public static float ActiveMultiplier = 1f;

	public static bool MidRangeEventActive = false;

	private static FieldInfo _grabbedPhysObjectField;

	private static FieldInfo _dollarValueField;

	private static FieldInfo _roundDirectorHaulGoalField;

	private static FieldInfo _roundDirectorCurrentHaulField;

	private static FieldInfo _roundDirectorTotalHaulField;

	private static FieldInfo _truckHealerStateField;

	private static FieldInfo _playerMaxHealthField;

	private static FieldInfo _playerHealthField;

	private static FieldInfo _playerIsLocalField;

	private static FieldInfo _enemyParentEnemyField;

	private static FieldInfo _enemyHealthField;

	private static FieldInfo _enemyHealthCurrentField;

	public static bool IsMidRangeChaosActive = false;

	private static Dictionary<int, float> _enemyDamageMultipliers = new Dictionary<int, float>();

	public static int LuckPoint => _luckPoints;

	public static float LuckPercentage => ((Object)(object)Instance != (Object)null) ? Instance._levelLuck : 50f;

	public static PhysicMaterial PlayerSuperSlip
	{
		get
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			if ((Object)(object)_playerSuperSlip == (Object)null)
			{
				_playerSuperSlip = new PhysicMaterial("PlayerSuperSlip")
				{
					staticFriction = 0f,
					dynamicFriction = 0f,
					frictionCombine = (PhysicMaterialCombine)2,
					bounceCombine = (PhysicMaterialCombine)2
				};
			}
			return _playerSuperSlip;
		}
	}

	public static PhysicMaterial SlipperyMat
	{
		get
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			if ((Object)(object)_slipperyMat == (Object)null)
			{
				_slipperyMat = new PhysicMaterial("GlobalIce")
				{
					staticFriction = 0.0015f,
					dynamicFriction = 0.0015f,
					frictionCombine = (PhysicMaterialCombine)2,
					bounciness = 0f,
					bounceCombine = (PhysicMaterialCombine)2
				};
			}
			return _slipperyMat;
		}
	}

	private void Awake()
	{
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		_grabbedPhysObjectField = AccessTools.Field(typeof(PhysGrabber), "grabbedPhysGrabObject");
		_dollarValueField = AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent");
		_roundDirectorHaulGoalField = AccessTools.Field(typeof(RoundDirector), "haulGoal");
		_roundDirectorCurrentHaulField = AccessTools.Field(typeof(RoundDirector), "currentHaul");
		_roundDirectorTotalHaulField = AccessTools.Field(typeof(RoundDirector), "totalHaul");
		_truckHealerStateField = AccessTools.Field(typeof(TruckHealer), "currentState");
		_playerMaxHealthField = AccessTools.Field(typeof(PlayerHealth), "maxHealth");
		_playerHealthField = AccessTools.Field(typeof(PlayerHealth), "health");
		_playerIsLocalField = AccessTools.Field(typeof(PlayerAvatar), "isLocal");
		Type type = AccessTools.TypeByName("Enemy");
		Type type2 = AccessTools.TypeByName("EnemyHealth");
		if (type != null)
		{
			_enemyHealthField = AccessTools.Field(type, "Health");
		}
		if (type2 != null)
		{
			_enemyHealthCurrentField = AccessTools.Field(type2, "healthCurrent");
		}
		_enemyParentEnemyField = AccessTools.Field(typeof(EnemyParent), "Enemy");
		Harmony val = new Harmony("com.yourname.luckmonitor");
		val.PatchAll(Assembly.GetExecutingAssembly());
		Harmony.CreateAndPatchAll(typeof(LuckMonitorPlugin), (string)null);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"R.E.P.O. Luck Monitor Loaded.");
	}

	private static int GetEnemyHealthCurrent(EnemyParent parent)
	{
		try
		{
			if (_enemyParentEnemyField == null || _enemyHealthField == null || _enemyHealthCurrentField == null)
			{
				return 999;
			}
			object value = _enemyParentEnemyField.GetValue(parent);
			if (value == null)
			{
				return 999;
			}
			object value2 = _enemyHealthField.GetValue(value);
			if (value2 == null)
			{
				return 999;
			}
			return (int)_enemyHealthCurrentField.GetValue(value2);
		}
		catch
		{
			return 999;
		}
	}

	private void Update()
	{
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown((KeyCode)117) && _luckPoints > 0 && IsInGameLevel)
		{
			UseLuckPoint();
		}
		if (!IsInGameLevel && !SemiFunc.RunIsShop())
		{
			IsHeavyHandsActive = false;
			_levelLuck = Mathf.Lerp(_levelLuck, 50f, Time.deltaTime * 2f);
			originalItemMasses.Clear();
			return;
		}
		if (IsInGameLevel && Time.time - _lastTextureUpdate > 0.4f)
		{
			UpdatePhosphorTexture(500, 220, GetLuckColor(_levelLuck));
			_lastTextureUpdate = Time.time;
		}
		_logTimer += Time.deltaTime;
		if (_logTimer > 5f)
		{
			_logTimer = 0f;
			Log.LogInfo((object)$"[Luck Monitor] Level: {_currentLevelIndex}, Overall: {_overallLuck}%, Current: {_levelLuck}%, Points: {_luckPoints}");
		}
		_updateTimer += Time.deltaTime;
		if (_updateTimer > 0.25f)
		{
			_updateTimer = 0f;
			CheckAllLootDamage();
		}
	}

	private void UpdatePhosphorTexture(int width, int height, Color luckColor)
	{
		//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_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: 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_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: 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)
		if ((Object)(object)_lensTexture == (Object)null)
		{
			_lensTexture = new Texture2D(width, height, (TextureFormat)4, false);
			((Texture)_lensTexture).filterMode = (FilterMode)1;
		}
		Color val = default(Color);
		for (int i = 0; i < height; i++)
		{
			float num = ((float)i - (float)height / 2f) / ((float)height / 2f);
			float num2 = Mathf.Sin((float)i * 1.6f) * 0.5f + 0.5f;
			float num3 = Mathf.Exp((0f - (num + 0.2f)) * (num + 0.2f) * 6f);
			for (int j = 0; j < width; j++)
			{
				float num4 = ((float)j - (float)width / 2f) / ((float)width / 2f);
				float num5 = Mathf.Clamp01(1f - num4 * num4 * 1.1f);
				float num6 = num2 * num3 * num5;
				((Color)(ref val))..ctor(luckColor.r * 0.1f, luckColor.g * 0.1f, luckColor.b * 0.1f, num3 * num5 * 0.5f);
				val += luckColor * num6 * 0.45f;
				val.a = Mathf.Max(val.a, num6 * 0.7f);
				_lensTexture.SetPixel(j, i, val);
			}
		}
		_lensTexture.Apply();
	}

	private void OnGUI()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: 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_00b2: Expected O, but got Unknown
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: 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_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		if ((IsInGameLevel || SemiFunc.RunIsShop()) && !((Object)(object)_lensTexture == (Object)null))
		{
			int num = 500;
			int num2 = 220;
			float num3 = 40f;
			GUIStyle style = new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)5,
				fontSize = 90,
				fontStyle = (FontStyle)1,
				wordWrap = false,
				richText = true
			};
			GUIStyle style2 = new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)3,
				fontSize = 60,
				fontStyle = (FontStyle)1,
				wordWrap = false
			};
			Color luckColor = GetLuckColor(_levelLuck);
			Color mainColor = default(Color);
			((Color)(ref mainColor))..ctor(0.22f, 1f, 0.38f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor((float)(Screen.width - num) - num3, (float)(Screen.height - num2) - num3, (float)num, (float)num2);
			GUI.DrawTexture(val, (Texture)(object)_lensTexture);
			string text = $"<size=20>OVERALL {Mathf.RoundToInt(_overallLuck)}%</size>";
			string text2 = $"{Mathf.RoundToInt(_levelLuck)}%";
			string text3 = text + "\n" + text2;
			DrawShadowedText(new Rect(((Rect)(ref val)).x - 45f, ((Rect)(ref val)).y, (float)num, (float)num2), text3, style, luckColor);
			if (_luckPoints > 0 && IsInGameLevel)
			{
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(num3, (float)(Screen.height - num2) - num3, (float)num, (float)num2);
				GUI.DrawTexture(val2, (Texture)(object)_lensTexture);
				string text4 = $"LUCK POINTS [U] {_luckPoints}";
				DrawShadowedText(new Rect(((Rect)(ref val2)).x + 45f, ((Rect)(ref val2)).y, (float)num, (float)num2), text4, style2, mainColor);
			}
		}
	}

	private void DrawShadowedText(Rect rect, string text, GUIStyle style, Color mainColor)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: 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_00a8: 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)
		style.normal.textColor = new Color(0f, 0f, 0f, 0.8f);
		GUI.Label(new Rect(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style);
		style.normal.textColor = mainColor * 0.4f;
		GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 1f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style);
		style.normal.textColor = mainColor;
		GUI.Label(rect, text, style);
	}

	private Color GetLuckColor(float luck)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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_006b: 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)
		if (luck <= 25f)
		{
			return new Color(1f, 0.12f, 0.12f);
		}
		if (luck <= 49f)
		{
			return new Color(1f, 0.52f, 0f);
		}
		if (luck <= 75f)
		{
			return new Color(1f, 0.9f, 0.08f);
		}
		return new Color(0.22f, 1f, 0.38f);
	}

	private static void ModifyLuck(float amount, string reason)
	{
		Instance._levelLuck = Mathf.Clamp(Instance._levelLuck + amount, 0f, 100f);
		Instance._statusMessage = reason;
		_luckChangesThisCycle.Add(amount);
		Log.LogInfo((object)$"[Luck] Modified: {amount} ({reason}). Level Luck: {Instance._levelLuck}%");
	}

	private void UseLuckPoint()
	{
		if (_luckPoints <= 0 || _storedPointValues.Count == 0)
		{
			return;
		}
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			Log.LogInfo((object)"[Luck Points] Client ignored point usage (Host Authority).");
			return;
		}
		_luckPoints--;
		float num = _storedPointValues[0];
		_storedPointValues.RemoveAt(0);
		Log.LogInfo((object)$"[Luck Points] Point Used. Points Remaining: {_luckPoints}. Hidden Value: {num}%");
		if (num <= 5f)
		{
			Log.LogInfo((object)$"[Luck Event] Point value {num}% <= 5%. Spawning Random Enemy!");
			SpawnRandomEnemy();
		}
		if (num <= 0f)
		{
			Log.LogInfo((object)$"[Luck Event] Point value {num}% <= 5%. Spawning Random Enemy!");
			SpawnEnemy();
		}
		else if (num == 12f)
		{
			Log.LogInfo((object)$"[Luck Event] EXACT CRITICAL LUCK: {num}%. Unleashing Darkness and Enemies!");
			TriggerLethalDarkness(1f);
		}
		else if (num == 11f)
		{
			Log.LogInfo((object)$"[Luck Event] EXACT CRITICAL LUCK: {num}%. Unleashing Darkness and Enemies!");
			TriggerLethalDarkness(1f);
		}
		else if (num >= 35f && num <= 50f)
		{
			Log.LogInfo((object)$"[Luck Event] Mid-Range Warp: {num}%. Size Matters!");
			LuckPointEventPatches.TriggerSizeMatters();
		}
		else if (num >= 45f && num <= 55f)
		{
			Log.LogInfo((object)$"[Luck Event] slippy: {num}%. ice!");
			LuckPointEventPatches.TriggerGlobalSlip();
		}
		else if (num >= 100f)
		{
			Log.LogInfo((object)$"[Luck Event] Point value {num}% >= 100%. Spawning Surplus Valuable!");
			SpawnSurplusValuable();
		}
		else if (num >= 93f)
		{
			Log.LogInfo((object)$"[Luck Event] Point value {num}% >= 95%. Spawning Surplus Valuable!");
			PrepareGoldenTouch();
		}
		else if (num >= 75f && num <= 79f)
		{
			Log.LogInfo((object)$"[Luck Event] High Luck {num}%: Applying Clear Sight!");
			TriggerClearSight();
		}
		if (num >= 87f && num <= 92f)
		{
			SpawnValuable();
			Log.LogInfo((object)"[Luck Event] Enemy Orb Drops are now DISABLED for this level.");
		}
		else if (num >= 16f && num <= 21f)
		{
			Log.LogInfo((object)$"[Luck Event] UNLUCKY ROLL: {num}%. Heavy Hands activated!");
			LuckPointEventPatches.TriggerHeavyHands();
		}
		else if (num >= 80f && num <= 85f)
		{
			Log.LogInfo((object)$"[Luck Event] UNLUCKY ROLL: {num}%. Heavy Hands activated!");
			LightHandActive = true;
			TriggerLightHand();
		}
		if (num >= 10f && num <= 15f)
		{
			Log.LogInfo((object)$"[Luck Event] 100% Trigger: Unleashing Cursed Darkness for {num}% luck.");
			TriggerLethalDarkness(1f);
		}
		if (num > 60f)
		{
			TriggerVignette(isGood: true);
		}
		else if (num < 40f)
		{
			TriggerVignette(isGood: false);
		}
		int num2 = ((!(num > 85f) && !(num < 15f)) ? 1 : 2);
		List<EffectType> list = new List<EffectType>
		{
			EffectType.Money,
			EffectType.PlayerStats,
			EffectType.EnemyStats,
			EffectType.SpawnEnemy,
			EffectType.SpawnItem,
			EffectType.ModuleRarity,
			EffectType.LevelList
		};
		for (int i = 0; i < list.Count; i++)
		{
			EffectType value = list[i];
			int index = Random.Range(i, list.Count);
			list[i] = list[index];
			list[index] = value;
		}
		for (int j = 0; j < num2 && j < list.Count; j++)
		{
			EffectType type = list[j];
			ExecuteEffect(type, num);
		}
	}

	private void SpawnEnemy()
	{
		//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_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		EnemySetup[] array = Resources.FindObjectsOfTypeAll<EnemySetup>();
		if (array == null || array.Length == 0)
		{
			return;
		}
		Vector3 val = GetPlayerPosition() + Vector3.up * 1.5f;
		for (int i = 0; i < 20; i++)
		{
			EnemySetup val2 = array[Random.Range(0, array.Length)];
			if (!((Object)(object)val2 == (Object)null) && val2.spawnObjects != null && val2.spawnObjects.Count != 0)
			{
				Vector3 val3 = Random.insideUnitSphere * 2f;
				val3.y = 0f;
				Vector3 spawnPos = val + val3;
				SpawnEnemySetupAt(val2, spawnPos);
			}
		}
		Log.LogInfo((object)"[Luck Event] Triggered 20 random enemy spawns.");
	}

	private void SpawnRandomEnemy()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		EnemySetup[] array = Resources.FindObjectsOfTypeAll<EnemySetup>();
		if (array != null && array.Length != 0)
		{
			EnemySetup val = array[Random.Range(0, array.Length)];
			if (!((Object)(object)val == (Object)null) && val.spawnObjects != null && val.spawnObjects.Count != 0)
			{
				Vector3 spawnPos = GetPlayerPosition() + Vector3.up * 1.5f;
				SpawnEnemySetupAt(val, spawnPos);
			}
		}
	}

	private void SpawnValuable()
	{
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string text = Path.Combine(directoryName, "hi");
		if (!File.Exists(text))
		{
			Log.LogError((object)("[Luck Event] AssetBundle 'hi' missing at: " + text));
			return;
		}
		AssetBundle val = AssetBundle.LoadFromFile(text);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		GameObject val2 = val.LoadAsset<GameObject>("bag");
		if ((Object)(object)val2 == (Object)null)
		{
			Log.LogError((object)"[Luck Event] Could not find 'bag' inside AssetBundle 'hi'.");
			val.Unload(true);
			return;
		}
		ValuableObject component = val2.GetComponent<ValuableObject>();
		if ((Object)(object)component != (Object)null && (Object)(object)component.valuePreset != (Object)null)
		{
			component.valuePreset.valueMin = 30000f;
			component.valuePreset.valueMax = 30000f;
		}
		Vector3 val3 = GetPlayerPosition() + Vector3.up * 1.5f + ((Component)Camera.main).transform.forward * 2.5f;
		for (int i = 0; i < 1; i++)
		{
			GameObject val4 = InstantiatePrefabRef(val2, val3 + Random.insideUnitSphere * 1f, Random.rotation);
			if (!((Object)(object)val4 != (Object)null))
			{
				continue;
			}
			PhotonView component2 = val4.GetComponent<PhotonView>();
			if ((Object)(object)component2 != (Object)null && PhotonNetwork.InRoom)
			{
				if (component2.ViewID == 0)
				{
					PhotonNetwork.AllocateViewID(component2);
				}
				component2.RPC("DollarValueSetRPC", (RpcTarget)1, new object[1] { 30000f });
			}
		}
		val.Unload(false);
		Log.LogInfo((object)"[Luck Event] 30 bags spawned from AssetBundle 'hi'.");
	}

	public static void TriggerClearSight()
	{
		Camera main = Camera.main;
		if (!((Object)(object)main == (Object)null))
		{
			if (!hasStoredOriginals)
			{
				originalFarClip = main.farClipPlane;
				originalFogState = RenderSettings.fog;
				hasStoredOriginals = true;
			}
			main.farClipPlane = originalFarClip * 2f;
			RenderSettings.fog = false;
		}
	}

	public static void ResetVisuals()
	{
		Camera main = Camera.main;
		if ((Object)(object)main != (Object)null && hasStoredOriginals)
		{
			main.farClipPlane = originalFarClip;
			RenderSettings.fog = originalFogState;
		}
		hasStoredOriginals = false;
		Debug.Log((object)"[Luck Mod] Visuals Reset to normal.");
	}

	public static void PrepareGoldenTouch()
	{
		Patch_GoldenTouchOnTouch._cachedGoldMat = ((IEnumerable<Material>)Resources.FindObjectsOfTypeAll<Material>()).FirstOrDefault((Func<Material, bool>)((Material m) => ((Object)m).name.Equals("GoldToothMaterial", StringComparison.OrdinalIgnoreCase) || ((Object)m).name.Contains("GoldTooth")));
		GoldenTouchActive = true;
		Debug.Log((object)"<color=gold>[Luck] Golden Touch CHARGED. Touch an item to transmute it!</color>");
	}

	[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
	[HarmonyPostfix]
	public static void ResetGoldenTouch()
	{
		GoldenTouchActive = false;
	}

	public static void TriggerLethalDarkness(float intensity)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		RenderSettings.ambientMode = (AmbientMode)3;
		RenderSettings.ambientIntensity = Mathf.Lerp(1f, 0f, intensity);
		RenderSettings.reflectionIntensity = Mathf.Lerp(1f, 0f, intensity);
		RenderSettings.fog = intensity > 0.05f;
		RenderSettings.fogMode = (FogMode)3;
		RenderSettings.fogColor = Color.black;
		RenderSettings.fogDensity = Mathf.Lerp(0f, 0.45f, intensity);
		Light[] array = Object.FindObjectsOfType<Light>();
		Light[] array2 = array;
		foreach (Light val in array2)
		{
			if (!originalLightIntensities.ContainsKey(val))
			{
				originalLightIntensities.Add(val, val.intensity);
			}
			val.intensity = Mathf.Lerp(originalLightIntensities[val], 0.01f, intensity);
		}
		Debug.Log((object)$"[Luck Mod] Darkness applied at {intensity * 100f}% intensity.");
	}

	public static void TriggerLightHand()
	{
		LightHandActive = true;
		PhysGrabObject[] array = Object.FindObjectsOfType<PhysGrabObject>();
		PhysGrabObject[] array2 = array;
		foreach (PhysGrabObject val in array2)
		{
			Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.mass *= 0.1f;
				component.drag = 0f;
				component.angularDrag = 0.05f;
			}
		}
		Debug.Log((object)"<color=yellow>[Luck Event] LIGHT HAND: Gravity is now a suggestion!</color>");
	}

	private void SpawnSurplusValuable()
	{
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string text = Path.Combine(directoryName, "hi");
		if (!File.Exists(text))
		{
			Log.LogError((object)("[Luck Event] AssetBundle 'hi' missing at: " + text));
			return;
		}
		AssetBundle val = AssetBundle.LoadFromFile(text);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		GameObject val2 = val.LoadAsset<GameObject>("bag");
		if ((Object)(object)val2 == (Object)null)
		{
			Log.LogError((object)"[Luck Event] Could not find 'bag' inside AssetBundle 'hi'.");
			val.Unload(true);
			return;
		}
		ValuableObject component = val2.GetComponent<ValuableObject>();
		if ((Object)(object)component != (Object)null && (Object)(object)component.valuePreset != (Object)null)
		{
			component.valuePreset.valueMin = 30000f;
			component.valuePreset.valueMax = 30000f;
		}
		Vector3 val3 = GetPlayerPosition() + Vector3.up * 1.5f + ((Component)Camera.main).transform.forward * 2.5f;
		for (int i = 0; i < 50; i++)
		{
			GameObject val4 = InstantiatePrefabRef(val2, val3 + Random.insideUnitSphere * 1f, Random.rotation);
			if (!((Object)(object)val4 != (Object)null))
			{
				continue;
			}
			PhotonView component2 = val4.GetComponent<PhotonView>();
			if ((Object)(object)component2 != (Object)null && PhotonNetwork.InRoom)
			{
				if (component2.ViewID == 0)
				{
					PhotonNetwork.AllocateViewID(component2);
				}
				component2.RPC("DollarValueSetRPC", (RpcTarget)1, new object[1] { 30000f });
			}
		}
		val.Unload(false);
		Log.LogInfo((object)"[Luck Event] 30 bags spawned from AssetBundle 'hi'.");
	}

	private bool SpawnEnemySetupAt(EnemySetup setup, Vector3 spawnPos)
	{
		//IL_0034: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
		bool result = false;
		foreach (PrefabRef spawnObject in setup.spawnObjects)
		{
			if (spawnObject == null)
			{
				continue;
			}
			GameObject val = InstantiatePrefabRef(spawnObject.Prefab, spawnPos, Quaternion.identity);
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			if (PhotonNetwork.InRoom && !HasValidPhotonView(val))
			{
				Object.Destroy((Object)(object)val);
				continue;
			}
			result = true;
			EnemyParent component = val.GetComponent<EnemyParent>();
			if ((Object)(object)component != (Object)null)
			{
				Traverse val2 = Traverse.Create((object)component);
				val2.Field("SetupDone").SetValue((object)true);
				val2.Field("firstSpawnPointUsed").SetValue((object)true);
			}
			Enemy componentInChildren = val.GetComponentInChildren<Enemy>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.EnemyTeleported(spawnPos);
			}
		}
		return result;
	}

	private GameObject InstantiatePrefabRef(GameObject prefab, Vector3 pos, Quaternion rot)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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)
		if ((Object)(object)prefab == (Object)null)
		{
			return null;
		}
		try
		{
			if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient)
			{
				return PhotonNetwork.Instantiate(((Object)prefab).name, pos, rot, (byte)0, (object[])null);
			}
			return Object.Instantiate<GameObject>(prefab, pos, rot);
		}
		catch (Exception ex)
		{
			Log.LogError((object)("[Luck Event] Spawn failed: " + ex.Message));
			return null;
		}
	}

	private bool HasValidPhotonView(GameObject go)
	{
		return go.GetComponentsInChildren<PhotonView>(true)?.Any((PhotonView v) => (Object)(object)v != (Object)null && v.ViewID != 0) ?? false;
	}

	private Vector3 GetPlayerPosition()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: 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_0040: 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)
		if ((Object)(object)PlayerController.instance != (Object)null)
		{
			return ((Component)PlayerController.instance).transform.position;
		}
		if ((Object)(object)Camera.main != (Object)null)
		{
			return ((Component)Camera.main).transform.position;
		}
		return Vector3.zero;
	}

	private void TriggerVignette(bool isGood)
	{
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Type type = AccessTools.TypeByName("HurtVignette");
			if (type != null)
			{
				object obj = AccessTools.Field(type, "instance")?.GetValue(null);
				if (obj != null)
				{
					FieldInfo fieldInfo = AccessTools.Field(type, "activeColor");
					FieldInfo fieldInfo2 = AccessTools.Field(type, "lerp");
					FieldInfo fieldInfo3 = AccessTools.Field(type, "rectTransform");
					FieldInfo fieldInfo4 = AccessTools.Field(type, "activeScale");
					fieldInfo.SetValue(obj, (object)(isGood ? new Color(0f, 1f, 0.3f) : new Color(1f, 0f, 0.2f)));
					fieldInfo2.SetValue(obj, 1f);
					object? value = fieldInfo3.GetValue(obj);
					RectTransform val = (RectTransform)((value is RectTransform) ? value : null);
					float num = (float)fieldInfo4.GetValue(obj);
					if ((Object)(object)val != (Object)null)
					{
						((Transform)val).localScale = Vector3.one * num;
					}
					Log.LogInfo((object)("[Luck Points] Triggered " + (isGood ? "Good" : "Bad") + " Vignette via HurtVignette."));
					return;
				}
			}
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Vignette Error: " + ex.Message));
		}
		Log.LogWarning((object)"[Luck Points] Could not find HurtVignette instance.");
	}

	private void ExecuteEffect(EffectType type, float luck)
	{
		bool isGood = luck >= 50f;
		switch (type)
		{
		case EffectType.Money:
			ExecuteMoneyEffect(luck, isGood);
			break;
		case EffectType.PlayerStats:
			ExecutePlayerStatsEffect(luck, isGood);
			break;
		case EffectType.EnemyStats:
			ExecuteEnemyStatsEffect(luck, isGood);
			break;
		case EffectType.SpawnEnemy:
			ExecuteSpawnEnemyEffect(luck, isGood);
			break;
		case EffectType.SpawnItem:
			ExecuteSpawnItemEffect(luck, isGood);
			break;
		case EffectType.ModuleRarity:
			ExecuteModuleEffect(luck, isGood);
			break;
		case EffectType.LevelList:
			ExecuteLevelListEffect(luck, isGood);
			break;
		}
	}

	private void ExecuteMoneyEffect(float luck, bool isGood)
	{
		float num = 0f;
		num = ((luck >= 100f) ? 200f : ((luck >= 95f) ? 150f : ((luck >= 90f) ? 100f : ((luck >= 85f) ? 75f : ((luck >= 80f) ? 50f : ((luck >= 70f) ? 20f : ((!(luck >= 60f)) ? 15000f : 10f)))))));
		if (isGood)
		{
			GiveMoney(Mathf.RoundToInt(num));
			return;
		}
		float num2 = Mathf.Lerp(0.8f, 0.1f, luck / 40f);
		num2 = Mathf.Clamp(num2, 0.1f, 0.8f);
		TakeMoney(num2);
	}

	private void ExecutePlayerStatsEffect(float luck, bool isGood)
	{
		//IL_0001: 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)
		SteamId steamId = SteamClient.SteamId;
		string text = ((object)(SteamId)(ref steamId)).ToString();
		if (string.IsNullOrEmpty(text))
		{
			return;
		}
		List<string> list = new List<string> { "Health", "Speed", "Strength", "Range", "Throw", "Stamina", "TumbleWings", "CrouchRest", "ExtraJump" };
		string text2 = list[Random.Range(0, list.Count)];
		int num = 0;
		if (isGood)
		{
			float num2 = Mathf.InverseLerp(50f, 100f, luck);
			num = Mathf.RoundToInt(num2 * 2f) + 1;
			ModifyPlayerStat(text2, num);
			Log.LogInfo((object)$"[Effect] Buff Player: {text2} +{num}");
			return;
		}
		float num3 = Mathf.InverseLerp(50f, 0f, luck);
		num = -Mathf.RoundToInt(num3 * 2f) - 1;
		bool flag = false;
		Dictionary<string, int> statDictionary = GetStatDictionary(text2);
		if (statDictionary != null && statDictionary.ContainsKey(text) && statDictionary[text] > 0)
		{
			flag = true;
		}
		if (flag)
		{
			ModifyPlayerStat(text2, num);
			Log.LogInfo((object)$"[Effect] Debuff Player: {text2} {num}");
			return;
		}
		Log.LogInfo((object)"[Effect] Player has no stats! Alternative Punishment.");
		TakeMoney(0.5f);
		HurtLocalPlayer(30);
		BuffRandomEnemy(1.5f);
	}

	private void ExecuteEnemyStatsEffect(float luck, bool isGood)
	{
		if (isGood)
		{
			float num = Mathf.InverseLerp(50f, 100f, luck);
			float num2 = 1f - num * 0.75f;
			DebuffAllEnemies(num2, num2);
			Log.LogInfo((object)$"[Effect] Debuff Enemies to {num2 * 100f}% stats.");
		}
		else
		{
			float num3 = Mathf.InverseLerp(50f, 0f, luck);
			float num4 = 1f + num3 * 2f;
			BuffAllEnemies(num4, num4);
			Log.LogInfo((object)$"[Effect] Buff Enemies to {num4 * 100f}% stats.");
		}
	}

	private void ExecuteSpawnEnemyEffect(float luck, bool isGood)
	{
		if (isGood)
		{
			GiveMoney(5);
			Log.LogInfo((object)"[Effect] Spawned Allied Support (Money).");
		}
		else
		{
			BuffRandomEnemy(3f);
			Log.LogInfo((object)"[Effect] Shadow Spawn (Buffed random enemy).");
		}
	}

	private void ExecuteSpawnItemEffect(float luck, bool isGood)
	{
		if (isGood)
		{
			GiveMoney(20);
			Log.LogInfo((object)"[Effect] Spawned Valuable (Money).");
		}
		else
		{
			DestroyRandomItems(1);
			Log.LogInfo((object)"[Effect] Destroyed Item.");
		}
	}

	private void ExecuteModuleEffect(float luck, bool isGood)
	{
		if (isGood)
		{
			DebuffAllEnemies(0.8f, 0.8f);
		}
		else
		{
			BuffAllEnemies(1.5f, 1.5f);
		}
		Log.LogInfo((object)("[Effect] Module/Global Enemy Adjustment (" + (isGood ? "Easier" : "Harder") + ")."));
	}

	private void ExecuteLevelListEffect(float luck, bool isGood)
	{
		RunManager instance = RunManager.instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		Level val = ((IEnumerable<Level>)instance.levels).FirstOrDefault((Func<Level, bool>)((Level l) => ((Object)l).name.ToLower().Contains("manor")));
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		if (isGood)
		{
			if (instance.levels.Contains(val))
			{
				instance.levels.Remove(val);
				Log.LogInfo((object)"[Effect] Removed Manor from Level Pool.");
			}
		}
		else if (!instance.levels.Contains(val))
		{
			instance.levels.Add(val);
			Log.LogInfo((object)"[Effect] Added Manor Duplicate.");
		}
	}

	private static Dictionary<string, int> GetStatDictionary(string statName)
	{
		return AccessTools.Field(typeof(StatsManager), "playerUpgrade" + statName)?.GetValue(StatsManager.instance) as Dictionary<string, int>;
	}

	private static void ForceRefreshUpgrade(string steamID, string key, int value)
	{
		if (GetPlayerSteamID(PlayerController.instance?.playerAvatarScript) != steamID)
		{
			return;
		}
		PlayerController instance = PlayerController.instance;
		PlayerAvatar val = instance?.playerAvatarScript;
		if ((Object)(object)instance == (Object)null || (Object)(object)val == (Object)null)
		{
			return;
		}
		switch (key)
		{
		case "playerUpgradeExtraJump":
			Traverse.Create((object)instance).Field("JumpExtra").SetValue((object)value);
			Traverse.Create((object)instance).Field("JumpExtraCurrent").SetValue((object)value);
			break;
		case "playerUpgradeSpeed":
		{
			float num2 = Traverse.Create((object)instance).Field<float>("playerOriginalSprintSpeed").Value;
			if (num2 < 0.5f)
			{
				num2 = 1f;
			}
			instance.SprintSpeed = num2 + (float)value;
			break;
		}
		case "playerUpgradeStamina":
			instance.EnergyStart = 100f + (float)value * 10f;
			instance.EnergyCurrent = instance.EnergyStart;
			break;
		case "playerUpgradeHealth":
			if ((Object)(object)val.playerHealth != (Object)null)
			{
				int num = 100 + value * 20;
				Traverse.Create((object)val.playerHealth).Field("maxHealth").SetValue((object)num);
				Traverse.Create((object)val.playerHealth).Field("health").SetValue((object)num);
				StatsManager.instance.SetPlayerHealth(steamID, num, true);
			}
			break;
		case "playerUpgradeLaunch":
		{
			PlayerTumble value2 = Traverse.Create((object)val).Field<PlayerTumble>("tumble").Value;
			if ((Object)(object)value2 != (Object)null)
			{
				Traverse.Create((object)value2).Field("tumbleLaunch").SetValue((object)value);
			}
			break;
		}
		case "playerUpgradeRange":
		{
			PhysGrabber instance4 = PhysGrabber.instance;
			if ((Object)(object)instance4 != (Object)null)
			{
				Traverse.Create((object)instance4).Field("grabRange").SetValue((object)(4f + (float)value));
			}
			break;
		}
		case "playerUpgradeStrength":
		{
			PhysGrabber instance3 = PhysGrabber.instance;
			if ((Object)(object)instance3 != (Object)null)
			{
				Traverse.Create((object)instance3).Field("grabStrength").SetValue((object)(1f + (float)value * 0.2f));
			}
			break;
		}
		case "playerUpgradeThrow":
		{
			PhysGrabber instance2 = PhysGrabber.instance;
			if ((Object)(object)instance2 != (Object)null)
			{
				Traverse.Create((object)instance2).Field("throwStrength").SetValue((object)((float)value * 0.3f));
			}
			break;
		}
		}
	}

	private static string GetPlayerSteamID(PlayerAvatar player)
	{
		if ((Object)(object)player == (Object)null)
		{
			return "";
		}
		FieldInfo field = typeof(PlayerAvatar).GetField("steamID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		return (field != null) ? ((string)field.GetValue(player)) : "";
	}

	private static void ModifyPlayerStat(string statName, int levelsToAdd)
	{
		//IL_0001: 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)
		SteamId steamId = SteamClient.SteamId;
		string text = ((object)(SteamId)(ref steamId)).ToString();
		if (string.IsNullOrEmpty(text) || text == "0")
		{
			return;
		}
		PlayerAvatar val = PlayerController.instance?.playerAvatarScript;
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		string key = "playerUpgrade" + statName;
		Dictionary<string, int> statDictionary = GetStatDictionary(statName);
		int value = 0;
		if (statDictionary != null)
		{
			if (!statDictionary.ContainsKey(text))
			{
				statDictionary.Add(text, 0);
			}
			statDictionary[text] = Mathf.Max(0, statDictionary[text] + levelsToAdd);
			value = statDictionary[text];
			SemiFunc.StatSyncAll();
		}
		ForceRefreshUpgrade(text, key, value);
	}

	private static void GiveMoney(int amount)
	{
		int num = SemiFunc.StatGetRunCurrency();
		SemiFunc.StatSetRunCurrency(num + amount);
		Log.LogInfo((object)$"[Luck Points] Gave ${amount}.");
	}

	private static void TakeMoney(float percent)
	{
		int num = SemiFunc.StatGetRunCurrency();
		int num2 = Mathf.RoundToInt((float)num * percent);
		SemiFunc.StatSetRunCurrency(num - num2);
		Log.LogInfo((object)$"[Luck Points] Took {percent * 100f}% money (${num2}).");
	}

	private static void HealLocalPlayer(int amount)
	{
		PlayerAvatar val = PlayerController.instance?.playerAvatarScript;
		if ((Object)(object)val != (Object)null)
		{
			val.playerHealth.Heal(amount, true);
		}
	}

	private static void HurtLocalPlayer(int amount)
	{
		PlayerAvatar val = PlayerController.instance?.playerAvatarScript;
		if ((Object)(object)val != (Object)null)
		{
			val.playerHealth.Hurt(amount, false, -1);
		}
	}

	private static void DebuffAllEnemies(float healthMult, float speedMult)
	{
		EnemyParent[] array = Object.FindObjectsOfType<EnemyParent>();
		foreach (EnemyParent val in array)
		{
			EnemyHealth componentInChildren = ((Component)val).GetComponentInChildren<EnemyHealth>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				int num = Mathf.RoundToInt((float)componentInChildren.health * healthMult);
				if (num < 1)
				{
					num = 1;
				}
				componentInChildren.health = num;
				Traverse.Create((object)componentInChildren).Field("healthCurrent").SetValue((object)num);
			}
			EnemyVision componentInChildren2 = ((Component)val).GetComponentInChildren<EnemyVision>();
			if ((Object)(object)componentInChildren2 != (Object)null)
			{
				componentInChildren2.VisionDistance *= healthMult;
			}
			NavMeshAgent componentInChildren3 = ((Component)val).GetComponentInChildren<NavMeshAgent>();
			if ((Object)(object)componentInChildren3 != (Object)null)
			{
				componentInChildren3.speed *= speedMult;
			}
		}
	}

	private static void BuffAllEnemies(float healthMult, float speedMult)
	{
		EnemyParent[] array = Object.FindObjectsOfType<EnemyParent>();
		foreach (EnemyParent val in array)
		{
			EnemyHealth componentInChildren = ((Component)val).GetComponentInChildren<EnemyHealth>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				int num = (componentInChildren.health = Mathf.RoundToInt((float)componentInChildren.health * healthMult));
				Traverse.Create((object)componentInChildren).Field("healthCurrent").SetValue((object)num);
			}
			EnemyVision componentInChildren2 = ((Component)val).GetComponentInChildren<EnemyVision>();
			if ((Object)(object)componentInChildren2 != (Object)null)
			{
				componentInChildren2.VisionDistance *= healthMult;
			}
			NavMeshAgent componentInChildren3 = ((Component)val).GetComponentInChildren<NavMeshAgent>();
			if ((Object)(object)componentInChildren3 != (Object)null)
			{
				componentInChildren3.speed *= speedMult;
			}
		}
	}

	private static void BuffRandomEnemy(float mult)
	{
		EnemyParent[] array = Object.FindObjectsOfType<EnemyParent>();
		if (array.Length != 0)
		{
			EnemyParent val = array[Random.Range(0, array.Length)];
			EnemyHealth componentInChildren = ((Component)val).GetComponentInChildren<EnemyHealth>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				int num = (componentInChildren.health = Mathf.RoundToInt((float)componentInChildren.health * mult));
				Traverse.Create((object)componentInChildren).Field("healthCurrent").SetValue((object)num);
			}
		}
	}

	private static void DestroyRandomItems(int count)
	{
		List<ValuableObject> list = (from v in Object.FindObjectsOfType<ValuableObject>()
			where (Object)(object)v != (Object)null && !((Object)((Component)v).gameObject).name.ToLower().Contains("enemy")
			select v).ToList();
		ListExtension.Shuffle<ValuableObject>((IList<ValuableObject>)list);
		int num = 0;
		for (int i = 0; i < Mathf.Min(count, list.Count); i++)
		{
			PhysGrabObject component = ((Component)list[i]).GetComponent<PhysGrabObject>();
			if ((Object)(object)component != (Object)null)
			{
				component.DestroyPhysGrabObject();
				num++;
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Arena), "Awake")]
	private static void Arena_Awake_Postfix()
	{
		Log.LogInfo((object)"[Luck Monitor] Arena Detected. Resetting all Luck Stats to 0.");
		_luckPoints = 0;
		Instance._overallLuck = 50f;
		Instance._levelLuck = 50f;
		_storedPointValues.Clear();
		_luckChangesThisCycle.Clear();
		_totalLuckSum = 0f;
		_completedLevelsCount = 0;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
	private static void RunManager_ChangeLevel_Postfix(bool _completedLevel, bool _levelFailed)
	{
		if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)RunManager.instance.levelCurrent == (Object)null)
		{
			return;
		}
		Level levelCurrent = RunManager.instance.levelCurrent;
		if (RunManager.instance.levelsCompleted == 0 && SemiFunc.RunIsLevel())
		{
			Log.LogInfo((object)"[Luck Monitor] Start of run detected (Level 1). Resetting stats to 0.");
			_luckPoints = 0;
			_storedPointValues.Clear();
			_totalLuckSum = 0f;
			_completedLevelsCount = 0;
			Instance._overallLuck = 50f;
		}
		bool isInGameLevel = IsInGameLevel;
		bool flag = (Object)(object)_lastLevel != (Object)null && ((Object)_lastLevel).name.ToLower().Contains("arena");
		if (isInGameLevel && !flag)
		{
			_totalLuckSum += Instance._levelLuck;
			_completedLevelsCount++;
			if (_completedLevelsCount > 0)
			{
				Instance._overallLuck = _totalLuckSum / (float)_completedLevelsCount;
			}
			float levelLuck = Instance._levelLuck;
			_luckPoints++;
			_storedPointValues.Add(levelLuck);
			_luckChangesThisCycle.Clear();
			Log.LogInfo((object)$"[Luck Points] Level Complete! Points: {_luckPoints}. Value: {levelLuck}%");
			Log.LogInfo((object)$"[Luck] Overall Luck Updated: {Instance._overallLuck}%");
		}
		else if (flag)
		{
			Log.LogInfo((object)"[Luck Monitor] Skipping point award (Previous level was Arena).");
		}
		Level levelLobby = RunManager.instance.levelLobby;
		Level levelMainMenu = RunManager.instance.levelMainMenu;
		Level levelLobbyMenu = RunManager.instance.levelLobbyMenu;
		if ((Object)(object)levelCurrent == (Object)(object)levelMainMenu || (Object)(object)levelCurrent == (Object)(object)levelLobbyMenu || (!SemiFunc.RunIsShop() && !SemiFunc.RunIsLevel()))
		{
			IsInGameLevel = false;
			return;
		}
		IsInGameLevel = SemiFunc.RunIsLevel();
		if (IsInGameLevel)
		{
			_lastLevel = levelCurrent;
			_activeEnemies.Clear();
			_levelEnemies.Clear();
			_foundWeaponThisLevel = false;
			_currentLevelIndex = RunManager.instance.levelsCompleted;
			_badModuleSpawns = 0;
			_trackedValuables.Clear();
			_totalLevelValue = 0f;
			_truckHealAnalyzed = false;
			_itemDestroyedThisLevel = false;
			_playerWasHealedByTruck = false;
			_hiddenRescueTriggered = false;
			_initialTotalMapValue = 0f;
			_deadPlayersProcessed.Clear();
			_levelStartTotalHaul = (((Object)(object)RoundDirector.instance != (Object)null) ? ((int)_roundDirectorTotalHaulField.GetValue(RoundDirector.instance)) : 0);
			Instance._levelLuck = 50f;
			string text = levelCurrent.NarrativeName?.ToLower() + " " + ((Object)levelCurrent).name?.ToLower();
			_isHeadmanManor = text.Contains("manor");
			if (_isHeadmanManor)
			{
				ModifyLuck(-5f, "Map: Headman Manor");
			}
			else if (text.Contains("museum") || text.Contains("wizard"))
			{
				ModifyLuck(15f, "Map: Open Layout");
			}
		}
	}

	public static void SetLevelSpeed(float mult)
	{
		ActiveMultiplier = mult;
		Log.LogInfo((object)$"[Luck] Level Speed Modifier set to: {mult}x");
	}

	public static void Reset()
	{
		ActiveMultiplier = 1f;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(LevelGenerator), "EnemySpawn")]
	private static void LevelGenerator_EnemySpawn_TruckProximity_Postfix(EnemySetup enemySetup, Vector3 position)
	{
		//IL_0021: 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)
		if (!LevelGenerator.Instance.Generated && !((Object)(object)TruckSafetySpawnPoint.instance == (Object)null) && Vector3.Distance(position, ((Component)TruckSafetySpawnPoint.instance).transform.position) < 20f)
		{
			ModifyLuck(-10f, "Enemy Spawned Near Truck!");
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(EnemyDuck), "OnGrabbed")]
	private static void EnemyDuck_OnGrabbed_Postfix(EnemyDuck __instance)
	{
		if (SemiFunc.IsMasterClientOrSingleplayer() && !(Time.time < _duckLuckCooldown))
		{
			PlayerAvatar value = Traverse.Create((object)__instance).Field<PlayerAvatar>("playerTarget").Value;
			if ((Object)(object)value != (Object)null && Traverse.Create((object)value).Field<bool>("isLocal").Value)
			{
				_duckLuckCooldown = Time.time + 15f;
				ModifyLuck(-5f, "Grabbed the Duck!");
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(BirthdayBoyBalloon), "OnTriggerEnter")]
	private static void BirthdayBoyBalloon_OnTriggerEnter_Postfix(BirthdayBoyBalloon __instance)
	{
		if (!__instance.popped && (Object)(object)__instance.popper != (Object)null && Traverse.Create((object)__instance.popper).Field<bool>("isLocal").Value)
		{
			ModifyLuck(-2.5f, "Popped a Balloon!");
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeathRPC")]
	private static void PlayerAvatar_PlayerDeathRPC_Postfix(PlayerAvatar __instance, PhotonMessageInfo _info)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.MasterAndOwnerOnlyRPC(_info, __instance.photonView))
		{
			string value = Traverse.Create((object)__instance).Field<string>("steamID").Value;
			if (!string.IsNullOrEmpty(value) && !_deadPlayersProcessed.Contains(value))
			{
				_deadPlayersProcessed.Add(value);
				ModifyLuck(-20f, "Player Died: " + Traverse.Create((object)__instance).Field<string>("playerName").Value);
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(EnemyHealth), "DeathImpulseRPC")]
	private static void EnemyHealth_DeathImpulse_Postfix(EnemyHealth __instance, PhotonMessageInfo _info)
	{
		//IL_0001: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected I4, but got Unknown
		if (!SemiFunc.MasterOnlyRPC(_info))
		{
			return;
		}
		EnemyParent componentInParent = ((Component)__instance).GetComponentInParent<EnemyParent>();
		if (!((Object)(object)componentInParent == (Object)null))
		{
			float num = 0f;
			string text = "";
			Difficulty difficulty = componentInParent.difficulty;
			Difficulty val = difficulty;
			switch ((int)val)
			{
			case 0:
				num = 2f;
				text = "Tier 1";
				break;
			case 1:
				num = 4f;
				text = "Tier 2";
				break;
			case 2:
				num = 6f;
				text = "Tier 3+";
				break;
			}
			if (num > 0f)
			{
				ModifyLuck(num, "Exterminated: " + componentInParent.enemyName + " (" + text + ")");
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlayerAvatar), "ReviveRPC")]
	private static void PlayerAvatar_ReviveRPC_Postfix(PlayerAvatar __instance, PhotonMessageInfo _info)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.MasterOnlyRPC(_info))
		{
			string value = Traverse.Create((object)__instance).Field<string>("steamID").Value;
			if (!string.IsNullOrEmpty(value) && _deadPlayersProcessed.Contains(value))
			{
				_deadPlayersProcessed.Remove(value);
				ModifyLuck(20f, "Player Revived: " + Traverse.Create((object)__instance).Field<string>("playerName").Value);
			}
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(AnimalCrateTrap), "TrapActivate")]
	private static bool AnimalCrateTrap_TrapActivate_Prefix(AnimalCrateTrap __instance)
	{
		if (Traverse.Create((object)__instance).Field<bool>("trapTriggered").Value)
		{
			return true;
		}
		PhysGrabObject value = Traverse.Create((object)__instance).Field<PhysGrabObject>("physgrabobject").Value;
		if (value != null && value.grabbedLocal)
		{
			ModifyLuck(-5f, "Triggered Animal Crate!");
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(ChompBookTrap), "TrapActivate")]
	private static bool ChompBookTrap_TrapActivate_Prefix(ChompBookTrap __instance)
	{
		if (Traverse.Create((object)__instance).Field<bool>("trapTriggered").Value)
		{
			return true;
		}
		PhysGrabObject value = Traverse.Create((object)__instance).Field<PhysGrabObject>("physGrabObject").Value;
		Transform value2 = Traverse.Create((object)__instance).Field<Transform>("targetTransform").Value;
		if (((Object)(object)value != (Object)null && value.grabbedLocal) || ((Object)(object)value2 != (Object)null && (Object)(object)((Component)value2).GetComponent<PlayerAvatar>() != (Object)null && Traverse.Create((object)((Component)value2).GetComponent<PlayerAvatar>()).Field<bool>("isLocal").Value))
		{
			ModifyLuck(-2f, "Triggered Chomp Book!");
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(FrogTrap), "TrapActivate")]
	private static bool FrogTrap_TrapActivate_Prefix(FrogTrap __instance)
	{
		if (Traverse.Create((object)__instance).Field<bool>("trapTriggered").Value)
		{
			return true;
		}
		PhysGrabObject value = Traverse.Create((object)__instance).Field<PhysGrabObject>("physgrabobject").Value;
		if (value != null && value.grabbedLocal)
		{
			ModifyLuck(-2f, "Triggered Frog Trap!");
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(TrapRadio), "RadioTrapActivated")]
	private static bool TrapRadio_RadioTrapActivated_Prefix(TrapRadio __instance)
	{
		if (Traverse.Create((object)__instance).Field<bool>("trapTriggered").Value)
		{
			return true;
		}
		PhysGrabObject value = Traverse.Create((object)__instance).Field<PhysGrabObject>("physGrabObject").Value;
		if (value != null && value.grabbedLocal)
		{
			ModifyLuck(-2f, "Triggered Radio Trap!");
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(TrapTV), "TrapActivate")]
	private static bool TrapTV_TrapActivate_Prefix(TrapTV __instance)
	{
		if (Traverse.Create((object)__instance).Field<bool>("trapTriggered").Value)
		{
			return true;
		}
		PhysGrabObject value = Traverse.Create((object)__instance).Field<PhysGrabObject>("physGrabObject").Value;
		if (value != null && value.grabbedLocal)
		{
			ModifyLuck(-2f, "Triggered TV Trap!");
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(TrapGramophone), "TrapActivate")]
	private static bool TrapGramophone_TrapActivate_Prefix(TrapGramophone __instance)
	{
		if (Traverse.Create((object)__instance).Field<bool>("trapTriggered").Value)
		{
			return true;
		}
		PhysGrabObject value = Traverse.Create((object)__instance).Field<PhysGrabObject>("physGrabObject").Value;
		if (value != null && value.grabbedLocal)
		{
			ModifyLuck(-2f, "Triggered Gramophone Trap!");
		}
		return true;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ValuableObject), "Start")]
	private static void ValuableObject_Start_Postfix(ValuableObject __instance)
	{
		if (IsInGameLevel && !((Object)(object)__instance == (Object)null) && !_trackedValuables.Any((TrackedValuable x) => (Object)(object)x.Valuable == (Object)(object)__instance))
		{
			_trackedValuables.Add(new TrackedValuable
			{
				Valuable = __instance,
				LastKnownValue = 0f
			});
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(PhysGrabObject), "DestroyPhysGrabObject")]
	private static void PhysGrabObject_DestroyPhysGrabObject_Prefix(PhysGrabObject __instance)
	{
		if (!IsInGameLevel || (Object)(object)__instance == (Object)null || SemiFunc.RunIsShop())
		{
			return;
		}
		string text = ((Object)((Component)__instance).gameObject).name.ToLower();
		if (text.Contains("cart"))
		{
			ModifyLuck(-15f, "Broke the Cart!");
		}
		if ((Object)(object)((Component)__instance).GetComponent<ItemAttributes>() != (Object)null)
		{
			if (text.Contains("gun"))
			{
				ModifyLuck(-10f, "Destroyed Weapon!");
			}
			else if (text.Contains("feather") || text.Contains("gravity") || text.Contains("indestructible"))
			{
				ModifyLuck(-5f, "Destroyed Drone!");
			}
		}
		TrackedValuable trackedValuable = _trackedValuables.FirstOrDefault((TrackedValuable x) => (Object)(object)x.Valuable != (Object)null && (Object)(object)((Component)x.Valuable).gameObject == (Object)(object)((Component)__instance).gameObject);
		if (trackedValuable == null)
		{
			return;
		}
		float num = (float)_dollarValueField.GetValue(trackedValuable.Valuable);
		List<GameObject> list = RoundDirector.instance?.dollarHaulList;
		if (list == null || !list.Contains(((Component)trackedValuable.Valuable).gameObject))
		{
			_itemDestroyedThisLevel = true;
			if (((Object)((Component)trackedValuable.Valuable).gameObject).name.ToLower().Contains("enemy valuable"))
			{
				if (!LuckEventManager.NukeActive)
				{
					ModifyLuck(-5f, "Destroyed Enemy Valuable!");
				}
			}
			else if (_initialTotalMapValue > 0f && num > 0f)
			{
				float num2 = num / _initialTotalMapValue * 100f;
				float num3 = num2 * -1f;
				if (num3 > -0.5f)
				{
					num3 = -0.5f;
				}
				ModifyLuck(num3, $"Item Destroyed (-{Mathf.RoundToInt(num2)}% Value)");
			}
			else
			{
				ModifyLuck(-0.5f, "Item Destroyed");
			}
		}
		_trackedValuables.Remove(trackedValuable);
	}

	private void CheckAllLootDamage()
	{
		if (!IsInGameLevel || (Object)(object)RunManager.instance == (Object)null || (Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated)
		{
			return;
		}
		if (_totalLevelValue <= 0f)
		{
			_totalLevelValue = _trackedValuables.Sum((TrackedValuable x) => (float)_dollarValueField.GetValue(x.Valuable));
		}
		List<GameObject> list = RoundDirector.instance?.dollarHaulList;
		for (int num = _trackedValuables.Count - 1; num >= 0; num--)
		{
			TrackedValuable trackedValuable = _trackedValuables[num];
			if ((Object)(object)trackedValuable.Valuable == (Object)null)
			{
				_trackedValuables.RemoveAt(num);
			}
			else
			{
				float num2 = (float)_dollarValueField.GetValue(trackedValuable.Valuable);
				if (trackedValuable.LastKnownValue <= 0f && num2 > 0f)
				{
					trackedValuable.LastKnownValue = num2;
				}
				else if (num2 < trackedValuable.LastKnownValue)
				{
					float num3 = trackedValuable.LastKnownValue - num2;
					if ((list == null || !list.Contains(((Component)trackedValuable.Valuable).gameObject)) && _totalLevelValue > 0f)
					{
						float num4 = num3 / _totalLevelValue * 100f;
						if (num4 > 0.1f)
						{
							float amount = num4 * -0.5f;
							ModifyLuck(amount, $"Loot Damaged (-${Mathf.RoundToInt(num3)})");
						}
					}
					trackedValuable.LastKnownValue = num2;
				}
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(LevelGenerator), "PickModule")]
	private static void LevelGenerator_PickModule_Postfix(PrefabRef __result, List<PrefabRef> _list1, List<PrefabRef> _list2, List<PrefabRef> _list3)
	{
		if (IsInGameLevel && __result != null)
		{
			if (_list3.Contains(__result))
			{
				_badModuleSpawns++;
			}
			else if (_list2.Contains(__result) && _currentLevelIndex < 3)
			{
				_badModuleSpawns++;
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(LevelGenerator), "GenerateDone")]
	private static void LevelGenerator_GenerateDone_Postfix()
	{
		if (IsInGameLevel)
		{
			((MonoBehaviour)Instance).StartCoroutine(WaitForQuotaAndAnalyze());
		}
	}

	[IteratorStateMachine(typeof(<WaitForQuotaAndAnalyze>d__142))]
	private static IEnumerator WaitForQuotaAndAnalyze()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WaitForQuotaAndAnalyze>d__142(0);
	}

	[IteratorStateMachine(typeof(<RecalculateTotalMapValue>d__143))]
	private static IEnumerator RecalculateTotalMapValue()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RecalculateTotalMapValue>d__143(0);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ShopManager), "ShopInitialize")]
	private static void ShopManager_ShopInitialize_Postfix()
	{
		if (SemiFunc.RunIsShop())
		{
			((MonoBehaviour)Instance).StartCoroutine(ScanShopItems());
		}
	}

	[IteratorStateMachine(typeof(<ScanShopItems>d__145))]
	private static IEnumerator ScanShopItems()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ScanShopItems>d__145(0);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(EnemyParent), "Despawn")]
	private static void EnemyParent_Despawn_Postfix(EnemyParent __instance)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		if (!IsInGameLevel || (Object)(object)__instance == (Object)null)
		{
			return;
		}
		if (((Object)((Component)__instance).gameObject).name.ToLower().Contains("valuable thrower") && ((Component)__instance).transform.position.y < -2.5f)
		{
			ModifyLuck(5f, "Big Brain: Baited the Rugrat!");
		}
		if (GetEnemyHealthCurrent(__instance) > 0)
		{
			return;
		}
		ExtractionPoint[] array = Object.FindObjectsOfType<ExtractionPoint>();
		foreach (ExtractionPoint val in array)
		{
			if (Vector3.Distance(((Component)__instance).transform.position, ((Component)val).transform.position) <= 0.5f)
			{
				ModifyLuck(10f, "Safety Kill!");
				break;
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(LevelGenerator), "EnemySpawn")]
	private static void LevelGenerator_EnemySpawn_Postfix(EnemySetup enemySetup, Vector3 position)
	{
		if (!IsInGameLevel || (Object)(object)enemySetup == (Object)null)
		{
			return;
		}
		string text = ((Object)enemySetup).name.ToLower();
		_levelEnemies.Add(text);
		if (_currentLevelIndex < 3 && (text.Contains("runner") || text.Contains("bomb thrower") || text.Contains("shadow") || text.Contains("head") || text.Contains("robe")))
		{
			ModifyLuck(-10f, "Early " + ((Object)enemySetup).name + "!");
		}
		if (_isHeadmanManor && text.Contains("shadow"))
		{
			ModifyLuck(-10f, "Loom in Manor!");
		}
		if (_activeEnemies.Any((string e) => e.Contains("shadow")) && _activeEnemies.Any((string e) => e.Contains("upscream")))
		{
			ModifyLuck(-25f, "CC Loop!");
		}
		if (_activeEnemies.Contains("hidden") && _activeEnemies.Any((string e) => e.Contains("hunter") || e.Contains("robe")))
		{
			ModifyLuck(-25f, "Run Ender Combo!");
		}
		if (_activeEnemies.Contains("bowtie"))
		{
			int num = _levelEnemies.Count((string e) => e.Contains("duck"));
			if (num >= 3)
			{
				ModifyLuck(-10f, "Panic Room: QUACK-POCALYPSE!");
			}
		}
		bool flag = _activeEnemies.Any((string e) => e.Contains("animal") || e.Contains("upscream") || e.Contains("man"));
		if (_activeEnemies.Contains("upscream") && flag)
		{
			ModifyLuck(-15f, "The Juggle!");
		}
		if (_activeEnemies.Contains("gnome") && _activeEnemies.Contains("valuable thrower"))
		{
			ModifyLuck(-10f, "Loot Shredders!");
		}
		_activeEnemies.Add(text);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ValuableObject), "DollarValueSetLogic")]
	private static void ValuableObject_ValueSet_Postfix(ValuableObject __instance)
	{
		if (IsInGameLevel && !((Object)(object)__instance == (Object)null))
		{
			string text = ((Object)__instance).name.ToLower();
			if (text.Contains("golden statue") || text.Contains("clown") || text.Contains("uranium") || text.Contains("wizard diamond") || text.Contains("propane tank") || text.Contains("ship in a bottle") || text.Contains("vase chunky") || text.Contains("cube of knowledge") || text.Contains("forever candle") || text.Contains("troll finger") || text.Contains("manor diamond") || text.Contains("sword") || text.Contains("griffin statue") || text.Contains("poison chalice") || text.Contains("barrel") || text.Contains("creature leg") || text.Contains("ice block") || text.Contains("heavy water")