Decompiled source of GetBlastedNerd v0.1.1

plugins/GetBlastedNerd/GetBlastedNerd.dll

Decompiled 3 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameplayEntities;
using LLBML.Math;
using LLBML.Networking;
using LLBML.Players;
using LLBML.States;
using LLBML.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("GetBlastedNerd (fr.glomzubuk.plugins.llb.getblastednerd)")]
[assembly: AssemblyProduct("GetBlastedNerd")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
namespace GetBlastedNerd;

[BepInPlugin("fr.glomzubuk.plugins.llb.getblastednerd", "GetBlastedNerd", "0.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class TheMetaCrippler : BaseUnityPlugin
{
	internal static ConfigEntry<KeyCode> getHitKey;

	internal static ConfigEntry<int> defaultDamageAmount;

	internal static ConfigEntry<int> knockDirection;

	internal static ConfigEntry<bool> doEffects;

	internal static ConfigEntry<bool> doDamage;

	public static ManualLogSource Log { get; private set; }

	internal static TheMetaCrippler Instance { get; private set; }

	private void Awake()
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Hello, world!");
		getHitKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keybinds", "GetHitKey", (KeyCode)98, (ConfigDescription)null);
		doEffects = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "DoEffects", true, (ConfigDescription)null);
		doDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "DoDamage", true, (ConfigDescription)null);
		defaultDamageAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Values", "DefaultDamageAmount", 32, new ConfigDescription("The amount of damage done when pressing the key", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 240), new object[0]));
		knockDirection = ((BaseUnityPlugin)this).Config.Bind<int>("Values", "knockDirection", 1, new ConfigDescription("Knock direction options: 1 = Back, 2 = Left, 3 = Right, 4 = Random", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), new object[0]));
	}

	private void Start()
	{
		ModDependenciesUtils.RegisterToModMenu(((BaseUnityPlugin)this).Info, new List<string> { "Knock direction options: 1 = Back, 2 = Left, 3 = Right, 4 = Random" });
	}

	private void Update()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkApi.IsOnline && GameStates.IsInMatch() && Input.GetKeyDown(getHitKey.Value))
		{
			PlayerEntity playerEntity = Player.GetLocalPlayer().playerEntity;
			GetHitByNerd(playerEntity);
		}
	}

	private void GetHitByNerd(PlayerEntity playerEntity)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: 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)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		((AbilityEntity)playerEntity).InterruptAbilities();
		((AnimatableEntity)playerEntity).PlayAnim("getHit", "main");
		((MovableData)((AttackingEntity)playerEntity).attackingData).gravityOff = false;
		((GetHitPlayerEntity)playerEntity).ReleaseHitEntities();
		Floatf val = Floatf.op_Implicit(0);
		Vector2f direction = GetDirection(Vector2f.op_Implicit(((HitableData)playerEntity.playerData).flyDirection));
		if (!DebugSettings.instance.dontLoseHP && doDamage.Value)
		{
			val = GetDamage();
			AttackingData attackingData = ((AttackingEntity)playerEntity).attackingData;
			((HitableData)attackingData).hp = Floatf.op_Implicit(Floatf.op_Implicit(((HitableData)attackingData).hp) - val);
			if (DebugSettings.instance.instaKill)
			{
				AttackingData attackingData2 = ((AttackingEntity)playerEntity).attackingData;
				((HitableData)attackingData2).hp = Floatf.op_Implicit(Floatf.op_Implicit(((HitableData)attackingData2).hp) - Floatf.op_Implicit(9999999));
			}
		}
		if (Floatf.op_Implicit(((HitableData)((AttackingEntity)playerEntity).attackingData).hp) <= Floatf.op_Implicit(0))
		{
			GameCamera.instance.StartShake(Floatf.op_Implicit(Floatf.op_Implicit(0.5m)), Floatf.op_Implicit(Floatf.op_Implicit(0.4m)), Vector2f.op_Implicit(direction));
			if (doEffects.Value)
			{
				((Entity)playerEntity).effectHandler.CreateKillPlayerEffect(((Entity)playerEntity).GetPosition(), Vector2f.op_Implicit(direction), Floatf.op_Implicit(Floatf.op_Implicit(64)));
			}
			((GetHitPlayerEntity)playerEntity).GetKilled(Floatf.op_Implicit(Floatf.op_Implicit(0.5m)), Vector2f.op_Implicit(direction));
			return;
		}
		StartHitstun(playerEntity);
		GameCamera.instance.StartShake(Floatf.op_Implicit(Floatf.op_Implicit(0.2m)), Floatf.op_Implicit(Floatf.op_Implicit(0.4m)), Vector2f.op_Implicit(direction));
		if (Floatf.op_Implicit(((HitableEntity)playerEntity).GetPixelFlySpeed(true)) > Floatf.op_Implicit(100))
		{
			GameCamera.StartWave(((Entity)playerEntity).GetPosition(), false, default(HHBCPNCDNDH));
		}
		if (doEffects.Value)
		{
			((Entity)playerEntity).effectHandler.CreateGetHitEffect(((Entity)playerEntity).GetPosition(), Vector2f.op_Implicit(direction), Floatf.op_Implicit(Floatf.op_Implicit(64)));
		}
		((MovableEntity)playerEntity).PlayGetHitSfx();
	}

	private Floatf GetDirection()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		return Floatf.op_Implicit((decimal)(defaultDamageAmount.Value / World.INSTAKILL_VELOCITY) + 0.0001m);
	}

	private Floatf GetDamage()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		return Floatf.op_Implicit(defaultDamageAmount.Value) / Floatf.op_Implicit(World.INSTAKILL_VELOCITY) + Floatf.op_Implicit(0.0001m);
	}

	private void StartHitstun(PlayerEntity playerEntity)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		if (GetDamage() > Floatf.op_Implicit(0.251m) || defaultDamageAmount.Value > 40 || DebugSettings.instance.alwaysFullKnockback)
		{
			((HitableEntity)playerEntity).StartHitstun(((GetHitPlayerEntity)playerEntity).bigKnockbackDuration, (HitstunState)48);
		}
		else if (defaultDamageAmount.Value > 18)
		{
			((HitableEntity)playerEntity).StartHitstun(((GetHitPlayerEntity)playerEntity).mediumKnockbackDuration, (HitstunState)47);
		}
		else
		{
			((HitableEntity)playerEntity).StartHitstun(((GetHitPlayerEntity)playerEntity).smallKnockbackDuration, (HitstunState)46);
		}
	}

	private Vector2f GetDirection(Vector2f playerFlyDirection)
	{
		//IL_0021: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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)
		switch (knockDirection.Value)
		{
		case 2:
			return Vector2f.left;
		case 3:
			return Vector2f.right;
		case 4:
			if (Random.Range(0, 2) == 0)
			{
				return playerFlyDirection;
			}
			return Floatf.op_Implicit(-1) * playerFlyDirection;
		default:
			return Floatf.op_Implicit(-1) * playerFlyDirection;
		}
	}
}
public static class PluginInfos
{
	public const string PLUGIN_NAME = "GetBlastedNerd";

	public const string PLUGIN_ID = "fr.glomzubuk.plugins.llb.getblastednerd";

	public const string PLUGIN_VERSION = "0.1.1";
}