Decompiled source of Dream Team Mod v0.1.6

Dream_Team_Mod.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.Events;

[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Narushiji")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("Dream_Team_Mod")]
[assembly: AssemblyTitle("Dream_Team_Mod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.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]
	[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]
	[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 Dream_Team_Mod
{
	[CreateAssetMenu(fileName = "Value - 100", menuName = "Phys Object/Value Preset 100", order = 1)]
	public class ValueHundred : Value
	{
		public ValueHundred()
		{
			base.valueMin = 100f;
			base.valueMax = 100f;
		}
	}
	[BepInPlugin("Narushiji.Dream_Team_Mod", "Dream_Team_Mod", "0.1.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Dream_Team_Mod : BaseUnityPlugin
	{
		internal static Dream_Team_Mod Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//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_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
	public class RotarEjeXY : MonoBehaviour
	{
		[Header("Configuración del Elemento")]
		[Tooltip("Arrastra aquí el objeto hijo que quieres que gire (ej: la llave)")]
		public Transform? objetoQueGira;

		[Header("Ajustes del Giro con Pausa")]
		public float velocidadGiro = 360f;

		public float tiempoPausa = 0.3f;

		public bool rotarEnX = true;

		private bool previousGrabState;

		private float voiceCoolDown = 1.5f;

		private float soundTime;

		private bool estaGirando = false;

		private MonoBehaviour? physGrabComponent;

		public void Start()
		{
			soundTime = Time.time;
			ref MonoBehaviour? reference = ref physGrabComponent;
			Component component = ((Component)this).GetComponent("PhysGrabObject");
			reference = (MonoBehaviour?)(object)((component is MonoBehaviour) ? component : null);
			if ((Object)(object)physGrabComponent == (Object)null)
			{
				Debug.LogError((object)"[Dream_Team_Mod] ¡No se encontró el componente PhysGrabObject en el objeto!");
			}
		}

		public void Update()
		{
			if ((Object)(object)physGrabComponent == (Object)null || (Object)(object)objetoQueGira == (Object)null)
			{
				return;
			}
			try
			{
				FieldInfo field = ((object)physGrabComponent).GetType().GetField("grabbed");
				if (!(field != null))
				{
					return;
				}
				bool flag = (bool)field.GetValue(physGrabComponent);
				if (flag != previousGrabState)
				{
					previousGrabState = flag;
					if (flag && Time.time - soundTime > voiceCoolDown)
					{
						soundTime = Time.time;
						ActivarGiroConPausa();
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[Dream_Team_Mod] Error leyendo el estado de agarre: " + ex.Message));
			}
		}

		public void ActivarGiroConPausa()
		{
			if (!estaGirando && !((Object)(object)objetoQueGira == (Object)null))
			{
				((MonoBehaviour)this).StartCoroutine(RutinaGiroDosTramos());
			}
		}

		private IEnumerator RutinaGiroDosTramos()
		{
			estaGirando = true;
			yield return ((MonoBehaviour)this).StartCoroutine(GirarGradosEspecificos(180f));
			yield return (object)new WaitForSeconds(tiempoPausa);
			yield return ((MonoBehaviour)this).StartCoroutine(GirarGradosEspecificos(180f));
			estaGirando = false;
		}

		private IEnumerator GirarGradosEspecificos(float gradosObjetivo)
		{
			float gradosGirados = 0f;
			while (gradosGirados < gradosObjetivo)
			{
				float pasoGiro = velocidadGiro * Time.deltaTime;
				if (gradosGirados + pasoGiro > gradosObjetivo)
				{
					pasoGiro = gradosObjetivo - gradosGirados;
				}
				if (rotarEnX)
				{
					objetoQueGira.Rotate(pasoGiro, 0f, 0f, (Space)1);
				}
				else
				{
					objetoQueGira.Rotate(0f, 0f, pasoGiro, (Space)1);
				}
				gradosGirados += pasoGiro;
				yield return null;
			}
		}
	}
	public class ItemAudioLoop : MonoBehaviour
	{
		[Header("Componente de Audio")]
		[Tooltip("Arrastra aquí el AudioSource de Unity asignado a este objeto")]
		public AudioSource? audioSourceComponent;

		[Header("Ajustes del Desvanecimiento (Fade)")]
		[Tooltip("Velocidad con la que el volumen sube o baja (Valores altos = más rápido)")]
		public float velocidadFade = 3f;

		[Tooltip("El volumen máximo que alcanzará el sonido al ser agarrado")]
		public float volumenMaximo = 1f;

		private PhysGrabObject? physGrabObject;

		private bool estabaAgarradoAnteriormente = false;

		private Coroutine? rutinaFadeActual;

		public void Start()
		{
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			if ((Object)(object)physGrabObject == (Object)null)
			{
				physGrabObject = ((Component)this).GetComponentInParent<PhysGrabObject>();
			}
			if ((Object)(object)audioSourceComponent != (Object)null)
			{
				audioSourceComponent.loop = true;
				audioSourceComponent.volume = 0f;
				audioSourceComponent.Stop();
			}
		}

		public void Update()
		{
			if (!((Object)(object)physGrabObject == (Object)null) && !((Object)(object)audioSourceComponent == (Object)null) && physGrabObject.grabbed != estabaAgarradoAnteriormente)
			{
				estabaAgarradoAnteriormente = physGrabObject.grabbed;
				if (rutinaFadeActual != null)
				{
					((MonoBehaviour)this).StopCoroutine(rutinaFadeActual);
				}
				if (physGrabObject.grabbed)
				{
					rutinaFadeActual = ((MonoBehaviour)this).StartCoroutine(FadeInYReanudar());
				}
				else
				{
					rutinaFadeActual = ((MonoBehaviour)this).StartCoroutine(FadeOutYPausar());
				}
			}
		}

		private IEnumerator FadeInYReanudar()
		{
			if (!audioSourceComponent.isPlaying)
			{
				audioSourceComponent.Play();
			}
			while (audioSourceComponent.volume < volumenMaximo)
			{
				AudioSource? obj = audioSourceComponent;
				obj.volume += velocidadFade * Time.deltaTime;
				yield return null;
			}
			audioSourceComponent.volume = volumenMaximo;
		}

		private IEnumerator FadeOutYPausar()
		{
			while (audioSourceComponent.volume > 0f)
			{
				AudioSource? obj = audioSourceComponent;
				obj.volume -= velocidadFade * Time.deltaTime;
				yield return null;
			}
			audioSourceComponent.volume = 0f;
			audioSourceComponent.Pause();
		}
	}
	public class ItemUpgradeHealthSound : MonoBehaviour
	{
		public ItemToggle itemToggle = null;

		[Header("Audio Personalizado")]
		[Tooltip("Arrastra aquí el asset de tipo 'Sound' único para esta mejora de vida")]
		public Sound CustomUpgradeSound = null;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void Upgrade()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)itemToggle == (Object)null))
			{
				if (CustomUpgradeSound != null)
				{
					CustomUpgradeSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				}
				if ((Object)(object)PunManager.instance != (Object)null)
				{
					PunManager.instance.UpgradePlayerHealth(SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID)), 1);
				}
			}
		}
	}
	public class PowerUpFlotante : MonoBehaviour
	{
		[Header("Ajustes de Rotación")]
		[Tooltip("Velocidad de giro continuo sobre el eje Y (grados por segundo)")]
		public float velocidadRotacion = 60f;

		[Header("Ajustes de Flotación Fija")]
		[Tooltip("Elevación extra (en metros) sobre la posición de spawn/mesa")]
		public float elevacionSobreMesa = 0.15f;

		private Rigidbody rb = null;

		private PhysGrabObject physGrab = null;

		private bool estaGirando = true;

		private RigidbodyConstraints constraintsOriginales;

		private float anguloYActual;

		private void Awake()
		{
			rb = ((Component)this).GetComponent<Rigidbody>();
			physGrab = ((Component)this).GetComponent<PhysGrabObject>();
		}

		private void Start()
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rb != (Object)null)
			{
				constraintsOriginales = rb.constraints;
				rb.useGravity = false;
				Transform transform = ((Component)this).transform;
				transform.position += Vector3.up * elevacionSobreMesa;
				Quaternion rotation = ((Component)this).transform.rotation;
				anguloYActual = ((Quaternion)(ref rotation)).eulerAngles.y;
				((Component)this).transform.rotation = Quaternion.Euler(0f, anguloYActual, 0f);
				rb.constraints = (RigidbodyConstraints)(constraintsOriginales | 2 | 4 | 8 | 0x10 | 0x40);
			}
		}

		private void FixedUpdate()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			if (!estaGirando)
			{
				return;
			}
			if ((Object)(object)physGrab != (Object)null && (physGrab.grabbed || physGrab.playerGrabbing.Count > 0))
			{
				DesactivarEfectoRotacion();
			}
			else if (!((Object)(object)rb == (Object)null))
			{
				anguloYActual += velocidadRotacion * Time.fixedDeltaTime;
				Quaternion val = Quaternion.Euler(0f, anguloYActual, 0f);
				if (rb.isKinematic)
				{
					rb.MoveRotation(val);
					return;
				}
				rb.MoveRotation(val);
				rb.angularVelocity = Vector3.zero;
			}
		}

		public void DesactivarEfectoRotacion()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (estaGirando)
			{
				estaGirando = false;
				if ((Object)(object)rb != (Object)null)
				{
					rb.constraints = constraintsOriginales;
					rb.useGravity = true;
					rb.isKinematic = false;
				}
				Object.Destroy((Object)(object)this);
			}
		}
	}
	public class WeaponAudioTogglePlayer : MonoBehaviour
	{
		[Header("Componente de Audio")]
		public AudioSource? audioSource;

		[Header("Lista de Audios Personalizados")]
		[Tooltip("Arrastra tus clips (.wav, .mp3) desde Unity")]
		public AudioClip[] misAudios = (AudioClip[])(object)new AudioClip[0];

		[Header("Ajustes de Audio y Cooldown")]
		[Range(0f, 1f)]
		public float volumen = 1f;

		[Range(0f, 0.3f)]
		public float variacionPitch = 0.05f;

		[Tooltip("Tiempo de espera en segundos entre cada reproducción para evitar solapamientos")]
		public float cooldownSonido = 1f;

		[Header("Alerta a Enemigos")]
		public float investigateRadius = 10f;

		private float ultimoTiempoSonido;

		private ItemToggle? itemToggle;

		private void Start()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
			if ((Object)(object)audioSource == (Object)null)
			{
				audioSource = ((Component)this).GetComponent<AudioSource>() ?? ((Component)this).gameObject.AddComponent<AudioSource>();
			}
			audioSource.spatialBlend = 1f;
			audioSource.playOnAwake = false;
			ultimoTiempoSonido = 0f - cooldownSonido;
			if ((Object)(object)itemToggle != (Object)null)
			{
				itemToggle.onToggle.AddListener(new UnityAction(OnItemToggled));
			}
		}

		private void OnDestroy()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			if ((Object)(object)itemToggle != (Object)null)
			{
				itemToggle.onToggle.RemoveListener(new UnityAction(OnItemToggled));
			}
		}

		private void OnItemToggled()
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			if (misAudios == null || misAudios.Length == 0 || Time.time - ultimoTiempoSonido < cooldownSonido)
			{
				return;
			}
			ultimoTiempoSonido = Time.time;
			int num = Random.Range(0, misAudios.Length);
			AudioClip val = misAudios[num];
			if ((Object)(object)val != (Object)null && (Object)(object)audioSource != (Object)null)
			{
				audioSource.pitch = 1f + Random.Range(0f - variacionPitch, variacionPitch);
				audioSource.PlayOneShot(val, volumen);
				if (investigateRadius > 0f && SemiFunc.IsMasterClientOrSingleplayer() && (Object)(object)EnemyDirector.instance != (Object)null)
				{
					EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, investigateRadius, false);
				}
			}
		}
	}
	public class HoldAudioItem : Trap
	{
		[Header("Configuración de Audio")]
		public Sound holdSound = null;

		public List<AudioClip> audioClipsList = new List<AudioClip>();

		private bool previousGrabState;

		private int currentPlayingIndex = -1;

		public override void Start()
		{
			((Trap)this).Start();
			if (holdSound != null && (Object)(object)holdSound.Source != (Object)null)
			{
				holdSound.Source.loop = true;
			}
		}

		public override void Update()
		{
			((Trap)this).Update();
			if (!SemiFunc.IsMasterClientOrSingleplayer() || base.physGrabObject.grabbed == previousGrabState)
			{
				return;
			}
			previousGrabState = base.physGrabObject.grabbed;
			if (base.physGrabObject.grabbed)
			{
				if (audioClipsList != null && audioClipsList.Count > 0)
				{
					int index = Random.Range(0, audioClipsList.Count);
					StartHoldAudio(index);
				}
			}
			else
			{
				StopHoldAudio();
			}
		}

		private void StartHoldAudio(int index)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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)
			EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, 15f, false);
			if (SemiFunc.IsMultiplayer())
			{
				base.photonView.RPC("PlayHoldAudioRPC", (RpcTarget)0, new object[1] { index });
			}
			else
			{
				PlayHoldAudioRPC(index);
			}
		}

		private void StopHoldAudio()
		{
			//IL_0029: 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)
			if (SemiFunc.IsMultiplayer())
			{
				base.photonView.RPC("StopHoldAudioRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				StopHoldAudioRPC();
			}
		}

		[PunRPC]
		private void PlayHoldAudioRPC(int index, PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: 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)
			if (!SemiFunc.MasterOnlyRPC(_info) || audioClipsList == null || index < 0 || index >= audioClipsList.Count)
			{
				return;
			}
			currentPlayingIndex = index;
			AudioClip val = audioClipsList[index];
			if (holdSound != null)
			{
				holdSound.Sounds = (AudioClip[])(object)new AudioClip[1] { val };
				if ((Object)(object)holdSound.Source != (Object)null)
				{
					holdSound.Source.loop = true;
				}
				holdSound.Play(base.physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
			}
		}

		[PunRPC]
		private void StopHoldAudioRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(_info))
			{
				if (holdSound != null)
				{
					holdSound.Stop();
				}
				currentPlayingIndex = -1;
			}
		}
	}
	public class CustomGrabExplosiveTrap : Trap
	{
		[Header("Explosion Setup")]
		[Tooltip("Prefab del efecto de carga (dura 16s).")]
		public GameObject? castVfxPrefab;

		[Tooltip("Prefab de la explosión final (dura 3s).")]
		public GameObject? explosionVfxPrefab;

		[Tooltip("Punto exacto donde aparecerán los VFX y el origen del daño.")]
		public Transform? explosionCenter;

		[Tooltip("Tiempo de espera desde que el jugador toca el área hasta iniciar la carga.")]
		public float delayBeforeCast = 1f;

		[Tooltip("Duración exacta de la animación de carga antes de explotar.")]
		public float castDuration = 16f;

		[Tooltip("Tiempo en segundos que vivirá el VFX de la explosión final.")]
		public float explosionVfxLifetime = 5f;

		[Header("Damage Setup")]
		[Tooltip("Radio del área de daño de la explosión en metros.")]
		public float explosionRadius = 5f;

		[Tooltip("Fuerza del empuje físico a los objetos cercanos.")]
		public float explosionForce = 300f;

		[Header("Audio Pool Setup")]
		public List<Sound> triggerSoundPool = new List<Sound>();

		private PhysGrabObject? physgrabobject;

		private ParticleScriptExplosion? particleScriptExplosion;

		private AudioSource? playingAudioSource;

		public override void Start()
		{
			((Trap)this).Start();
			physgrabobject = ((Component)this).GetComponent<PhysGrabObject>();
			particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
			if ((Object)(object)explosionCenter == (Object)null)
			{
				explosionCenter = ((Component)this).transform;
			}
		}

		public void TriggerTrap()
		{
			if (GameManager.instance.gameMode == 0)
			{
				TriggerTrapLogic();
			}
			else if (PhotonNetwork.IsMasterClient)
			{
				base.photonView.RPC("TriggerTrapRPC", (RpcTarget)0, Array.Empty<object>());
			}
		}

		[PunRPC]
		private void TriggerTrapRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(_info))
			{
				TriggerTrapLogic();
			}
		}

		private void TriggerTrapLogic()
		{
			if (!base.trapTriggered)
			{
				base.trapTriggered = true;
				base.trapActive = true;
				PlayRandomSound();
				((MonoBehaviour)this).StartCoroutine(TrapSequence());
			}
		}

		private void PlayRandomSound()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if (triggerSoundPool != null && triggerSoundPool.Count > 0 && (Object)(object)physgrabobject != (Object)null)
			{
				int index = Random.Range(0, triggerSoundPool.Count);
				Sound val = triggerSoundPool[index];
				if (val != null)
				{
					playingAudioSource = val.Play(physgrabobject.centerPoint, 1f, 1f, 1f, 1f);
				}
			}
		}

		private IEnumerator TrapSequence()
		{
			if (delayBeforeCast > 0f)
			{
				yield return (object)new WaitForSeconds(delayBeforeCast);
			}
			Vector3 spawnPosition = (((Object)(object)explosionCenter != (Object)null) ? explosionCenter.position : ((Component)this).transform.position);
			if ((Object)(object)castVfxPrefab != (Object)null)
			{
				GameObject spawnedCast = Object.Instantiate<GameObject>(castVfxPrefab, spawnPosition, Quaternion.identity);
				Object.Destroy((Object)(object)spawnedCast, castDuration + 1f);
			}
			yield return (object)new WaitForSeconds(castDuration);
			if ((Object)(object)explosionVfxPrefab != (Object)null)
			{
				GameObject spawnedExplosion = Object.Instantiate<GameObject>(explosionVfxPrefab, spawnPosition, Quaternion.identity);
				Object.Destroy((Object)(object)spawnedExplosion, explosionVfxLifetime);
			}
			ApplyExplosionDamage(spawnPosition);
			Detonate();
		}

		private void ApplyExplosionDamage(Vector3 position)
		{
			//IL_003f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)particleScriptExplosion != (Object)null)
			{
				particleScriptExplosion.Spawn(position, explosionRadius, (int)explosionForce, 300, 1f, false, false, 1f);
				return;
			}
			Collider[] array = Physics.OverlapSphere(position, explosionRadius);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				Rigidbody attachedRigidbody = val.attachedRigidbody;
				if ((Object)(object)attachedRigidbody != (Object)null)
				{
					attachedRigidbody.AddExplosionForce(explosionForce, position, explosionRadius);
				}
			}
		}

		private void Detonate()
		{
			base.trapActive = false;
			if ((Object)(object)playingAudioSource != (Object)null)
			{
				playingAudioSource.Stop();
			}
			if ((Object)(object)physgrabobject != (Object)null)
			{
				physgrabobject.dead = true;
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void OnDrawGizmosSelected()
		{
			//IL_0022: 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_0027: 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_0047: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (((Object)(object)explosionCenter != (Object)null) ? explosionCenter.position : ((Component)this).transform.position);
			Gizmos.color = new Color(1f, 0f, 0f, 0.25f);
			Gizmos.DrawSphere(val, explosionRadius);
			Gizmos.color = Color.red;
			Gizmos.DrawWireSphere(val, explosionRadius);
		}
	}
	[HarmonyPatch(typeof(PlayerController))]
	internal static class ExamplePlayerControllerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void Start_Prefix(PlayerController __instance)
		{
			Dream_Team_Mod.Logger.LogDebug((object)$"{__instance} Start Prefix");
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Start_Postfix(PlayerController __instance)
		{
			Dream_Team_Mod.Logger.LogDebug((object)$"{__instance} Start Postfix");
		}
	}
	public class GachaponSystem_B : Trap
	{
		[Header("Componentes Visuales (Asignar en Unity)")]
		[Tooltip("El objeto de la palanca que va a rotar hacia abajo")]
		public Transform? palancaTransform;

		[Tooltip("El objeto de la llave que girará después")]
		public Transform? llaveTransform;

		[Tooltip("El cuerpo completo de la máquina que va a vibrar")]
		public Transform? cuerpoMaquinaTransform;

		[Header("Ajustes de Animación de la Palanca")]
		public float inclinacionPalanca = 45f;

		public float velocidadPalanca = 180f;

		[Header("Ajustes de Animación de la Llave")]
		public float velocidadLlave = 360f;

		public float tiempoPausaLlave = 0.3f;

		public bool rotarLlaveEnX = false;

		[Header("Ajustes de Vibración Mecánica")]
		public float duracionVibracion = 0.4f;

		public float intensidadVibracion = 0.02f;

		[Header("Sonidos del Gachapon")]
		public Sound? sonidoRecompensa;

		[Tooltip("Lista de audios que sonarán AL AZAR cuando intenten usar la máquina vacía")]
		public Sound[] sonidosSinStock = (Sound[])(object)new Sound[0];

		[Header("--- TIMING Y DISPENSADOR MULTI-ITEM ---")]
		[Tooltip("Segundos de espera entre el giro de la llave y la entrega (vibración + spawn del ítem)")]
		public float tiempoEsperaSpawn = 2f;

		[Tooltip("Lista de las Poké Balls decorativas que están fijas dentro del vidrio")]
		public List<GameObject> esferasVitrina = new List<GameObject>();

		[Tooltip("Lista de los Prefabs reales que saldrán abajo (Mismo orden que esferasVitrina)")]
		public List<GameObject> prefabsRecompensas = new List<GameObject>();

		[Tooltip("Punto vacío (Transform) donde va a nacer el ítem real abajo")]
		public Transform? puntoSalidaSpawn;

		[Tooltip("Fuerza de impulso físico con la que saldrá expulsado el ítem")]
		public float fuerzaExpulsion = 2f;

		private float cooldownAccion = 2f;

		private float ultimaAccionTime;

		private bool sistemaBloqueado = false;

		private Quaternion rotacionInicialPalanca;

		public override void Start()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			((Trap)this).Start();
			ultimaAccionTime = Time.time;
			if ((Object)(object)palancaTransform != (Object)null)
			{
				rotacionInicialPalanca = palancaTransform.localRotation;
			}
		}

		private List<int> ObtenerIndicesValidosVitrina()
		{
			List<int> list = new List<int>();
			for (int i = 0; i < esferasVitrina.Count; i++)
			{
				if ((Object)(object)esferasVitrina[i] != (Object)null && esferasVitrina[i].activeSelf)
				{
					list.Add(i);
				}
			}
			return list;
		}

		public void JalarPalanca()
		{
			if (!sistemaBloqueado && !(Time.time - ultimaAccionTime < cooldownAccion))
			{
				ultimaAccionTime = Time.time;
				List<int> list = ObtenerIndicesValidosVitrina();
				bool flag = list.Count > 0;
				if (GameManager.instance.gameMode == 0)
				{
					ProcesarGiroPalanca(flag);
				}
				else if (PhotonNetwork.IsMasterClient)
				{
					base.photonView.RPC("SincronizarPalancaRPC", (RpcTarget)0, new object[1] { flag });
				}
			}
		}

		[PunRPC]
		private void SincronizarPalancaRPC(bool tieneStock, PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(_info))
			{
				ProcesarGiroPalanca(tieneStock);
			}
		}

		private void ProcesarGiroPalanca(bool tieneStock)
		{
			//IL_003f: 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)
			if (tieneStock)
			{
				EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, 15f, false);
				((MonoBehaviour)this).StartCoroutine(SecuenciaMecanicaGachapon());
			}
			else
			{
				EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, 4f, false);
				((MonoBehaviour)this).StartCoroutine(SecuenciaPalancaVaciaSincronizada());
			}
		}

		private IEnumerator SecuenciaMecanicaGachapon()
		{
			sistemaBloqueado = true;
			if ((Object)(object)palancaTransform != (Object)null)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(RotarPalancaHacia(Quaternion.Euler(inclinacionPalanca, 0f, 0f)));
			}
			if ((Object)(object)palancaTransform != (Object)null)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(RotarPalancaHacia(rotacionInicialPalanca));
			}
			if (sonidoRecompensa != null)
			{
				sonidoRecompensa.Play(base.physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
			}
			if ((Object)(object)llaveTransform != (Object)null)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(GirarLlaveGrados(180f));
				yield return (object)new WaitForSeconds(tiempoPausaLlave);
				yield return ((MonoBehaviour)this).StartCoroutine(GirarLlaveGrados(180f));
			}
			if (tiempoEsperaSpawn > 0f)
			{
				yield return (object)new WaitForSeconds(tiempoEsperaSpawn);
			}
			if ((Object)(object)cuerpoMaquinaTransform != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(VibrarCuerpoMaquina());
			}
			List<int> indicesValidos = ObtenerIndicesValidosVitrina();
			if (indicesValidos.Count > 0)
			{
				int indiceElegidoEnListaValida = Random.Range(0, indicesValidos.Count);
				int indiceReal = indicesValidos[indiceElegidoEnListaValida];
				GameObject bolaADesactivar = esferasVitrina[indiceReal];
				if ((Object)(object)bolaADesactivar != (Object)null)
				{
					bolaADesactivar.SetActive(false);
				}
				GameObject prefabAInstanciar = null;
				if (indiceReal < prefabsRecompensas.Count)
				{
					prefabAInstanciar = prefabsRecompensas[indiceReal];
				}
				if (GameManager.instance.gameMode == 0 || PhotonNetwork.IsMasterClient)
				{
					DespacharItemReal(prefabAInstanciar);
				}
			}
			else if (sonidosSinStock != null && sonidosSinStock.Length != 0)
			{
				int indiceAleatorio = Random.Range(0, sonidosSinStock.Length);
				Sound sonidoElegido = sonidosSinStock[indiceAleatorio];
				if (sonidoElegido != null)
				{
					sonidoElegido.Play(base.physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
				}
			}
			sistemaBloqueado = false;
		}

		private IEnumerator SecuenciaPalancaVaciaSincronizada()
		{
			sistemaBloqueado = true;
			if ((Object)(object)palancaTransform != (Object)null)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(RotarPalancaHacia(Quaternion.Euler(inclinacionPalanca, 0f, 0f)));
			}
			if ((Object)(object)palancaTransform != (Object)null)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(RotarPalancaHacia(rotacionInicialPalanca));
			}
			if (sonidosSinStock != null && sonidosSinStock.Length != 0)
			{
				int indiceAleatorio = Random.Range(0, sonidosSinStock.Length);
				Sound sonidoElegido = sonidosSinStock[indiceAleatorio];
				if (sonidoElegido != null)
				{
					sonidoElegido.Play(base.physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
				}
			}
			yield return (object)new WaitForSeconds(3f);
			sistemaBloqueado = false;
		}

		private void DespacharItemReal(GameObject? prefabASpawnear)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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)
			if (!((Object)(object)prefabASpawnear == (Object)null) && !((Object)(object)puntoSalidaSpawn == (Object)null))
			{
				GameObject val = Object.Instantiate<GameObject>(prefabASpawnear, puntoSalidaSpawn.position, puntoSalidaSpawn.rotation);
				Rigidbody component = val.GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddForce(puntoSalidaSpawn.forward * fuerzaExpulsion, (ForceMode)1);
				}
			}
		}

		private IEnumerator VibrarCuerpoMaquina()
		{
			Vector3 posicionOriginal = cuerpoMaquinaTransform.localPosition;
			float tiempoTranscurrido = 0f;
			while (tiempoTranscurrido < duracionVibracion)
			{
				Vector3 desplazamiento = Random.insideUnitSphere * intensidadVibracion;
				cuerpoMaquinaTransform.localPosition = posicionOriginal + desplazamiento;
				tiempoTranscurrido += Time.deltaTime;
				yield return null;
			}
			cuerpoMaquinaTransform.localPosition = posicionOriginal;
		}

		private IEnumerator RotarPalancaHacia(Quaternion rotacionDestino)
		{
			//IL_000e: 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)
			while (Quaternion.Angle(palancaTransform.localRotation, rotacionDestino) > 0.1f)
			{
				palancaTransform.localRotation = Quaternion.RotateTowards(palancaTransform.localRotation, rotacionDestino, velocidadPalanca * Time.deltaTime);
				yield return null;
			}
			palancaTransform.localRotation = rotacionDestino;
		}

		private IEnumerator GirarLlaveGrados(float gradosObjetivo)
		{
			float gradosGirados = 0f;
			while (gradosGirados < gradosObjetivo)
			{
				float pasoGiro = velocidadLlave * Time.deltaTime;
				if (gradosGirados + pasoGiro > gradosObjetivo)
				{
					pasoGiro = gradosObjetivo - gradosGirados;
				}
				if (rotarLlaveEnX)
				{
					llaveTransform.Rotate(pasoGiro, 0f, 0f, (Space)1);
				}
				else
				{
					llaveTransform.Rotate(0f, 0f, pasoGiro, (Space)1);
				}
				gradosGirados += pasoGiro;
				yield return null;
			}
		}
	}
	public class GachaponSystem : Trap
	{
		[Header("Componentes Visuales (Asignar en Unity)")]
		[Tooltip("El objeto de la palanca que va a rotar hacia abajo")]
		public Transform? palancaTransform;

		[Tooltip("El objeto de la llave que girará después")]
		public Transform? llaveTransform;

		[Tooltip("El cuerpo completo de la máquina que va a vibrar")]
		public Transform? cuerpoMaquinaTransform;

		[Header("Ajustes de Animación de la Palanca")]
		public float inclinacionPalanca = 45f;

		public float velocidadPalanca = 180f;

		[Header("Ajustes de Animación de la Llave")]
		public float velocidadLlave = 360f;

		public float tiempoPausaLlave = 0.3f;

		public bool rotarLlaveEnX = false;

		[Header("Ajustes de Vibración Mecánica")]
		public float duracionVibracion = 0.4f;

		public float intensidadVibracion = 0.02f;

		[Header("Sonidos del Gachapon")]
		public Sound? sonidoRecompensa;

		[Tooltip("Lista de audios que sonarán AL AZAR cuando intenten usar la máquina vacía")]
		public Sound[] sonidosSinStock = (Sound[])(object)new Sound[0];

		[Header("--- SISTEMA DE DISPENSADOR CON FÍSICAS LIBRES ---")]
		[Tooltip("Segundos de espera entre el giro de la llave y la entrega (vibración + expulsión)")]
		public float tiempoEsperaSpawn = 2f;

		[Tooltip("Lista de las Poké Balls REALES que están sueltas con gravedad dentro del vidrio")]
		public List<GameObject> esferasVitrina = new List<GameObject>();

		[Tooltip("Punto vacío (Transform) fuera de la máquina por donde saldrá disparada la bola")]
		public Transform? puntoSalidaSpawn;

		[Tooltip("Fuerza de impulso físico con la que saldrá expulsada la bola")]
		public float fuerzaExpulsion = 2f;

		private float cooldownAccion = 2f;

		private float ultimaAccionTime;

		private bool sistemaBloqueado = false;

		private Quaternion rotacionInicialPalanca;

		public override void Start()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			((Trap)this).Start();
			ultimaAccionTime = Time.time;
			if ((Object)(object)palancaTransform != (Object)null)
			{
				rotacionInicialPalanca = palancaTransform.localRotation;
			}
		}

		private List<GameObject> ObtenerEsferasValidas()
		{
			List<GameObject> list = new List<GameObject>();
			for (int num = esferasVitrina.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)esferasVitrina[num] != (Object)null && esferasVitrina[num].activeSelf)
				{
					list.Add(esferasVitrina[num]);
				}
				else
				{
					esferasVitrina.RemoveAt(num);
				}
			}
			return list;
		}

		public void JalarPalanca()
		{
			if (!sistemaBloqueado && !(Time.time - ultimaAccionTime < cooldownAccion))
			{
				ultimaAccionTime = Time.time;
				List<GameObject> list = ObtenerEsferasValidas();
				bool flag = list.Count > 0;
				int num = -1;
				if (!flag && sonidosSinStock != null && sonidosSinStock.Length != 0)
				{
					num = Random.Range(0, sonidosSinStock.Length);
				}
				if (GameManager.instance.gameMode == 0)
				{
					ProcesarGiroPalanca(flag, num);
				}
				else if (PhotonNetwork.IsMasterClient)
				{
					base.photonView.RPC("SincronizarPalancaRPC", (RpcTarget)0, new object[2] { flag, num });
				}
			}
		}

		[PunRPC]
		private void SincronizarPalancaRPC(bool tieneStock, int indiceSonidoError, PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(_info))
			{
				ProcesarGiroPalanca(tieneStock, indiceSonidoError);
			}
		}

		private void ProcesarGiroPalanca(bool tieneStock, int indiceSonidoError)
		{
			//IL_0040: 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)
			if (tieneStock)
			{
				EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, 15f, false);
				((MonoBehaviour)this).StartCoroutine(SecuenciaMecanicaGachapon(indiceSonidoError));
			}
			else
			{
				EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, 4f, false);
				((MonoBehaviour)this).StartCoroutine(SecuenciaPalancaVaciaSincronizada(indiceSonidoError));
			}
		}

		private IEnumerator SecuenciaMecanicaGachapon(int indiceSonidoError)
		{
			sistemaBloqueado = true;
			if ((Object)(object)palancaTransform != (Object)null)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(RotarPalancaHacia(Quaternion.Euler(inclinacionPalanca, 0f, 0f)));
			}
			if ((Object)(object)palancaTransform != (Object)null)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(RotarPalancaHacia(rotacionInicialPalanca));
			}
			if (sonidoRecompensa != null)
			{
				sonidoRecompensa.Play(base.physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
			}
			if ((Object)(object)llaveTransform != (Object)null)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(GirarLlaveGrados(180f));
				yield return (object)new WaitForSeconds(tiempoPausaLlave);
				yield return ((MonoBehaviour)this).StartCoroutine(GirarLlaveGrados(180f));
			}
			if (tiempoEsperaSpawn > 0f)
			{
				yield return (object)new WaitForSeconds(tiempoEsperaSpawn);
			}
			if ((Object)(object)cuerpoMaquinaTransform != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(VibrarCuerpoMaquina());
			}
			List<GameObject> esferasDisponibles = ObtenerEsferasValidas();
			if (esferasDisponibles.Count > 0)
			{
				GameObject bolaAEntregar = esferasDisponibles[esferasDisponibles.Count - 1];
				esferasVitrina.Remove(bolaAEntregar);
				if ((Object)(object)bolaAEntregar != (Object)null)
				{
					DispensarEsferaFisica(bolaAEntregar);
				}
			}
			else
			{
				ReproducirSonidoSinStock(indiceSonidoError);
			}
			sistemaBloqueado = false;
		}

		private IEnumerator SecuenciaPalancaVaciaSincronizada(int indiceSonidoError)
		{
			sistemaBloqueado = true;
			if ((Object)(object)palancaTransform != (Object)null)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(RotarPalancaHacia(Quaternion.Euler(inclinacionPalanca, 0f, 0f)));
			}
			if ((Object)(object)palancaTransform != (Object)null)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(RotarPalancaHacia(rotacionInicialPalanca));
			}
			ReproducirSonidoSinStock(indiceSonidoError);
			sistemaBloqueado = false;
		}

		private void DispensarEsferaFisica(GameObject esfera)
		{
			//IL_008d: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)puntoSalidaSpawn == (Object)null || (Object)(object)esfera == (Object)null)
			{
				return;
			}
			Rigidbody component = esfera.GetComponent<Rigidbody>();
			PhysGrabObject component2 = esfera.GetComponent<PhysGrabObject>();
			PhotonView component3 = esfera.GetComponent<PhotonView>();
			if ((Object)(object)component3 != (Object)null && SemiFunc.IsMultiplayer() && !component3.IsMine && PhotonNetwork.IsMasterClient)
			{
				component3.TransferOwnership(PhotonNetwork.LocalPlayer);
			}
			esfera.transform.SetParent((Transform)null);
			esfera.transform.position = puntoSalidaSpawn.position;
			esfera.transform.rotation = puntoSalidaSpawn.rotation;
			if ((Object)(object)component != (Object)null)
			{
				component.isKinematic = false;
				component.velocity = Vector3.zero;
				component.angularVelocity = Vector3.zero;
				component.position = puntoSalidaSpawn.position;
				component.rotation = puntoSalidaSpawn.rotation;
			}
			if ((Object)(object)component2 != (Object)null)
			{
				component2.centerPoint = puntoSalidaSpawn.position;
				if ((Object)(object)component2.rb != (Object)null)
				{
					component2.rb.isKinematic = false;
					component2.rb.velocity = Vector3.zero;
					component2.rb.angularVelocity = Vector3.zero;
				}
			}
			if ((Object)(object)component != (Object)null)
			{
				component.AddForce(puntoSalidaSpawn.forward * fuerzaExpulsion, (ForceMode)1);
			}
		}

		private void ReproducirSonidoSinStock(int indiceSincronizado)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (sonidosSinStock != null && sonidosSinStock.Length != 0 && indiceSincronizado >= 0 && indiceSincronizado < sonidosSinStock.Length)
			{
				Sound val = sonidosSinStock[indiceSincronizado];
				if (val != null)
				{
					val.Play(base.physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
				}
			}
		}

		private IEnumerator VibrarCuerpoMaquina()
		{
			Vector3 posicionOriginal = cuerpoMaquinaTransform.localPosition;
			float tiempoTranscurrido = 0f;
			while (tiempoTranscurrido < duracionVibracion)
			{
				Vector3 desplazamiento = Random.insideUnitSphere * intensidadVibracion;
				cuerpoMaquinaTransform.localPosition = posicionOriginal + desplazamiento;
				tiempoTranscurrido += Time.deltaTime;
				yield return null;
			}
			cuerpoMaquinaTransform.localPosition = posicionOriginal;
		}

		private IEnumerator RotarPalancaHacia(Quaternion rotacionDestino)
		{
			//IL_000e: 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)
			while (Quaternion.Angle(palancaTransform.localRotation, rotacionDestino) > 0.1f)
			{
				palancaTransform.localRotation = Quaternion.RotateTowards(palancaTransform.localRotation, rotacionDestino, velocidadPalanca * Time.deltaTime);
				yield return null;
			}
			palancaTransform.localRotation = rotacionDestino;
		}

		private IEnumerator GirarLlaveGrados(float gradosObjetivo)
		{
			float gradosGirados = 0f;
			while (gradosGirados < gradosObjetivo)
			{
				float pasoGiro = velocidadLlave * Time.deltaTime;
				if (gradosGirados + pasoGiro > gradosObjetivo)
				{
					pasoGiro = gradosObjetivo - gradosGirados;
				}
				if (rotarLlaveEnX)
				{
					llaveTransform.Rotate(pasoGiro, 0f, 0f, (Space)1);
				}
				else
				{
					llaveTransform.Rotate(0f, 0f, pasoGiro, (Space)1);
				}
				gradosGirados += pasoGiro;
				yield return null;
			}
		}
	}
	public class ItemConsumibleTransformable : MonoBehaviour
	{
		[Header("Ajustes de Curación")]
		[Tooltip("Cantidad de vida que restaurarán las galletas")]
		public int healAmount = 15;

		[Header("Modelos 3D (Asignar en Unity)")]
		[Tooltip("El objeto 3D del paquete de galletas LLENO")]
		public GameObject? modeloLleno;

		[Tooltip("El objeto 3D del paquete de galletas VACÍO")]
		public GameObject? modeloVacio;

		[Space]
		public ParticleSystem[] particles = (ParticleSystem[])(object)new ParticleSystem[0];

		public ParticleSystem[] rejectParticles = (ParticleSystem[])(object)new ParticleSystem[0];

		[Header("Sonidos de las Galletas")]
		[Tooltip("Sonido que sonará al comer (ej. masticar/crujido)")]
		public Sound? soundUse;

		[Tooltip("Sonido que sonará si se rechaza el consumo")]
		public Sound? soundReject;

		private ItemToggle? itemToggle;

		private ItemEquippable? itemEquippable;

		private ItemAttributes? itemAttributes;

		private PhotonView? photonView;

		private PhysGrabObject? physGrabObject;

		private NotValuableObject? notValuableObject;

		private bool used;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
			itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
			itemAttributes = ((Component)this).GetComponent<ItemAttributes>();
			photonView = ((Component)this).GetComponent<PhotonView>();
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			notValuableObject = ((Component)this).GetComponent<NotValuableObject>();
			if ((Object)(object)notValuableObject != (Object)null)
			{
				notValuableObject.hasHealth = false;
			}
			if ((Object)(object)modeloLleno != (Object)null)
			{
				modeloLleno.SetActive(true);
			}
			if ((Object)(object)modeloVacio != (Object)null)
			{
				modeloVacio.SetActive(false);
			}
		}

		private void Update()
		{
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0129: 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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.RunIsShop() || RunManager.instance.levelIsShop || (Object)(object)itemToggle == (Object)null || (Object)(object)physGrabObject == (Object)null || (Object)(object)itemAttributes == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer() || !itemToggle.toggleState || used)
			{
				return;
			}
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			if (val.playerHealth.health >= val.playerHealth.maxHealth)
			{
				if (SemiFunc.IsMultiplayer() && (Object)(object)photonView != (Object)null)
				{
					photonView.RPC("RejectRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					RejectRPC();
				}
				itemToggle.ToggleItem(false, -1);
				physGrabObject.rb.AddForce(Vector3.up * 2f, (ForceMode)1);
				physGrabObject.rb.AddTorque(-((Component)physGrabObject).transform.right * 0.05f, (ForceMode)1);
			}
			else
			{
				val.playerHealth.HealOther(healAmount, true);
				StatsManager.instance.ItemRemove(itemAttributes.instanceName);
				if (SemiFunc.IsMultiplayer() && (Object)(object)photonView != (Object)null)
				{
					photonView.RPC("UsedRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					UsedRPC();
				}
				itemToggle.ToggleDisable(true);
			}
		}

		[PunRPC]
		private void UsedRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterOnlyRPC(_info))
			{
				return;
			}
			if ((Object)(object)notValuableObject != (Object)null)
			{
				notValuableObject.hasHealth = true;
			}
			GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)this).transform.position, 0.2f);
			if ((Object)(object)itemAttributes != (Object)null)
			{
				itemAttributes.DisableUI(true);
			}
			if ((Object)(object)itemEquippable != (Object)null)
			{
				Object.Destroy((Object)(object)itemEquippable);
			}
			if ((Object)(object)modeloLleno != (Object)null)
			{
				modeloLleno.SetActive(false);
			}
			if ((Object)(object)modeloVacio != (Object)null)
			{
				modeloVacio.SetActive(true);
			}
			for (int i = 0; i < particles.Length; i++)
			{
				if ((Object)(object)particles[i] != (Object)null)
				{
					particles[i].Play();
				}
			}
			if (soundUse != null)
			{
				soundUse.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
			used = true;
		}

		[PunRPC]
		private void RejectRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterOnlyRPC(_info) || (Object)(object)itemToggle == (Object)null || (Object)(object)photonView == (Object)null)
			{
				return;
			}
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID);
			if ((Object)(object)val != (Object)null && val.isLocal)
			{
				if (SemiFunc.IsMultiplayer())
				{
					val.physGrabber.photonView.RPC("ReleaseObjectRPC", (RpcTarget)0, new object[3] { false, 1f, photonView.ViewID });
				}
				else
				{
					val.physGrabber.ReleaseObject(photonView.ViewID, 1f);
				}
			}
			for (int i = 0; i < rejectParticles.Length; i++)
			{
				if ((Object)(object)rejectParticles[i] != (Object)null)
				{
					rejectParticles[i].Play();
				}
			}
			GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)this).transform.position, 0.2f);
			if (soundReject != null)
			{
				soundReject.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
		}

		public void OnDestroy()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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)
			ParticleSystem[] array = particles;
			foreach (ParticleSystem val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && val.isPlaying)
				{
					((Component)val).transform.SetParent((Transform)null);
					MainModule main = val.main;
					((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)2;
				}
			}
			ParticleSystem[] array2 = rejectParticles;
			foreach (ParticleSystem val2 in array2)
			{
				if (Object.op_Implicit((Object)(object)val2) && val2.isPlaying)
				{
					((Component)val2).transform.SetParent((Transform)null);
					MainModule main2 = val2.main;
					((MainModule)(ref main2)).stopAction = (ParticleSystemStopAction)2;
				}
			}
		}
	}
	public class ItemPotionHeal : MonoBehaviour
	{
		[Header("Ajustes de Curación")]
		[Tooltip("Cantidad de vida que restaurará la poción")]
		public int healAmount = 25;

		[Header("Efectos Visuales de la Poción")]
		[Tooltip("El objeto 3D dentro de la botella que representa el líquido de la poción")]
		public GameObject? objetoLiquido;

		[Space]
		public ParticleSystem[] particles = (ParticleSystem[])(object)new ParticleSystem[0];

		public ParticleSystem[] rejectParticles = (ParticleSystem[])(object)new ParticleSystem[0];

		[Header("Sonidos de la Poción")]
		public Sound? soundUse;

		public Sound? soundReject;

		private ItemToggle? itemToggle;

		private ItemEquippable? itemEquippable;

		private ItemAttributes? itemAttributes;

		private PhotonView? photonView;

		private PhysGrabObject? physGrabObject;

		private NotValuableObject? notValuableObject;

		private bool used;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
			itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
			itemAttributes = ((Component)this).GetComponent<ItemAttributes>();
			photonView = ((Component)this).GetComponent<PhotonView>();
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			notValuableObject = ((Component)this).GetComponent<NotValuableObject>();
			if ((Object)(object)notValuableObject != (Object)null)
			{
				notValuableObject.hasHealth = false;
			}
			if ((Object)(object)objetoLiquido != (Object)null)
			{
				objetoLiquido.SetActive(true);
			}
		}

		private void Update()
		{
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0129: 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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.RunIsShop() || RunManager.instance.levelIsShop || (Object)(object)itemToggle == (Object)null || (Object)(object)physGrabObject == (Object)null || (Object)(object)itemAttributes == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer() || !itemToggle.toggleState || used)
			{
				return;
			}
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			if (val.playerHealth.health >= val.playerHealth.maxHealth)
			{
				if (SemiFunc.IsMultiplayer() && (Object)(object)photonView != (Object)null)
				{
					photonView.RPC("RejectRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					RejectRPC();
				}
				itemToggle.ToggleItem(false, -1);
				physGrabObject.rb.AddForce(Vector3.up * 2f, (ForceMode)1);
				physGrabObject.rb.AddTorque(-((Component)physGrabObject).transform.right * 0.05f, (ForceMode)1);
			}
			else
			{
				val.playerHealth.HealOther(healAmount, true);
				StatsManager.instance.ItemRemove(itemAttributes.instanceName);
				if (SemiFunc.IsMultiplayer() && (Object)(object)photonView != (Object)null)
				{
					photonView.RPC("UsedRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					UsedRPC();
				}
				itemToggle.ToggleDisable(true);
			}
		}

		[PunRPC]
		private void UsedRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterOnlyRPC(_info))
			{
				return;
			}
			if ((Object)(object)notValuableObject != (Object)null)
			{
				notValuableObject.hasHealth = true;
			}
			GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)this).transform.position, 0.2f);
			if ((Object)(object)itemAttributes != (Object)null)
			{
				itemAttributes.DisableUI(true);
			}
			if ((Object)(object)itemEquippable != (Object)null)
			{
				Object.Destroy((Object)(object)itemEquippable);
			}
			if ((Object)(object)objetoLiquido != (Object)null)
			{
				objetoLiquido.SetActive(false);
			}
			for (int i = 0; i < particles.Length; i++)
			{
				if ((Object)(object)particles[i] != (Object)null)
				{
					particles[i].Play();
				}
			}
			if (soundUse != null)
			{
				soundUse.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
			used = true;
		}

		[PunRPC]
		private void RejectRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterOnlyRPC(_info) || (Object)(object)itemToggle == (Object)null || (Object)(object)photonView == (Object)null)
			{
				return;
			}
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID);
			if ((Object)(object)val != (Object)null && val.isLocal)
			{
				if (SemiFunc.IsMultiplayer())
				{
					val.physGrabber.photonView.RPC("ReleaseObjectRPC", (RpcTarget)0, new object[3] { false, 1f, photonView.ViewID });
				}
				else
				{
					val.physGrabber.ReleaseObject(photonView.ViewID, 1f);
				}
			}
			for (int i = 0; i < rejectParticles.Length; i++)
			{
				if ((Object)(object)rejectParticles[i] != (Object)null)
				{
					rejectParticles[i].Play();
				}
			}
			GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)this).transform.position, 0.2f);
			if (soundReject != null)
			{
				soundReject.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
		}

		public void OnDestroy()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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)
			ParticleSystem[] array = particles;
			foreach (ParticleSystem val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && val.isPlaying)
				{
					((Component)val).transform.SetParent((Transform)null);
					MainModule main = val.main;
					((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)2;
				}
			}
			ParticleSystem[] array2 = rejectParticles;
			foreach (ParticleSystem val2 in array2)
			{
				if (Object.op_Implicit((Object)(object)val2) && val2.isPlaying)
				{
					((Component)val2).transform.SetParent((Transform)null);
					MainModule main2 = val2.main;
					((MainModule)(ref main2)).stopAction = (ParticleSystemStopAction)2;
				}
			}
		}
	}
	[RequireComponent(typeof(Rigidbody))]
	public class ObjetoCaidaLibreAudio : MonoBehaviour
	{
		[Header("Configuración de Caída")]
		[Tooltip("Tiempo cayendo (en segundos) necesario para activar el sonido")]
		public float tiempoCaidaRequerido = 1f;

		[Tooltip("Velocidad vertical mínima (hacia abajo, valor negativo) para considerar que está cayendo")]
		public float velocidadCaidaMinima = -2f;

		[Header("Sonido")]
		[Tooltip("Audio que se reproducirá al caer durante el tiempo especificado")]
		public Sound? sonidoCaida;

		private Rigidbody rb = null;

		private float tiempoCayendoActual = 0f;

		private bool sonidoReproducido = false;

		private void Awake()
		{
			rb = ((Component)this).GetComponent<Rigidbody>();
		}

		private void Update()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (rb.velocity.y < velocidadCaidaMinima)
			{
				tiempoCayendoActual += Time.deltaTime;
				if (tiempoCayendoActual >= tiempoCaidaRequerido && !sonidoReproducido)
				{
					ReproducirSonidoCaida();
				}
			}
			else
			{
				tiempoCayendoActual = 0f;
				sonidoReproducido = false;
			}
		}

		private void ReproducirSonidoCaida()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			sonidoReproducido = true;
			if (sonidoCaida != null)
			{
				sonidoCaida.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
		}

		private void OnCollisionEnter(Collision collision)
		{
			tiempoCayendoActual = 0f;
			sonidoReproducido = false;
		}
	}
}