Decompiled source of SuperBattleGolf Valuables v1.0.0

SuperBattleGolfValuables.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;

[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("Empress")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5f1b735e473ca4ccf3b383128fbebd889cb564da")]
[assembly: AssemblyProduct("SuperBattleGolfValuables")]
[assembly: AssemblyTitle("SuperBattleGolfValuables")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Empress.REPO.SuperBattleGolfValuables
{
	internal static class RepoValuableAccess
	{
		private delegate void PlayerHealthHurtOtherDelegate(PlayerHealth instance, int damage, Vector3 hurtPosition, bool savingGrace, int enemyIndex, bool hurtByHeal);

		private delegate void PlayerTumbleRequestDelegate(PlayerTumble instance, bool isTumbling, bool playerInput);

		private delegate void PlayerTumbleOverrideTimeDelegate(PlayerTumble instance, float time);

		private delegate void EnemyHealthHurtDelegate(EnemyHealth instance, int damage, Vector3 hurtDirection);

		private delegate void ImpactDestroyObjectDelegate(PhysGrabObjectImpactDetector instance, bool effects);

		private static readonly FieldRef<RunManager> RunManagerInstanceRef = AccessTools.StaticFieldRefAccess<RunManager>(RequiredField(typeof(RunManager), "instance"));

		private static readonly FieldRef<LevelValuables, List<PrefabRef>> TinyRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("tiny");

		private static readonly FieldRef<LevelValuables, List<PrefabRef>> SmallRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("small");

		private static readonly FieldRef<LevelValuables, List<PrefabRef>> MediumRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("medium");

		private static readonly FieldRef<LevelValuables, List<PrefabRef>> BigRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("big");

		private static readonly FieldRef<LevelValuables, List<PrefabRef>> WideRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("wide");

		private static readonly FieldRef<LevelValuables, List<PrefabRef>> TallRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("tall");

		private static readonly FieldRef<LevelValuables, List<PrefabRef>> VeryTallRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("veryTall");

		private static readonly FieldRef<ValuableObject, Value> ValuePresetRef = AccessTools.FieldRefAccess<ValuableObject, Value>("valuePreset");

		private static readonly FieldRef<ValuableObject, Durability> DurabilityPresetRef = AccessTools.FieldRefAccess<ValuableObject, Durability>("durabilityPreset");

		private static readonly FieldRef<ValuableObject, PhysAttribute> PhysAttributePresetRef = AccessTools.FieldRefAccess<ValuableObject, PhysAttribute>("physAttributePreset");

		private static readonly FieldRef<ValuableObject, Type> VolumeTypeRef = AccessTools.FieldRefAccess<ValuableObject, Type>("volumeType");

		private static readonly FieldRef<ValuableObject, int> DollarValueOverrideRef = AccessTools.FieldRefAccess<ValuableObject, int>("dollarValueOverride");

		private static readonly FieldRef<ValuableObject, bool> DebugVolumeRef = AccessTools.FieldRefAccess<ValuableObject, bool>("debugVolume");

		private static readonly FieldRef<ValuableObject, Gradient> ParticleColorsRef = AccessTools.FieldRefAccess<ValuableObject, Gradient>("particleColors");

		private static readonly FieldRef<Value, float> ValueMinRef = AccessTools.FieldRefAccess<Value, float>("valueMin");

		private static readonly FieldRef<Value, float> ValueMaxRef = AccessTools.FieldRefAccess<Value, float>("valueMax");

		private static readonly FieldRef<Durability, float> FragilityRef = AccessTools.FieldRefAccess<Durability, float>("fragility");

		private static readonly FieldRef<Durability, float> DurabilityRef = AccessTools.FieldRefAccess<Durability, float>("durability");

		private static readonly FieldRef<PhysAttribute, float> MassRef = AccessTools.FieldRefAccess<PhysAttribute, float>("mass");

		private static readonly FieldRef<PhysGrabObject, bool> GrabbedRef = AccessTools.FieldRefAccess<PhysGrabObject, bool>("grabbed");

		private static readonly FieldRef<PhysGrabObject, bool> GrabbedLocalRef = AccessTools.FieldRefAccess<PhysGrabObject, bool>("grabbedLocal");

		private static readonly FieldRef<PhysGrabObject, bool> HeldByLocalPlayerRef = AccessTools.FieldRefAccess<PhysGrabObject, bool>("heldByLocalPlayer");

		private static readonly FieldRef<PhysGrabObject, List<PhysGrabber>> PlayerGrabbingRef = AccessTools.FieldRefAccess<PhysGrabObject, List<PhysGrabber>>("playerGrabbing");

		private static readonly FieldRef<PhysGrabObjectImpactDetector, int> BreakLevelHeavyRef = AccessTools.FieldRefAccess<PhysGrabObjectImpactDetector, int>("breakLevelHeavy");

		private static readonly FieldRef<PhysGrabObjectImpactDetector, int> BreakLevelMediumRef = AccessTools.FieldRefAccess<PhysGrabObjectImpactDetector, int>("breakLevelMedium");

		private static readonly FieldRef<PhysGrabObjectImpactDetector, int> BreakLevelLightRef = AccessTools.FieldRefAccess<PhysGrabObjectImpactDetector, int>("breakLevelLight");

		private static readonly FieldRef<PlayerAvatar, bool> PlayerIsDisabledRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isDisabled");

		private static readonly FieldRef<PlayerAvatar, bool> PlayerDeadSetRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("deadSet");

		private static readonly FieldRef<PlayerAvatar, PlayerHealth> PlayerHealthRef = AccessTools.FieldRefAccess<PlayerAvatar, PlayerHealth>("playerHealth");

		private static readonly FieldRef<PlayerAvatar, PlayerTumble> PlayerTumbleRef = AccessTools.FieldRefAccess<PlayerAvatar, PlayerTumble>("tumble");

		private static readonly FieldRef<PhysGrabObjectBoxCollider, bool> BoxColliderDrawGizmosRef = AccessTools.FieldRefAccess<PhysGrabObjectBoxCollider, bool>("drawGizmos");

		private static readonly FieldRef<PhysGrabObjectMeshCollider, bool> MeshColliderShowGizmoRef = AccessTools.FieldRefAccess<PhysGrabObjectMeshCollider, bool>("showGizmo");

		private static readonly PlayerHealthHurtOtherDelegate PlayerHealthHurtOtherRef = AccessTools.MethodDelegate<PlayerHealthHurtOtherDelegate>(RequiredMethod(typeof(PlayerHealth), "HurtOther", typeof(int), typeof(Vector3), typeof(bool), typeof(int), typeof(bool)), (object)null, true);

		private static readonly PlayerTumbleRequestDelegate PlayerTumbleRequestRef = AccessTools.MethodDelegate<PlayerTumbleRequestDelegate>(RequiredMethod(typeof(PlayerTumble), "TumbleRequest", typeof(bool), typeof(bool)), (object)null, true);

		private static readonly PlayerTumbleOverrideTimeDelegate PlayerTumbleOverrideTimeRef = AccessTools.MethodDelegate<PlayerTumbleOverrideTimeDelegate>(RequiredMethod(typeof(PlayerTumble), "TumbleOverrideTime", typeof(float)), (object)null, true);

		private static readonly EnemyHealthHurtDelegate EnemyHealthHurtRef = AccessTools.MethodDelegate<EnemyHealthHurtDelegate>(RequiredMethod(typeof(EnemyHealth), "Hurt", typeof(int), typeof(Vector3)), (object)null, true);

		private static readonly ImpactDestroyObjectDelegate ImpactDestroyObjectRef = AccessTools.MethodDelegate<ImpactDestroyObjectDelegate>(RequiredMethod(typeof(PhysGrabObjectImpactDetector), "DestroyObject", typeof(bool)), (object)null, true);

		public static RunManager? GetRunManagerInstance()
		{
			return RunManagerInstanceRef.Invoke();
		}

		public static List<PrefabRef> GetList(LevelValuables preset, Type type)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			return (int)type switch
			{
				0 => TinyRef.Invoke(preset), 
				1 => SmallRef.Invoke(preset), 
				2 => MediumRef.Invoke(preset), 
				3 => BigRef.Invoke(preset), 
				4 => WideRef.Invoke(preset), 
				5 => TallRef.Invoke(preset), 
				6 => VeryTallRef.Invoke(preset), 
				_ => MediumRef.Invoke(preset), 
			};
		}

		public static void ConfigureValuable(ValuableObject valuable, SuperBattleGolfValuableDefinition definition)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected I4, but got Unknown
			ValuePresetRef.Invoke(valuable) = CreateValuePreset(definition);
			DurabilityPresetRef.Invoke(valuable) = CreateDurabilityPreset(definition);
			PhysAttributePresetRef.Invoke(valuable) = CreatePhysAttributePreset(definition);
			VolumeTypeRef.Invoke(valuable) = (Type)(int)definition.VolumeType;
			DollarValueOverrideRef.Invoke(valuable) = 0;
			DebugVolumeRef.Invoke(valuable) = false;
			ParticleColorsRef.Invoke(valuable) = CreateParticleGradient(definition);
		}

		public static bool IsGrabbed(PhysGrabObject physGrabObject)
		{
			return GrabbedRef.Invoke(physGrabObject);
		}

		public static bool IsGrabbedForVoice(PhysGrabObject physGrabObject)
		{
			List<PhysGrabber> list = PlayerGrabbingRef.Invoke(physGrabObject);
			if (!GrabbedRef.Invoke(physGrabObject) && !GrabbedLocalRef.Invoke(physGrabObject) && !HeldByLocalPlayerRef.Invoke(physGrabObject))
			{
				if (list != null)
				{
					return list.Count > 0;
				}
				return false;
			}
			return true;
		}

		public static ImpactState GetBreakState(PhysGrabObjectImpactDetector detector, int breakLevel)
		{
			if (breakLevel != BreakLevelHeavyRef.Invoke(detector))
			{
				if (breakLevel != BreakLevelMediumRef.Invoke(detector))
				{
					if (breakLevel != BreakLevelLightRef.Invoke(detector))
					{
						return (ImpactState)0;
					}
					return (ImpactState)1;
				}
				return (ImpactState)2;
			}
			return (ImpactState)3;
		}

		public static bool CanAffectPlayer(PlayerAvatar player)
		{
			if ((Object)(object)player != (Object)null && !PlayerIsDisabledRef.Invoke(player) && !PlayerDeadSetRef.Invoke(player))
			{
				return (Object)(object)PlayerHealthRef.Invoke(player) != (Object)null;
			}
			return false;
		}

		public static void HurtPlayer(PlayerAvatar player, int damage)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			PlayerHealth val = PlayerHealthRef.Invoke(player);
			if ((Object)(object)val != (Object)null)
			{
				PlayerHealthHurtOtherRef(val, damage, Vector3.zero, savingGrace: false, -1, hurtByHeal: false);
			}
		}

		public static void TumblePlayer(PlayerAvatar player, float time)
		{
			PlayerTumble val = PlayerTumbleRef.Invoke(player);
			if (!((Object)(object)val == (Object)null))
			{
				PlayerTumbleRequestRef(val, isTumbling: true, playerInput: false);
				PlayerTumbleOverrideTimeRef(val, time);
			}
		}

		public static void HurtEnemy(EnemyHealth enemyHealth, int damage, Vector3 hurtDirection)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)enemyHealth != (Object)null)
			{
				EnemyHealthHurtRef(enemyHealth, damage, hurtDirection);
			}
		}

		public static void DestroyImpactObject(PhysGrabObjectImpactDetector detector, bool effects)
		{
			if ((Object)(object)detector != (Object)null)
			{
				ImpactDestroyObjectRef(detector, effects);
			}
		}

		public static void HideGrabMeshColliderGizmo(PhysGrabObjectMeshCollider meshHelper)
		{
			if ((Object)(object)meshHelper != (Object)null)
			{
				MeshColliderShowGizmoRef.Invoke(meshHelper) = false;
			}
		}

		public static void HideGrabBoxColliderGizmo(PhysGrabObjectBoxCollider boxHelper)
		{
			if ((Object)(object)boxHelper != (Object)null)
			{
				BoxColliderDrawGizmosRef.Invoke(boxHelper) = false;
			}
		}

		private static Value CreateValuePreset(SuperBattleGolfValuableDefinition definition)
		{
			Value val = ScriptableObject.CreateInstance<Value>();
			((Object)val).hideFlags = (HideFlags)61;
			((Object)val).name = "Value - " + definition.DisplayName;
			ValueMinRef.Invoke(val) = definition.ValueMin;
			ValueMaxRef.Invoke(val) = definition.ValueMax;
			return val;
		}

		private static Durability CreateDurabilityPreset(SuperBattleGolfValuableDefinition definition)
		{
			Durability val = ScriptableObject.CreateInstance<Durability>();
			((Object)val).hideFlags = (HideFlags)61;
			((Object)val).name = "Durability - " + definition.DisplayName;
			FragilityRef.Invoke(val) = Mathf.Clamp(definition.Fragility + StableJitter(definition.PrefabName, "fragility", 5.5f), 5f, 95f);
			DurabilityRef.Invoke(val) = Mathf.Clamp(definition.Durability + StableJitter(definition.PrefabName, "durability", 5.5f), 5f, 100f);
			return val;
		}

		private static PhysAttribute CreatePhysAttributePreset(SuperBattleGolfValuableDefinition definition)
		{
			PhysAttribute val = ScriptableObject.CreateInstance<PhysAttribute>();
			((Object)val).hideFlags = (HideFlags)61;
			((Object)val).name = "PhysAttribute - " + definition.DisplayName;
			MassRef.Invoke(val) = definition.Mass;
			return val;
		}

		private static float StableJitter(string name, string salt, float radius)
		{
			uint num = 2166136261u;
			string text = name + ":" + salt;
			for (int i = 0; i < text.Length; i++)
			{
				num ^= text[i];
				num *= 16777619;
			}
			return ((float)(num & 0xFFFFu) / 65535f * 2f - 1f) * radius;
		}

		private static Gradient CreateParticleGradient(SuperBattleGolfValuableDefinition definition)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005d: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(definition.Accent, 0f),
				new GradientColorKey(Color.Lerp(definition.Primary, definition.Secondary, 0.6f), 0.55f),
				new GradientColorKey(definition.Secondary, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0.8f, 0.75f),
				new GradientAlphaKey(0f, 1f)
			});
			return val;
		}

		private static FieldInfo RequiredField(Type type, string fieldName)
		{
			FieldInfo fieldInfo = AccessTools.Field(type, fieldName);
			if (fieldInfo == null)
			{
				throw new MissingFieldException(type.FullName, fieldName);
			}
			return fieldInfo;
		}

		private static MethodInfo RequiredMethod(Type type, string methodName, params Type[] parameters)
		{
			MethodInfo methodInfo = AccessTools.Method(type, methodName, parameters, (Type[])null);
			if (methodInfo == null)
			{
				throw new MissingMethodException(type.FullName, methodName);
			}
			return methodInfo;
		}
	}
	[HarmonyPatch]
	internal static class SuperBattleGolfPhysGrabObjectStartPatches
	{
		private static readonly string[] GrabMethodNames = new string[4] { "GrabStarted", "GrabStartedRPC", "GrabPlayerAddRPC", "GrabLinkRPC" };

		private static IEnumerable<MethodBase> TargetMethods()
		{
			string[] grabMethodNames = GrabMethodNames;
			foreach (string text in grabMethodNames)
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(PhysGrabObject), text, (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					yield return methodInfo;
				}
			}
		}

		private static void Postfix(PhysGrabObject __instance, MethodBase __originalMethod)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				SuperBattleGolfValuableGrabFeedback.TriggerFrom(__instance, __originalMethod.Name);
			}
		}
	}
	[HarmonyPatch]
	internal static class SuperBattleGolfPhysGrabObjectReleasePatches
	{
		private static readonly string[] ReleaseMethodNames = new string[3] { "GrabEnded", "GrabEndedRPC", "GrabPlayerRemoveRPC" };

		private static IEnumerable<MethodBase> TargetMethods()
		{
			string[] releaseMethodNames = ReleaseMethodNames;
			foreach (string text in releaseMethodNames)
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(PhysGrabObject), text, (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					yield return methodInfo;
				}
			}
		}

		private static void Postfix(PhysGrabObject __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				SuperBattleGolfValuableGrabFeedback.ReleaseFrom(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")]
	internal static class SuperBattleGolfImpactBreakPatch
	{
		private static void Postfix(PhysGrabObjectImpactDetector __instance, Vector3 _contactPoint, int breakLevel)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			SuperBattleGolfValuableBreakFeedback.TriggerFrom(__instance, _contactPoint, breakLevel, destroyed: false);
		}
	}
	[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "DestroyObjectRPC")]
	internal static class SuperBattleGolfImpactDestroyPatch
	{
		private static void Postfix(PhysGrabObjectImpactDetector __instance, bool effects)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if (effects)
			{
				SuperBattleGolfValuableBreakFeedback.TriggerFrom(__instance, ((Component)__instance).transform.position, 0, destroyed: true);
			}
		}
	}
	internal sealed class SuperBattleGolfValuableActiveLogic : MonoBehaviour
	{
		private const float LandmineArmDelay = 0.85f;

		private const float LandmineTriggerRadius = 0.95f;

		private const float LandmineBeepInterval = 1.35f;

		private const float MagnetDuration = 2.6f;

		private const float MagnetTickInterval = 0.08f;

		private const float RocketArmDelay = 0.35f;

		private const float FreezeArmDelay = 0.35f;

		private static readonly Collider[] NearbyColliders = (Collider[])(object)new Collider[64];

		private SuperBattleGolfValuableDefinition? _definition;

		private PhysGrabObject? _physGrabObject;

		private PhysGrabObjectImpactDetector? _impactDetector;

		private Rigidbody? _rigidbody;

		private bool _runtimeReady;

		private bool _landmineArming;

		private bool _landmineArmed;

		private bool _landmineDetonated;

		private bool _rocketArmed;

		private bool _freezeArmed;

		private float _landmineArmTime;

		private float _nextLandmineBeepTime;

		private float _rocketArmTime;

		private float _freezeArmTime;

		private float _magnetEndTime;

		private float _nextMagnetTickTime;

		public void Configure(SuperBattleGolfValuableDefinition definition)
		{
			_definition = definition;
		}

		private void Start()
		{
			EnsureRuntimeReady();
		}

		private void Update()
		{
			EnsureRuntimeReady();
			if (_definition != null)
			{
				UpdateLandmine();
				UpdateMagnet();
			}
		}

		private void OnCollisionEnter(Collision collision)
		{
			HandleCollision(collision);
		}

		private void OnCollisionStay(Collision collision)
		{
			HandleCollision(collision);
		}

		internal static void TriggerFrom(PhysGrabObject physGrabObject, string source)
		{
			if (!((Object)(object)physGrabObject == (Object)null))
			{
				SuperBattleGolfValuableActiveLogic superBattleGolfValuableActiveLogic = ((Component)physGrabObject).GetComponent<SuperBattleGolfValuableActiveLogic>();
				if ((Object)(object)superBattleGolfValuableActiveLogic == (Object)null)
				{
					superBattleGolfValuableActiveLogic = ((Component)physGrabObject).GetComponentInChildren<SuperBattleGolfValuableActiveLogic>(true);
				}
				superBattleGolfValuableActiveLogic?.OnGrab(source);
			}
		}

		private void EnsureRuntimeReady()
		{
			_physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			_impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			_rigidbody = ((Component)this).GetComponent<Rigidbody>();
			if (_definition == null)
			{
				string prefabName = ((Object)((Component)this).gameObject).name.Replace("(Clone)", string.Empty).Trim();
				_definition = SuperBattleGolfValuableDefinitions.FindByPrefabName(prefabName);
			}
			_runtimeReady = true;
		}

		private void OnGrab(string source)
		{
			EnsureRuntimeReady();
			if (_definition != null)
			{
				switch (_definition.PrefabName)
				{
				case "SuperBattleGolfValuable_Landmine":
					ArmLandmine();
					break;
				case "SuperBattleGolfValuable_Electromagnet":
					ActivateMagnet();
					break;
				case "SuperBattleGolfValuable_FreezeBomb":
				case "SuperBattleGolfValuable_FreezeBombIceBlock":
					ArmFreezeBomb();
					break;
				case "SuperBattleGolfValuable_Rocket":
					ArmRocket();
					break;
				}
			}
		}

		private void ArmLandmine()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (!_landmineArmed && !_landmineArming && !_landmineDetonated)
			{
				_landmineArming = true;
				_landmineArmTime = Time.time + 0.85f;
				_nextLandmineBeepTime = _landmineArmTime;
				SpawnPulse(((Component)this).transform.position, 1.2f, new Color(1f, 0.48f, 0.16f), 1.9f, 0.32f);
			}
		}

		private void UpdateLandmine()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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)
			if (_definition?.PrefabName != "SuperBattleGolfValuable_Landmine" || _landmineDetonated)
			{
				return;
			}
			if (_landmineArming && Time.time >= _landmineArmTime)
			{
				_landmineArming = false;
				_landmineArmed = true;
				PlayClip("SBG_LandmineArmedBeep", ((Component)this).transform.position, 0.9f);
				SpawnPulse(((Component)this).transform.position, 1.45f, new Color(1f, 0.2f, 0.1f), 2.3f, 0.3f);
			}
			if (!_landmineArmed)
			{
				return;
			}
			if (Time.time >= _nextLandmineBeepTime)
			{
				_nextLandmineBeepTime = Time.time + 1.35f;
				PlayClip("SBG_LandmineArmedBeep", ((Component)this).transform.position, 0.55f);
				SpawnPulse(((Component)this).transform.position, 0.95f, new Color(1f, 0.12f, 0.05f), 1.4f, 0.2f);
			}
			if (IsGrabbed() || !IsAuthoritative())
			{
				return;
			}
			int num = Physics.OverlapSphereNonAlloc(((Component)this).transform.position, 0.95f, NearbyColliders, -1, (QueryTriggerInteraction)2);
			for (int i = 0; i < num; i++)
			{
				Collider collider = NearbyColliders[i];
				if (IsMeaningfulTrigger(collider))
				{
					Detonate();
					break;
				}
			}
		}

		private void ActivateMagnet()
		{
			//IL_002d: 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)
			_magnetEndTime = Mathf.Max(_magnetEndTime, Time.time + 2.6f);
			_nextMagnetTickTime = 0f;
			SpawnPulse(((Component)this).transform.position, 2.35f, new Color(0.48f, 0.62f, 1f), 2.1f, 0.38f);
		}

		private void UpdateMagnet()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (!(_definition?.PrefabName != "SuperBattleGolfValuable_Electromagnet") && !(Time.time > _magnetEndTime) && !(Time.time < _nextMagnetTickTime) && IsAuthoritative())
			{
				_nextMagnetTickTime = Time.time + 0.08f;
				PullNearby(((Component)this).transform.position, 5.2f, 0.34f);
			}
		}

		private void ArmFreezeBomb()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			_freezeArmed = true;
			_freezeArmTime = Time.time + 0.35f;
			SpawnPulse(((Component)this).transform.position, 1.7f, new Color(0.45f, 0.95f, 1f), 2f, 0.36f);
		}

		private void ArmRocket()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			_rocketArmed = true;
			_rocketArmTime = Time.time + 0.35f;
			SpawnPulse(((Component)this).transform.position, 1.6f, new Color(1f, 0.42f, 0.16f), 2f, 0.32f);
			if ((Object)(object)_rigidbody != (Object)null && IsAuthoritative())
			{
				_rigidbody.AddForce(((Component)this).transform.forward * 0.9f, (ForceMode)1);
			}
		}

		private void HandleCollision(Collision collision)
		{
			if (_runtimeReady && _definition != null && IsAuthoritative())
			{
				if (_definition.PrefabName == "SuperBattleGolfValuable_Landmine" && _landmineArmed && !_landmineDetonated && !IsGrabbed() && (Object)(object)collision.collider != (Object)null && IsMeaningfulTrigger(collision.collider))
				{
					Detonate();
				}
				else if ((_definition.PrefabName == "SuperBattleGolfValuable_FreezeBomb" || _definition.PrefabName == "SuperBattleGolfValuable_FreezeBombIceBlock") && _freezeArmed && Time.time >= _freezeArmTime && !IsGrabbed() && IsMeaningfulCollision(collision, 0.7f))
				{
					Detonate();
				}
				else if (_definition.PrefabName == "SuperBattleGolfValuable_Rocket" && _rocketArmed && Time.time >= _rocketArmTime && !IsGrabbed() && IsMeaningfulCollision(collision, 1.2f))
				{
					Detonate();
				}
			}
		}

		private bool IsMeaningfulCollision(Collision collision, float minimumVelocity)
		{
			//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)
			if (collision == null || (Object)(object)collision.collider == (Object)null)
			{
				return false;
			}
			Vector3 relativeVelocity = collision.relativeVelocity;
			if (((Vector3)(ref relativeVelocity)).magnitude >= minimumVelocity)
			{
				return true;
			}
			return IsMeaningfulTrigger(collision.collider);
		}

		private bool IsMeaningfulTrigger(Collider collider)
		{
			if ((Object)(object)collider == (Object)null || (Object)(object)((Component)collider).transform == (Object)null || ((Component)collider).transform.IsChildOf(((Component)this).transform))
			{
				return false;
			}
			PhysGrabObject componentInParent = ((Component)collider).GetComponentInParent<PhysGrabObject>();
			if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent == (Object)(object)_physGrabObject)
			{
				return false;
			}
			if ((Object)(object)((Component)collider).GetComponentInParent<PlayerAvatar>() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent<EnemyHealth>() != (Object)null)
			{
				return true;
			}
			Rigidbody attachedRigidbody = collider.attachedRigidbody;
			if ((Object)(object)attachedRigidbody != (Object)null && !attachedRigidbody.isKinematic)
			{
				return (Object)(object)attachedRigidbody != (Object)(object)_rigidbody;
			}
			return false;
		}

		private void Detonate()
		{
			if (!_landmineDetonated)
			{
				_landmineDetonated = true;
				if ((Object)(object)_impactDetector != (Object)null)
				{
					RepoValuableAccess.DestroyImpactObject(_impactDetector, effects: true);
				}
			}
		}

		private bool IsGrabbed()
		{
			if ((Object)(object)_physGrabObject != (Object)null)
			{
				return RepoValuableAccess.IsGrabbedForVoice(_physGrabObject);
			}
			return false;
		}

		private void PullNearby(Vector3 origin, float radius, float force)
		{
			//IL_0000: 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_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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			int num = Physics.OverlapSphereNonAlloc(origin, radius, NearbyColliders, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < num; i++)
			{
				Rigidbody val = (((Object)(object)NearbyColliders[i] != (Object)null) ? NearbyColliders[i].attachedRigidbody : null);
				if (!((Object)(object)val == (Object)null) && !val.isKinematic && !((Component)val).transform.IsChildOf(((Component)this).transform))
				{
					Vector3 val2 = origin - val.worldCenterOfMass;
					float num2 = Mathf.Max(0.1f, ((Vector3)(ref val2)).magnitude);
					val.AddForce(val2 / num2 * (force * Mathf.Clamp01(1f - num2 / radius)), (ForceMode)1);
				}
			}
		}

		private static bool IsAuthoritative()
		{
			if (!PhotonNetwork.OfflineMode && PhotonNetwork.InRoom)
			{
				return PhotonNetwork.IsMasterClient;
			}
			return true;
		}

		private static void PlayClip(string clipName, Vector3 origin, float volume)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			AudioClip val = SuperBattleGolfValuableBundleVisuals.LoadAudioClip(clipName);
			if (!((Object)(object)val == (Object)null))
			{
				if ((int)val.loadState == 0)
				{
					val.LoadAudioData();
				}
				if ((int)val.loadState != 3)
				{
					AudioSource.PlayClipAtPoint(val, origin, volume);
				}
			}
		}

		private static void SpawnPulse(Vector3 origin, float radius, Color color, float intensity, float duration)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_001e: 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 = new GameObject("Super Battle Golf Active Pulse")
			{
				hideFlags = (HideFlags)52
			};
			val.transform.position = origin;
			Light val2 = val.AddComponent<Light>();
			val2.type = (LightType)2;
			val2.color = color;
			val2.intensity = intensity;
			val2.range = radius;
			val.AddComponent<SuperBattleGolfValuableLightFade>().Configure(val2, duration);
		}
	}
	internal sealed class SuperBattleGolfValuableBreakFeedback : MonoBehaviour
	{
		private const float LogicCooldown = 0.5f;

		private static readonly Collider[] NearbyColliders = (Collider[])(object)new Collider[64];

		private SuperBattleGolfValuableDefinition? _definition;

		private PhysGrabObject? _physGrabObject;

		private float _lastLogicTime = -999f;

		public void Configure(SuperBattleGolfValuableDefinition definition)
		{
			_definition = definition;
		}

		private void Start()
		{
			EnsureRuntimeReady();
		}

		private void EnsureRuntimeReady()
		{
			_physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			if (_definition == null)
			{
				string prefabName = ((Object)((Component)this).gameObject).name.Replace("(Clone)", string.Empty).Trim();
				_definition = SuperBattleGolfValuableDefinitions.FindByPrefabName(prefabName);
			}
		}

		internal static void TriggerFrom(PhysGrabObjectImpactDetector detector, Vector3 contactPoint, int breakLevel, bool destroyed)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)detector == (Object)null))
			{
				SuperBattleGolfValuableBreakFeedback superBattleGolfValuableBreakFeedback = ((Component)detector).GetComponent<SuperBattleGolfValuableBreakFeedback>();
				if ((Object)(object)superBattleGolfValuableBreakFeedback == (Object)null)
				{
					superBattleGolfValuableBreakFeedback = ((Component)detector).GetComponentInChildren<SuperBattleGolfValuableBreakFeedback>(true);
				}
				ImpactState state = (ImpactState)(destroyed ? 3 : ((int)RepoValuableAccess.GetBreakState(detector, breakLevel)));
				superBattleGolfValuableBreakFeedback?.TriggerBreak(contactPoint, state, destroyed);
			}
		}

		private void TriggerBreak(Vector3 contactPoint, ImpactState state, bool destroyed)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: 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_014f: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			EnsureRuntimeReady();
			if (_definition == null || (int)state == 0 || Time.time - _lastLogicTime < 0.5f)
			{
				return;
			}
			_lastLogicTime = Time.time;
			bool flag = destroyed || (int)state == 3;
			string prefabName = _definition.PrefabName;
			if (prefabName == null)
			{
				return;
			}
			switch (prefabName.Length)
			{
			case 42:
				switch (prefabName[24])
				{
				default:
					return;
				case 'F':
					break;
				case 'O':
					if (prefabName == "SuperBattleGolfValuable_OrbitalLaserRemote" && flag)
					{
						Explode(contactPoint + Vector3.up * 0.35f, 4.6f, 5.4f, new Color(0.45f, 0.95f, 1f), "SBG_OrbitalLaserExplosion");
					}
					return;
				}
				if (!(prefabName == "SuperBattleGolfValuable_FreezeBombIceBlock"))
				{
					break;
				}
				goto IL_01ad;
			case 30:
				if (!(prefabName == "SuperBattleGolfValuable_Rocket"))
				{
					break;
				}
				goto IL_013d;
			case 38:
				if (!(prefabName == "SuperBattleGolfValuable_RocketLauncher"))
				{
					break;
				}
				goto IL_013d;
			case 32:
				if (prefabName == "SuperBattleGolfValuable_Landmine")
				{
					Explode(contactPoint, flag ? 5.6f : 4.2f, flag ? 7.5f : 4.8f, new Color(1f, 0.45f, 0.16f), "SBG_LandmineExplosion");
				}
				break;
			case 34:
				if (!(prefabName == "SuperBattleGolfValuable_FreezeBomb"))
				{
					break;
				}
				goto IL_01ad;
			case 37:
				if (prefabName == "SuperBattleGolfValuable_Electromagnet")
				{
					MagnetPulse(contactPoint, flag ? 5.4f : 4f, flag ? 4.5f : 2.6f);
				}
				break;
			case 31:
				if (prefabName == "SuperBattleGolfValuable_Airhorn" && flag)
				{
					Explode(contactPoint, 3.6f, 3.4f, new Color(1f, 0.92f, 0.48f), "SBG_Airhorn");
				}
				break;
			case 35:
				if (prefabName == "SuperBattleGolfValuable_SpringBoots")
				{
					SpringPulse(contactPoint, flag ? 3.8f : 2.6f, flag ? 5.6f : 3.4f);
				}
				break;
			case 33:
			case 36:
			case 39:
			case 40:
			case 41:
				break;
				IL_013d:
				if (flag)
				{
					Explode(contactPoint, 5.2f, 6.2f, Color.Lerp(Color.red, Color.yellow, 0.45f), "SBG_RocketExplosion");
				}
				break;
				IL_01ad:
				FreezePulse(contactPoint, flag ? 4.8f : 3.6f, flag ? 0.12f : 0.32f);
				break;
			}
		}

		private void Explode(Vector3 origin, float radius, float force, Color color, string clipName)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			SpawnPulse(origin, radius, color, 3.8f, 0.55f);
			PlayClip(clipName, origin);
			if (IsAuthoritative())
			{
				PushNearby(origin, radius, force, 0.45f);
				DamageNearby(origin, radius, Mathf.RoundToInt(force * 8f));
			}
		}

		private void FreezePulse(Vector3 origin, float radius, float velocityMultiplier)
		{
			//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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			SpawnPulse(origin, radius, new Color(0.45f, 0.95f, 1f), 3.2f, 0.7f);
			PlayClip("SBG_FreezeBombExplosion", origin);
			if (!IsAuthoritative())
			{
				return;
			}
			int num = Physics.OverlapSphereNonAlloc(origin, radius, NearbyColliders, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < num; i++)
			{
				Rigidbody val = (((Object)(object)NearbyColliders[i] != (Object)null) ? NearbyColliders[i].attachedRigidbody : null);
				if (!((Object)(object)val == (Object)null) && !ShouldSkip(val))
				{
					val.velocity *= velocityMultiplier;
					val.angularVelocity *= velocityMultiplier;
					val.AddForce(Vector3.up * 0.35f, (ForceMode)1);
				}
			}
			DamageNearby(origin, radius * 0.75f, 8);
		}

		private void MagnetPulse(Vector3 origin, float radius, float force)
		{
			//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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a0: 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)
			SpawnPulse(origin, radius, new Color(0.58f, 0.65f, 1f), 3f, 0.5f);
			PlayClip("SBG_ElectromagnetActivation", origin);
			if (!IsAuthoritative())
			{
				return;
			}
			int num = Physics.OverlapSphereNonAlloc(origin, radius, NearbyColliders, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < num; i++)
			{
				Rigidbody val = (((Object)(object)NearbyColliders[i] != (Object)null) ? NearbyColliders[i].attachedRigidbody : null);
				if (!((Object)(object)val == (Object)null) && !ShouldSkip(val))
				{
					Vector3 val2 = origin - val.worldCenterOfMass;
					float num2 = Mathf.Max(0.1f, ((Vector3)(ref val2)).magnitude);
					val.AddForce(val2 / num2 * (force * Mathf.Clamp01(1f - num2 / radius)), (ForceMode)1);
				}
			}
		}

		private void SpringPulse(Vector3 origin, float radius, float force)
		{
			//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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			SpawnPulse(origin, radius, new Color(0.55f, 1f, 0.35f), 2.8f, 0.45f);
			PlayClip("SBG_SpringBootsActivation", origin);
			if (IsAuthoritative())
			{
				PushNearby(origin, radius, force, 1.15f);
			}
		}

		private void PushNearby(Vector3 origin, float radius, float force, float upwardBias)
		{
			//IL_0000: 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_004d: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00a2: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			int num = Physics.OverlapSphereNonAlloc(origin, radius, NearbyColliders, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < num; i++)
			{
				Rigidbody val = (((Object)(object)NearbyColliders[i] != (Object)null) ? NearbyColliders[i].attachedRigidbody : null);
				if (!((Object)(object)val == (Object)null) && !ShouldSkip(val))
				{
					Vector3 val2 = val.worldCenterOfMass - origin;
					float num2 = Mathf.Max(0.1f, ((Vector3)(ref val2)).magnitude);
					Vector3 val3 = val2 / num2 + Vector3.up * upwardBias;
					Vector3 val4 = ((Vector3)(ref val3)).normalized * (force * Mathf.Clamp01(1f - num2 / radius));
					val.AddForce(val4, (ForceMode)1);
					val.AddTorque(Random.insideUnitSphere * force, (ForceMode)1);
				}
			}
		}

		private bool ShouldSkip(Rigidbody target)
		{
			if (!target.isKinematic)
			{
				return ((Component)target).transform.IsChildOf(((Component)this).transform);
			}
			return true;
		}

		private static void DamageNearby(Vector3 origin, float radius, int maxDamage)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0092: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
			foreach (PlayerAvatar val in array)
			{
				if (RepoValuableAccess.CanAffectPlayer(val))
				{
					float num = Vector3.Distance(((Component)val).transform.position, origin);
					if (!(num > radius))
					{
						int damage = Mathf.Max(1, Mathf.RoundToInt((float)maxDamage * Mathf.Lerp(1f, 0.35f, num / radius)));
						RepoValuableAccess.HurtPlayer(val, damage);
						RepoValuableAccess.TumblePlayer(val, 1.1f);
					}
				}
			}
			EnemyHealth[] array2 = Object.FindObjectsOfType<EnemyHealth>();
			foreach (EnemyHealth val2 in array2)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					float num2 = Vector3.Distance(((Component)val2).transform.position, origin);
					if (!(num2 > radius))
					{
						Vector3 val3 = ((Component)val2).transform.position - origin;
						RepoValuableAccess.HurtEnemy(val2, Mathf.Max(1, Mathf.RoundToInt((float)maxDamage * Mathf.Lerp(1f, 0.35f, num2 / radius))), ((Vector3)(ref val3)).normalized);
					}
				}
			}
		}

		private static bool IsAuthoritative()
		{
			if (!PhotonNetwork.OfflineMode && PhotonNetwork.InRoom)
			{
				return PhotonNetwork.IsMasterClient;
			}
			return true;
		}

		private static void PlayClip(string clipName, Vector3 origin)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			AudioClip val = SuperBattleGolfValuableBundleVisuals.LoadAudioClip(clipName);
			if (!((Object)(object)val == (Object)null))
			{
				if ((int)val.loadState == 0)
				{
					val.LoadAudioData();
				}
				if ((int)val.loadState != 3)
				{
					AudioSource.PlayClipAtPoint(val, origin, 1f);
				}
			}
		}

		private static void SpawnPulse(Vector3 origin, float radius, Color color, float intensity, float duration)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_001e: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_00b9: Expected O, but got Unknown
			//IL_00b9: 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_00c8: 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)
			GameObject val = new GameObject("Super Battle Golf Break Pulse")
			{
				hideFlags = (HideFlags)52
			};
			val.transform.position = origin;
			Light val2 = val.AddComponent<Light>();
			val2.type = (LightType)2;
			val2.color = color;
			val2.intensity = intensity;
			val2.range = radius;
			val.AddComponent<SuperBattleGolfValuableLightFade>().Configure(val2, duration);
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)obj).name = "Super Battle Golf Visible Pulse";
			((Object)obj).hideFlags = (HideFlags)52;
			obj.transform.position = origin;
			obj.transform.localScale = Vector3.one * radius * 2f;
			Collider component = obj.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Material val3 = new Material(Shader.Find("Standard"));
			Color color2 = color;
			color2.a = 0.26f;
			val3.color = color2;
			val3.SetFloat("_Mode", 3f);
			val3.SetInt("_SrcBlend", 5);
			val3.SetInt("_DstBlend", 10);
			val3.SetInt("_ZWrite", 0);
			val3.DisableKeyword("_ALPHATEST_ON");
			val3.EnableKeyword("_ALPHABLEND_ON");
			val3.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val3.renderQueue = 3000;
			Renderer component2 = obj.GetComponent<Renderer>();
			component2.sharedMaterial = val3;
			obj.AddComponent<SuperBattleGolfValuablePulseFade>().Configure(component2, val3, color2, duration);
		}
	}
	internal static class SuperBattleGolfValuableBundleVisuals
	{
		private const string BundleFileName = "superbattlegolfvaluablesassets";

		private static readonly Dictionary<string, GameObject?> VisualPrefabs = new Dictionary<string, GameObject>();

		private static readonly Dictionary<string, AudioClip> AudioClipsByName = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase);

		private static readonly List<AudioClip> AudioClips = new List<AudioClip>();

		private static ManualLogSource? _log;

		private static AssetBundle? _bundle;

		private static bool _loadAttempted;

		private static bool _audioLoaded;

		public static void Initialize(string pluginDirectory, ManualLogSource log)
		{
			_log = log;
			if (_loadAttempted)
			{
				return;
			}
			_loadAttempted = true;
			string text = Path.Combine(pluginDirectory, "superbattlegolfvaluablesassets");
			if (!File.Exists(text))
			{
				log.LogWarning((object)("Generated valuable asset bundle was not found at " + text + ". Falling back to procedural visuals."));
				return;
			}
			try
			{
				foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
				{
					if (string.Equals(((Object)allLoadedAssetBundle).name, "superbattlegolfvaluablesassets", StringComparison.OrdinalIgnoreCase))
					{
						_bundle = allLoadedAssetBundle;
						log.LogInfo((object)"Using already-loaded generated valuable asset bundle: superbattlegolfvaluablesassets");
						return;
					}
				}
				_bundle = AssetBundle.LoadFromFile(text);
				if ((Object)(object)_bundle == (Object)null)
				{
					log.LogWarning((object)("Unity returned null when loading " + text + ". Falling back to procedural visuals."));
				}
				else
				{
					log.LogInfo((object)("Loaded generated valuable asset bundle: " + text));
				}
			}
			catch (Exception arg)
			{
				log.LogWarning((object)$"Failed to load generated valuable asset bundle {text}: {arg}");
				_bundle = null;
			}
		}

		public static bool TryAttach(Transform parent, SuperBattleGolfValuableDefinition definition)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = LoadVisualPrefab(definition.PrefabName);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, parent, false);
			((Object)val2).name = "SuperBattleGolfValuableVisual";
			val2.transform.localPosition = Vector3.zero;
			val2.transform.localRotation = Quaternion.identity;
			val2.transform.localScale = Vector3.one;
			((Object)val2).hideFlags = (HideFlags)52;
			SetLayerRecursively(val2.transform, ((Component)parent).gameObject.layer);
			Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren[i]);
			}
			StripParticleEffects(val2);
			return true;
		}

		public static AudioClip[] LoadAllAudioClips()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (_audioLoaded)
			{
				return AudioClips.ToArray();
			}
			_audioLoaded = true;
			if ((Object)(object)_bundle == (Object)null)
			{
				return Array.Empty<AudioClip>();
			}
			try
			{
				AudioClip[] array = _bundle.LoadAllAssets<AudioClip>();
				foreach (AudioClip val in array)
				{
					if ((Object)(object)val != (Object)null)
					{
						if ((int)val.loadState == 0)
						{
							val.LoadAudioData();
						}
						AudioClips.Add(val);
						AudioClipsByName[((Object)val).name] = val;
					}
				}
			}
			catch (Exception arg)
			{
				ManualLogSource? log = _log;
				if (log != null)
				{
					log.LogWarning((object)$"Failed to load grab audio clips from generated bundle: {arg}");
				}
			}
			return AudioClips.ToArray();
		}

		public static AudioClip? LoadAudioClip(string name)
		{
			LoadAllAudioClips();
			if (!AudioClipsByName.TryGetValue(name, out AudioClip value))
			{
				return null;
			}
			return value;
		}

		public static AudioClip[] LoadAudioClipsFor(SuperBattleGolfValuableDefinition definition)
		{
			LoadAllAudioClips();
			object obj = definition.PrefabName switch
			{
				"SuperBattleGolfValuable_MiniGolfCart" => new string[5] { "SBG_GolfCartHonk", "SBG_GolfCartSpecialHonk", "SBG_GolfCartEngine", "SBG_GolfCartJump", "SBG_GolfCartCollision" }, 
				"SuperBattleGolfValuable_SpectatorCamera" => new string[3] { "SBG_ItemBoxCollected", "SBG_BallInHole", "SBG_GolfCartSpecialHonk" }, 
				"SuperBattleGolfValuable_BattleGolfBall" => new string[3] { "SBG_BallInHole", "SBG_NormalClubSwing", "SBG_ItemBoxCollected" }, 
				"SuperBattleGolfValuable_GolfClub" => new string[2] { "SBG_NormalClubSwing", "SBG_BallInHole" }, 
				"SuperBattleGolfValuable_GolfTee" => new string[2] { "SBG_NormalClubSwing", "SBG_ItemBoxCollected" }, 
				"SuperBattleGolfValuable_CoffeeCup" => new string[2] { "SBG_CoffeeDrink", "SBG_GolfCartBriefcaseOpenEnd" }, 
				"SuperBattleGolfValuable_CoffeePlate" => new string[2] { "SBG_CoffeeDrink", "SBG_GolfCartBriefcaseOpenStart" }, 
				"SuperBattleGolfValuable_HotCoffee" => new string[2] { "SBG_CoffeeDrink", "SBG_SpringBootFlip" }, 
				"SuperBattleGolfValuable_Airhorn" => new string[1] { "SBG_Airhorn" }, 
				"SuperBattleGolfValuable_DuelingPistol" => new string[2] { "SBG_GunAim", "SBG_PistolShot" }, 
				"SuperBattleGolfValuable_ElephantGun" => new string[2] { "SBG_GunAim", "SBG_ElephantGunShot" }, 
				"SuperBattleGolfValuable_Electromagnet" => new string[3] { "SBG_ElectromagnetActivation", "SBG_ElectromagnetReflect", "SBG_ElectromagnetShieldActivation" }, 
				"SuperBattleGolfValuable_FreezeBomb" => new string[3] { "SBG_FreezeBombShot", "SBG_FreezeBombExplosion", "SBG_FreezeBombProjectileLoop" }, 
				"SuperBattleGolfValuable_FreezeBombIceBlock" => new string[3] { "SBG_FreezeBombUnfreeze", "SBG_FreezeBombPlatformBreak", "SBG_FreezeBombExplosion" }, 
				"SuperBattleGolfValuable_OrbitalLaserRemote" => new string[3] { "SBG_OrbitalLaserActivation", "SBG_OrbitalLaserCharge", "SBG_OrbitalLaserExplosion" }, 
				"SuperBattleGolfValuable_RocketLauncher" => new string[2] { "SBG_RocketLauncherShot", "SBG_RocketExplosion" }, 
				"SuperBattleGolfValuable_Rocket" => new string[2] { "SBG_RocketEngine", "SBG_RocketExplosion" }, 
				"SuperBattleGolfValuable_SpringBoots" => new string[2] { "SBG_SpringBootsActivation", "SBG_SpringBootFlip" }, 
				"SuperBattleGolfValuable_Landmine" => new string[3] { "SBG_LandmineArm", "SBG_LandmineArmedBeep", "SBG_LandmineExplosion" }, 
				"SuperBattleGolfValuable_GolfCartBriefcase" => new string[3] { "SBG_GolfCartBriefcaseOpenStart", "SBG_GolfCartBriefcaseOpenEnd", "SBG_GolfCartEngineOff" }, 
				_ => Array.Empty<string>(), 
			};
			List<AudioClip> list = new List<AudioClip>(((Array)obj).Length);
			string[] array = (string[])obj;
			foreach (string key in array)
			{
				if (AudioClipsByName.TryGetValue(key, out AudioClip value) && (Object)(object)value != (Object)null)
				{
					list.Add(value);
				}
			}
			return list.ToArray();
		}

		private static GameObject? LoadVisualPrefab(string prefabName)
		{
			if (VisualPrefabs.TryGetValue(prefabName, out GameObject value))
			{
				return value;
			}
			if ((Object)(object)_bundle == (Object)null)
			{
				VisualPrefabs[prefabName] = null;
				return null;
			}
			try
			{
				GameObject val = _bundle.LoadAsset<GameObject>(prefabName);
				if ((Object)(object)val == (Object)null)
				{
					val = _bundle.LoadAsset<GameObject>("Assets/SuperBattleGolfValuables/Prefabs/" + prefabName + ".prefab");
				}
				if ((Object)(object)val == (Object)null)
				{
					ManualLogSource? log = _log;
					if (log != null)
					{
						log.LogWarning((object)("Generated bundle is missing valuable visual prefab '" + prefabName + "'."));
					}
				}
				VisualPrefabs[prefabName] = val;
				return val;
			}
			catch (Exception arg)
			{
				ManualLogSource? log2 = _log;
				if (log2 != null)
				{
					log2.LogWarning((object)$"Failed to load visual prefab '{prefabName}' from generated bundle: {arg}");
				}
				VisualPrefabs[prefabName] = null;
				return null;
			}
		}

		private static void SetLayerRecursively(Transform root, int layer)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			((Component)root).gameObject.layer = layer;
			foreach (Transform item in root)
			{
				SetLayerRecursively(item, layer);
			}
		}

		private static void StripParticleEffects(GameObject root)
		{
			ParticleSystem[] componentsInChildren = root.GetComponentsInChildren<ParticleSystem>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren[i]);
			}
			ParticleSystemRenderer[] componentsInChildren2 = root.GetComponentsInChildren<ParticleSystemRenderer>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren2[i]);
			}
			TrailRenderer[] componentsInChildren3 = root.GetComponentsInChildren<TrailRenderer>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren3[i]);
			}
			LineRenderer[] componentsInChildren4 = root.GetComponentsInChildren<LineRenderer>(true);
			for (int i = 0; i < componentsInChildren4.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren4[i]);
			}
		}
	}
	internal sealed class SuperBattleGolfValuableDefinition
	{
		public string PrefabName { get; }

		public string DisplayName { get; }

		public string SourceReference { get; }

		public Type VolumeType { get; }

		public int ValueMin { get; }

		public int ValueMax { get; }

		public float Fragility { get; }

		public float Durability { get; }

		public float Mass { get; }

		public Color Primary { get; }

		public Color Secondary { get; }

		public Color Accent { get; }

		public Vector3 GrabBoundsCenter { get; }

		public Vector3 GrabBoundsSize { get; }

		public bool GrabGlow { get; }

		public bool PlayAnimationsOnGrab { get; }

		public bool PlaySoundsOnGrab { get; }

		public SuperBattleGolfValuableDefinition(string prefabName, string displayName, string sourceReference, Type volumeType, int valueMin, int valueMax, float fragility, float durability, float mass, Color primary, Color secondary, Color accent, Vector3 grabBoundsCenter, Vector3 grabBoundsSize, bool playAnimationsOnGrab, bool playSoundsOnGrab)
		{
			//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_004c: 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_0054: 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_005c: 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_0064: 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_006c: 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)
			PrefabName = prefabName;
			DisplayName = displayName;
			SourceReference = sourceReference;
			VolumeType = volumeType;
			ValueMin = valueMin;
			ValueMax = valueMax;
			Fragility = fragility;
			Durability = durability;
			Mass = mass;
			Primary = primary;
			Secondary = secondary;
			Accent = accent;
			GrabBoundsCenter = grabBoundsCenter;
			GrabBoundsSize = grabBoundsSize;
			GrabGlow = true;
			PlayAnimationsOnGrab = playAnimationsOnGrab;
			PlaySoundsOnGrab = playSoundsOnGrab;
		}
	}
	internal static class SuperBattleGolfValuableDefinitions
	{
		public static readonly SuperBattleGolfValuableDefinition[] All = new SuperBattleGolfValuableDefinition[20]
		{
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_MiniGolfCart", "Mini Golf Cart", "GameObject/Golf Cart.prefab", (Type)4, 5600, 9400, 10f, 117f, 3f, new Color(0.188f, 0.428f, 0.403f), new Color(0.443f, 0.654f, 0.618f), new Color(0.567f, 0.205f, 0.615f), new Vector3(0f, 0.14f, 0f), new Vector3(0.36f, 0.28f, 0.28f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_SpectatorCamera", "Spectator Camera", "GameObject/Spectator Camera.prefab", (Type)2, 3900, 7600, 24f, 112f, 1.9f, new Color(0.279f, 0.383f, 0.471f), new Color(0.352f, 0.711f, 0.544f), new Color(0.838f, 0.838f, 0.793f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_BattleGolfBall", "Battle Golf Ball", "GameObject/Ball.prefab", (Type)0, 2500, 7400, 15f, 100f, 0.65f, new Color(0.428f, 0.812f, 0.386f), new Color(0.654f, 0.299f, 0.863f), new Color(0.203f, 0.759f, 0.759f), new Vector3(0f, 0.24f, 0f), new Vector3(0.5f, 0.5f, 0.46f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_GolfClub", "Golf Club", "GameObject/Golf club.prefab", (Type)2, 3900, 8900, 23f, 87f, 1.9f, new Color(0.804f, 0.683f, 0.572f), new Color(0.731f, 0.654f, 0.841f), new Color(0.245f, 0.561f, 0.53f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_GolfTee", "Golf Tee", "GameObject/Tee.prefab", (Type)2, 4800, 7400, 10f, 117f, 1.9f, new Color(0.211f, 0.572f, 0.496f), new Color(0.42f, 0.784f, 0.632f), new Color(0.635f, 0.287f, 0.606f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_CoffeeCup", "Coffee Cup", "GameObject/Coffee mug.prefab", (Type)0, 2400, 6900, 17f, 93f, 0.65f, new Color(0.355f, 0.313f, 0.491f), new Color(0.547f, 0.7f, 0.426f), new Color(0.705f, 0.304f, 0.457f), new Vector3(0f, 0.24f, 0f), new Vector3(0.5f, 0.5f, 0.46f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_CoffeePlate", "Coffee Plate", "GameObject/Coffee plate.prefab", (Type)2, 1400, 6300, 24f, 102f, 1.9f, new Color(0.55f, 0.773f, 0.604f), new Color(0.804f, 0.533f, 0.369f), new Color(0.205f, 0.702f, 0.307f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_HotCoffee", "Hot Coffee", "GameObject/Coffee.prefab", (Type)2, 2400, 5100, 14f, 87f, 1.9f, new Color(0.403f, 0.33f, 0.423f), new Color(0.589f, 0.508f, 0.496f), new Color(0.488f, 0.38f, 0.262f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_Airhorn", "Airhorn", "GameObject/Airhorn.prefab", (Type)2, 1900, 6400, 27f, 89f, 1.9f, new Color(0.265f, 0.547f, 0.866f), new Color(0.637f, 0.725f, 0.53f), new Color(0.434f, 0.601f, 0.618f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_DuelingPistol", "Dueling Pistol", "GameObject/Dueling pistol.prefab", (Type)2, 3600, 7400, 18f, 102f, 1.9f, new Color(0.462f, 0.564f, 0.361f), new Color(0.259f, 0.553f, 0.767f), new Color(0.304f, 0.753f, 0.194f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_ElephantGun", "Elephant Gun", "GameObject/Elephant gun.prefab", (Type)2, 1400, 6300, 24f, 91f, 1.9f, new Color(0.378f, 0.615f, 0.378f), new Color(0.524f, 0.671f, 0.575f), new Color(0.773f, 0.86f, 0.27f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_Electromagnet", "Electromagnet", "GameObject/Electromagnet.prefab", (Type)2, 1300, 6400, 21f, 105f, 1.9f, new Color(0.245f, 0.688f, 0.428f), new Color(0.748f, 0.762f, 0.714f), new Color(0.736f, 0.29f, 0.462f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_FreezeBomb", "Freeze Bomb", "GameObject/Freeze bomb.prefab", (Type)2, 5300, 10600, 10f, 115f, 1.9f, new Color(0.366f, 0.547f, 0.64f), new Color(0.897f, 0.736f, 0.756f), new Color(0.739f, 0.652f, 0.663f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_FreezeBombIceBlock", "Freeze Bomb Ice Block", "GameObject/Freeze bomb ice block.prefab", (Type)2, 4400, 7400, 23f, 103f, 1.9f, new Color(0.688f, 0.635f, 0.239f), new Color(0.756f, 0.598f, 0.626f), new Color(0.259f, 0.719f, 0.228f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_OrbitalLaserRemote", "Orbital Laser Remote", "GameObject/Orbital laser.prefab", (Type)2, 5200, 9100, 24f, 88f, 1.9f, new Color(0.55f, 0.228f, 0.615f), new Color(0.804f, 0.265f, 0.654f), new Color(0.205f, 0.875f, 0.784f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_RocketLauncher", "Rocket Launcher", "GameObject/Rocket launcher.prefab", (Type)2, 3900, 9100, 18f, 116f, 1.9f, new Color(0.454f, 0.657f, 0.239f), new Color(0.719f, 0.547f, 0.629f), new Color(0.64f, 0.666f, 0.239f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_Rocket", "Rocket", "GameObject/Rocket.prefab", (Type)2, 3000, 7200, 27f, 105f, 1.9f, new Color(0.505f, 0.623f, 0.242f), new Color(0.849f, 0.225f, 0.714f), new Color(0.793f, 0.589f, 0.592f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_SpringBoots", "Spring Boots", "GameObject/Spring boots.prefab", (Type)2, 4400, 8500, 27f, 102f, 1.9f, new Color(0.776f, 0.666f, 0.203f), new Color(0.578f, 0.849f, 0.214f), new Color(0.883f, 0.493f, 0.496f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_Landmine", "Landmine", "GameObject/Landmine.prefab", (Type)2, 3900, 9100, 22f, 100f, 1.9f, new Color(0.205f, 0.502f, 0.335f), new Color(0.245f, 0.764f, 0.694f), new Color(0.618f, 0.434f, 0.448f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true),
			new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_GolfCartBriefcase", "Golf Cart Briefcase", "GameObject/Golf cart equipment whole.prefab", (Type)4, 6000, 10800, 11f, 92f, 3f, new Color(0.875f, 0.666f, 0.572f), new Color(0.75f, 0.86f, 0.838f), new Color(0.818f, 0.544f, 0.522f), new Vector3(0f, 0.35f, 0f), new Vector3(1.18f, 0.72f, 0.78f), playAnimationsOnGrab: true, playSoundsOnGrab: true)
		};

		public static SuperBattleGolfValuableDefinition? FindByPrefabName(string prefabName)
		{
			SuperBattleGolfValuableDefinition[] all = All;
			foreach (SuperBattleGolfValuableDefinition superBattleGolfValuableDefinition in all)
			{
				if (string.Equals(superBattleGolfValuableDefinition.PrefabName, prefabName, StringComparison.OrdinalIgnoreCase))
				{
					return superBattleGolfValuableDefinition;
				}
			}
			return null;
		}
	}
	internal static class SuperBattleGolfValuableGrabBounds
	{
		private const int MaxColliderTriangles = 40;

		private const float MinColliderExtent = 0.015f;

		public static void Add(Transform root, SuperBattleGolfValuableDefinition definition)
		{
			RemoveTemplateColliders(root);
			if (AddMeshColliders(root) == 0)
			{
				AddFallbackBox(root, definition);
				SuperBattleGolfValuablesPlugin.Log.LogWarning((object)(definition.DisplayName + " had no usable renderer meshes for grab colliders; using fitted fallback bounds."));
			}
		}

		private static int AddMeshColliders(Transform root)
		{
			int num = 0;
			Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (val.enabled && !(val is ParticleSystemRenderer))
				{
					Mesh val2 = CreateCollisionMesh(val);
					if ((Object)(object)val2 == (Object)null || !HasValidCollisionShape(val2))
					{
						DestroyMesh(val2);
						continue;
					}
					MeshCollider obj = ((Component)val).gameObject.AddComponent<MeshCollider>();
					obj.cookingOptions = (MeshColliderCookingOptions)14;
					obj.convex = true;
					((Collider)obj).isTrigger = false;
					obj.sharedMesh = val2;
					ConfigureColliderObject(((Component)val).gameObject);
					((Component)val).gameObject.AddComponent<PhysGrabObjectCollider>();
					RepoValuableAccess.HideGrabMeshColliderGizmo(((Component)val).gameObject.AddComponent<PhysGrabObjectMeshCollider>());
					num++;
				}
			}
			return num;
		}

		private static Mesh? CreateCollisionMesh(Renderer renderer)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			Mesh val = null;
			Mesh val2 = null;
			SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null);
			if (val3 != null && (Object)(object)val3.sharedMesh != (Object)null)
			{
				val2 = new Mesh
				{
					name = ((Object)renderer).name + "_SuperBattleGolfGrabCollider",
					hideFlags = (HideFlags)61
				};
				try
				{
					val3.BakeMesh(val2);
					val = val2;
				}
				catch
				{
					val = val3.sharedMesh;
				}
			}
			else
			{
				MeshFilter component = ((Component)renderer).GetComponent<MeshFilter>();
				if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null)
				{
					val = component.sharedMesh;
				}
			}
			Mesh val4 = CreateReducedMesh(val, ((Object)renderer).name + "_SuperBattleGolfGrabCollider");
			if ((Object)(object)val4 == (Object)null && (Object)(object)val != (Object)null)
			{
				val4 = CreateBoxMesh(val.bounds, ((Object)renderer).name + "_SuperBattleGolfGrabCollider");
			}
			DestroyMesh(val2);
			return val4;
		}

		private static Mesh? CreateReducedMesh(Mesh? sourceMesh, string name)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)sourceMesh == (Object)null)
			{
				return null;
			}
			if (!sourceMesh.isReadable)
			{
				return null;
			}
			Vector3[] vertices = sourceMesh.vertices;
			int[] triangles = sourceMesh.triangles;
			if (!HasValidVertexSet(vertices, sourceMesh.bounds) || triangles.Length < 3)
			{
				return null;
			}
			int num = triangles.Length / 3;
			int num2 = Mathf.Min(num, 40);
			Vector3[] array = (Vector3[])(object)new Vector3[num2 * 3];
			int[] array2 = new int[num2 * 3];
			for (int i = 0; i < num2; i++)
			{
				int num3 = ((num2 > 1) ? Mathf.RoundToInt((float)i * ((float)num - 1f) / ((float)num2 - 1f)) : 0) * 3;
				int num4 = i * 3;
				array[num4] = vertices[triangles[num3]];
				array[num4 + 1] = vertices[triangles[num3 + 1]];
				array[num4 + 2] = vertices[triangles[num3 + 2]];
				array2[num4] = num4;
				array2[num4 + 1] = num4 + 1;
				array2[num4 + 2] = num4 + 2;
			}
			Mesh val = new Mesh
			{
				name = name,
				hideFlags = (HideFlags)61
			};
			val.vertices = array;
			val.triangles = array2;
			val.RecalculateBounds();
			if (!HasValidCollisionShape(val))
			{
				DestroyMesh(val);
				return null;
			}
			return val;
		}

		private static Mesh? CreateBoxMesh(Bounds bounds, string name)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0066: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0097: 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_00a2: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00c7: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Expected O, but got Unknown
			Vector3 size = ((Bounds)(ref bounds)).size;
			if (Mathf.Max(new float[3] { size.x, size.y, size.z }) < 0.015f)
			{
				return null;
			}
			Vector3 min = ((Bounds)(ref bounds)).min;
			Vector3 max = ((Bounds)(ref bounds)).max;
			Vector3[] vertices = (Vector3[])(object)new Vector3[8]
			{
				new Vector3(min.x, min.y, min.z),
				new Vector3(max.x, min.y, min.z),
				new Vector3(max.x, max.y, min.z),
				new Vector3(min.x, max.y, min.z),
				new Vector3(min.x, min.y, max.z),
				new Vector3(max.x, min.y, max.z),
				new Vector3(max.x, max.y, max.z),
				new Vector3(min.x, max.y, max.z)
			};
			int[] triangles = new int[36]
			{
				0, 2, 1, 0, 3, 2, 4, 5, 6, 4,
				6, 7, 0, 1, 5, 0, 5, 4, 2, 3,
				7, 2, 7, 6, 1, 2, 6, 1, 6, 5,
				3, 0, 4, 3, 4, 7
			};
			Mesh val = new Mesh
			{
				name = name,
				hideFlags = (HideFlags)61,
				vertices = vertices,
				triangles = triangles
			};
			val.RecalculateBounds();
			return val;
		}

		private static bool HasValidCollisionShape(Mesh mesh)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (mesh.isReadable && mesh.vertexCount >= 3)
			{
				return HasValidVertexSet(mesh.vertices, mesh.bounds);
			}
			return false;
		}

		private static bool HasValidVertexSet(IReadOnlyList<Vector3> vertices, Bounds bounds)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_006c: 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)
			Vector3 size = ((Bounds)(ref bounds)).size;
			if (Mathf.Max(new float[3] { size.x, size.y, size.z }) < 0.015f)
			{
				return false;
			}
			HashSet<Vector3Int> hashSet = new HashSet<Vector3Int>();
			for (int i = 0; i < vertices.Count; i++)
			{
				Vector3 val = vertices[i];
				hashSet.Add(new Vector3Int(Mathf.RoundToInt(val.x * 10000f), Mathf.RoundToInt(val.y * 10000f), Mathf.RoundToInt(val.z * 10000f)));
				if (hashSet.Count >= 3)
				{
					return true;
				}
			}
			return false;
		}

		private static void AddFallbackBox(Transform root, SuperBattleGolfValuableDefinition definition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_003c: 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_004c: 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_005d: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			Bounds val = CalculateVisualBounds(root);
			GameObject val2 = new GameObject("SuperBattleGolfValuableFallbackGrabBounds");
			val2.transform.SetParent(root, false);
			val2.transform.localPosition = root.InverseTransformPoint(((Bounds)(ref val)).center);
			val2.transform.localRotation = Quaternion.identity;
			val2.transform.localScale = Vector3.one;
			Vector3 size = ((Bounds)(ref val)).size;
			Vector3 lossyScale = root.lossyScale;
			size.x = ((lossyScale.x == 0f) ? definition.GrabBoundsSize.x : (size.x / Mathf.Abs(lossyScale.x)));
			size.y = ((lossyScale.y == 0f) ? definition.GrabBoundsSize.y : (size.y / Mathf.Abs(lossyScale.y)));
			size.z = ((lossyScale.z == 0f) ? definition.GrabBoundsSize.z : (size.z / Mathf.Abs(lossyScale.z)));
			BoxCollider obj = val2.AddComponent<BoxCollider>();
			obj.center = Vector3.zero;
			obj.size = Vector3.Max(size, Vector3.one * 0.12f);
			((Collider)obj).isTrigger = false;
			ConfigureColliderObject(val2);
			val2.AddComponent<PhysGrabObjectCollider>();
			RepoValuableAccess.HideGrabBoxColliderGizmo(val2.AddComponent<PhysGrabObjectBoxCollider>());
		}

		private static void ConfigureColliderObject(GameObject gameObject)
		{
			gameObject.tag = "Phys Grab Object";
			int num = LayerMask.NameToLayer("PhysGrabObject");
			if (num >= 0)
			{
				gameObject.layer = num;
			}
		}

		private static Bounds CalculateVisualBounds(Transform root)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_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_0048: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true);
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(root.position, Vector3.one * 0.3f);
			bool flag = false;
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				if (val.enabled && !(val is ParticleSystemRenderer))
				{
					if (flag)
					{
						((Bounds)(ref bounds)).Encapsulate(val.bounds);
						continue;
					}
					bounds = val.bounds;
					flag = true;
				}
			}
			return bounds;
		}

		private static void RemoveTemplateColliders(Transform root)
		{
			PhysGrabObjectCollider[] componentsInChildren = ((Component)root).GetComponentsInChildren<PhysGrabObjectCollider>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				DestroyComponent((Component)(object)componentsInChildren[i]);
			}
			PhysGrabObjectBoxCollider[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<PhysGrabObjectBoxCollider>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				DestroyComponent((Component)(object)componentsInChildren2[i]);
			}
			PhysGrabObjectMeshCollider[] componentsInChildren3 = ((Component)root).GetComponentsInChildren<PhysGrabObjectMeshCollider>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				DestroyComponent((Component)(object)componentsInChildren3[i]);
			}
			Collider[] componentsInChildren4 = ((Component)root).GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren4.Length; i++)
			{
				DestroyComponent((Component)(object)componentsInChildren4[i]);
			}
		}

		private static void DestroyComponent(Component component)
		{
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
		}

		private static void DestroyMesh(Mesh? mesh)
		{
			//IL_000a: 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)
			if ((Object)(object)mesh != (Object)null && (((Object)mesh).hideFlags & 0x3D) != 0)
			{
				Object.DestroyImmediate((Object)(object)mesh);
			}
		}
	}
	internal sealed class SuperBattleGolfValuableGrabFeedback : MonoBehaviour
	{
		private const float TriggerCooldown = 1.45f;

		private readonly List<Animator> _animators = new List<Animator>();

		private readonly List<Animation> _legacyAnimations = new List<Animation>();

		private AudioClip[] _audioClips = Array.Empty<AudioClip>();

		private SuperBattleGolfValuableDefinition? _definition;

		private AudioSource? _audioSource;

		private PhysGrabObject? _physGrabObject;

		private bool _playAnimations;

		private bool _playSounds;

		private bool _runtimeReady;

		private bool _grabActive;

		private bool _wasGrabbed;

		private int _grabCount;

		private float _lastTriggerTime = -999f;

		public void Configure(SuperBattleGolfValuableDefinition definition, AudioClip[] audioClips, bool playAnimations, bool playSounds)
		{
			_definition = definition;
			_audioClips = audioClips ?? Array.Empty<AudioClip>();
			_playAnimations = playAnimations;
			_playSounds = playSounds;
		}

		private void Start()
		{
			EnsureRuntimeReady();
		}

		private void EnsureRuntimeReady()
		{
			_physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			RecoverConfigurationFromSpawnedName();
			if (_runtimeReady)
			{
				CollectAnimationsIfNeeded();
				CreateAudioSourceIfNeeded();
			}
			else
			{
				_runtimeReady = true;
				CollectAnimationsIfNeeded();
				CreateAudioSourceIfNeeded();
			}
		}

		private void CollectAnimationsIfNeeded()
		{
			if (_playAnimations && _animators.Count == 0 && _legacyAnimations.Count == 0)
			{
				_animators.AddRange(((Component)this).GetComponentsInChildren<Animator>(true));
				_legacyAnimations.AddRange(((Component)this).GetComponentsInChildren<Animation>(true));
			}
		}

		private void RecoverConfigurationFromSpawnedName()
		{
			if (_definition != null)
			{
				return;
			}
			string b = ((Object)((Component)this).gameObject).name.Replace("(Clone)", string.Empty).Trim();
			SuperBattleGolfValuableDefinition[] all = SuperBattleGolfValuableDefinitions.All;
			foreach (SuperBattleGolfValuableDefinition superBattleGolfValuableDefinition in all)
			{
				if (string.Equals(superBattleGolfValuableDefinition.PrefabName, b, StringComparison.OrdinalIgnoreCase))
				{
					Configure(superBattleGolfValuableDefinition, SuperBattleGolfValuableBundleVisuals.LoadAudioClipsFor(superBattleGolfValuableDefinition), superBattleGolfValuableDefinition.PlayAnimationsOnGrab, superBattleGolfValuableDefinition.PlaySoundsOnGrab);
					break;
				}
			}
		}

		private void CreateAudioSourceIfNeeded()
		{
			if (_playSounds && _audioClips.Length != 0 && !((Object)(object)_audioSource != (Object)null))
			{
				_audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
				_audioSource.playOnAwake = false;
				_audioSource.spatialBlend = 1f;
				_audioSource.rolloffMode = (AudioRolloffMode)1;
				_audioSource.minDistance = 1.5f;
				_audioSource.maxDistance = 28f;
				_audioSource.volume = 1f;
			}
		}

		private void Update()
		{
			EnsureRuntimeReady();
			if (!((Object)(object)_physGrabObject == (Object)null))
			{
				bool flag = RepoValuableAccess.IsGrabbedForVoice(_physGrabObject);
				if (!flag || flag == _wasGrabbed)
				{
					_wasGrabbed = flag;
					return;
				}
				_wasGrabbed = flag;
				TriggerGrab("poll");
			}
		}

		internal static void TriggerFrom(PhysGrabObject physGrabObject, string source)
		{
			SuperBattleGolfValuableGrabFeedback superBattleGolfValuableGrabFeedback = ((Component)physGrabObject).GetComponent<SuperBattleGolfValuableGrabFeedback>();
			if ((Object)(object)superBattleGolfValuableGrabFeedback == (Object)null)
			{
				superBattleGolfValuableGrabFeedback = ((Component)physGrabObject).GetComponentInChildren<SuperBattleGolfValuableGrabFeedback>(true);
			}
			superBattleGolfValuableGrabFeedback?.TriggerGrab(source);
		}

		internal static void ReleaseFrom(PhysGrabObject physGrabObject)
		{
			SuperBattleGolfValuableGrabFeedback superBattleGolfValuableGrabFeedback = ((Component)physGrabObject).GetComponent<SuperBattleGolfValuableGrabFeedback>();
			if ((Object)(object)superBattleGolfValuableGrabFeedback == (Object)null)
			{
				superBattleGolfValuableGrabFeedback = ((Component)physGrabObject).GetComponentInChildren<SuperBattleGolfValuableGrabFeedback>(true);
			}
			superBattleGolfValuableGrabFeedback?.ReleaseGrab();
		}

		internal void TriggerGrab(string source)
		{
			if (!_grabActive && !(Time.time - _lastTriggerTime < 1.45f))
			{
				_lastTriggerTime = Time.time;
				_grabActive = true;
				_wasGrabbed = true;
				_grabCount++;
				EnsureRuntimeReady();
				PlayGrabAnimation();
				PlayGrabSound();
				if (_definition != null && (Object)(object)_physGrabObject != (Object)null)
				{
					SuperBattleGolfValuableActiveLogic.TriggerFrom(_physGrabObject, source);
					SuperBattleGolfValuableGrabLogic.Play(_definition, ((Component)this).transform, _physGrabObject, _grabCount);
				}
			}
		}

		private void ReleaseGrab()
		{
			_grabActive = false;
			_wasGrabbed = false;
		}

		private void PlayGrabAnimation()
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			if (!_playAnimations)
			{
				return;
			}
			foreach (Animator animator in _animators)
			{
				if (!((Object)(object)animator == (Object)null) && !((Object)(object)animator.runtimeAnimatorController == (Object)null))
				{
					AnimationClip[] animationClips = animator.runtimeAnimatorController.animationClips;
					if (animationClips.Length != 0)
					{
						AnimationClip val = animationClips[_grabCount % animationClips.Length];
						animator.Play(((Object)val).name, 0, 0f);
						animator.Update(0f);
					}
				}
			}
			foreach (Animation legacyAnimation in _legacyAnimations)
			{
				if ((Object)(object)legacyAnimation == (Object)null || legacyAnimation.GetClipCount() == 0)
				{
					continue;
				}
				{
					IEnumerator enumerator3 = legacyAnimation.GetEnumerator();
					try
					{
						if (enumerator3.MoveNext())
						{
							AnimationState val2 = (AnimationState)enumerator3.Current;
							legacyAnimation.Play(val2.name);
						}
					}
					finally
					{
						IDisposable disposable = enumerator3 as IDisposable;
						if (disposable != null)
						{
							disposable.Dispose();
						}
					}
				}
			}
		}

		private void PlayGrabSound()
		{
			//IL_003d: 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_0052: Invalid comparison between Unknown and I4
			if (_playSounds && !((Object)(object)_audioSource == (Object)null) && _audioClips.Length != 0)
			{
				AudioClip val = _audioClips[Mathf.Abs(_grabCount) % _audioClips.Length];
				if ((int)val.loadState == 0)
				{
					val.LoadAudioData();
				}
				if ((int)val.loadState == 3)
				{
					SuperBattleGolfValuablesPlugin.Log.LogWarning((object)("Grab audio '" + ((Object)val).name + "' failed to load."));
				}
				else
				{
					_audioSource.PlayOneShot(val, 1f);
				}
			}
		}
	}
	internal sealed class SuperBattleGolfValuableGrabGlow : MonoBehaviour
	{
		private readonly List<Material> _materials = new List<Material>();

		private PhysGrabObject? _physGrabObject;

		[SerializeField]
		private Color _glowColor = Color.cyan;

		private bool _wasGrabbed;

		public void Configure(Color glowColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_glowColor = glowColor;
		}

		private void Start()
		{
			_physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!val.enabled)
				{
					continue;
				}
				Material[] materials = val.materials;
				foreach (Material val2 in materials)
				{
					if ((Object)(object)val2 != (Object)null && val2.HasProperty("_EmissionColor"))
					{
						val2.EnableKeyword("_EMISSION");
						_materials.Add(val2);
					}
				}
			}
		}

		private void Update()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_physGrabObject == (Object)null)
			{
				return;
			}
			bool flag = RepoValuableAccess.IsGrabbed(_physGrabObject);
			if (flag == _wasGrabbed)
			{
				return;
			}
			_wasGrabbed = flag;
			Color val = (flag ? (_glowColor * 1.35f) : Color.black);
			foreach (Material material in _mater