Decompiled source of Soda Perks v1.2.2

MichPerksSystem.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using Photon.Pun;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MichPerksSystem")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MichPerksSystem")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f47ea826-6616-4160-9d0e-37f4b2284353")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MichPerks;

[BepInPlugin("com.Mich.PerksSystem", "Mich Perk System v48 Bulletproof", "48.0.0")]
public class PerkSystemPlugin : BaseUnityPlugin
{
	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Mich Perk System v48: ESCÁNER DE IDs PROFUNDO ACTIVADO.");
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		R_PerkGhost.ResetStatics();
		R_PerkGhost[] array = Object.FindObjectsOfType<R_PerkGhost>();
		foreach (R_PerkGhost r_PerkGhost in array)
		{
			Object.Destroy((Object)(object)((Component)r_PerkGhost).gameObject);
		}
	}
}
public class R_VendingMachine : MonoBehaviourPun
{
	[Header("--- CONFIGURACIÓN VENDING ---")]
	public GameObject lataPrefab;

	public Transform puntoDeSpawn;

	public AudioClip sonidoComprar;

	public AudioClip sonidoError;

	private AudioSource _audio;

	private bool _yaUsada = false;

	private bool _procesando = false;

	private void Awake()
	{
		_audio = ((Component)this).GetComponent<AudioSource>();
		if (!Object.op_Implicit((Object)(object)_audio))
		{
			_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
		}
		_audio.spatialBlend = 1f;
	}

	public void ComprarSoda()
	{
		if (_yaUsada || _procesando)
		{
			if (Object.op_Implicit((Object)(object)sonidoError))
			{
				_audio.PlayOneShot(sonidoError);
			}
			return;
		}
		_procesando = true;
		if (PhotonNetwork.IsConnected && PhotonNetwork.InRoom)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				int num = PhotonNetwork.AllocateViewID(0);
				((MonoBehaviourPun)this).photonView.RPC("SpawnSodaManualRPC", (RpcTarget)3, new object[1] { num });
			}
			else
			{
				((MonoBehaviourPun)this).photonView.RPC("SolicitarCompraRPC", (RpcTarget)2, Array.Empty<object>());
			}
		}
		else
		{
			SpawnSodaLocal(-1);
			_yaUsada = true;
			_procesando = false;
		}
	}

	[PunRPC]
	public void SolicitarCompraRPC()
	{
		if (PhotonNetwork.IsMasterClient && !_yaUsada)
		{
			int num = PhotonNetwork.AllocateViewID(0);
			((MonoBehaviourPun)this).photonView.RPC("SpawnSodaManualRPC", (RpcTarget)3, new object[1] { num });
		}
	}

	[PunRPC]
	public void SpawnSodaManualRPC(int viewID)
	{
		if (!_yaUsada)
		{
			SpawnSodaLocal(viewID);
			_yaUsada = true;
			_procesando = false;
		}
	}

	private void SpawnSodaLocal(int photonID)
	{
		//IL_0030: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)lataPrefab) || !Object.op_Implicit((Object)(object)puntoDeSpawn))
		{
			return;
		}
		GameObject val = Object.Instantiate<GameObject>(lataPrefab, puntoDeSpawn.position, puntoDeSpawn.rotation);
		if (photonID != -1)
		{
			PhotonView component = val.GetComponent<PhotonView>();
			if ((Object)(object)component != (Object)null)
			{
				component.ViewID = photonID;
				PhotonNetwork.RegisterPhotonView(component);
				component.OwnershipTransfer = (OwnershipOption)1;
			}
		}
		else
		{
			PhotonView component2 = val.GetComponent<PhotonView>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
		}
		val.SetActive(true);
		if (Object.op_Implicit((Object)(object)sonidoComprar))
		{
			_audio.PlayOneShot(sonidoComprar);
		}
	}
}
public enum SodaType
{
	SpeedCola,
	Juggernog,
	DoubleTap,
	QuickRevive
}
public class R_PerkSoda : MonoBehaviourPun
{
	[CompilerGenerated]
	private sealed class <RutinaBeber>d__22 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public bool soyYo;

		public int idDelBebedor;

		public R_PerkSoda <>4__this;

		private Rigidbody <rb>5__1;

		private GameObject <fantasma>5__2;

		private R_PerkGhost <scriptFantasma>5__3;

		private Collider[] <>s__4;

		private int <>s__5;

		private Collider <c>5__6;

		private Camera <mainCam>5__7;

		private Vector3 <startPos>5__8;

		private Quaternion <startRot>5__9;

		private Quaternion <finalRot>5__10;

		private float <timer>5__11;

		private float <p>5__12;

		private float <smooth>5__13;

		private Renderer[] <>s__14;

		private int <>s__15;

		private Renderer <r>5__16;

		private Renderer[] <>s__17;

		private int <>s__18;

		private Renderer <r>5__19;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<rb>5__1 = null;
			<fantasma>5__2 = null;
			<scriptFantasma>5__3 = null;
			<>s__4 = null;
			<c>5__6 = null;
			<mainCam>5__7 = null;
			<>s__14 = null;
			<r>5__16 = null;
			<>s__17 = null;
			<r>5__19 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Expected O, but got Unknown
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if ((Object)(object)<>4__this._physGrabObjectCache != (Object)null)
				{
					((Behaviour)(MonoBehaviour)<>4__this._physGrabObjectCache).enabled = false;
				}
				<rb>5__1 = ((Component)<>4__this).GetComponent<Rigidbody>();
				if (Object.op_Implicit((Object)(object)<rb>5__1))
				{
					<rb>5__1.velocity = Vector3.zero;
					<rb>5__1.isKinematic = true;
				}
				<>s__4 = ((Component)<>4__this).GetComponentsInChildren<Collider>();
				for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++)
				{
					<c>5__6 = <>s__4[<>s__5];
					<c>5__6.enabled = false;
					<c>5__6 = null;
				}
				<>s__4 = null;
				if (soyYo)
				{
					<mainCam>5__7 = Camera.main;
					if ((Object)(object)<mainCam>5__7 != (Object)null)
					{
						((Component)<>4__this).transform.SetParent(((Component)<mainCam>5__7).transform);
					}
					if (Object.op_Implicit((Object)(object)<>4__this.sonidoBeber) && Object.op_Implicit((Object)(object)<mainCam>5__7))
					{
						AudioSource.PlayClipAtPoint(<>4__this.sonidoBeber, ((Component)<mainCam>5__7).transform.position);
					}
					<startPos>5__8 = ((Component)<>4__this).transform.localPosition;
					<startRot>5__9 = ((Component)<>4__this).transform.localRotation;
					<finalRot>5__10 = Quaternion.Euler(<>4__this.rotacionBoca);
					<timer>5__11 = 0f;
					goto IL_02ab;
				}
				<>s__14 = ((Component)<>4__this).GetComponentsInChildren<Renderer>();
				for (<>s__15 = 0; <>s__15 < <>s__14.Length; <>s__15++)
				{
					<r>5__16 = <>s__14[<>s__15];
					<r>5__16.enabled = false;
					<r>5__16 = null;
				}
				<>s__14 = null;
				<>2__current = (object)new WaitForSeconds(<>4__this.tiempoBeber);
				<>1__state = 2;
				return true;
			case 1:
				<>1__state = -1;
				goto IL_02ab;
			case 2:
				<>1__state = -1;
				goto IL_0363;
			case 3:
				{
					<>1__state = -1;
					if (PhotonNetwork.IsConnected)
					{
						if (PhotonNetwork.IsMasterClient && (Object)(object)((MonoBehaviourPun)<>4__this).photonView != (Object)null)
						{
							PhotonNetwork.Destroy(((Component)<>4__this).gameObject);
						}
					}
					else
					{
						Object.Destroy((Object)(object)((Component)<>4__this).gameObject);
					}
					return false;
				}
				IL_0363:
				<fantasma>5__2 = new GameObject($"GHOST_{<>4__this.tipoDeSoda}_{Time.time}");
				<scriptFantasma>5__3 = <fantasma>5__2.AddComponent<R_PerkGhost>();
				<scriptFantasma>5__3.Setup(<>4__this, idDelBebedor, soyYo);
				<scriptFantasma>5__3.Activar();
				<>s__17 = ((Component)<>4__this).GetComponentsInChildren<Renderer>();
				for (<>s__18 = 0; <>s__18 < <>s__17.Length; <>s__18++)
				{
					<r>5__19 = <>s__17[<>s__18];
					<r>5__19.enabled = false;
					<r>5__19 = null;
				}
				<>s__17 = null;
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 3;
				return true;
				IL_02ab:
				if (<timer>5__11 < <>4__this.tiempoBeber)
				{
					<p>5__12 = <timer>5__11 / <>4__this.tiempoBeber;
					<smooth>5__13 = <p>5__12 * <p>5__12 * (3f - 2f * <p>5__12);
					((Component)<>4__this).transform.localPosition = Vector3.Lerp(<startPos>5__8, <>4__this.posicionBoca, <smooth>5__13);
					((Component)<>4__this).transform.localRotation = Quaternion.Lerp(<startRot>5__9, <finalRot>5__10, <smooth>5__13);
					<timer>5__11 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<mainCam>5__7 = null;
				goto IL_0363;
			}
		}

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

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

	[Header("--- DATOS ---")]
	public SodaType tipoDeSoda;

	public Texture2D iconoPerk;

	public float duracionEfecto = 30f;

	public float tiempoBeber = 1.3f;

	public Vector3 posicionBoca = new Vector3(0f, -0.2f, 0.4f);

	public Vector3 rotacionBoca = new Vector3(-45f, 0f, 0f);

	[Header("--- EFECTOS ---")]
	public float speedMultiplier = 1.5f;

	public bool energiaInfinita = true;

	public int vidaModoTanque = 500;

	public float fuerzaExtra = 50f;

	public float rangoExtra = 5f;

	public int vidaBuffer = 5000;

	public bool ocultarVidaExtraEnHUD = true;

	[Header("--- AUDIO ---")]
	public AudioClip sonidoBeber;

	public AudioClip sonidoEructo;

	public AudioClip sonidoSalvacion;

	private bool _bebiendo = false;

	private Component _physGrabObjectCache;

	private void Start()
	{
		_physGrabObjectCache = ((Component)this).GetComponent("PhysGrabObject");
	}

	private bool AmIHoldingThis()
	{
		//IL_0118: 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)
		if (!PhotonNetwork.IsConnected)
		{
			return true;
		}
		if ((Object)(object)_physGrabObjectCache != (Object)null)
		{
			try
			{
				FieldInfo field = ((object)_physGrabObjectCache).GetType().GetField("playerGrabbing");
				if (field != null && field.GetValue(_physGrabObjectCache) is IList list && list.Count > 0)
				{
					object obj = list[0];
					object? value = obj.GetType().GetProperty("photonView").GetValue(obj, null);
					PhotonView val = (PhotonView)((value is PhotonView) ? value : null);
					if ((Object)(object)val != (Object)null && val.IsMine)
					{
						return true;
					}
					MonoBehaviour val2 = (MonoBehaviour)((obj is MonoBehaviour) ? obj : null);
					if ((Object)(object)val2 != (Object)null && ((Component)val2).GetComponentInParent<PhotonView>().IsMine)
					{
						return true;
					}
					return false;
				}
			}
			catch
			{
			}
		}
		if ((Object)(object)Camera.main != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)Camera.main).transform.position) > 1.5f)
		{
			return false;
		}
		return true;
	}

	public void DrinkMe()
	{
		if (!_bebiendo && AmIHoldingThis())
		{
			_bebiendo = true;
			int num = (PhotonNetwork.IsConnected ? PhotonNetwork.LocalPlayer.ActorNumber : (-1));
			if (PhotonNetwork.IsConnected)
			{
				((MonoBehaviourPun)this).photonView.RPC("EjecutarBebidaGlobalRPC", (RpcTarget)0, new object[1] { num });
			}
			else
			{
				EjecutarBebidaGlobalRPC(-1);
			}
		}
	}

	[PunRPC]
	public void EjecutarBebidaGlobalRPC(int idDelBebedor)
	{
		_bebiendo = true;
		bool soyYo = !PhotonNetwork.IsConnected || PhotonNetwork.LocalPlayer.ActorNumber == idDelBebedor;
		((MonoBehaviour)this).StartCoroutine(RutinaBeber(soyYo, idDelBebedor));
	}

	[IteratorStateMachine(typeof(<RutinaBeber>d__22))]
	private IEnumerator RutinaBeber(bool soyYo, int idDelBebedor)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RutinaBeber>d__22(0)
		{
			<>4__this = this,
			soyYo = soyYo,
			idDelBebedor = idDelBebedor
		};
	}
}
public class R_PerkGhost : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <RutinaEfecto>d__27 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public R_PerkGhost <>4__this;

		private int <pid>5__1;

		private PlayerController <pc>5__2;

		private PlayerHealth <hp>5__3;

		private MonoBehaviour <grabber>5__4;

		private PlayerHealth <hp>5__5;

		private int <total>5__6;

		private bool <salvado>5__7;

		private int <actual>5__8;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<pc>5__2 = null;
			<hp>5__3 = null;
			<grabber>5__4 = null;
			<hp>5__5 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a97: Expected O, but got Unknown
			//IL_0a59: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a74: Expected O, but got Unknown
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Expected O, but got Unknown
			//IL_07a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b3: Expected O, but got Unknown
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if (<>4__this.isLocalPlayer && Object.op_Implicit((Object)(object)Camera.main) && Object.op_Implicit((Object)(object)<>4__this.sEructo))
				{
					AudioSource.PlayClipAtPoint(<>4__this.sEructo, ((Component)Camera.main).transform.position);
				}
				<pid>5__1 = <>4__this.targetPlayerID;
				if (!speedStacks.ContainsKey(<pid>5__1))
				{
					speedStacks[<pid>5__1] = 0;
					originalSpeeds[<pid>5__1] = -1f;
					originalDrains[<pid>5__1] = -1f;
				}
				if (!juggStacks.ContainsKey(<pid>5__1))
				{
					juggStacks[<pid>5__1] = 0;
					originalMaxHPs[<pid>5__1] = -1;
				}
				if (!tapStacks.ContainsKey(<pid>5__1))
				{
					tapStacks[<pid>5__1] = 0;
					originalStrs[<pid>5__1] = -1f;
					originalRanges[<pid>5__1] = -1f;
				}
				if (<>4__this.tipo == SodaType.SpeedCola)
				{
					<pc>5__2 = <>4__this.FindPlayerComponent<PlayerController>(<pid>5__1, <>4__this.isLocalPlayer, "");
					if (Object.op_Implicit((Object)(object)<pc>5__2))
					{
						if (speedStacks[<pid>5__1] == 0)
						{
							originalSpeeds[<pid>5__1] = <pc>5__2.SprintSpeed;
							originalDrains[<pid>5__1] = <pc>5__2.EnergySprintDrain;
						}
						speedStacks[<pid>5__1]++;
						<pc>5__2.SprintSpeed = originalSpeeds[<pid>5__1] * <>4__this.v1;
						if (<>4__this.vBool)
						{
							<pc>5__2.EnergySprintDrain = 0f;
						}
						<>2__current = (object)new WaitForSeconds(<>4__this.duracion);
						<>1__state = 1;
						return true;
					}
					goto IL_03d4;
				}
				if (<>4__this.tipo == SodaType.Juggernog)
				{
					<hp>5__3 = <>4__this.FindPlayerComponent<PlayerHealth>(<pid>5__1, <>4__this.isLocalPlayer, "");
					if (Object.op_Implicit((Object)(object)<hp>5__3))
					{
						if (juggStacks[<pid>5__1] == 0)
						{
							originalMaxHPs[<pid>5__1] = <>4__this.GetField<int>(<hp>5__3, "maxHealth");
						}
						juggStacks[<pid>5__1]++;
						<>4__this.SetField(<hp>5__3, "maxHealth", <>4__this.vInt);
						if (<>4__this.GetField<int>(<hp>5__3, "health") < <>4__this.vInt)
						{
							<>4__this.SetField(<hp>5__3, "health", <>4__this.vInt);
						}
						<>2__current = (object)new WaitForSeconds(<>4__this.duracion);
						<>1__state = 2;
						return true;
					}
					goto IL_0640;
				}
				if (<>4__this.tipo == SodaType.DoubleTap)
				{
					<grabber>5__4 = <>4__this.FindPlayerComponent<MonoBehaviour>(<pid>5__1, <>4__this.isLocalPlayer, "PhysGrabber");
					if (Object.op_Implicit((Object)(object)<grabber>5__4))
					{
						if (tapStacks[<pid>5__1] == 0)
						{
							originalStrs[<pid>5__1] = <>4__this.GetField<float>(<grabber>5__4, "grabStrength");
							originalRanges[<pid>5__1] = <>4__this.GetField<float>(<grabber>5__4, "grabRange");
						}
						tapStacks[<pid>5__1]++;
						<>4__this.SetField(<grabber>5__4, "grabStrength", originalStrs[<pid>5__1] + <>4__this.v1);
						<>4__this.SetField(<grabber>5__4, "grabRange", originalRanges[<pid>5__1] + <>4__this.v2);
						<>2__current = (object)new WaitForSeconds(<>4__this.duracion);
						<>1__state = 3;
						return true;
					}
					goto IL_08de;
				}
				if (<>4__this.tipo != SodaType.QuickRevive)
				{
					break;
				}
				<hp>5__5 = <>4__this.FindPlayerComponent<PlayerHealth>(<pid>5__1, <>4__this.isLocalPlayer, "");
				if (Object.op_Implicit((Object)(object)<hp>5__5))
				{
					<>4__this.vidaOriginalLocal = <>4__this.GetField<int>(<hp>5__5, "maxHealth");
					<total>5__6 = <>4__this.vidaOriginalLocal + <>4__this.vInt;
					<>4__this.SetField(<hp>5__5, "maxHealth", <total>5__6);
					<>4__this.SetField(<hp>5__5, "health", <total>5__6);
					<salvado>5__7 = false;
					goto IL_0ac7;
				}
				goto IL_0b49;
			case 1:
				<>1__state = -1;
				speedStacks[<pid>5__1]--;
				if (speedStacks[<pid>5__1] <= 0)
				{
					speedStacks[<pid>5__1] = 0;
					if (originalSpeeds[<pid>5__1] != -1f)
					{
						<pc>5__2.SprintSpeed = originalSpeeds[<pid>5__1];
					}
					if (originalDrains[<pid>5__1] != -1f)
					{
						<pc>5__2.EnergySprintDrain = originalDrains[<pid>5__1];
					}
					originalSpeeds[<pid>5__1] = -1f;
					originalDrains[<pid>5__1] = -1f;
				}
				goto IL_03d4;
			case 2:
				<>1__state = -1;
				juggStacks[<pid>5__1]--;
				if (juggStacks[<pid>5__1] <= 0)
				{
					juggStacks[<pid>5__1] = 0;
					if (originalMaxHPs[<pid>5__1] != -1)
					{
						<>4__this.SetField(<hp>5__3, "maxHealth", originalMaxHPs[<pid>5__1]);
					}
					if (<>4__this.GetField<int>(<hp>5__3, "health") > originalMaxHPs[<pid>5__1])
					{
						<>4__this.SetField(<hp>5__3, "health", originalMaxHPs[<pid>5__1]);
					}
					originalMaxHPs[<pid>5__1] = -1;
				}
				goto IL_0640;
			case 3:
				<>1__state = -1;
				tapStacks[<pid>5__1]--;
				if (tapStacks[<pid>5__1] <= 0)
				{
					tapStacks[<pid>5__1] = 0;
					if (originalStrs[<pid>5__1] != -1f)
					{
						<>4__this.SetField(<grabber>5__4, "grabStrength", originalStrs[<pid>5__1]);
					}
					if (originalRanges[<pid>5__1] != -1f)
					{
						<>4__this.SetField(<grabber>5__4, "grabRange", originalRanges[<pid>5__1]);
					}
					originalStrs[<pid>5__1] = -1f;
					originalRanges[<pid>5__1] = -1f;
				}
				goto IL_08de;
			case 4:
				<>1__state = -1;
				goto IL_0aa7;
			case 5:
				<>1__state = -1;
				goto IL_0aa7;
			case 6:
				{
					<>1__state = -1;
					goto IL_0ac7;
				}
				IL_0aa7:
				<salvado>5__7 = true;
				goto IL_0aaf;
				IL_03d4:
				<pc>5__2 = null;
				break;
				IL_0640:
				<hp>5__3 = null;
				break;
				IL_0aaf:
				<>2__current = null;
				<>1__state = 6;
				return true;
				IL_0ac7:
				if (!<salvado>5__7 && (Object)(object)<hp>5__5 != (Object)null)
				{
					<actual>5__8 = <>4__this.GetField<int>(<hp>5__5, "health");
					if (<total>5__6 - <actual>5__8 >= <>4__this.vidaOriginalLocal)
					{
						if (<>4__this.isLocalPlayer && Object.op_Implicit((Object)(object)<>4__this.sSalvacion) && Object.op_Implicit((Object)(object)Camera.main))
						{
							AudioSource.PlayClipAtPoint(<>4__this.sSalvacion, ((Component)Camera.main).transform.position);
							<>2__current = (object)new WaitForSeconds(2f);
							<>1__state = 4;
							return true;
						}
						<>2__current = (object)new WaitForSeconds(0.5f);
						<>1__state = 5;
						return true;
					}
					goto IL_0aaf;
				}
				if (Object.op_Implicit((Object)(object)<hp>5__5))
				{
					<>4__this.SetField(<hp>5__5, "maxHealth", <>4__this.vidaOriginalLocal);
					<>4__this.SetField(<hp>5__5, "health", <>4__this.vidaOriginalLocal);
				}
				goto IL_0b49;
				IL_0b49:
				<hp>5__5 = null;
				break;
				IL_08de:
				<grabber>5__4 = null;
				break;
			}
			Object.Destroy((Object)(object)((Component)<>4__this).gameObject);
			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();
		}
	}

	private static Dictionary<int, int> speedStacks = new Dictionary<int, int>();

	private static Dictionary<int, float> originalSpeeds = new Dictionary<int, float>();

	private static Dictionary<int, float> originalDrains = new Dictionary<int, float>();

	private static Dictionary<int, int> juggStacks = new Dictionary<int, int>();

	private static Dictionary<int, int> originalMaxHPs = new Dictionary<int, int>();

	private static Dictionary<int, int> tapStacks = new Dictionary<int, int>();

	private static Dictionary<int, float> originalStrs = new Dictionary<int, float>();

	private static Dictionary<int, float> originalRanges = new Dictionary<int, float>();

	public SodaType tipo;

	public Texture2D icono;

	public float duracion;

	public float v1;

	public float v2;

	public int vInt;

	public bool vBool;

	public AudioClip sEructo;

	public AudioClip sSalvacion;

	private int vidaOriginalLocal = 100;

	public int targetPlayerID = -1;

	public bool isLocalPlayer = false;

	public static void ResetStatics()
	{
		speedStacks.Clear();
		originalSpeeds.Clear();
		originalDrains.Clear();
		juggStacks.Clear();
		originalMaxHPs.Clear();
		tapStacks.Clear();
		originalStrs.Clear();
		originalRanges.Clear();
	}

	public void Setup(R_PerkSoda origen, int playerID, bool isLocal)
	{
		tipo = origen.tipoDeSoda;
		icono = origen.iconoPerk;
		duracion = origen.duracionEfecto;
		sEructo = origen.sonidoEructo;
		sSalvacion = origen.sonidoSalvacion;
		if (tipo == SodaType.SpeedCola)
		{
			v1 = origen.speedMultiplier;
			vBool = origen.energiaInfinita;
		}
		if (tipo == SodaType.Juggernog)
		{
			vInt = origen.vidaModoTanque;
		}
		if (tipo == SodaType.DoubleTap)
		{
			v1 = origen.fuerzaExtra;
			v2 = origen.rangoExtra;
		}
		if (tipo == SodaType.QuickRevive)
		{
			vInt = origen.vidaBuffer;
		}
		targetPlayerID = playerID;
		isLocalPlayer = isLocal;
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
	}

	public void Activar()
	{
		((MonoBehaviour)this).StartCoroutine(RutinaEfecto());
	}

	private void OnGUI()
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		if (isLocalPlayer && (Object)(object)icono != (Object)null)
		{
			int num = (int)tipo;
			float num2 = 20f + (float)num * 74f;
			GUI.DrawTexture(new Rect(num2, (float)Screen.height - 84f, 64f, 64f), (Texture)(object)icono);
		}
	}

	private void LateUpdate()
	{
		if (!isLocalPlayer || tipo != SodaType.QuickRevive)
		{
			return;
		}
		MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>();
		foreach (MonoBehaviour val in array)
		{
			if (!((Object)(object)val == (Object)null))
			{
				string name = ((object)val).GetType().Name;
				if (name.Contains("Text") || name.Contains("TMP"))
				{
					FixUI(val);
				}
			}
		}
	}

	private void FixUI(object txt)
	{
		try
		{
			PropertyInfo property = txt.GetType().GetProperty("text");
			if (property == null)
			{
				return;
			}
			string text = (string)property.GetValue(txt, null);
			string text2 = text;
			int num = vidaOriginalLocal + vInt;
			if (text.Contains(num.ToString()))
			{
				text = text.Replace(num.ToString(), vidaOriginalLocal.ToString());
			}
			MatchCollection matchCollection = Regex.Matches(text, "\\d+");
			foreach (Match item in matchCollection)
			{
				if (int.TryParse(item.Value, out var result) && result > vidaOriginalLocal + vInt / 2 && result <= num)
				{
					int num2 = result - vInt;
					if (num2 < 0)
					{
						num2 = 0;
					}
					text = new Regex("\\b" + item.Value + "\\b").Replace(text, num2.ToString(), 1);
				}
			}
			if (text2 != text)
			{
				property.SetValue(txt, text, null);
			}
		}
		catch
		{
		}
	}

	private T FindPlayerComponent<T>(int targetID, bool isLocal, string className = "") where T : MonoBehaviour
	{
		T[] array = Object.FindObjectsOfType<T>();
		foreach (T val in array)
		{
			if (!string.IsNullOrEmpty(className) && !((object)val).GetType().Name.Contains(className))
			{
				continue;
			}
			PhotonView val2 = ((Component)(object)val).GetComponent<PhotonView>();
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = ((Component)(object)val).GetComponentInParent<PhotonView>();
			}
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = ((Component)((Component)(object)val).transform.root).GetComponentInChildren<PhotonView>();
			}
			if (PhotonNetwork.IsConnected)
			{
				if (!((Object)(object)val2 != (Object)null))
				{
					continue;
				}
				if (isLocal && val2.IsMine)
				{
					return val;
				}
				if (isLocal)
				{
					continue;
				}
				if (val2.OwnerActorNr == targetID)
				{
					return val;
				}
				try
				{
					PropertyInfo property = ((object)val2).GetType().GetProperty("ControllerActorNr");
					if (property != null && (int)property.GetValue(val2, null) == targetID)
					{
						return val;
					}
				}
				catch
				{
				}
				try
				{
					PropertyInfo property2 = ((object)val2).GetType().GetProperty("CreatorActorNr");
					if (property2 != null && (int)property2.GetValue(val2, null) == targetID)
					{
						return val;
					}
				}
				catch
				{
				}
				continue;
			}
			return val;
		}
		return default(T);
	}

	[IteratorStateMachine(typeof(<RutinaEfecto>d__27))]
	private IEnumerator RutinaEfecto()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RutinaEfecto>d__27(0)
		{
			<>4__this = this
		};
	}

	private void SetField(object t, string n, object v)
	{
		FieldInfo field = t.GetType().GetField(n, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (field != null)
		{
			field.SetValue(t, v);
		}
	}

	private T GetField<T>(object t, string n)
	{
		FieldInfo field = t.GetType().GetField(n, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		return (field != null) ? ((T)field.GetValue(t)) : default(T);
	}
}