Decompiled source of LimpaDrop v1.0.0

LimpaDrop.dll

Decompiled an hour ago
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace LimpaDrop;

[BepInPlugin("yuri.LimpaDrop", "Limpa Drop", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private ConfigEntry<bool> Ligado;

	private ConfigEntry<KeyboardShortcut> Tecla;

	private ConfigEntry<float> Raio;

	private void Awake()
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		Ligado = ((BaseUnityPlugin)this).Config.Bind<bool>("Geral", "Ligado", true, "Apaga o drop no chao perto de voce. So no seu jogo.");
		Tecla = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Geral", "Tecla", new KeyboardShortcut((KeyCode)290, (KeyCode[])(object)new KeyCode[0]), "Tecla que limpa o drop perto.");
		Raio = ((BaseUnityPlugin)this).Config.Bind<float>("Geral", "Raio", 12f, "Distancia em metros. De 3 a 40.");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Limpa Drop 1.0.0");
	}

	private void Update()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		if (!Ligado.Value)
		{
			return;
		}
		KeyboardShortcut value = Tecla.Value;
		if (((KeyboardShortcut)(ref value)).IsDown())
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead() && PodeAgir(localPlayer))
			{
				Limpar(localPlayer);
			}
		}
	}

	private void Limpar(Player jogador)
	{
		//IL_0045: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		float num = Raio.Value;
		if (num < 3f)
		{
			num = 3f;
		}
		if (num > 40f)
		{
			num = 40f;
		}
		float num2 = num * num;
		Vector3 position = ((Component)jogador).transform.position;
		ItemDrop[] array = Object.FindObjectsOfType<ItemDrop>();
		int num3 = 0;
		if (array != null)
		{
			foreach (ItemDrop val in array)
			{
				if (!((Object)(object)val == (Object)null) && !val.IsPiece() && !EhProtegido((Component)(object)val))
				{
					Vector3 val2 = ((Component)val).transform.position - position;
					if (!(((Vector3)(ref val2)).sqrMagnitude > num2) && Apagar(((Component)val).gameObject))
					{
						num3++;
					}
				}
			}
		}
		if (num3 == 0)
		{
			((Character)jogador).Message((MessageType)2, "Nao tem drop perto.", 0, (Sprite)null, true);
		}
		else
		{
			((Character)jogador).Message((MessageType)2, "Drop perto limpo. " + num3 + ".", 0, (Sprite)null, true);
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Drop limpo " + num3));
	}

	private static bool PodeAgir(Player jogador)
	{
		MethodInfo method = typeof(Player).GetMethod("TakeInput", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (method == null)
		{
			return true;
		}
		object obj = method.Invoke(jogador, null);
		return obj is bool && (bool)obj;
	}

	private static bool EhProtegido(Component coisa)
	{
		if ((Object)(object)coisa == (Object)null)
		{
			return true;
		}
		if ((Object)(object)coisa.GetComponentInParent<TombStone>() != (Object)null)
		{
			return true;
		}
		if ((Object)(object)coisa.GetComponentInParent<ItemStand>() != (Object)null)
		{
			return true;
		}
		if ((Object)(object)coisa.GetComponentInParent<ArmorStand>() != (Object)null)
		{
			return true;
		}
		Transform val = coisa.transform;
		while ((Object)(object)val != (Object)null)
		{
			string name = ((Object)val).name;
			if (name != null && name.ToLower().IndexOf("tomb") >= 0)
			{
				return true;
			}
			val = val.parent;
		}
		return false;
	}

	private static bool Apagar(GameObject go)
	{
		if ((Object)(object)go == (Object)null)
		{
			return false;
		}
		ZNetView component = go.GetComponent<ZNetView>();
		if ((Object)(object)component != (Object)null && component.IsValid())
		{
			if (!component.IsOwner())
			{
				component.ClaimOwnership();
			}
			component.Destroy();
			return true;
		}
		Object.Destroy((Object)(object)go);
		return true;
	}
}