Decompiled source of LethalClawMachine v1.0.0

BepInEx\plugins\LethalClawMachine\LethalClawMachine.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalClawMachine.Integration;
using LethalClawMachine.Machine;
using LethalClawMachine.Physics;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalClawMachine")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalClawMachine")]
[assembly: AssemblyTitle("LethalClawMachine")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalClawMachine
{
	public enum ClawTier
	{
		Low,
		Medium,
		High
	}
	public struct ClawTierSettings
	{
		public ClawTier Tier;

		public string DisplayName;

		public string Subtitle;

		public int PlayCost;

		public int MinPrizeValue;

		public int MaxPrizeValue;

		public float BaseGripStrength;

		public float BaseSlipChance;

		public float ClawSpeed;

		public float DropSpeed;

		public float AimTimeLimit;

		public float ProngReachBonus;

		public Color PrimaryColor;

		public Color GlowColor;
	}
	public static class ClawConfig
	{
		public static ConfigEntry<float> SpawnPosX;

		public static ConfigEntry<float> SpawnPosY;

		public static ConfigEntry<float> SpawnPosZ;

		public static ConfigEntry<float> SpawnRotationY;

		public static ConfigEntry<float> MachineSpacing;

		public static ConfigEntry<bool> SnapToGround;

		public static ConfigEntry<bool> SpawnWithoutLethalCasino;

		public static ConfigEntry<int> LowCost;

		public static ConfigEntry<int> LowMinPrize;

		public static ConfigEntry<int> LowMaxPrize;

		public static ConfigEntry<float> LowGripStrength;

		public static ConfigEntry<float> LowSlipChance;

		public static ConfigEntry<int> MediumCost;

		public static ConfigEntry<int> MediumMinPrize;

		public static ConfigEntry<int> MediumMaxPrize;

		public static ConfigEntry<float> MediumGripStrength;

		public static ConfigEntry<float> MediumSlipChance;

		public static ConfigEntry<int> HighCost;

		public static ConfigEntry<int> HighMinPrize;

		public static ConfigEntry<int> HighMaxPrize;

		public static ConfigEntry<float> HighGripStrength;

		public static ConfigEntry<float> HighSlipChance;

		public static ConfigEntry<bool> EnableLuckyPipeIntegration;

		public static ConfigEntry<float> LuckyPipeGripBonus;

		public static ConfigEntry<float> LuckyPipeSlipReduction;

		public static ConfigEntry<float> LuckyPipeValueMultiplier;

		public static ConfigEntry<float> LuckyPipeMagnetAssist;

		public static ConfigEntry<int> PrizesPerMachine;

		public static ConfigEntry<bool> FreePlayMode;

		public static ConfigEntry<bool> AllowCreditsFallback;

		public static ConfigEntry<float> SoundVolume;

		public static void Bind(ConfigFile config)
		{
			SpawnPosX = config.Bind<float>("Placement", "SpawnPosX", -26.5f, "Center X coordinate on Gordion (Company moon) for the 3 claw machines.");
			SpawnPosY = config.Bind<float>("Placement", "SpawnPosY", -2.53f, "Center Y coordinate on Gordion (Company moon). Automatically snapped to floor if SnapToGround is true.");
			SpawnPosZ = config.Bind<float>("Placement", "SpawnPosZ", 16.15f, "Center Z coordinate on Gordion (Company moon), right next to the Roulette table inside LethalCasino.");
			SpawnRotationY = config.Bind<float>("Placement", "SpawnRotationY", 270f, "Y rotation (degrees) for the row of claw machines. 270 faces +X into the casino room.");
			MachineSpacing = config.Bind<float>("Placement", "MachineSpacing", 1.52f, "Distance in meters between adjacent claw machines.");
			SnapToGround = config.Bind<bool>("Placement", "SnapToGround", true, "Raycast downward on spawn to sit each claw machine flush on the ground.");
			SpawnWithoutLethalCasino = config.Bind<bool>("Placement", "SpawnWithoutLethalCasino", true, "Spawn the claw machines on the Company moon even if LethalCasino is not installed.");
			LowCost = config.Bind<int>("Tier_Low", "PlayCost", 25, "Loot value required to play the Low-Tier (Easy) claw machine.");
			LowMinPrize = config.Bind<int>("Tier_Low", "MinPrizeValue", 38, "Minimum scrap value of prizes inside the Low-Tier claw machine.");
			LowMaxPrize = config.Bind<int>("Tier_Low", "MaxPrizeValue", 90, "Maximum scrap value of prizes inside the Low-Tier claw machine.");
			LowGripStrength = config.Bind<float>("Tier_Low", "BaseGripStrength", 0.88f, "Base claw grip strength (0.0 - 1.0) for the Low-Tier machine. Higher = easier to win.");
			LowSlipChance = config.Bind<float>("Tier_Low", "BaseSlipChance", 0.08f, "Base probability (0.0 - 1.0) that a grabbed prize slips on the Low-Tier machine.");
			MediumCost = config.Bind<int>("Tier_Medium", "PlayCost", 60, "Loot value required to play the Medium-Tier (Standard) claw machine.");
			MediumMinPrize = config.Bind<int>("Tier_Medium", "MinPrizeValue", 95, "Minimum scrap value of prizes inside the Medium-Tier claw machine.");
			MediumMaxPrize = config.Bind<int>("Tier_Medium", "MaxPrizeValue", 180, "Maximum scrap value of prizes inside the Medium-Tier claw machine.");
			MediumGripStrength = config.Bind<float>("Tier_Medium", "BaseGripStrength", 0.5f, "Base claw grip strength (0.0 - 1.0) for the Medium-Tier machine.");
			MediumSlipChance = config.Bind<float>("Tier_Medium", "BaseSlipChance", 0.6f, "Base probability (0.0 - 1.0) that a grabbed prize slips on the Medium-Tier machine.");
			HighCost = config.Bind<int>("Tier_High", "PlayCost", 130, "Loot value required to play the High-Tier (Jackpot) claw machine.");
			HighMinPrize = config.Bind<int>("Tier_High", "MinPrizeValue", 230, "Minimum scrap value of prizes inside the High-Tier claw machine.");
			HighMaxPrize = config.Bind<int>("Tier_High", "MaxPrizeValue", 450, "Maximum scrap value of prizes inside the High-Tier claw machine.");
			HighGripStrength = config.Bind<float>("Tier_High", "BaseGripStrength", 0.34f, "Base claw grip strength (0.0 - 1.0) for the High-Tier machine. Tough without Lucky Pipe!");
			HighSlipChance = config.Bind<float>("Tier_High", "BaseSlipChance", 0.65f, "Base probability (0.0 - 1.0) that a grabbed prize slips on the High-Tier machine.");
			EnableLuckyPipeIntegration = config.Bind<bool>("LuckyPipe", "EnableLuckyPipeIntegration", true, "Read the player's Lucky Pipe luckiness stat from LethalCasino and apply it to claw grip, slip resistance, centering assist, and prize value.");
			LuckyPipeGripBonus = config.Bind<float>("LuckyPipe", "MaxGripBonus", 0.3f, "Extra grip strength added at 100% Lucky Pipe luckiness.");
			LuckyPipeSlipReduction = config.Bind<float>("LuckyPipe", "MaxSlipReduction", 0.48f, "Fraction of slip chance removed at 100% Lucky Pipe luckiness (0.48 = 48% less slipping).");
			LuckyPipeValueMultiplier = config.Bind<float>("LuckyPipe", "MaxPrizeValueBonus", 0.35f, "Bonus multiplier applied to won prize scrap value at 100% Lucky Pipe luckiness (0.35 = +35% value).");
			LuckyPipeMagnetAssist = config.Bind<float>("LuckyPipe", "MaxMagnetAssist", 0.035f, "Extra magnetic centering assist radius (in meters) when closing the claw at 100% Lucky Pipe luckiness.");
			PrizesPerMachine = config.Bind<int>("Gameplay", "PrizesPerMachine", 12, "Number of physical scrap prizes stocked inside each claw machine.");
			FreePlayMode = config.Bind<bool>("Gameplay", "FreePlayMode", false, "If true, players can play all claw machines for free without holding any loot. Default false: spend held scrap loot value to win higher-value scrap.");
			AllowCreditsFallback = config.Bind<bool>("Gameplay", "AllowCreditsFallback", false, "If true and the player is not holding scrap, allow spending Terminal credits instead of scrap loot value.");
			SoundVolume = config.Bind<float>("Gameplay", "SoundVolume", 0.65f, "Volume multiplier (0.0 - 1.0) for claw machine arcade sound effects.");
		}

		public static ClawTierSettings GetTierSettings(ClawTier tier)
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			return tier switch
			{
				ClawTier.Low => new ClawTierSettings
				{
					Tier = ClawTier.Low,
					DisplayName = "EASY GRAB",
					Subtitle = "LOW STAKES",
					PlayCost = Mathf.Max(1, LowCost.Value),
					MinPrizeValue = Mathf.Max(5, LowMinPrize.Value),
					MaxPrizeValue = Mathf.Max(10, LowMaxPrize.Value),
					BaseGripStrength = Mathf.Clamp01(LowGripStrength.Value),
					BaseSlipChance = Mathf.Clamp01(LowSlipChance.Value),
					ClawSpeed = 0.72f,
					DropSpeed = 0.75f,
					AimTimeLimit = 24f,
					ProngReachBonus = 0.025f,
					PrimaryColor = new Color(0.1f, 0.45f, 0.32f),
					GlowColor = new Color(0.15f, 1f, 0.58f)
				}, 
				ClawTier.Medium => new ClawTierSettings
				{
					Tier = ClawTier.Medium,
					DisplayName = "STANDARD CLAW",
					Subtitle = "MID STAKES",
					PlayCost = Mathf.Max(1, MediumCost.Value),
					MinPrizeValue = Mathf.Max(10, MediumMinPrize.Value),
					MaxPrizeValue = Mathf.Max(20, MediumMaxPrize.Value),
					BaseGripStrength = Mathf.Clamp01(MediumGripStrength.Value),
					BaseSlipChance = Mathf.Clamp01(MediumSlipChance.Value),
					ClawSpeed = 0.85f,
					DropSpeed = 0.85f,
					AimTimeLimit = 20f,
					ProngReachBonus = 0.01f,
					PrimaryColor = new Color(0.55f, 0.36f, 0.08f),
					GlowColor = new Color(1f, 0.76f, 0.14f)
				}, 
				_ => new ClawTierSettings
				{
					Tier = ClawTier.High,
					DisplayName = "JACKPOT CLAW",
					Subtitle = "HIGH STAKES",
					PlayCost = Mathf.Max(1, HighCost.Value),
					MinPrizeValue = Mathf.Max(20, HighMinPrize.Value),
					MaxPrizeValue = Mathf.Max(40, HighMaxPrize.Value),
					BaseGripStrength = Mathf.Clamp01(HighGripStrength.Value),
					BaseSlipChance = Mathf.Clamp01(HighSlipChance.Value),
					ClawSpeed = 0.9f,
					DropSpeed = 0.82f,
					AimTimeLimit = 18f,
					ProngReachBonus = 0.02f,
					PrimaryColor = new Color(0.52f, 0.07f, 0.25f),
					GlowColor = new Color(1f, 0.18f, 0.52f)
				}, 
			};
		}
	}
	[BepInPlugin("LethalClawMachine", "LethalClawMachine", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "LethalClawMachine";

		public const string PluginName = "LethalClawMachine";

		public const string PluginVersion = "1.0.0";

		private static Harmony _harmony;

		public static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ClawConfig.Bind(((BaseUnityPlugin)this).Config);
			_harmony = new Harmony("LethalClawMachine");
			_harmony.PatchAll(typeof(Plugin).Assembly);
			LethalCasinoBridge.EnsureInitialized();
			Log.LogInfo((object)"LethalClawMachine v1.0.0 loaded! 3 Claw Machines will spawn inside LethalCasino on Gordion.");
		}
	}
}
namespace LethalClawMachine.Physics
{
	public enum ClawState
	{
		Idle,
		Aiming,
		Descending,
		Closing,
		Lifting,
		ReturningToChute,
		Releasing,
		Resetting
	}
	public class ClawAssembly : MonoBehaviour
	{
		public const float MinX = -0.54f;

		public const float MaxX = 0.54f;

		public const float MinZ = -0.44f;

		public const float MaxZ = 0.44f;

		public static readonly Vector2 ChuteTargetXZ = new Vector2(-0.44f, -0.34f);

		public static readonly Vector2 HomeXZ = new Vector2(0.05f, 0f);

		public const float TopCableLength = 0.14f;

		public const float MaxCableLength = 0.84f;

		public Transform RailZ;

		public Transform CarriageX;

		public Transform CableVisual;

		public Transform ClawHub;

		public Transform[] ProngPivots;

		public Collider[] ProngColliders;

		public Transform GrabCenterPoint;

		private ClawTierSettings _tier;

		private float _activeLuckiness;

		private float _gantryX;

		private float _gantryZ;

		private float _cableLength = 0.14f;

		private float _currentProngAngle = 15f;

		private float _stateTimer;

		private Vector3 _swayAngles;

		private Vector3 _swayVelocity;

		private Vector2 _lastGantryXZ;

		private float _grabCenterAccuracy;

		private bool _checkedLiftSlip;

		private bool _checkedReturnSlip;

		private float _returnSlipProgressTrigger;

		private Vector2 _returnStartXZ;

		private Vector3 _grabbedLocalOffset;

		private float _activeEffectiveGrip;

		private float _snagGraceTimer;

		public ClawState State { get; private set; }

		public ClawPrizeItem GrabbedPrize { get; private set; }

		public Vector2 CurrentXZ => new Vector2(_gantryX, _gantryZ);

		public float CurrentCableLength => _cableLength;

		public float ProngOpenAngle => _currentProngAngle;

		public event Action<ClawState> OnStateChanged;

		public event Action<ClawPrizeItem> OnPrizeGrabbed;

		public event Action<ClawPrizeItem> OnPrizeSlipped;

		public event Action OnCycleFinished;

		public void Configure(ClawTierSettings tier)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			_tier = tier;
			_gantryX = HomeXZ.x;
			_gantryZ = HomeXZ.y;
			_lastGantryXZ = HomeXZ;
			_cableLength = 0.14f;
			_currentProngAngle = 15f;
			ApplyTransforms();
		}

		public void BeginAiming(float playerLuckiness)
		{
			_activeLuckiness = Mathf.Clamp01(playerLuckiness);
			GrabbedPrize = null;
			_checkedLiftSlip = false;
			_checkedReturnSlip = false;
			SetState(ClawState.Aiming);
		}

		public void TriggerDrop()
		{
			if (State == ClawState.Aiming)
			{
				SetState(ClawState.Descending);
			}
		}

		public void MoveGantry(Vector2 inputXZ, float dt)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (State == ClawState.Aiming)
			{
				float clawSpeed = _tier.ClawSpeed;
				_gantryX = Mathf.Clamp(_gantryX + inputXZ.x * clawSpeed * dt, -0.54f, 0.54f);
				_gantryZ = Mathf.Clamp(_gantryZ + inputXZ.y * clawSpeed * dt, -0.44f, 0.44f);
			}
		}

		public void ApplyNetworkMirror(float x, float z, float cableLen, float prongAngle, ClawState remoteState)
		{
			_gantryX = Mathf.Lerp(_gantryX, x, Time.deltaTime * 14f);
			_gantryZ = Mathf.Lerp(_gantryZ, z, Time.deltaTime * 14f);
			_cableLength = Mathf.Lerp(_cableLength, cableLen, Time.deltaTime * 14f);
			_currentProngAngle = Mathf.Lerp(_currentProngAngle, prongAngle, Time.deltaTime * 14f);
			State = remoteState;
			ApplyTransforms();
		}

		private void SetState(ClawState newState)
		{
			State = newState;
			_stateTimer = 0f;
			bool enabled = newState != ClawState.Closing;
			if (ProngColliders != null)
			{
				for (int i = 0; i < ProngColliders.Length; i++)
				{
					if ((Object)(object)ProngColliders[i] != (Object)null)
					{
						ProngColliders[i].enabled = enabled;
					}
				}
			}
			this.OnStateChanged?.Invoke(newState);
		}

		private void Update()
		{
			float deltaTime = Time.deltaTime;
			_stateTimer += deltaTime;
			switch (State)
			{
			case ClawState.Idle:
				_currentProngAngle = Mathf.MoveTowards(_currentProngAngle, 16f, deltaTime * 60f);
				break;
			case ClawState.Aiming:
				_currentProngAngle = Mathf.MoveTowards(_currentProngAngle, 36f, deltaTime * 80f);
				break;
			case ClawState.Descending:
				UpdateDescending(deltaTime);
				break;
			case ClawState.Closing:
				UpdateClosing(deltaTime);
				break;
			case ClawState.Lifting:
				UpdateLifting(deltaTime);
				break;
			case ClawState.ReturningToChute:
				UpdateReturning(deltaTime);
				break;
			case ClawState.Releasing:
				UpdateReleasing(deltaTime);
				break;
			case ClawState.Resetting:
				UpdateResetting(deltaTime);
				break;
			}
			UpdatePendulumSway(deltaTime);
			ApplyTransforms();
		}

		private void FixedUpdate()
		{
			UpdateGrabbedPrizePhysics(Time.fixedDeltaTime);
		}

		private void UpdateDescending(float dt)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			_currentProngAngle = Mathf.MoveTowards(_currentProngAngle, 52f, dt * 110f);
			_cableLength += _tier.DropSpeed * dt;
			bool flag = false;
			if (_cableLength > 0.35f && (Object)(object)GrabCenterPoint != (Object)null)
			{
				Collider[] array = Physics.OverlapSphere(GrabCenterPoint.position + Vector3.down * 0.02f, 0.045f);
				for (int i = 0; i < array.Length; i++)
				{
					if ((Object)(object)((Component)array[i]).GetComponentInParent<ClawPrizeItem>() != (Object)null)
					{
						flag = true;
						break;
					}
				}
			}
			if (flag || _cableLength >= 0.84f)
			{
				_cableLength = Mathf.Min(_cableLength, 0.84f);
				SetState(ClawState.Closing);
			}
		}

		private void UpdateClosing(float dt)
		{
			_currentProngAngle = Mathf.MoveTowards(_currentProngAngle, 6f, dt * 95f);
			if (_stateTimer >= 0.55f)
			{
				AttemptGrabPrize();
				_checkedLiftSlip = false;
				SetState(ClawState.Lifting);
			}
		}

		private void AttemptGrabPrize()
		{
			//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_004a: Unknown result type (might be due to invalid IL or missing references)
			//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_0055: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00a6: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GrabCenterPoint == (Object)null)
			{
				return;
			}
			float num = _activeLuckiness * ClawConfig.LuckyPipeMagnetAssist.Value;
			float num2 = 0.145f + _tier.ProngReachBonus + num;
			Vector3 val = GrabCenterPoint.position + Vector3.up * 0.03f;
			Collider[] array = Physics.OverlapSphere(val, num2);
			ClawPrizeItem clawPrizeItem = null;
			float num3 = float.MaxValue;
			for (int i = 0; i < array.Length; i++)
			{
				ClawPrizeItem componentInParent = ((Component)array[i]).GetComponentInParent<ClawPrizeItem>();
				if (!((Object)(object)componentInParent == (Object)null) && !componentInParent.HasScored)
				{
					Vector3 val2 = array[i].ClosestPoint(val);
					Vector3 val3 = ((Component)this).transform.InverseTransformPoint(val);
					Vector3 val4 = ((Component)this).transform.InverseTransformPoint(val2);
					float num4 = Vector2.Distance(new Vector2(val3.x, val3.z), new Vector2(val4.x, val4.z));
					float num5 = Mathf.Abs(val3.y - val4.y);
					float num6 = num4 + num5 * 0.35f;
					if (num6 < num3)
					{
						num3 = num6;
						clawPrizeItem = componentInParent;
					}
				}
			}
			if ((Object)(object)clawPrizeItem != (Object)null)
			{
				_grabCenterAccuracy = Mathf.Clamp01(1f - num3 / Mathf.Max(0.08f, num2 + 0.04f));
				float num7 = Mathf.Lerp(-0.08f, 0.14f, clawPrizeItem.NormalizedWeight);
				float num8 = Mathf.Clamp01(_tier.BaseGripStrength - num7 + _activeLuckiness * ClawConfig.LuckyPipeGripBonus.Value);
				float num9 = Mathf.Clamp01(0.68f + _grabCenterAccuracy * 0.26f + num8 * 0.12f);
				if (Random.value <= num9)
				{
					GrabbedPrize = clawPrizeItem;
					GrabbedPrize.IsGripped = true;
					_activeEffectiveGrip = num8;
					_snagGraceTimer = 0.45f;
					GrabbedPrize.Body.isKinematic = false;
					SetProngCollisionIgnored(GrabbedPrize, ignore: true);
					Vector3 val5 = GrabCenterPoint.InverseTransformPoint(((Component)GrabbedPrize).transform.position);
					_grabbedLocalOffset = Vector3.Lerp(val5, new Vector3(0f, -0.02f, 0f), 0.65f + _activeLuckiness * 0.25f);
					this.OnPrizeGrabbed?.Invoke(GrabbedPrize);
				}
				else
				{
					clawPrizeItem.Body.AddForce(new Vector3(Random.Range(-0.9f, 0.9f), 0.7f, Random.Range(-0.9f, 0.9f)), (ForceMode)1);
				}
			}
		}

		private void UpdateLifting(float dt)
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			float num = (((Object)(object)GrabbedPrize != (Object)null) ? (_tier.DropSpeed * 0.72f) : (_tier.DropSpeed * 1.05f));
			_cableLength = Mathf.MoveTowards(_cableLength, 0.14f, num * dt);
			if ((Object)(object)GrabbedPrize != (Object)null && !_checkedLiftSlip && _cableLength < 0.5208f)
			{
				_checkedLiftSlip = true;
				if (ShouldPrizeSlip(0.55f))
				{
					DropGrabbedPrizeMidAir();
				}
			}
			if (_cableLength <= 0.145f)
			{
				_cableLength = 0.14f;
				_returnStartXZ = new Vector2(_gantryX, _gantryZ);
				_checkedReturnSlip = false;
				_returnSlipProgressTrigger = Random.Range(0.28f, 0.72f);
				SetState(ClawState.ReturningToChute);
			}
		}

		private void UpdateReturning(float dt)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0032: 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_00b6: 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)
			//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_0070: 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)
			float num = _tier.ClawSpeed * 0.78f;
			Vector2 val = Vector2.MoveTowards(new Vector2(_gantryX, _gantryZ), ChuteTargetXZ, num * dt);
			_gantryX = val.x;
			_gantryZ = val.y;
			if ((Object)(object)GrabbedPrize != (Object)null && !_checkedReturnSlip)
			{
				float num2 = Vector2.Distance(_returnStartXZ, ChuteTargetXZ);
				float num3 = Vector2.Distance(val, ChuteTargetXZ);
				if (((num2 > 0.05f) ? (1f - num3 / num2) : 1f) >= _returnSlipProgressTrigger)
				{
					_checkedReturnSlip = true;
					if (ShouldPrizeSlip(0.45f))
					{
						DropGrabbedPrizeMidAir();
					}
				}
			}
			if (Vector2.Distance(val, ChuteTargetXZ) < 0.01f)
			{
				_gantryX = ChuteTargetXZ.x;
				_gantryZ = ChuteTargetXZ.y;
				SetState(ClawState.Releasing);
			}
		}

		private bool ShouldPrizeSlip(float phaseWeight)
		{
			float num = (((Object)(object)GrabbedPrize != (Object)null) ? GrabbedPrize.NormalizedWeight : 0.25f);
			float num2 = Mathf.Lerp(0.74f, 1.48f, num);
			float num3 = 1f - _activeLuckiness * ClawConfig.LuckyPipeSlipReduction.Value;
			float num4 = Mathf.Clamp01(_tier.BaseGripStrength + _activeLuckiness * ClawConfig.LuckyPipeGripBonus.Value);
			float num5 = Mathf.Lerp(1.35f, 0.55f, _grabCenterAccuracy);
			float num6 = _tier.BaseSlipChance * num2 * num3 * num5 * (1.35f - num4 * 0.65f) * phaseWeight;
			num6 = Mathf.Clamp(num6, 0.01f, 0.92f);
			return Random.value < num6;
		}

		private void DropGrabbedPrizeMidAir()
		{
			//IL_0055: 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)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)GrabbedPrize == (Object)null))
			{
				ClawPrizeItem grabbedPrize = GrabbedPrize;
				GrabbedPrize = null;
				grabbedPrize.IsGripped = false;
				SetProngCollisionIgnored(grabbedPrize, ignore: false);
				grabbedPrize.Body.AddForce(new Vector3(Random.Range(-0.4f, 0.4f), -0.3f, Random.Range(-0.4f, 0.4f)), (ForceMode)1);
				grabbedPrize.Body.AddTorque(Random.insideUnitSphere * 1.4f, (ForceMode)1);
				_currentProngAngle = 24f;
				this.OnPrizeSlipped?.Invoke(grabbedPrize);
			}
		}

		private void UpdateReleasing(float dt)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			_currentProngAngle = Mathf.MoveTowards(_currentProngAngle, 52f, dt * 130f);
			if ((Object)(object)GrabbedPrize != (Object)null && _stateTimer >= 0.16f)
			{
				ClawPrizeItem grabbedPrize = GrabbedPrize;
				GrabbedPrize = null;
				grabbedPrize.IsGripped = false;
				SetProngCollisionIgnored(grabbedPrize, ignore: false);
				grabbedPrize.Body.velocity = new Vector3(grabbedPrize.Body.velocity.x * 0.35f, -0.35f, grabbedPrize.Body.velocity.z * 0.35f);
			}
			if (_stateTimer >= 1.45f)
			{
				SetState(ClawState.Resetting);
			}
		}

		private void UpdateResetting(float dt)
		{
			//IL_0029: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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)
			_currentProngAngle = Mathf.MoveTowards(_currentProngAngle, 16f, dt * 80f);
			Vector2 val = Vector2.MoveTowards(new Vector2(_gantryX, _gantryZ), HomeXZ, _tier.ClawSpeed * 0.9f * dt);
			_gantryX = val.x;
			_gantryZ = val.y;
			if (Vector2.Distance(val, HomeXZ) < 0.01f)
			{
				_gantryX = HomeXZ.x;
				_gantryZ = HomeXZ.y;
				SetState(ClawState.Idle);
				this.OnCycleFinished?.Invoke();
			}
		}

		private void UpdatePendulumSway(float dt)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_008d: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (!(dt <= 0.0001f))
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(_gantryX, _gantryZ);
				Vector2 val2 = (val - _lastGantryXZ) / dt;
				_lastGantryXZ = val;
				Vector3 val3 = (new Vector3(Mathf.Clamp(val2.y * 14f, -16f, 16f), 0f, Mathf.Clamp((0f - val2.x) * 14f, -16f, 16f)) - _swayAngles) * 42f - _swayVelocity * 6.5f;
				_swayVelocity += val3 * dt;
				_swayAngles += _swayVelocity * dt;
			}
		}

		private void ApplyTransforms()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)RailZ != (Object)null)
			{
				Vector3 localPosition = RailZ.localPosition;
				localPosition.z = _gantryZ;
				RailZ.localPosition = localPosition;
			}
			if ((Object)(object)CarriageX != (Object)null)
			{
				Vector3 localPosition2 = CarriageX.localPosition;
				localPosition2.x = _gantryX;
				CarriageX.localPosition = localPosition2;
			}
			if ((Object)(object)CableVisual != (Object)null)
			{
				CableVisual.localPosition = new Vector3(0f, (0f - _cableLength) * 0.5f, 0f);
				CableVisual.localScale = new Vector3(0.018f, _cableLength * 0.5f, 0.018f);
			}
			if ((Object)(object)ClawHub != (Object)null)
			{
				ClawHub.localPosition = new Vector3(0f, 0f - _cableLength, 0f);
				ClawHub.localRotation = Quaternion.Euler(_swayAngles);
			}
			if (ProngPivots == null)
			{
				return;
			}
			for (int i = 0; i < ProngPivots.Length; i++)
			{
				if (!((Object)(object)ProngPivots[i] == (Object)null))
				{
					ProngPivots[i].localRotation = Quaternion.Euler(_currentProngAngle, 0f, 0f);
				}
			}
		}

		private void SetProngCollisionIgnored(ClawPrizeItem prize, bool ignore)
		{
			if ((Object)(object)prize == (Object)null || (Object)(object)prize.PrizeCollider == (Object)null || ProngColliders == null)
			{
				return;
			}
			for (int i = 0; i < ProngColliders.Length; i++)
			{
				if ((Object)(object)ProngColliders[i] != (Object)null)
				{
					Physics.IgnoreCollision(ProngColliders[i], prize.PrizeCollider, ignore);
				}
			}
		}

		private void UpdateGrabbedPrizePhysics(float fdt)
		{
			//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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_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)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)GrabbedPrize == (Object)null) && !((Object)(object)GrabCenterPoint == (Object)null) && !((Object)(object)GrabbedPrize.Body == (Object)null))
			{
				Rigidbody body = GrabbedPrize.Body;
				Vector3 val = GrabCenterPoint.TransformPoint(_grabbedLocalOffset) - body.worldCenterOfMass;
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (_snagGraceTimer > 0f)
				{
					_snagGraceTimer -= fdt;
				}
				if (_snagGraceTimer <= 0f && magnitude > 0.42f)
				{
					DropGrabbedPrizeMidAir();
					return;
				}
				float normalizedWeight = GrabbedPrize.NormalizedWeight;
				float num = Mathf.Lerp(165f, 260f, _activeEffectiveGrip) * Mathf.Lerp(1.06f, 0.85f, normalizedWeight);
				float num2 = Mathf.Lerp(16f, 24f, _activeEffectiveGrip);
				Vector3 val2 = (val * num - body.velocity * num2) * body.mass;
				float num3 = Mathf.Lerp(0.95f, 1.04f, _activeEffectiveGrip) - normalizedWeight * 0.04f * (1f - _activeLuckiness);
				Vector3 val3 = -Physics.gravity * body.mass * num3;
				Vector3 val4 = Vector3.ClampMagnitude(val2 + val3, 180f * body.mass);
				body.AddForce(val4, (ForceMode)0);
				body.angularVelocity *= Mathf.Clamp01(1f - fdt * 6.5f);
			}
		}
	}
	public class ClawPrizeItem : MonoBehaviour
	{
		private Vector3 _pitCenterLocal;

		private Vector3 _pitHalfExtents;

		private Transform _machineRoot;

		private float _boundsCheckTimer;

		public Item ScrapItem { get; private set; }

		public int ItemListIndex { get; private set; }

		public int BasePrizeValue { get; private set; }

		public float WeightLbs { get; private set; }

		public float NormalizedWeight { get; private set; }

		public Rigidbody Body { get; private set; }

		public Collider PrizeCollider { get; private set; }

		public bool IsGripped { get; set; }

		public bool HasScored { get; set; }

		public void Initialize(Item item, int itemListIndex, int prizeValue, Transform machineRoot, Vector3 pitCenterLocal, Vector3 pitHalfExtents, Material fallbackMaterial)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			ScrapItem = item;
			ItemListIndex = itemListIndex;
			BasePrizeValue = prizeValue;
			_machineRoot = machineRoot;
			_pitCenterLocal = pitCenterLocal;
			_pitHalfExtents = pitHalfExtents;
			WeightLbs = (((Object)(object)item != (Object)null) ? Mathf.Max(0f, (item.weight - 1f) * 105f) : 12f);
			NormalizedWeight = Mathf.Clamp01(WeightLbs / 80f);
			Body = ((Component)this).gameObject.AddComponent<Rigidbody>();
			Body.mass = Mathf.Lerp(0.55f, 2.25f, NormalizedWeight);
			Body.drag = 0.55f;
			Body.angularDrag = 1.6f;
			Body.maxDepenetrationVelocity = 1.8f;
			Body.collisionDetectionMode = (CollisionDetectionMode)2;
			Body.interpolation = (RigidbodyInterpolation)1;
			BoxCollider val = ((Component)this).gameObject.AddComponent<BoxCollider>();
			val.size = new Vector3(0.16f, 0.16f, 0.16f);
			PrizeCollider = (Collider)(object)val;
			PhysicMaterial material = new PhysicMaterial("ClawPrizePhysMat")
			{
				dynamicFriction = 0.72f,
				staticFriction = 0.8f,
				bounciness = 0.06f,
				frictionCombine = (PhysicMaterialCombine)0,
				bounceCombine = (PhysicMaterialCombine)2
			};
			((Collider)val).material = material;
			if (TryBuildScrapVisual(item))
			{
				return;
			}
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val2).name = "FallbackPrizeVisual";
			val2.transform.SetParent(((Component)this).transform, false);
			val2.transform.localScale = Vector3.one * 0.18f;
			Object.Destroy((Object)(object)val2.GetComponent<Collider>());
			if ((Object)(object)fallbackMaterial != (Object)null)
			{
				MeshRenderer component = val2.GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).sharedMaterial = fallbackMaterial;
				}
			}
		}

		private bool TryBuildScrapVisual(Item item)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0059: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: 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_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null || (Object)(object)item.spawnPrefab == (Object)null)
			{
				return false;
			}
			GameObject val = new GameObject("VisualRoot");
			val.transform.SetParent(((Component)this).transform, false);
			GameObject val2 = new GameObject("PrefabRoot");
			val2.transform.SetParent(val.transform, false);
			val2.transform.localPosition = Vector3.zero;
			val2.transform.localRotation = item.spawnPrefab.transform.localRotation;
			val2.transform.localScale = item.spawnPrefab.transform.localScale;
			if (MirrorVisualHierarchy(item.spawnPrefab.transform, val2.transform, isRoot: true) == 0)
			{
				Object.Destroy((Object)(object)val);
				return false;
			}
			Quaternion rotation = ((Component)this).transform.rotation;
			Vector3 position = ((Component)this).transform.position;
			((Component)this).transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
			val.transform.localScale = Vector3.one * 0.48f;
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(Vector3.zero, Vector3.zero);
			bool flag = false;
			MeshRenderer[] componentsInChildren = val.GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val3 in componentsInChildren)
			{
				if (!flag)
				{
					bounds = ((Renderer)val3).bounds;
					flag = true;
				}
				else
				{
					((Bounds)(ref bounds)).Encapsulate(((Renderer)val3).bounds);
				}
			}
			if (flag)
			{
				float num = Mathf.Max(((Bounds)(ref bounds)).size.x, Mathf.Max(((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).size.z));
				float num2 = ((num > 0.28f) ? (0.28f / num) : 1f);
				float num3 = 0.48f * num2;
				val.transform.localScale = Vector3.one * num3;
				val.transform.localPosition = -((Bounds)(ref bounds)).center * num2;
				BoxCollider component = ((Component)this).GetComponent<BoxCollider>();
				if ((Object)(object)component != (Object)null)
				{
					Vector3 val4 = ((Bounds)(ref bounds)).size * num2;
					component.size = new Vector3(Mathf.Clamp(val4.x, 0.055f, 0.28f), Mathf.Clamp(val4.y, 0.055f, 0.28f), Mathf.Clamp(val4.z, 0.055f, 0.28f));
				}
			}
			((Component)this).transform.SetPositionAndRotation(position, rotation);
			return true;
		}

		private static int MirrorVisualHierarchy(Transform src, Transform dstParent, bool isRoot)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			string text = ((((Object)src).name != null) ? ((Object)src).name.ToLowerInvariant() : "");
			if (!isRoot && (text.Contains("scan") || text.Contains("trigger") || text.Contains("collider")))
			{
				return 0;
			}
			Transform val;
			if (isRoot)
			{
				val = dstParent;
			}
			else
			{
				val = new GameObject(((Object)src).name).transform;
				val.SetParent(dstParent, false);
				val.localPosition = src.localPosition;
				val.localRotation = src.localRotation;
				val.localScale = src.localScale;
			}
			int num = 0;
			MeshFilter component = ((Component)src).GetComponent<MeshFilter>();
			MeshRenderer component2 = ((Component)src).GetComponent<MeshRenderer>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null && (Object)(object)component2 != (Object)null && ((Renderer)component2).enabled)
			{
				((Component)val).gameObject.AddComponent<MeshFilter>().sharedMesh = component.sharedMesh;
				MeshRenderer obj = ((Component)val).gameObject.AddComponent<MeshRenderer>();
				((Renderer)obj).sharedMaterials = ((Renderer)component2).sharedMaterials;
				((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
				num++;
			}
			else
			{
				SkinnedMeshRenderer component3 = ((Component)src).GetComponent<SkinnedMeshRenderer>();
				if ((Object)(object)component3 != (Object)null && (Object)(object)component3.sharedMesh != (Object)null && ((Renderer)component3).enabled)
				{
					((Component)val).gameObject.AddComponent<MeshFilter>().sharedMesh = component3.sharedMesh;
					MeshRenderer obj2 = ((Component)val).gameObject.AddComponent<MeshRenderer>();
					((Renderer)obj2).sharedMaterials = ((Renderer)component3).sharedMaterials;
					((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)0;
					num++;
				}
			}
			for (int i = 0; i < src.childCount; i++)
			{
				num += MirrorVisualHierarchy(src.GetChild(i), val, isRoot: false);
			}
			return num;
		}

		private void FixedUpdate()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0061: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_017c: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (IsGripped || HasScored || (Object)(object)_machineRoot == (Object)null)
			{
				return;
			}
			_boundsCheckTimer += Time.fixedDeltaTime;
			if (!(_boundsCheckTimer < 0.75f))
			{
				_boundsCheckTimer = 0f;
				Vector3 val = _machineRoot.InverseTransformPoint(((Component)this).transform.position);
				Vector3 val2 = val - _pitCenterLocal;
				if (Mathf.Abs(val2.x) > _pitHalfExtents.x + 0.15f || Mathf.Abs(val2.z) > _pitHalfExtents.z + 0.15f || val.y < _pitCenterLocal.y - 0.65f || val.y > _pitCenterLocal.y + 1.5f)
				{
					Vector3 val3 = default(Vector3);
					((Vector3)(ref val3))..ctor(_pitCenterLocal.x + Random.Range((0f - _pitHalfExtents.x) * 0.4f, _pitHalfExtents.x * 0.6f), _pitCenterLocal.y + 0.35f, _pitCenterLocal.z + Random.Range((0f - _pitHalfExtents.z) * 0.4f, _pitHalfExtents.z * 0.6f));
					((Component)this).transform.position = _machineRoot.TransformPoint(val3);
					Body.velocity = Vector3.zero;
					Body.angularVelocity = Vector3.zero;
				}
			}
		}
	}
	public class PrizeChuteSensor : MonoBehaviour
	{
		public event Action<ClawPrizeItem> OnPrizeEnteredChute;

		private void OnTriggerEnter(Collider other)
		{
			ClawPrizeItem componentInParent = ((Component)other).GetComponentInParent<ClawPrizeItem>();
			if (!((Object)(object)componentInParent == (Object)null) && !componentInParent.HasScored)
			{
				componentInParent.HasScored = true;
				this.OnPrizeEnteredChute?.Invoke(componentInParent);
			}
		}
	}
}
namespace LethalClawMachine.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	internal static class RoundManagerPatches
	{
		private const int CompanyMoonLevelId = 3;

		[HarmonyPatch("FinishGeneratingNewLevelClientRpc")]
		[HarmonyPostfix]
		private static void OnFinishGeneratingNewLevelClientRpc(RoundManager __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.currentLevel == (Object)null))
			{
				if (__instance.currentLevel.levelID == 3)
				{
					ClawMachineManager.SpawnAllMachinesOnCompanyMoon();
				}
				else
				{
					ClawMachineManager.DespawnAllMachines();
				}
			}
		}

		[HarmonyPatch("DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		private static void OnDespawnPropsAtEndOfRound()
		{
			ClawMachineManager.DespawnAllMachines();
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal static class StartOfRoundPatches
	{
		private const int CompanyMoonLevelId = 3;

		[HarmonyPatch("OnShipLandedMiscEvents")]
		[HarmonyPostfix]
		private static void OnShipLanded(StartOfRound __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.currentLevel == (Object)null) && __instance.currentLevel.levelID == 3)
			{
				ClawMachineManager.SpawnAllMachinesOnCompanyMoon();
			}
		}

		[HarmonyPatch("ShipLeave")]
		[HarmonyPostfix]
		private static void OnShipLeave()
		{
			ClawMachineManager.DespawnAllMachines();
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal static class GameNetworkManagerPatches
	{
		[HarmonyPatch("StartDisconnect")]
		[HarmonyPrefix]
		private static void OnStartDisconnect()
		{
			ClawMachineManager.DespawnAllMachines();
			ClawMachineManager.UnregisterNetworkHandlers();
		}
	}
	[HarmonyPatch(typeof(GiftBoxItem))]
	internal static class GiftBoxItemPatches
	{
		[HarmonyPatch("OpenGiftBoxClientRpc")]
		[HarmonyPostfix]
		private static void OnOpenGiftBoxClientRpc(NetworkObjectReference netObjectRef, Vector3 startFallingPos)
		{
			//IL_0032: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkObject val = default(NetworkObject);
			if (!((Object)(object)StartOfRound.Instance == (Object)null) && !((Object)(object)StartOfRound.Instance.currentLevel == (Object)null) && StartOfRound.Instance.currentLevel.levelID == 3 && !(startFallingPos.y < -2.55f) && ((NetworkObjectReference)(ref netObjectRef)).TryGet(ref val, (NetworkManager)null) && (Object)(object)val != (Object)null)
			{
				((Component)val).gameObject.AddComponent<GiftBoxCarpetFloorFixer>().StartPos = startFallingPos;
			}
		}
	}
	internal class GiftBoxCarpetFloorFixer : MonoBehaviour
	{
		public Vector3 StartPos;

		private int _framesWaited;

		private void LateUpdate()
		{
			//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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			_framesWaited++;
			if (_framesWaited >= 3)
			{
				GrabbableObject component = ((Component)this).GetComponent<GrabbableObject>();
				if ((Object)(object)component != (Object)null && !component.isHeld && component.targetFloorPosition.y < -2.53f)
				{
					Vector3 targetFloorPosition = component.targetFloorPosition;
					targetFloorPosition.y = -2.46f;
					component.targetFloorPosition = targetFloorPosition;
					component.fallTime = 0f;
					component.hasHitGround = false;
					component.reachedFloorTarget = false;
				}
				Object.Destroy((Object)(object)this);
			}
		}
	}
}
namespace LethalClawMachine.Machine
{
	public struct BuiltClawMachineRefs
	{
		public GameObject Root;

		public ClawAssembly Claw;

		public PrizeChuteSensor ChuteSensor;

		public InteractTrigger InteractTrigger;

		public Transform JoystickPivot;

		public Transform DropButtonVisual;

		public Transform CameraAnchor;

		public Transform PlayerStandPoint;

		public Transform PrizePickupSpawnPoint;

		public Transform PrizesContainer;

		public Light InteriorLight;

		public Material FallbackPrizeMat;

		public Vector3 PitCenterLocal;

		public Vector3 PitHalfExtents;
	}
	public static class ClawMachineBuilder
	{
		private const int InteractableLayer = 9;

		public static BuiltClawMachineRefs Build(int machineIndex, ClawTierSettings tier, Vector3 worldPos, Quaternion worldRot)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//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_0048: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: 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_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Expected O, but got Unknown
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_065d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0674: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_073c: Unknown result type (might be due to invalid IL or missing references)
			//IL_074d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_0785: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0818: Unknown result type (might be due to invalid IL or missing references)
			//IL_082c: Unknown result type (might be due to invalid IL or missing references)
			//IL_083e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0843: Unknown result type (might be due to invalid IL or missing references)
			//IL_0851: Unknown result type (might be due to invalid IL or missing references)
			//IL_0866: Unknown result type (might be due to invalid IL or missing references)
			//IL_0870: Unknown result type (might be due to invalid IL or missing references)
			//IL_088c: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0921: Unknown result type (might be due to invalid IL or missing references)
			//IL_0935: Unknown result type (might be due to invalid IL or missing references)
			//IL_0959: Unknown result type (might be due to invalid IL or missing references)
			//IL_096d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0980: Unknown result type (might be due to invalid IL or missing references)
			//IL_0985: Unknown result type (might be due to invalid IL or missing references)
			//IL_0993: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a01: Expected O, but got Unknown
			//IL_0a26: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abd: Expected O, but got Unknown
			//IL_0add: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b03: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0a: Expected O, but got Unknown
			//IL_0b2a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b94: Expected O, but got Unknown
			//IL_0bc8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bdc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c04: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c32: Expected O, but got Unknown
			//IL_0c5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c9a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca1: Expected O, but got Unknown
			//IL_0cc8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cdc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cfe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d20: Expected O, but got Unknown
			//IL_0d5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ead: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ec6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0edb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0efb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f14: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f1e: Expected O, but got Unknown
			//IL_0f20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f2a: Expected O, but got Unknown
			//IL_0f2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f36: Expected O, but got Unknown
			//IL_0f38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f42: Expected O, but got Unknown
			//IL_0f44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f4e: Expected O, but got Unknown
			//IL_0dcf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e04: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe8: Expected O, but got Unknown
			//IL_100d: Unknown result type (might be due to invalid IL or missing references)
			//IL_102d: Unknown result type (might be due to invalid IL or missing references)
			//IL_103c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1043: Expected O, but got Unknown
			//IL_106c: Unknown result type (might be due to invalid IL or missing references)
			//IL_107d: Unknown result type (might be due to invalid IL or missing references)
			//IL_108c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1093: Expected O, but got Unknown
			//IL_10bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_10cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d2: Expected O, but got Unknown
			//IL_1183: Unknown result type (might be due to invalid IL or missing references)
			//IL_1188: Unknown result type (might be due to invalid IL or missing references)
			//IL_119e: Unknown result type (might be due to invalid IL or missing references)
			//IL_11a3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject($"LethalClawMachine_{tier.Tier}_{machineIndex}");
			val.transform.position = worldPos;
			val.transform.rotation = worldRot;
			Material mat = CreateOpaqueMat(new Color(0.11f, 0.12f, 0.15f), 0.65f, 0.45f);
			Material mat2 = CreateOpaqueMat(tier.PrimaryColor, 0.35f, 0.55f);
			Material mat3 = CreateOpaqueMat(new Color(0.78f, 0.8f, 0.85f), 0.9f, 0.78f);
			Material val2 = CreateEmissiveMat(tier.GlowColor, 2.8f);
			Material mat4 = CreateEmissiveMat(new Color(1f, 0.15f, 0.12f), 2.2f);
			Material mat5 = CreateOpaqueMat(new Color(0.16f, 0.17f, 0.21f), 0.2f, 0.35f);
			Material mat6 = CreateGlassMat(new Color(0.72f, 0.88f, 1f, 0.13f));
			Material fallbackPrizeMat = CreateOpaqueMat(tier.GlowColor, 0.3f, 0.6f);
			CreateBox("BaseCabinet", val.transform, new Vector3(0f, 0.76f, 0f), new Vector3(1.4f, 1.52f, 1.16f), mat, withCollider: false);
			((Renderer)CreateBox("BaseLowerCollider", val.transform, new Vector3(0f, 0.59000003f, 0f), new Vector3(1.38f, 1.1800001f, 1.14f), mat, withCollider: true).GetComponent<MeshRenderer>()).enabled = false;
			CreateBox("FrontPanel", val.transform, new Vector3(0.16f, 0.75f, -0.592f), new Vector3(0.96f, 1.174f, 0.02f), mat2, withCollider: false);
			CreateBox("PickupBayFrame", val.transform, new Vector3(-0.43f, 0.73f, -0.592f), new Vector3(0.42f, 0.44f, 0.02f), mat3, withCollider: false);
			CreateBox("PickupBayInterior", val.transform, new Vector3(-0.43f, 0.73f, -0.606f), new Vector3(0.36f, 0.38f, 0.01f), mat, withCollider: false);
			CreateBox("PickupTrayShelf", val.transform, new Vector3(-0.43f, 0.51f, -0.71f), new Vector3(0.44f, 0.05f, 0.22f), mat, withCollider: true);
			CreateBox("BaseNeonFront", val.transform, new Vector3(0f, 1.4300001f, -0.592f), new Vector3(1.41f, 0.03f, 0.02f), val2, withCollider: false);
			GameObject val3 = new GameObject("UpperCabinet");
			val3.transform.SetParent(val.transform, false);
			val3.transform.localPosition = new Vector3(0f, 0.62f, 0f);
			Transform transform = val3.transform;
			CreateBox("ControlDeck", transform, new Vector3(0f, 0.88f, -0.715f), new Vector3(1.38f, 0.1f, 0.26f), mat2, withCollider: true);
			CreateCylinder("JoystickBase", transform, new Vector3(-0.18f, 0.935f, -0.69f), new Vector3(0.09f, 0.015f, 0.09f), mat, withCollider: false);
			GameObject val4 = new GameObject("JoystickPivot");
			val4.transform.SetParent(transform, false);
			val4.transform.localPosition = new Vector3(-0.18f, 0.94f, -0.69f);
			CreateCylinder("JoystickShaft", val4.transform, new Vector3(0f, 0.055f, 0f), new Vector3(0.018f, 0.055f, 0.018f), mat3, withCollider: false);
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)obj).name = "JoystickBall";
			obj.transform.SetParent(val4.transform, false);
			obj.transform.localPosition = new Vector3(0f, 0.12f, 0f);
			obj.transform.localScale = Vector3.one * 0.065f;
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = val2;
			CreateCylinder("DropButtonRim", transform, new Vector3(0.18f, 0.935f, -0.69f), new Vector3(0.11f, 0.015f, 0.11f), mat3, withCollider: false);
			GameObject val5 = CreateCylinder("DropButtonCap", transform, new Vector3(0.18f, 0.955f, -0.69f), new Vector3(0.085f, 0.02f, 0.085f), mat4, withCollider: false);
			CreateBox("ScrapSlotPlate", transform, new Vector3(0.48f, 0.935f, -0.69f), new Vector3(0.14f, 0.015f, 0.12f), mat3, withCollider: false);
			CreateBox("ScrapSlotGlow", transform, new Vector3(0.48f, 0.945f, -0.69f), new Vector3(0.08f, 0.008f, 0.025f), val2, withCollider: false);
			float num = 0.92f;
			float num2 = 2.06f;
			float num3 = num2 - num;
			float num4 = (num + num2) * 0.5f;
			Vector2[] array = (Vector2[])(object)new Vector2[4]
			{
				new Vector2(-0.67f, -0.55f),
				new Vector2(0.67f, -0.55f),
				new Vector2(-0.67f, 0.55f),
				new Vector2(0.67f, 0.55f)
			};
			for (int i = 0; i < array.Length; i++)
			{
				CreateBox($"CornerPillar_{i}", transform, new Vector3(array[i].x, num4, array[i].y), new Vector3(0.07f, num3, 0.07f), mat2, withCollider: true);
				CreateBox($"CornerNeon_{i}", transform, new Vector3(array[i].x * 0.93f, num4, array[i].y * 0.92f), new Vector3(0.02f, num3 - 0.08f, 0.02f), val2, withCollider: false);
			}
			CreateBox("GlassFront", transform, new Vector3(0f, num4, -0.55f), new Vector3(1.26f, num3, 0.02f), mat6, withCollider: true);
			CreateBox("GlassBack", transform, new Vector3(0f, num4, 0.55f), new Vector3(1.26f, num3, 0.02f), mat6, withCollider: true);
			CreateBox("GlassLeft", transform, new Vector3(-0.67f, num4, 0f), new Vector3(0.02f, num3, 1.02f), mat6, withCollider: true);
			CreateBox("GlassRight", transform, new Vector3(0.67f, num4, 0f), new Vector3(0.02f, num3, 1.02f), mat6, withCollider: true);
			CreateBox("PitFloorRight", transform, new Vector3(0.205f, 0.935f, 0f), new Vector3(0.89f, 0.04f, 1.06f), mat5, withCollider: true);
			CreateBox("PitFloorBackLeft", transform, new Vector3(-0.445f, 0.935f, 0.195f), new Vector3(0.41f, 0.04f, 0.67f), mat5, withCollider: true);
			CreateBox("ChuteRimRight", transform, new Vector3(-0.24f, 1.085f, -0.335f), new Vector3(0.025f, 0.26f, 0.39f), mat3, withCollider: true);
			CreateBox("ChuteRimBack", transform, new Vector3(-0.4525f, 1.085f, -0.14f), new Vector3(0.395f, 0.26f, 0.025f), mat3, withCollider: true);
			GameObject val6 = new GameObject("PrizeChuteSensor");
			val6.transform.SetParent(transform, false);
			val6.transform.localPosition = new Vector3(-0.44f, 0.66f, -0.335f);
			BoxCollider obj2 = val6.AddComponent<BoxCollider>();
			((Collider)obj2).isTrigger = true;
			obj2.size = new Vector3(0.4f, 0.24f, 0.38f);
			PrizeChuteSensor chuteSensor = val6.AddComponent<PrizeChuteSensor>();
			CreateBox("TopCanopy", transform, new Vector3(0f, 2.22f, 0f), new Vector3(1.44f, 0.32f, 1.2f), mat, withCollider: true);
			CreateBox("MarqueeFrame", transform, new Vector3(0f, 2.22f, -0.61f), new Vector3(1.36f, 0.24f, 0.02f), mat2, withCollider: false);
			CreateBox("MarqueeNeonTop", transform, new Vector3(0f, 2.36f, -0.615f), new Vector3(1.4f, 0.03f, 0.02f), val2, withCollider: false);
			CreateBox("MarqueeNeonBottom", transform, new Vector3(0f, 2.08f, -0.615f), new Vector3(1.4f, 0.03f, 0.02f), val2, withCollider: false);
			GameObject val7 = new GameObject("InteriorLight");
			val7.transform.SetParent(transform, false);
			val7.transform.localPosition = new Vector3(0f, 1.92f, 0f);
			Light val8 = val7.AddComponent<Light>();
			val8.type = (LightType)2;
			val8.color = Color.Lerp(Color.white, tier.GlowColor, 0.45f);
			val8.range = 3.2f;
			val8.intensity = 18f;
			GameObject val9 = new GameObject("ClawAssemblyRoot");
			val9.transform.SetParent(transform, false);
			val9.transform.localPosition = new Vector3(0f, 2f, 0f);
			ClawAssembly clawAssembly = val9.AddComponent<ClawAssembly>();
			CreateBox("FixedRailLeft", val9.transform, new Vector3(-0.62f, 0f, 0f), new Vector3(0.03f, 0.03f, 1.02f), mat3, withCollider: false);
			CreateBox("FixedRailRight", val9.transform, new Vector3(0.62f, 0f, 0f), new Vector3(0.03f, 0.03f, 1.02f), mat3, withCollider: false);
			GameObject val10 = new GameObject("MovingRailZ");
			val10.transform.SetParent(val9.transform, false);
			CreateBox("RailZBar", val10.transform, Vector3.zero, new Vector3(1.24f, 0.035f, 0.035f), mat3, withCollider: false);
			GameObject val11 = new GameObject("CarriageX");
			val11.transform.SetParent(val10.transform, false);
			CreateBox("CarriageBox", val11.transform, Vector3.zero, new Vector3(0.14f, 0.07f, 0.14f), mat2, withCollider: false);
			GameObject val12 = CreateCylinder("Cable", val11.transform, new Vector3(0f, -0.07f, 0f), new Vector3(0.018f, 0.07f, 0.018f), mat, withCollider: false);
			GameObject val13 = new GameObject("ClawHub");
			val13.transform.SetParent(val11.transform, false);
			Rigidbody obj3 = val13.AddComponent<Rigidbody>();
			obj3.isKinematic = true;
			obj3.interpolation = (RigidbodyInterpolation)1;
			CreateCylinder("ClawHubCore", val13.transform, Vector3.zero, new Vector3(0.11f, 0.045f, 0.11f), mat3, withCollider: false);
			CreateCylinder("ClawHubRing", val13.transform, new Vector3(0f, -0.02f, 0f), new Vector3(0.125f, 0.012f, 0.125f), val2, withCollider: false);
			GameObject val14 = new GameObject("GrabCenterPoint");
			val14.transform.SetParent(val13.transform, false);
			val14.transform.localPosition = new Vector3(0f, -0.17f, 0f);
			Transform[] array2 = (Transform[])(object)new Transform[3];
			List<Collider> list = new List<Collider>(6);
			for (int j = 0; j < 3; j++)
			{
				float num5 = (float)j * 120f;
				GameObject val15 = new GameObject($"ProngMount_{j}");
				val15.transform.SetParent(val13.transform, false);
				val15.transform.localPosition = Quaternion.Euler(0f, num5, 0f) * new Vector3(0f, -0.03f, 0.052f);
				val15.transform.localRotation = Quaternion.Euler(0f, num5, 0f);
				GameObject val16 = new GameObject($"ProngPivot_{j}");
				val16.transform.SetParent(val15.transform, false);
				array2[j] = val16.transform;
				GameObject obj4 = CreateBox("ProngUpper", val16.transform, new Vector3(0f, -0.055f, 0.025f), new Vector3(0.022f, 0.12f, 0.022f), mat3, withCollider: true);
				obj4.transform.localRotation = Quaternion.Euler(-22f, 0f, 0f);
				Collider component = obj4.GetComponent<Collider>();
				if ((Object)(object)component != (Object)null)
				{
					list.Add(component);
				}
				GameObject obj5 = CreateBox("ProngLower", val16.transform, new Vector3(0f, -0.145f, 0.022f), new Vector3(0.022f, 0.11f, 0.022f), mat3, withCollider: true);
				obj5.transform.localRotation = Quaternion.Euler(28f, 0f, 0f);
				Collider component2 = obj5.GetComponent<Collider>();
				if ((Object)(object)component2 != (Object)null)
				{
					list.Add(component2);
				}
			}
			clawAssembly.RailZ = val10.transform;
			clawAssembly.CarriageX = val11.transform;
			clawAssembly.CableVisual = val12.transform;
			clawAssembly.ClawHub = val13.transform;
			clawAssembly.ProngPivots = array2;
			clawAssembly.ProngColliders = list.ToArray();
			clawAssembly.GrabCenterPoint = val14.transform;
			clawAssembly.Configure(tier);
			GameObject val17 = new GameObject("ClawInteractTrigger")
			{
				layer = 9,
				tag = "InteractTrigger"
			};
			val17.transform.SetParent(transform, false);
			val17.transform.localPosition = new Vector3(0f, 1.24f, -0.68f);
			BoxCollider obj6 = val17.AddComponent<BoxCollider>();
			obj6.size = new Vector3(1.32f, 1.18f, 0.58f);
			((Collider)obj6).isTrigger = true;
			InteractTrigger val18 = val17.AddComponent<InteractTrigger>();
			val18.onInteract = new InteractEvent();
			val18.onInteractEarly = new InteractEvent();
			val18.onInteractEarlyOtherClients = new InteractEvent();
			val18.onStopInteract = new InteractEvent();
			val18.holdingInteractEvent = new InteractEventFloat();
			Sprite disabledIcon;
			Sprite val19 = FindHandHoverIcon(out disabledIcon);
			if ((Object)(object)val19 != (Object)null)
			{
				val18.hoverIcon = val19;
			}
			if ((Object)(object)disabledIcon != (Object)null)
			{
				val18.disabledHoverIcon = disabledIcon;
			}
			val18.hoverTip = (ClawConfig.FreePlayMode.Value ? "Play Claw Machine (FREE PLAY) : [E]" : "This game requires scrap!");
			val18.disabledHoverTip = "This game requires scrap!";
			val18.interactable = true;
			val18.oneHandedItemAllowed = true;
			val18.twoHandedItemAllowed = true;
			val18.holdInteraction = false;
			val18.interactCooldown = true;
			val18.cooldownTime = 0.6f;
			GameObject val20 = new GameObject("CameraAnchor");
			val20.transform.SetParent(transform, false);
			val20.transform.localPosition = new Vector3(0f, 1.58f, -1.36f);
			val20.transform.localRotation = Quaternion.Euler(14f, 0f, 0f);
			GameObject val21 = new GameObject("PlayerStandPoint");
			val21.transform.SetParent(val.transform, false);
			val21.transform.localPosition = new Vector3(0f, 0.05f, -1.3f);
			val21.transform.localRotation = Quaternion.identity;
			GameObject val22 = new GameObject("PrizePickupSpawnPoint");
			val22.transform.SetParent(val.transform, false);
			val22.transform.localPosition = new Vector3(-0.43f, 0.96f, -0.96f);
			GameObject val23 = new GameObject("PrizesContainer");
			val23.transform.SetParent(transform, false);
			return new BuiltClawMachineRefs
			{
				Root = val,
				Claw = clawAssembly,
				ChuteSensor = chuteSensor,
				InteractTrigger = val18,
				JoystickPivot = val4.transform,
				DropButtonVisual = val5.transform,
				CameraAnchor = val20.transform,
				PlayerStandPoint = val21.transform,
				PrizePickupSpawnPoint = val22.transform,
				PrizesContainer = val23.transform,
				InteriorLight = val8,
				FallbackPrizeMat = fallbackPrizeMat,
				PitCenterLocal = new Vector3(0.08f, 1.8f, 0.05f),
				PitHalfExtents = new Vector3(0.56f, 0.4f, 0.45f)
			};
		}

		private static Sprite FindHandHoverIcon(out Sprite disabledIcon)
		{
			disabledIcon = null;
			Sprite val = null;
			InteractTrigger[] array = Object.FindObjectsOfType<InteractTrigger>(true);
			foreach (InteractTrigger val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.hoverIcon == (Object)null))
				{
					if ((Object)(object)disabledIcon == (Object)null && (Object)(object)val2.disabledHoverIcon != (Object)null)
					{
						disabledIcon = val2.disabledHoverIcon;
					}
					string text = ((((Object)val2.hoverIcon).name != null) ? ((Object)val2.hoverIcon).name.ToLowerInvariant() : "");
					if (text.Contains("hand") || text.Contains("grab"))
					{
						return val2.hoverIcon;
					}
					if ((Object)(object)val == (Object)null)
					{
						val = val2.hoverIcon;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Sprite[] array2 = Resources.FindObjectsOfTypeAll<Sprite>();
				for (int j = 0; j < array2.Length; j++)
				{
					if (!((Object)(object)array2[j] == (Object)null) && !string.IsNullOrEmpty(((Object)array2[j]).name) && ((Object)array2[j]).name.ToLowerInvariant().Contains("handicon"))
					{
						return array2[j];
					}
				}
			}
			return val;
		}

		private static GameObject CreateBox(string name, Transform parent, Vector3 localPos, Vector3 localScale, Material mat, bool withCollider)
		{
			//IL_0021: 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)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = name;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localScale = localScale;
			if (!withCollider)
			{
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
			}
			MeshRenderer component = val.GetComponent<MeshRenderer>();
			if ((Object)(object)component != (Object)null && (Object)(object)mat != (Object)null)
			{
				((Renderer)component).sharedMaterial = mat;
			}
			return val;
		}

		private static GameObject CreateCylinder(string name, Transform parent, Vector3 localPos, Vector3 localScale, Material mat, bool withCollider)
		{
			//IL_0021: 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)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val).name = name;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localScale = localScale;
			if (!withCollider)
			{
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
			}
			MeshRenderer component = val.GetComponent<MeshRenderer>();
			if ((Object)(object)component != (Object)null && (Object)(object)mat != (Object)null)
			{
				((Renderer)component).sharedMaterial = mat;
			}
			return val;
		}

		private static Shader FindLitShader()
		{
			Shader val = Shader.Find("HDRP/Lit");
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			val = Shader.Find("Standard");
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			return Shader.Find("Sprites/Default");
		}

		private static Material CreateOpaqueMat(Color color, float metallic, float smoothness)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(FindLitShader());
			val.color = color;
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", color);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", metallic);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", smoothness);
			}
			return val;
		}

		private static Material CreateEmissiveMat(Color glowColor, float intensity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			Material val = CreateOpaqueMat(glowColor, 0.1f, 0.8f);
			Color val2 = glowColor * intensity;
			if (val.HasProperty("_EmissiveColor"))
			{
				val.SetColor("_EmissiveColor", val2);
				val.EnableKeyword("_EMISSIVE_COLOR_MAP");
			}
			if (val.HasProperty("_UseEmissiveIntensity"))
			{
				val.SetFloat("_UseEmissiveIntensity", 1f);
			}
			if (val.HasProperty("_EmissiveIntensity"))
			{
				val.SetFloat("_EmissiveIntensity", intensity);
			}
			if (val.HasProperty("_EmissionColor"))
			{
				val.EnableKeyword("_EMISSION");
				val.SetColor("_EmissionColor", val2);
			}
			return val;
		}

		private static Material CreateGlassMat(Color tint)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0022: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("HDRP/Unlit");
			if ((Object)(object)val == (Object)null)
			{
				val = FindLitShader();
			}
			Material val2 = new Material(val);
			val2.color = tint;
			if (val2.HasProperty("_UnlitColor"))
			{
				val2.SetColor("_UnlitColor", tint);
			}
			if (val2.HasProperty("_BaseColor"))
			{
				val2.SetColor("_BaseColor", tint);
			}
			if (val2.HasProperty("_Smoothness"))
			{
				val2.SetFloat("_Smoothness", 0.92f);
			}
			if (val2.HasProperty("_Metallic"))
			{
				val2.SetFloat("_Metallic", 0.05f);
			}
			if (val2.HasProperty("_SurfaceType"))
			{
				val2.SetFloat("_SurfaceType", 1f);
				val2.SetFloat("_BlendMode", 0f);
				val2.SetFloat("_AlphaCutoffEnable", 0f);
				val2.SetFloat("_ZWrite", 0f);
				val2.SetFloat("_TransparentZWrite", 0f);
				val2.SetFloat("_ZTestGBuffer", 4f);
				val2.SetFloat("_ZTestDepthEqualForOpaque", 4f);
				val2.SetFloat("_SrcBlend", 5f);
				val2.SetFloat("_DstBlend", 10f);
				val2.SetFloat("_AlphaSrcBlend", 1f);
				val2.SetFloat("_AlphaDstBlend", 10f);
				val2.SetOverrideTag("RenderType", "Transparent");
				val2.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
				val2.EnableKeyword("_BLENDMODE_ALPHA");
				val2.EnableKeyword("_ENABLE_FOG_ON_TRANSPARENT");
				val2.SetShaderPassEnabled("GBuffer", false);
				val2.SetShaderPassEnabled("DepthOnly", false);
				val2.SetShaderPassEnabled("ShadowCaster", false);
				val2.SetShaderPassEnabled("MotionVectors", false);
				val2.SetShaderPassEnabled("Forward", true);
				val2.SetShaderPassEnabled("ForwardOnly", true);
				val2.renderQueue = 3000;
			}
			else
			{
				val2.SetFloat("_Mode", 3f);
				val2.SetInt("_SrcBlend", 5);
				val2.SetInt("_DstBlend", 10);
				val2.SetInt("_ZWrite", 0);
				val2.DisableKeyword("_ALPHATEST_ON");
				val2.EnableKeyword("_ALPHABLEND_ON");
				val2.DisableKeyword("_ALPHAPREMULTIPLY_ON");
				val2.renderQueue = 3000;
			}
			return val2;
		}
	}
	public class ClawMachineController : MonoBehaviour
	{
		private ulong _activeClientId = ulong.MaxValue;

		private bool _isLocalControlling;

		private PlayerControllerB _localPlayer;

		private float _activeLuckiness;

		private float _aimTimer;

		private bool _wonThisTurn;

		private int _depositedValue;

		private string _statusBanner = "";

		private float _lightFlashTimer;

		private float _baseLightIntensity;

		private Vector3 _savedCamLocalPos;

		private Quaternion _savedCamLocalRot;

		private bool _cameraHijacked;

		private bool _visorWasActive;

		private AudioSource _sfxSource;

		private AudioSource _motorSource;

		private float _netSyncTimer;

		private float _hoverUpdateTimer;

		private Vector3 _dropButtonRestPos;

		private readonly List<ClawPrizeItem> _stockedPrizes = new List<ClawPrizeItem>();

		private readonly List<int> _tierItemIndices = new List<int>();

		private GUIStyle _panelStyle;

		private GUIStyle _titleStyle;

		private GUIStyle _subStyle;

		private GUIStyle _luckStyle;

		private Texture2D _darkTex;

		private Texture2D _accentTex;

		public int MachineIndex { get; private set; }

		public ClawTierSettings Tier { get; private set; }

		public BuiltClawMachineRefs Refs { get; private set; }

		public bool IsOccupied => _activeClientId != ulong.MaxValue;

		public bool IsLocalPlayerActive => _isLocalControlling;

		public void Initialize(int machineIndex, ClawTierSettings tier, BuiltClawMachineRefs refs)
		{
			//IL_00ef: 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)
			MachineIndex = machineIndex;
			Tier = tier;
			Refs = refs;
			ClawSoundBank.EnsureInitialized();
			_sfxSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			_sfxSource.spatialBlend = 1f;
			_sfxSource.minDistance = 2f;
			_sfxSource.maxDistance = 14f;
			_sfxSource.playOnAwake = false;
			_motorSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			_motorSource.spatialBlend = 1f;
			_motorSource.minDistance = 2f;
			_motorSource.maxDistance = 10f;
			_motorSource.loop = true;
			_motorSource.clip = ClawSoundBank.MotorLoop;
			_motorSource.playOnAwake = false;
			if ((Object)(object)Refs.DropButtonVisual != (Object)null)
			{
				_dropButtonRestPos = Refs.DropButtonVisual.localPosition;
			}
			if ((Object)(object)Refs.InteriorLight != (Object)null)
			{
				_baseLightIntensity = Refs.InteriorLight.intensity;
			}
			Refs.Claw.OnStateChanged += HandleClawStateChanged;
			Refs.Claw.OnPrizeGrabbed += HandlePrizeGrabbed;
			Refs.Claw.OnPrizeSlipped += HandlePrizeSlipped;
			Refs.Claw.OnCycleFinished += HandleCycleFinished;
			Refs.ChuteSensor.OnPrizeEnteredChute += HandlePrizeEnteredChute;
			((UnityEvent<PlayerControllerB>)(object)Refs.InteractTrigger.onInteract).AddListener((UnityAction<PlayerControllerB>)OnPlayerInteract);
			BuildTierScrapPool();
			StockInitialPrizes();
		}

		private void OnDestroy()
		{
			if (_isLocalControlling)
			{
				ForceExitLocalPlayer();
			}
			if ((Object)(object)_darkTex != (Object)null)
			{
				Object.Destroy((Object)(object)_darkTex);
			}
			if ((Object)(object)_accentTex != (Object)null)
			{
				Object.Destroy((Object)(object)_accentTex);
			}
		}

		private void BuildTierScrapPool()
		{
			_tierItemIndices.Clear();
			if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.allItemsList == (Object)null)
			{
				return;
			}
			List<Item> itemsList = StartOfRound.Instance.allItemsList.itemsList;
			List<(int, float)> list = new List<(int, float)>();
			for (int i = 0; i < itemsList.Count; i++)
			{
				Item val = itemsList[i];
				if ((Object)(object)val == (Object)null || !val.isScrap || (Object)(object)val.spawnPrefab == (Object)null)
				{
					continue;
				}
				string text = ((val.itemName != null) ? val.itemName.ToLowerInvariant() : "");
				if (!text.Contains("hive") && !text.Contains("body") && !text.Contains("corpse") && !text.Contains("shotgun") && !text.Contains("knife") && !text.Contains("sign") && (!((Object)(object)val.spawnPrefab.GetComponentInChildren<MeshRenderer>(true) == (Object)null) || !((Object)(object)val.spawnPrefab.GetComponentInChildren<SkinnedMeshRenderer>(true) == (Object)null)))
				{
					float num = (float)(val.minValue + val.maxValue) * 0.5f;
					if (text.Contains("gold bar") || text.Contains("cash register") || text.Contains("wedding ring") || text.Contains("ring") || text.Contains("fancy lamp") || text.Contains("painting") || text.Contains("perfume") || text.Contains("chalice") || text.Contains("golden cup") || text.Contains("apparatus") || text.Contains("zed dog") || text.Contains("ruby"))
					{
						num = Mathf.Max(num, 190f);
					}
					else if (text.Contains("bottles") || text.Contains("airhorn") || text.Contains("clown horn") || text.Contains("hairdryer") || text.Contains("brass bell") || text.Contains("toy robot") || text.Contains("large axle") || text.Contains("v-type") || text.Contains("chemical jug") || text.Contains("magic 7") || text.Contains("laser pointer"))
					{
						num = Mathf.Clamp(num, 95f, 155f);
					}
					else if (text.Contains("rubber ducky") || text.Contains("whoopie") || text.Contains("soccer") || text.Contains("ball") || text.Contains("candy") || text.Contains("mug") || text.Contains("toothpaste") || text.Contains("red soda") || text.Contains("dust pan") || text.Contains("pill bottle") || text.Contains("plastic fish") || text.Contains("cookie") || text.Contains("egg beater") || text.Contains("hairbrush") || text.Contains("steering"))
					{
						num = Mathf.Min(num, 82f);
					}
					list.Add((i, num));
				}
			}
			if (list.Count != 0)
			{
				list.Sort(((int index, float score) a, (int index, float score) b) => a.score.CompareTo(b.score));
				int count = list.Count;
				int num2;
				int num3;
				switch (Tier.Tier)
				{
				case ClawTier.Low:
					num2 = 0;
					num3 = Mathf.Max(1, Mathf.CeilToInt((float)count * 0.34f));
					break;
				case ClawTier.Medium:
					num2 = Mathf.FloorToInt((float)count * 0.33f);
					num3 = Mathf.Max(num2 + 1, Mathf.CeilToInt((float)count * 0.67f));
					break;
				default:
					num2 = Mathf.FloorToInt((float)count * 0.66f);
					num3 = count;
					break;
				}
				num2 = Mathf.Clamp(num2, 0, count - 1);
				num3 = Mathf.Clamp(num3, num2 + 1, count);
				for (int num4 = num2; num4 < num3; num4++)
				{
					_tierItemIndices.Add(list[num4].Item1);
				}
			}
		}

		private void StockInitialPrizes()
		{
			int num = Mathf.Clamp(ClawConfig.PrizesPerMachine.Value, 4, 24);
			for (int i = 0; i < num; i++)
			{
				SpawnOnePhysicalPrize(i);
			}
		}

		private void SpawnOnePhysicalPrize(int seedOffset = 0)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00a6: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			if (_tierItemIndices.Count != 0 && !((Object)(object)StartOfRound.Instance == (Object)null))
			{
				int num = _tierItemIndices[Random.Range(0, _tierItemIndices.Count)];
				Item val = StartOfRound.Instance.allItemsList.itemsList[num];
				int prizeValue = Random.Range(Tier.MinPrizeValue, Tier.MaxPrizeValue + 1);
				GameObject val2 = new GameObject("ClawPrize_" + val.itemName);
				val2.transform.SetParent(Refs.PrizesContainer, false);
				Vector3 localPosition = PickSafePitSpawnPos(seedOffset);
				val2.transform.localPosition = localPosition;
				val2.transform.localRotation = Random.rotation;
				ClawPrizeItem clawPrizeItem = val2.AddComponent<ClawPrizeItem>();
				clawPrizeItem.Initialize(val, num, prizeValue, ((Component)this).transform, Refs.PitCenterLocal, Refs.PitHalfExtents, Refs.FallbackPrizeMat);
				_stockedPrizes.Add(clawPrizeItem);
			}
		}

		private Vector3 PickSafePitSpawnPos(int seedOffset)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 25; i++)
			{
				float num = Random.Range(-0.48f, 0.5f);
				float num2 = Random.Range(-0.38f, 0.4f);
				if (!(num < -0.06f) || !(num2 < 0.04f))
				{
					float num3 = 1.06f + (float)(seedOffset % 3) * 0.11f + Random.Range(0f, 0.03f);
					return new Vector3(num, num3, num2);
				}
			}
			return new Vector3(0.24f, 1.12f, 0.16f);
		}

		private void OnPlayerInteract(PlayerControllerB player)
		{
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || !((NetworkBehaviour)player).IsOwner)
			{
				return;
			}
			if (IsOccupied)
			{
				HUDManager instance = HUDManager.Instance;
				if (instance != null)
				{
					instance.DisplayTip("Claw Machine Busy", "Another player is currently using this claw machine.", true, false, "LC_Tip1");
				}
				return;
			}
			if (ClawConfig.FreePlayMode.Value)
			{
				StartLocalPlaySession(player);
				return;
			}
			GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
			bool flag = false;
			if ((Object)(object)currentlyHeldObjectServer != (Object)null && (Object)(object)currentlyHeldObjectServer.itemProperties != (Object)null && currentlyHeldObjectServer.itemProperties.isScrap && currentlyHeldObjectServer.scrapValue > 0)
			{
				int num = Mathf.Max(0, Tier.PlayCost - _depositedValue);
				if (currentlyHeldObjectServer.scrapValue <= num)
				{
					_depositedValue += currentlyHeldObjectServer.scrapValue;
					player.DestroyItemInSlotAndS