Decompiled source of SpamKeyMod v1.0.0

SpamKeyMod.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SpamKeyMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SpamKeyMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f72eb7b3-46b0-4e28-8909-055df9d8afca")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SpamKeyMod;

[BepInPlugin("Shinsu.spamkeymod", "Spam Key Mod", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class SpamKeyModPlugin : BaseUnityPlugin
{
	private class ActionPulse
	{
		private float timer;

		public void Tick(float dt)
		{
			timer += dt;
		}

		public void Reset()
		{
			timer = 0f;
		}

		public bool ConsumeTick(float interval)
		{
			if (timer >= interval)
			{
				timer = 0f;
				return true;
			}
			return false;
		}
	}

	public const string PluginGUID = "Shinsu.spamkeymod";

	public const string PluginName = "Spam Key Mod";

	public const string PluginVersion = "1.0.0";

	public static ManualLogSource Log;

	public static ConfigEntry<KeyCode> TriggerKey;

	public static ConfigEntry<float> Interval;

	public static ConfigEntry<bool> ShowIndicator;

	public static ConfigEntry<bool> DoAttack;

	public static ConfigEntry<bool> DoBlock;

	public static ConfigEntry<bool> DoJump;

	public static ConfigEntry<bool> DoUse;

	public static ConfigEntry<bool> DoForward;

	public static ConfigEntry<bool> BlockHoldOverride;

	public static bool SpamActive;

	private static readonly ActionPulse AttackPulse = new ActionPulse();

	private static readonly ActionPulse BlockPulse = new ActionPulse();

	private static readonly ActionPulse JumpPulse = new ActionPulse();

	private static readonly ActionPulse UsePulse = new ActionPulse();

	private static FieldInfo hoveringField;

	private static MethodInfo interactMethod;

	private void Awake()
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		TriggerKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("1. Кнопка", "Триггер-клавиша", (KeyCode)326, "Клавиша, которая включает/выключает спам выбранных действий. По умолчанию — боковая кнопка мыши \"назад\" (Mouse3).");
		Interval = ((BaseUnityPlugin)this).Config.Bind<float>("1. Кнопка", "Интервал спама (сек)", 0.1f, new ConfigDescription("Пауза между повторами действия", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.02f, 2f), Array.Empty<object>()));
		ShowIndicator = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Кнопка", "Показывать индикатор на экране", true, "Отображать надпись в углу экрана, когда спам активен");
		DoAttack = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Действия", "Атака", false, "Спамить атаку");
		DoBlock = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Действия", "Блок", false, "Спамить блок");
		DoJump = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Действия", "Прыжок", false, "Спамить прыжок");
		DoUse = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Действия", "Взаимодействовать", true, "Спамить взаимодействие. Сработает только если в прицеле есть интерактивный объект (дверь, сундук, NPC и т.п.) — это требование самой игры.");
		DoForward = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Действия", "Вперёд", false, "Удерживать движение вперёд");
		BlockHoldOverride = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Удержание", "Удерживать блок (а не спамить)", false, "По умолчанию блок спамится так же, как другие действия. Если включить — блок будет сплошным удержанием, пока активен триггер.");
		hoveringField = typeof(Player).GetField("m_hovering", BindingFlags.Instance | BindingFlags.NonPublic);
		interactMethod = typeof(Player).GetMethod("Interact", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[3]
		{
			typeof(GameObject),
			typeof(bool),
			typeof(bool)
		}, null);
		if (hoveringField == null || interactMethod == null)
		{
			Log.LogError((object)"[SpamKeyMod] Не найдены ожидаемые члены класса Player — вероятно, версия игры отличается. Функция 'Взаимодействовать' может не работать.");
		}
		Harmony.CreateAndPatchAll(typeof(Player_SetControls_Patch), "Shinsu.spamkeymod");
	}

	private void OnGUI()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		if (ShowIndicator.Value && SpamActive)
		{
			GUIStyle val = new GUIStyle
			{
				fontSize = 20,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)0
			};
			val.normal.textColor = Color.red;
			GUIStyle val2 = new GUIStyle(val);
			val2.normal.textColor = Color.black;
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(20f, 20f, 400f, 40f);
			GUI.Label(new Rect(((Rect)(ref val3)).x + 2f, ((Rect)(ref val3)).y + 2f, ((Rect)(ref val3)).width, ((Rect)(ref val3)).height), "SPAM KEY: Вкл", val2);
			GUI.Label(val3, "SPAM KEY: Вкл", val);
		}
	}

	private void Update()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			SpamActive = false;
			return;
		}
		if (Input.GetKeyDown(TriggerKey.Value))
		{
			SpamActive = !SpamActive;
		}
		if (!SpamActive)
		{
			AttackPulse.Reset();
			BlockPulse.Reset();
			JumpPulse.Reset();
			UsePulse.Reset();
			return;
		}
		float deltaTime = Time.deltaTime;
		AttackPulse.Tick(deltaTime);
		BlockPulse.Tick(deltaTime);
		JumpPulse.Tick(deltaTime);
		if (DoUse.Value)
		{
			UsePulse.Tick(deltaTime);
			if (UsePulse.ConsumeTick(Interval.Value))
			{
				TryInteract();
			}
		}
	}

	private static void TryInteract()
	{
		if (interactMethod == null || hoveringField == null)
		{
			return;
		}
		object? value = hoveringField.GetValue(Player.m_localPlayer);
		GameObject val = (GameObject)((value is GameObject) ? value : null);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		try
		{
			interactMethod.Invoke(Player.m_localPlayer, new object[3] { val, false, false });
		}
		catch (Exception ex)
		{
			Log.LogError((object)("[SpamKeyMod] Ошибка вызова Interact: " + ex.Message));
		}
	}

	private static bool ShouldPulse(ActionPulse pulse)
	{
		return pulse.ConsumeTick(Interval.Value);
	}

	public static bool GetAttackState()
	{
		return ShouldPulse(AttackPulse);
	}

	public static bool GetBlockState()
	{
		if (!BlockHoldOverride.Value)
		{
			return ShouldPulse(BlockPulse);
		}
		return SpamActive;
	}

	public static bool GetJumpState()
	{
		return ShouldPulse(JumpPulse);
	}
}
[HarmonyPatch(typeof(Player), "SetControls")]
public static class Player_SetControls_Patch
{
	private static void Prefix(ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool block, ref bool blockHold, ref bool jump)
	{
		if (SpamKeyModPlugin.SpamActive)
		{
			if (SpamKeyModPlugin.DoForward.Value)
			{
				movedir.z = 1f;
			}
			if (SpamKeyModPlugin.DoAttack.Value)
			{
				bool attackState = SpamKeyModPlugin.GetAttackState();
				attack |= attackState;
				attackHold |= attackState;
			}
			if (SpamKeyModPlugin.DoBlock.Value)
			{
				bool blockState = SpamKeyModPlugin.GetBlockState();
				block |= blockState;
				blockHold |= blockState;
			}
			if (SpamKeyModPlugin.DoJump.Value)
			{
				bool jumpState = SpamKeyModPlugin.GetJumpState();
				jump |= jumpState;
			}
		}
	}
}