Decompiled source of Luck Assessor v3.1.5

EmptyChildMod.dll

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

[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.0.0")]
public class LuckMonitorPlugin : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <RecalculateTotalMapValue>d__69 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		private ValuableObject[] <allValuables>5__1;

		private ValuableObject[] <>s__2;

		private int <>s__3;

		private ValuableObject <val>5__4;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<allValuables>5__1 = null;
			<>s__2 = null;
			<val>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				_initialTotalMapValue = 0f;
				<allValuables>5__1 = Object.FindObjectsOfType<ValuableObject>();
				<>s__2 = <allValuables>5__1;
				for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++)
				{
					<val>5__4 = <>s__2[<>s__3];
					if ((Object)(object)<val>5__4 != (Object)null)
					{
						_initialTotalMapValue += (float)_dollarValueField.GetValue(<val>5__4);
					}
					<val>5__4 = null;
				}
				<>s__2 = 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__71 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		private int <currentWallet>5__1;

		private bool <hasTracker>5__2;

		private bool <hasWeapon>5__3;

		private bool <hasBat>5__4;

		private bool <hasDrones>5__5;

		private bool <hasGrenade>5__6;

		private bool <hasCannons>5__7;

		private int <countStamina>5__8;

		private int <countHealth>5__9;

		private int <countStrength>5__10;

		private int <countRange>5__11;

		private ItemAttributes[] <items>5__12;

		private float <totalChange>5__13;

		private bool <anyUpgrades>5__14;

		private string <mood>5__15;

		private ItemAttributes[] <>s__16;

		private int <>s__17;

		private ItemAttributes <attr>5__18;

		private string <n>5__19;

		private int <cost>5__20;

		private bool <canAfford>5__21;

		private bool <isGunMatch>5__22;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<items>5__12 = null;
			<mood>5__15 = null;
			<>s__16 = null;
			<attr>5__18 = null;
			<n>5__19 = 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();
				<hasTracker>5__2 = false;
				<hasWeapon>5__3 = false;
				<hasBat>5__4 = false;
				<hasDrones>5__5 = false;
				<hasGrenade>5__6 = false;
				<hasCannons>5__7 = false;
				<countStamina>5__8 = 0;
				<countHealth>5__9 = 0;
				<countStrength>5__10 = 0;
				<countRange>5__11 = 0;
				<items>5__12 = Object.FindObjectsOfType<ItemAttributes>();
				<>s__16 = <items>5__12;
				for (<>s__17 = 0; <>s__17 < <>s__16.Length; <>s__17++)
				{
					<attr>5__18 = <>s__16[<>s__17];
					if (!((Object)(object)<attr>5__18 == (Object)null) && !((Object)(object)<attr>5__18.item == (Object)null))
					{
						<n>5__19 = ((Object)<attr>5__18.item).name.ToLower();
						<cost>5__20 = Traverse.Create((object)<attr>5__18).Field<int>("value").Value;
						<canAfford>5__21 = <currentWallet>5__1 >= <cost>5__20;
						if ((<n>5__19.Contains("cart cannon") || <n>5__19.Contains("cart laser")) && <canAfford>5__21)
						{
							<hasCannons>5__7 = true;
						}
						<isGunMatch>5__22 = <n>5__19.Contains("gun") || <n>5__19.Contains("tranq") || <n>5__19.Contains("shotgun") || <n>5__19.Contains("photon") || <n>5__19.Contains("blaster");
						if ((<isGunMatch>5__22 && !<n>5__19.Contains("stun")) & <canAfford>5__21)
						{
							<hasWeapon>5__3 = true;
						}
						if (<n>5__19.Contains("baseball") || (<n>5__19.Contains("hammer") & <canAfford>5__21))
						{
							<hasBat>5__4 = true;
						}
						if (<n>5__19.Contains("tracker"))
						{
							<hasTracker>5__2 = true;
						}
						if ((<n>5__19.Contains("feather") || <n>5__19.Contains("indestructible")) & <canAfford>5__21)
						{
							<hasDrones>5__5 = true;
						}
						if (<canAfford>5__21)
						{
							if (<n>5__19.Contains("strength"))
							{
								<countStrength>5__10++;
							}
							else if (<n>5__19.Contains("upgrade player health"))
							{
								<countHealth>5__9++;
							}
							else if (<n>5__19.Contains("energy"))
							{
								<countStamina>5__8++;
							}
							else if (<n>5__19.Contains("range"))
							{
								<countRange>5__11++;
							}
							if ((<n>5__19.Contains("grenade") || <n>5__19.Contains("human") || <n>5__19.Contains("mine")) && !<n>5__19.Contains("stun") && !<n>5__19.Contains("shockwave"))
							{
								<hasGrenade>5__6 = true;
							}
						}
						<n>5__19 = null;
						<attr>5__18 = null;
					}
				}
				<>s__16 = null;
				<totalChange>5__13 = 0f;
				if (<hasCannons>5__7)
				{
					<totalChange>5__13 += 15f;
				}
				if (<hasWeapon>5__3)
				{
					_foundWeaponThisLevel = true;
					_weaponlessLevels = 0;
					<totalChange>5__13 += 20f;
				}
				if (<hasBat>5__4)
				{
					_foundWeaponThisLevel = true;
					_weaponlessLevels = 0;
					<totalChange>5__13 += 8f;
				}
				if (<hasDrones>5__5)
				{
					<totalChange>5__13 += 8f;
				}
				<totalChange>5__13 += (float)<countStrength>5__10 * 5f + (float)<countHealth>5__9 * 4f + (float)<countStamina>5__8 * 3f + (float)<countRange>5__11 * 3f;
				if (!<hasCannons>5__7)
				{
					<totalChange>5__13 -= 5f;
				}
				if (!<hasWeapon>5__3)
				{
					<totalChange>5__13 -= 10f;
				}
				if (!<hasBat>5__4)
				{
					<totalChange>5__13 -= 8f;
				}
				if (!<hasDrones>5__5)
				{
					<totalChange>5__13 -= 5f;
				}
				if (<hasTracker>5__2)
				{
					<totalChange>5__13 -= 2f;
				}
				<anyUpgrades>5__14 = <countStrength>5__10 + <countHealth>5__9 + <countStamina>5__8 + <countRange>5__11 > 0;
				if (!<hasWeapon>5__3 && !<hasBat>5__4 && !<hasDrones>5__5 && !<anyUpgrades>5__14 && !<hasGrenade>5__6 && !<hasCannons>5__7)
				{
					<totalChange>5__13 -= 35f;
				}
				<mood>5__15 = ((<totalChange>5__13 > 0f) ? "Good Stock" : "Bad Stock (Unreachable)");
				ModifyLuck(<totalChange>5__13, "Shop: " + <mood>5__15);
				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__68 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		private int <totalGoal>5__1;

		private float <totalPenalty>5__2;

		private string <reason>5__3;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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;
				<totalGoal>5__1 = (int)_roundDirectorHaulGoalField.GetValue(RoundDirector.instance);
				if (<totalGoal>5__1 == 0)
				{
					return false;
				}
				<>2__current = (object)new WaitForSeconds(2f);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<>2__current = ((MonoBehaviour)Instance).StartCoroutine(RecalculateTotalMapValue());
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				if (_badModuleSpawns > 0)
				{
					<totalPenalty>5__2 = 0f;
					<reason>5__3 = "";
					if (_currentLevelIndex <= 3)
					{
						<totalPenalty>5__2 = (float)_badModuleSpawns * -5f;
						<reason>5__3 = $"Bad Gen: {_badModuleSpawns} Hard Modules";
					}
					else if (_currentLevelIndex == 4)
					{
						<totalPenalty>5__2 = (float)_badModuleSpawns * -3f;
						<reason>5__3 = $"Rough Gen: {_badModuleSpawns} Hard Modules";
					}
					else if (_currentLevelIndex == 5)
					{
						<totalPenalty>5__2 = (float)_badModuleSpawns * -1f;
						<reason>5__3 = $"Okay Gen: {_badModuleSpawns} Hard Modules";
					}
					else
					{
						<totalPenalty>5__2 = (float)_badModuleSpawns * 0.5f;
						<reason>5__3 = $"Good Gen: {_badModuleSpawns} Hard Modules";
					}
					ModifyLuck(<totalPenalty>5__2, <reason>5__3);
					<reason>5__3 = 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;

	private Rect _windowRect = new Rect((float)(Screen.width - 180), (float)(Screen.height - 100), 170f, 90f);

	private float _logTimer = 0f;

	private float _updateTimer = 0f;

	private Texture2D _lensTexture;

	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 int _levelStartTotalHaul = 0;

	private static float _initialTotalMapValue = 0f;

	private static bool IsInGameLevel = false;

	private static Level _lastLevel;

	private float _lastTextureUpdate;

	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 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;

	private static bool _hiddenRescueTriggered = false;

	private void Awake()
	{
		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.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_005e: Unknown result type (might be due to invalid IL or missing references)
		if (!IsInGameLevel)
		{
			_levelLuck = Mathf.Lerp(_levelLuck, 50f, Time.deltaTime * 2f);
			return;
		}
		if (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] Status - Level: {_currentLevelIndex}, Overall: {_overallLuck}%, Current: {_levelLuck}%");
		}
		_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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: 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_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: 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_00a0: Expected O, but got Unknown
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: 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_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Expected O, but got Unknown
		//IL_01b9: 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)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		if (IsInGameLevel && !((Object)(object)_lensTexture == (Object)null))
		{
			int num = 500;
			int num2 = 220;
			float num3 = (Screen.width - num) / 2;
			float num4 = Screen.height - num2 - 20;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(num3, num4, (float)num, (float)num2);
			GUI.DrawTexture(val, (Texture)(object)_lensTexture);
			GUILayout.BeginArea(val);
			Color luckColor = GetLuckColor(_levelLuck);
			GUIStyle val2 = new GUIStyle(GUI.skin.label)
			{
				fontSize = 90,
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)1
			};
			string text = $"{Mathf.RoundToInt(_levelLuck)}%";
			val2.normal.textColor = new Color(0f, 0f, 0f, 0.8f);
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(2f, 22f, (float)num, 100f);
			GUI.Label(val3, text, val2);
			val2.normal.textColor = luckColor * 0.4f;
			Rect val4 = default(Rect);
			((Rect)(ref val4))..ctor(0f, 21f, (float)num, 100f);
			GUI.Label(val4, text, val2);
			val2.normal.textColor = luckColor;
			GUILayout.Space(20f);
			GUILayout.Label(text, val2, Array.Empty<GUILayoutOption>());
			GUIStyle val5 = new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)4,
				fontSize = 16,
				fontStyle = (FontStyle)1
			};
			string text2 = $"OVERALL: {Mathf.RoundToInt(_overallLuck)}%";
			val5.normal.textColor = Color.black;
			GUILayout.Space(-14f);
			Rect val6 = default(Rect);
			((Rect)(ref val6))..ctor(1f, 116f, (float)num, 20f);
			GUI.Label(val6, text2, val5);
			val5.normal.textColor = new Color(luckColor.r, luckColor.g, luckColor.b, 0.9f);
			GUILayout.Label(text2, val5, Array.Empty<GUILayoutOption>());
			GUILayout.EndArea();
		}
	}

	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;
		Log.LogInfo((object)$"[Luck] Modified: {amount} ({reason}). Level Luck: {Instance._levelLuck}%");
	}

	[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 (IsInGameLevel)
		{
			_totalLuckSum += Instance._levelLuck;
			_completedLevelsCount++;
			if (_completedLevelsCount > 0)
			{
				Instance._overallLuck = _totalLuckSum / (float)_completedLevelsCount;
			}
			Log.LogInfo((object)$"[Luck] Round Recorded. Final Level Luck: {Instance._levelLuck}%. New Overall Average: {Instance._overallLuck}% ({_completedLevelsCount} rounds)");
		}
		_lastLevel = levelCurrent;
		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;
			Log.LogInfo((object)"[Luck] Entered Menu/Lobby - Tracking Paused.");
			return;
		}
		IsInGameLevel = true;
		_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;
		Log.LogInfo((object)$"[Luck] New Level/Shop Started. Index: {_currentLevelIndex}. Level Luck Reset to 50%.");
		string text = levelCurrent.NarrativeName?.ToLower() ?? "";
		string text2 = ((Object)levelCurrent).name?.ToLower() ?? "";
		string text3 = text + " " + text2;
		_isHeadmanManor = text3.Contains("manor");
		if (_isHeadmanManor)
		{
			ModifyLuck(-5f, "Map: Headman Manor");
		}
		else if (text3.Contains("museum") || text3.Contains("wizard"))
		{
			ModifyLuck(15f, "Map: Open Layout");
		}
		int num = RunManager.instance.CalculateMoonLevel(_currentLevelIndex);
		if (num > 0)
		{
			List<string> list = RunManager.instance.MoonGetAttributes(num);
			if (list != null && list.Any((string a) => a.ToLower().Contains("overcharge")) && SemiFunc.PlayerGetList().Count == 1)
			{
				ModifyLuck(-2f, "Moon: Overcharge Solo!");
			}
		}
	}

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

	[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);
				string value2 = Traverse.Create((object)__instance).Field<string>("playerName").Value;
				ModifyLuck(-20f, "Player Died: " + value2);
			}
		}
	}

	[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);
				string value2 = Traverse.Create((object)__instance).Field<string>("playerName").Value;
				ModifyLuck(20f, "Player Revived: " + value2);
			}
		}
	}

	[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 ((Object)(object)value != (Object)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;
		bool flag = false;
		if ((Object)(object)value != (Object)null && value.grabbedLocal)
		{
			flag = true;
		}
		if ((Object)(object)value2 != (Object)null)
		{
			PlayerAvatar component = ((Component)value2).GetComponent<PlayerAvatar>();
			if ((Object)(object)component != (Object)null && Traverse.Create((object)component).Field<bool>("isLocal").Value)
			{
				flag = true;
			}
		}
		if (flag)
		{
			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 ((Object)(object)value != (Object)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 ((Object)(object)value != (Object)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 ((Object)(object)value != (Object)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 ((Object)(object)value != (Object)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,
				WasDestroyed = false
			});
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(PhysGrabObject), "DestroyPhysGrabObject")]
	private static void PhysGrabObject_DestroyPhysGrabObject_Prefix(PhysGrabObject __instance)
	{
		if (!IsInGameLevel || (Object)(object)__instance == (Object)null)
		{
			return;
		}
		string text = ((Object)((Component)__instance).gameObject).name.ToLower();
		if (text.Contains("cart"))
		{
			ModifyLuck(-15f, "Broke the Cart!");
		}
		ItemAttributes component = ((Component)__instance).GetComponent<ItemAttributes>();
		if ((Object)(object)component != (Object)null)
		{
			if (text.Contains("gun"))
			{
				ModifyLuck(-10f, "Destroyed Weapon!");
			}
			else if (text.Contains("feather") || 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);
		string text2 = ((Object)((Component)trackedValuable.Valuable).gameObject).name.ToLower();
		List<GameObject> list = RoundDirector.instance?.dollarHaulList;
		if (list == null || !list.Contains(((Component)trackedValuable.Valuable).gameObject))
		{
			_itemDestroyedThisLevel = true;
			if (text2.Contains("enemy valuable"))
			{
				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;
				}
				string text3 = ((num2 < 1f) ? num2.ToString("F2") : Mathf.RoundToInt(num2).ToString());
				ModifyLuck(num3, "Item Destroyed (-" + text3 + "% 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__68))]
	private static IEnumerator WaitForQuotaAndAnalyze()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WaitForQuotaAndAnalyze>d__68(0);
	}

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

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

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

	[HarmonyPostfix]
	[HarmonyPatch(typeof(EnemyParent), "Despawn")]
	private static void EnemyParent_Despawn_Postfix(EnemyParent __instance)
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		if (!IsInGameLevel || (Object)(object)__instance == (Object)null)
		{
			return;
		}
		string text = ((Object)((Component)__instance).gameObject).name.ToLower();
		if (text.Contains("valuable thrower") && ((Component)__instance).transform.position.y < -2.5f)
		{
			ModifyLuck(5f, "Big Brain: Baited the Rugrat!");
		}
		int enemyHealthCurrent = GetEnemyHealthCurrent(__instance);
		if (enemyHealthCurrent > 0)
		{
			return;
		}
		ExtractionPoint[] array = Object.FindObjectsOfType<ExtractionPoint>();
		ExtractionPoint[] array2 = array;
		foreach (ExtractionPoint val in array2)
		{
			if (!((Object)(object)val == (Object)null))
			{
				float num = Vector3.Distance(((Component)__instance).transform.position, ((Component)val).transform.position);
				if (num <= 0.5f)
				{
					ModifyLuck(10f, "Safety Kill (Extraction)!");
					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 < 2 && (text.Contains("runner") || text.Contains("bomb thrower") || 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!");
			}
			else
			{
				switch (num)
				{
				case 2:
					ModifyLuck(-7.5f, "Panic Room: Double Duck Trouble");
					break;
				case 1:
					ModifyLuck(-5f, "Panic Room (Projectiles!)");
					break;
				}
			}
		}
		bool flag = _activeEnemies.Any((string e) => e.Contains("animal") || e.Contains("upscream") || e.Contains("child"));
		if (_activeEnemies.Contains("upscream") && flag)
		{
			ModifyLuck(-15f, "The Juggle (Stun Locked!)");
		}
		if (_activeEnemies.Contains("gnome") && _activeEnemies.Contains("valuable thrower"))
		{
			ModifyLuck(-10f, "Loot Shredders!");
		}
		if (text.Contains("bowtie") && _activeEnemies.Contains("hidden"))
		{
			ModifyLuck(-5f, "Hated Combo: Invisible Bomber!");
		}
		if (text.Contains("shadow") && _activeEnemies.Count((string e) => e.Contains("shadow")) >= 1)
		{
			ModifyLuck(-5f, "Hated Combo: Double Shadow!");
		}
		if (text.Contains("hunter") && _activeEnemies.Contains("hidden"))
		{
			ModifyLuck(-5f, "Hated Combo: Hunter Ambush!");
		}
		if (text.Contains("bowtie") && _activeEnemies.Contains("animal"))
		{
			ModifyLuck(-5f, "Hated Combo: Bodyguards!");
		}
		if (text.Contains("gnome") && _activeEnemies.Contains("gnome"))
		{
			ModifyLuck(-5f, "Hated Combo: Gnome Swarm!");
		}
		if (text.Contains("shadow") && _activeEnemies.Contains("hidden"))
		{
			ModifyLuck(-5f, "Hated Combo: Silent Stalker!");
		}
		if (text.Contains("hunter") && _activeEnemies.Contains("upscream"))
		{
			ModifyLuck(-5f, "Hated Combo: Screaming Target!");
		}
		if (text.Contains("shadow") && _activeEnemies.Contains("eye"))
		{
			ModifyLuck(-5f, "Hated Combo: Eye Contact Hell!");
		}
		if (_currentLevelIndex < 2)
		{
			int num2 = _activeEnemies.Count((string e) => e.Contains("runner") || e.Contains("tumbler") || e.Contains("robe"));
			if (num2 >= 2)
			{
				ModifyLuck(-5f, "Hated Combo: Early Mob!");
			}
		}
		_activeEnemies.Add(text);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ValuableObject), "DollarValueSetLogic")]
	private static void ValuableObject_ValueSet_Postfix(ValuableObject __instance)
	{
		if (IsInGameLevel && !((Object)(object)__instance == (Object)null))
		{
			float num = (float)_dollarValueField.GetValue(__instance);
			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") || text.Contains("server rack") || text.Contains("tall guy") || text.Contains("milk") || text.Contains("vinyl") || text.Contains("golden swirl") || text.Contains("gem burger"))
			{
				ModifyLuck(4f, "Found Grail!");
			}
			else if (text.Contains("animal crate") || text.Contains("vase big") || text.Contains("piano") || text.Contains("diamond display") || text.Contains("dinosaur") || text.Contains("alchemy station") || text.Contains("phone") || text.Contains("fan") || text.Contains("ice saw") || text.Contains("sample cooler") || text.Contains("orpigox") || text.Contains("crystal ball") || text.Contains("master potion") || text.Contains("cauldron box") || text.Contains("goblin head") || text.Contains("chomp book") || text.Contains("flamethrower") || text.Contains("boombox") || text.Contains("baby head") || text.Contains("cubic sculpture") || text.Contains("tray") || text.Contains("gumball") || text.Contains("egg") || text.Contains("pacifier") || text.Contains("scream doll") || text.Contains("music box"))
			{
				ModifyLuck(-3f, "Bad Loot!");
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlayerHealth), "Hurt")]
	private static void PlayerHealth_Hurt_Postfix(PlayerHealth __instance, int damage, bool savingGrace, int enemyIndex)
	{
		if (!IsInGameLevel || (Object)(object)__instance == (Object)null)
		{
			return;
		}
		PlayerAvatar component = ((Component)__instance).GetComponent<PlayerAvatar>();
		if (!((Object)(object)component == (Object)null) && (bool)_playerIsLocalField.GetValue(component))
		{
			bool flag = false;
			if (enemyIndex != -1 && (Object)(object)SemiFunc.EnemyGetFromIndex(enemyIndex) != (Object)null)
			{
				flag = true;
			}
			if (!flag)
			{
				int value = Traverse.Create((object)__instance).Field<int>("maxHealth").Value;
				float num = ((value > 0) ? ((float)value) : 100f);
				float num2 = (float)damage / num * 100f;
				float amount = 0f - num2 / 2f;
				string reason = $"Blunder! {num2:F0}% HP Damage";
				ModifyLuck(amount, reason);
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlayerHealth), "Death")]
	private static void PlayerHealth_Death_Postfix(PlayerHealth __instance)
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Expected O, but got Unknown
		if (!IsInGameLevel || (Object)(object)__instance == (Object)null)
		{
			return;
		}
		Log.LogInfo((object)"[Luck] Player Died.");
		if (_playerWasHealedByTruck)
		{
			ModifyLuck(-10f, "Saved, then Lost!");
			_playerWasHealedByTruck = false;
		}
		try
		{
			PlayerAvatar component = ((Component)__instance).GetComponent<PlayerAvatar>();
			if (!((Object)(object)component != (Object)null) || !((Object)(object)component.physGrabber != (Object)null))
			{
				return;
			}
			PhysGrabObject val = null;
			if (_grabbedPhysObjectField != null)
			{
				try
				{
					val = (PhysGrabObject)_grabbedPhysObjectField.GetValue(component.physGrabber);
				}
				catch
				{
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				ValuableObject component2 = ((Component)val).GetComponent<ValuableObject>();
				float num = (((Object)(object)component2 != (Object)null) ? ((float)_dollarValueField.GetValue(component2)) : 0f);
				if (num > 5000f)
				{
					ModifyLuck(-15f, "Died w/ High Value!");
				}
			}
		}
		catch
		{
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(TruckHealer), "Heal")]
	private static void TruckHealer_Heal_Postfix(TruckHealer __instance, PlayerAvatar _playerAvatar)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Invalid comparison between Unknown and I4
		if ((Object)(object)_playerAvatar == (Object)null || !(bool)_playerIsLocalField.GetValue(_playerAvatar))
		{
			return;
		}
		State val = (State)_truckHealerStateField.GetValue(__instance);
		if ((int)val != 2 || _truckHealAnalyzed)
		{
			return;
		}
		_truckHealAnalyzed = true;
		PlayerHealth playerHealth = _playerAvatar.playerHealth;
		if ((Object)(object)playerHealth == (Object)null)
		{
			return;
		}
		_playerWasHealedByTruck = true;
		int num = (int)_playerHealthField.GetValue(playerHealth);
		int num2 = (int)_playerMaxHealthField.GetValue(playerHealth);
		float num3 = (float)num / (float)num2 * 100f;
		float num4 = 0f;
		string text = "";
		if (num3 >= 75f)
		{
			num4 = 5f;
			text = "Healthy Extraction!";
		}
		else if (num3 >= 50f)
		{
			num4 = 2f;
			text = "Safe Extraction";
		}
		else if (num3 >= 25f)
		{
			num4 = -4f;
			text = "Rough Exit";
		}
		else
		{
			num4 = -7f;
			text = "Critical Escape";
		}
		ModifyLuck(num4, text);
		if (!SemiFunc.RunIsShop() && _initialTotalMapValue > 0f && (Object)(object)RoundDirector.instance != (Object)null)
		{
			ModifyLuck(10f, "Extraction Success!");
			int num5 = (int)_roundDirectorTotalHaulField.GetValue(RoundDirector.instance);
			int num6 = num5 - _levelStartTotalHaul;
			float num7 = _initialTotalMapValue - (float)num6;
			if (num7 < 0f)
			{
				num7 = 0f;
			}
			float num8 = num7 / _initialTotalMapValue * 100f;
			float num9 = 0f;
			num9 = ((num8 >= 90f) ? (-35f) : ((num8 >= 75f) ? (-25f) : ((num8 >= 50f) ? (-15f) : ((!(num8 >= 25f)) ? 10f : (-8f)))));
			ModifyLuck(num9, $"Loot Efficiency: {Mathf.RoundToInt(100f - num8)}% Extracted");
			if (!_itemDestroyedThisLevel && num8 < 25f)
			{
				ModifyLuck(10f, "Clean Run Bonus!");
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(EnemyHidden), "StatePlayerMove")]
	private static void EnemyHidden_StatePlayerMove_Postfix(EnemyHidden __instance)
	{
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)TruckSafetySpawnPoint.instance == (Object)null || (Object)(object)RoundDirector.instance == (Object)null)
		{
			return;
		}
		bool flag = false;
		try
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(RoundDirector), "allExtractionPointsCompleted");
			if (fieldInfo != null)
			{
				flag = (bool)fieldInfo.GetValue(RoundDirector.instance);
			}
		}
		catch
		{
		}
		if (flag && !_hiddenRescueTriggered)
		{
			float num = Vector3.Distance(((Component)__instance).transform.position, ((Component)TruckSafetySpawnPoint.instance).transform.position);
			if (num < 10f)
			{
				_hiddenRescueTriggered = true;
				ModifyLuck(25f, "Hidden Monster Rescue!");
			}
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(TruckScreenText), "CheckTextMeshLines")]
	private static bool PreventLuckFromScrolling(TruckScreenText __instance)
	{
		if (((TMP_Text)__instance.textMesh).text.Contains("FINAL LUCK"))
		{
			if (((TMP_Text)__instance.textMesh).textInfo.lineCount > 22)
			{
				return true;
			}
			return false;
		}
		return true;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(TruckScreenText), "NextLineLogic")]
	private static void InjectLuckIntoData(TruckScreenText __instance)
	{
		if (!((Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelArena) && Traverse.Create((object)__instance).Field("currentPageIndex").GetValue<int>() == 0)
		{
			float overallLuck = Instance._overallLuck;
			int num = Mathf.RoundToInt(overallLuck);
			string text = "#ffffff";
			text = ((overallLuck <= 25f) ? "#ff3333" : ((overallLuck <= 50f) ? "#ff9933" : ((!(overallLuck <= 75f)) ? "#33ff33" : "#ffff33")));
			string text2 = $"FINAL LUCK: <color={text}>{num}%</color>\n";
			if (!((TMP_Text)__instance.textMesh).text.Contains("FINAL LUCK"))
			{
				((TMP_Text)__instance.textMesh).text = text2 + ((TMP_Text)__instance.textMesh).text;
			}
		}
	}
}