Decompiled source of LethalCompanyValuables v1.2.1

com.github.zehsteam.LethalCompanyValuables.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;
using com.github.zehsteam.LethalCompanyValuables.Objects;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Zehs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Zehs")]
[assembly: AssemblyDescription("Adds 30 scrap items from Lethal Company as valuables. Some valuables have special interactions.")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1+3f70713530c4162f9dc63d86a6e11e973504f9d6")]
[assembly: AssemblyProduct("LethalCompanyValuables")]
[assembly: AssemblyTitle("com.github.zehsteam.LethalCompanyValuables")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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 com.github.zehsteam.LethalCompanyValuables
{
	internal static class ConfigManager
	{
		public static ConfigFile ConfigFile { get; private set; }

		public static ConfigEntry<bool> ExtendedLogging { get; private set; }

		public static void Initialize(ConfigFile configFile)
		{
			ConfigFile = configFile;
			BindConfigs();
		}

		private static void BindConfigs()
		{
			ExtendedLogging = ConfigFile.Bind<bool>("General", "ExtendedLogging", false, "Enable extended logging.");
		}
	}
	internal static class Logger
	{
		public static ManualLogSource ManualLogSource { get; private set; }

		public static void Initialize(ManualLogSource manualLogSource)
		{
			ManualLogSource = manualLogSource;
		}

		public static void LogDebug(object data, bool extended = true)
		{
			Log((LogLevel)32, data, extended);
		}

		public static void LogInfo(object data, bool extended = false)
		{
			Log((LogLevel)16, data, extended);
		}

		public static void LogWarning(object data, bool extended = false)
		{
			Log((LogLevel)4, data, extended);
		}

		public static void LogError(object data, bool extended = false)
		{
			Log((LogLevel)2, data, extended);
		}

		public static void LogFatal(object data, bool extended = false)
		{
			Log((LogLevel)1, data, extended);
		}

		public static void Log(LogLevel logLevel, object data, bool extended = false)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!extended || IsExtendedLoggingEnabled())
			{
				ManualLogSource manualLogSource = ManualLogSource;
				if (manualLogSource != null)
				{
					manualLogSource.Log(logLevel, data);
				}
			}
		}

		public static bool IsExtendedLoggingEnabled()
		{
			if (ConfigManager.ExtendedLogging == null)
			{
				return false;
			}
			return ConfigManager.ExtendedLogging.Value;
		}
	}
	[BepInPlugin("com.github.zehsteam.LethalCompanyValuables", "LethalCompanyValuables", "1.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		internal static Plugin Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.LethalCompanyValuables"));
			Logger.LogInfo("LethalCompanyValuables has awoken!");
			ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
			string text = Path.Combine(Utils.GetPluginDirectory(), "lethalcompanyvaluables_assets");
			BundleLoader.LoadBundle(text, (Action<AssetBundle>)delegate(AssetBundle assetBundle)
			{
				ValuableList valuableList = LoadAsset<ValuableList>("ValuableList", assetBundle);
				GameObject[] valuables = valuableList.Valuables;
				foreach (GameObject val in valuables)
				{
					Valuables.RegisterValuable(val);
				}
			}, false);
		}

		private T LoadAsset<T>(string name, AssetBundle assetBundle) where T : Object
		{
			if ((Object)(object)assetBundle == (Object)null)
			{
				return default(T);
			}
			return assetBundle.LoadAsset<T>(name);
		}

		private bool TryLoadAsset<T>(string name, AssetBundle assetBundle, out T asset) where T : Object
		{
			asset = LoadAsset<T>(name, assetBundle);
			return (Object)(object)asset != (Object)null;
		}
	}
	internal static class Utils
	{
		public static string GetPluginDirectory()
		{
			return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.LethalCompanyValuables";

		public const string PLUGIN_NAME = "LethalCompanyValuables";

		public const string PLUGIN_VERSION = "1.2.1";
	}
}
namespace com.github.zehsteam.LethalCompanyValuables.Objects
{
	[CreateAssetMenu(fileName = "ValuableList", menuName = "LethalCompanyValuables/ValuableList")]
	public class ValuableList : ScriptableObject
	{
		public GameObject[] Valuables = Array.Empty<GameObject>();
	}
}
namespace com.github.zehsteam.LethalCompanyValuables.MonoBehaviours
{
	public class Apparatus : MonoBehaviour
	{
		[SerializeField]
		private ParticleSystem _sparks;

		public void PlaySparks()
		{
			_sparks.Play();
		}
	}
	[RequireComponent(typeof(ValuableSoundPlayer))]
	public class BrassBell : MonoBehaviour
	{
		private ValuableSoundPlayer _valuableSoundPlayer;

		private Random _random;

		private void Start()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			_valuableSoundPlayer = ((Component)this).GetComponent<ValuableSoundPlayer>();
			_random = new Random((int)(((Component)this).transform.position.x + ((Component)this).transform.position.z));
		}

		public void RingBellHostOnly()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				RingBell();
			}
		}

		public void RingBell()
		{
			float num = 1f;
			switch (_random.Next(0, 7))
			{
			case 1:
				num *= Mathf.Pow(1.05946f, 3f);
				break;
			case 2:
				num *= Mathf.Pow(1.05946f, 5f);
				break;
			case 3:
				num /= Mathf.Pow(1.05946f, 3f);
				break;
			case 4:
				num /= Mathf.Pow(1.05946f, 5f);
				break;
			case 5:
				num /= Mathf.Pow(1.05946f, 7f);
				break;
			case 6:
				num /= Mathf.Pow(1.05946f, 10f);
				break;
			}
			_valuableSoundPlayer.PlaySound(num);
		}
	}
	[RequireComponent(typeof(ValuableSoundPlayer))]
	public class CashRegister : MonoBehaviour
	{
		[SerializeField]
		private Animator _animator;

		private ValuableSoundPlayer _valuableSoundPlayer;

		private PhotonView _photonView;

		private void Start()
		{
			_valuableSoundPlayer = ((Component)this).GetComponent<ValuableSoundPlayer>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
		}

		public void PullLever()
		{
			if (SemiFunc.IsMultiplayer())
			{
				_photonView.RPC("PullLeverRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				PullLeverLocal();
			}
			_valuableSoundPlayer.PlaySound();
		}

		[PunRPC]
		private void PullLeverRPC()
		{
			PullLeverLocal();
		}

		private void PullLeverLocal()
		{
			_animator.SetTrigger("playAnim");
		}
	}
	public class GiftBox : MonoBehaviour
	{
		private static List<ValuableObject> _valuablesCache = new List<ValuableObject>();

		[SerializeField]
		private Transform _spawnTransform;

		[SerializeField]
		private GameObject _poofEffectPrefab;

		public void OpenGiftBox()
		{
			SpawnPoofEffect();
			SpawnRandomValuable();
		}

		private void SpawnRandomValuable()
		{
			//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)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			Logger.LogInfo("GiftBox: Spawning random valuable.");
			if ((Object)(object)_spawnTransform == (Object)null)
			{
				Logger.LogError("GiftBox: Failed to spawn random valuable. Spawn transform is null.");
				return;
			}
			if (_valuablesCache.Count == 0)
			{
				CacheValuables();
				if (_valuablesCache.Count == 0)
				{
					Logger.LogError("GiftBox: Failed to spawn random valuable. Valuables cache is empty.");
					return;
				}
			}
			int index = Random.Range(0, _valuablesCache.Count);
			ValuableObject val = _valuablesCache[index];
			Valuables.SpawnValuable(val, _spawnTransform.position, Quaternion.identity);
		}

		private void CacheValuables()
		{
			_valuablesCache = Valuables.AllValuables.Select((GameObject x) => x.GetComponent<ValuableObject>()).Where(IsValidValuableObject).ToList();
		}

		private bool IsValidValuableObject(ValuableObject valuableObject)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected I4, but got Unknown
			if ((Object)(object)valuableObject == (Object)null)
			{
				return false;
			}
			Type volumeType = valuableObject.volumeType;
			if (1 == 0)
			{
			}
			bool result = (int)volumeType switch
			{
				0 => false, 
				4 => false, 
				5 => false, 
				6 => false, 
				_ => true, 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		private void SpawnPoofEffect()
		{
			//IL_000d: 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)
			Object.Instantiate<GameObject>(_poofEffectPrefab, ((Component)this).transform.position, Quaternion.identity);
		}
	}
	[RequireComponent(typeof(ValuableSoundPlayer))]
	public class Hairdryer : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <PlayWindParticlesCoroutine>d__19 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Hairdryer <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this._active = true;
					<>4__this._windParticles.Play();
					<>4__this._windSmallParticles.Play();
					<>2__current = (object)new WaitForSeconds(1.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this._windParticles.Stop();
					<>4__this._windSmallParticles.Stop();
					<>4__this._active = false;
					<>4__this._playWindParticlesCoroutine = null;
					return false;
				}
			}

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

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

		[SerializeField]
		private HurtCollider _hurtCollider;

		[SerializeField]
		private ParticleSystem _windParticles;

		[SerializeField]
		private ParticleSystem _windSmallParticles;

		[SerializeField]
		private AnimationCurve fanBladeSpeedCurve;

		private ValuableSoundPlayer _valuableSoundPlayer;

		private PhotonView _photonView;

		private bool _active;

		private float _secondsToStart = 0.15f;

		private float _secondsToStop = 0.5f;

		private float _fanBladeLerp;

		private float _initialPlayerHitForce;

		private float _initialPhysHitForce;

		private float _initialEnemyHitForce;

		private Coroutine _playWindParticlesCoroutine;

		private void Start()
		{
			_valuableSoundPlayer = ((Component)this).GetComponent<ValuableSoundPlayer>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_initialPlayerHitForce = _hurtCollider.playerHitForce;
			_initialPhysHitForce = _hurtCollider.physHitForce;
			_initialEnemyHitForce = _hurtCollider.enemyHitForce;
			((Component)_hurtCollider).gameObject.SetActive(false);
		}

		private void Update()
		{
			if (_active)
			{
				if (_fanBladeLerp < 1f)
				{
					_fanBladeLerp += Time.deltaTime / _secondsToStart;
				}
			}
			else if (_fanBladeLerp > 0f)
			{
				_fanBladeLerp -= Time.deltaTime / _secondsToStop;
			}
			((Component)_hurtCollider).gameObject.SetActive(_active);
			_hurtCollider.playerHitForce = Mathf.Lerp(0f, _initialPlayerHitForce, fanBladeSpeedCurve.Evaluate(_fanBladeLerp));
			_hurtCollider.physHitForce = Mathf.Lerp(0f, _initialPhysHitForce, fanBladeSpeedCurve.Evaluate(_fanBladeLerp));
			_hurtCollider.enemyHitForce = Mathf.Lerp(0f, _initialEnemyHitForce, fanBladeSpeedCurve.Evaluate(_fanBladeLerp));
		}

		public void StartHairdryer()
		{
			if (SemiFunc.IsMultiplayer())
			{
				_photonView.RPC("StartHairdryerRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				StartHairdryerLocal();
			}
			_valuableSoundPlayer.PlaySound();
		}

		[PunRPC]
		private void StartHairdryerRPC()
		{
			StartHairdryerLocal();
		}

		private void StartHairdryerLocal()
		{
			if (_playWindParticlesCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_playWindParticlesCoroutine);
			}
			_playWindParticlesCoroutine = ((MonoBehaviour)this).StartCoroutine(PlayWindParticlesCoroutine());
		}

		[IteratorStateMachine(typeof(<PlayWindParticlesCoroutine>d__19))]
		private IEnumerator PlayWindParticlesCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PlayWindParticlesCoroutine>d__19(0)
			{
				<>4__this = this
			};
		}
	}
	public class TeethTrap : Trap
	{
		[SerializeField]
		private AudioSource _chatterAudio;

		[SerializeField]
		private int _movementAmount = 25;

		[SerializeField]
		private float _movementCooldown = 0.37f;

		[SerializeField]
		private float _movementForce = 2f;

		private Animator _animator;

		private Rigidbody _rigidbody;

		private Transform _targetTransform;

		private Vector3 _playerDirection;

		private int _movementCount;

		private Quaternion _lookRotation;

		private float _movementTimer;

		private bool _trapStopped;

		public override void Start()
		{
			((Trap)this).Start();
			_animator = ((Component)this).GetComponent<Animator>();
			_rigidbody = ((Component)this).GetComponent<Rigidbody>();
		}

		public override void Update()
		{
			((Trap)this).Update();
			if (base.trapStart)
			{
				TrapActivate();
			}
			if (base.trapActive)
			{
				base.physGrabObject.OverrideIndestructible(0.1f);
				base.enemyInvestigate = true;
			}
		}

		private void FixedUpdate()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !base.trapActive)
			{
				return;
			}
			if (_movementTimer <= 0f)
			{
				Move();
			}
			else
			{
				_movementTimer -= Time.fixedDeltaTime;
			}
			base.physGrabObject.OverrideZeroGravity(0.1f);
			if (!((Object)(object)_targetTransform == (Object)null))
			{
				Quaternion val = Quaternion.LookRotation(_targetTransform.position - base.physGrabObject.midPoint);
				_lookRotation = Quaternion.Slerp(_lookRotation, val, Time.deltaTime * 5f);
				Vector3 val2 = SemiFunc.PhysFollowRotation(((Component)this).transform, _lookRotation, _rigidbody, 0.3f);
				if (base.physGrabObject.playerGrabbing.Count > 0)
				{
					val2 *= 0.25f;
				}
				_rigidbody.AddTorque(val2, (ForceMode)1);
			}
		}

		private void Move()
		{
			//IL_0020: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			if (base.isLocal)
			{
				_targetTransform = SemiFunc.PlayerGetNearestTransformWithinRange(10f, base.physGrabObject.centerPoint, true, LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "Default" })));
				Vector3 val;
				if ((Object)(object)_targetTransform != (Object)null)
				{
					val = _targetTransform.position - base.physGrabObject.midPoint;
					_playerDirection = ((Vector3)(ref val)).normalized;
					_rigidbody.velocity = Vector3.zero;
					_rigidbody.AddForce(_playerDirection * _movementForce, (ForceMode)1);
				}
				else
				{
					val = Random.insideUnitSphere;
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					_rigidbody.AddForce(normalized * _movementForce, (ForceMode)1);
					_rigidbody.AddTorque(normalized, (ForceMode)1);
				}
				_movementTimer = _movementCooldown;
				_movementCount++;
				if (_movementCount >= _movementAmount)
				{
					TrapStop();
				}
			}
		}

		public void StartAnimation()
		{
			_animator.SetBool("active", true);
		}

		public void StopAnimation()
		{
			_animator.SetBool("active", false);
		}

		public void TrapActivate()
		{
			if (base.trapTriggered)
			{
				return;
			}
			foreach (PhysGrabber item in base.physGrabObject.playerGrabbing.ToList())
			{
				if (SemiFunc.IsMultiplayer())
				{
					item.photonView.RPC("ReleaseObjectRPC", (RpcTarget)0, new object[2] { false, 1f });
				}
				else
				{
					item.ReleaseObjectRPC(true, 1f);
				}
			}
			base.trapActive = true;
			base.trapTriggered = true;
			StartAnimation();
			_chatterAudio.Play();
		}

		public void TrapStop()
		{
			if (GameManager.Multiplayer())
			{
				base.photonView.RPC("TrapStopRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				TrapStopLocal();
			}
		}

		[PunRPC]
		private void TrapStopRPC()
		{
			TrapStopLocal();
		}

		private void TrapStopLocal()
		{
			base.trapActive = false;
			_trapStopped = true;
			StopAnimation();
			_chatterAudio.Stop();
		}
	}
	public class ValuableInteract : MonoBehaviour
	{
		[SerializeField]
		private float _interactCooldown = 0.3f;

		[SerializeField]
		private UnityEvent _onInteractEvent = new UnityEvent();

		private PhysGrabObject _physGrabObject;

		private float _timeSinceInteraction = float.NegativeInfinity;

		public event Action OnInteract;

		private void Start()
		{
			_physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
		}

		private void Update()
		{
			if (_physGrabObject.heldByLocalPlayer && SemiFunc.InputDown((InputKey)2) && !IsCooldownActive())
			{
				InvokeOnInteract();
			}
		}

		private bool IsCooldownActive()
		{
			return Time.realtimeSinceStartup - _timeSinceInteraction <= _interactCooldown;
		}

		private void InvokeOnInteract()
		{
			this.OnInteract?.Invoke();
			UnityEvent onInteractEvent = _onInteractEvent;
			if (onInteractEvent != null)
			{
				onInteractEvent.Invoke();
			}
			_timeSinceInteraction = Time.realtimeSinceStartup;
		}
	}
	public class ValuableSoundPlayer : MonoBehaviour
	{
		[SerializeField]
		private Sound _sound;

		[Space(20f)]
		[Header("Sound Properties")]
		[Space(5f)]
		[SerializeField]
		private Transform _positionTransform;

		[SerializeField]
		private float _minPitch = 0.95f;

		[SerializeField]
		private float _maxPitch = 1f;

		[SerializeField]
		private bool _alertEnemies = true;

		[SerializeField]
		private float _alertEnemiesRadius = 1f;

		private PhysGrabObject _physGrabObject;

		private PhotonView _photonView;

		private void Start()
		{
			_physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
		}

		public void PlaySoundHostOnly()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				PlaySound();
			}
		}

		public void PlaySoundHostOnly(float pitch)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				PlaySound(pitch);
			}
		}

		public void PlaySound()
		{
			float pitch = Random.Range(_minPitch, _maxPitch);
			PlaySound(pitch);
		}

		public void PlaySound(float pitch)
		{
			if (SemiFunc.IsMultiplayer())
			{
				_photonView.RPC("PlaySoundRPC", (RpcTarget)0, new object[1] { pitch });
			}
			else
			{
				PlaySoundLocal(pitch);
			}
		}

		[PunRPC]
		private void PlaySoundRPC(float pitch)
		{
			PlaySoundLocal(pitch);
		}

		public void PlaySoundLocal(float pitch)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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)
			Vector3 val = ((!((Object)(object)_positionTransform != (Object)null)) ? _physGrabObject.centerPoint : _positionTransform.position);
			_sound.Pitch = pitch;
			_sound.Play(val, 1f, 1f, 1f, 1f);
			if (_alertEnemies && SemiFunc.IsMasterClientOrSingleplayer())
			{
				EnemyInvestigate(_alertEnemiesRadius);
			}
		}

		private void EnemyInvestigate(float radius)
		{
			if (!((Object)(object)_physGrabObject == (Object)null) && !((Object)(object)_physGrabObject.impactDetector == (Object)null))
			{
				_physGrabObject.impactDetector.EnemyInvestigate(radius);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}