Decompiled source of PeakJumpClean v1.0.0

PeakJumpClean.dll

Decompiled 16 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using Peak.Afflictions;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("AERX")]
[assembly: AssemblyCopyright("Copyright (c) 2026 AERX")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 PeakJumpClean
{
	[BepInPlugin("local.peak.jumpclean", "Peak Jump & Clean", "1.0.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		private ConfigEntry<bool> jumpEnabled;

		private ConfigEntry<float> jumpMultiplier;

		private ConfigEntry<bool> showHelp;

		private ConfigEntry<Key> toggleKey;

		private ConfigEntry<Key> clearKey;

		private ConfigEntry<Key> cycleKey;

		private ConfigEntry<Key> helpKey;

		private CharacterMovement movement;

		private float originalImpulse;

		private float appliedImpulse;

		private bool hasApplied;

		private string notice = "";

		private float noticeUntil;

		private Font uiFont;

		private GUIStyle labelStyle;

		private readonly float[] presets = new float[5] { 1f, 1.5f, 2f, 3f, 4f };

		private void Awake()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			jumpEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Jump", "Enabled", false, "Enable enhanced jumping for the local player.");
			jumpMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Jump", "ImpulseMultiplier", 2f, new ConfigDescription("Jump impulse multiplier; actual height depends on game physics.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 4f), Array.Empty<object>()));
			showHelp = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "ShowHelp", true, "Show keyboard shortcuts.");
			toggleKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keys", "ToggleJump", (Key)100, "Toggle enhanced jumping.");
			clearKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keys", "ClearNegativeStatuses", (Key)101, "Clear current negative statuses once.");
			cycleKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keys", "CycleJumpMultiplier", (Key)102, "Cycle jump impulse: 1 / 1.5 / 2 / 3 / 4.");
			helpKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keys", "ToggleHelp", (Key)99, "Show/hide shortcut help.");
			uiFont = Font.CreateDynamicFontFromOSFont(new string[3] { "Microsoft YaHei", "SimHei", "Arial" }, 17);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Peak Jump & Clean 1.0.0 loaded. F7 jump, F8 cleanse, F9 multiplier, F6 help.");
		}

		private bool Pressed(Keyboard keyboard, Key key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if ((int)key != 0 && keyboard[key] != null)
			{
				return ((ButtonControl)keyboard[key]).wasPressedThisFrame;
			}
			return false;
		}

		private void Update()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			Character localCharacter = Character.localCharacter;
			CharacterMovement val = (((Object)(object)localCharacter != (Object)null && localCharacter.IsLocal && localCharacter.refs != null) ? localCharacter.refs.movement : null);
			if ((Object)(object)val != (Object)(object)movement)
			{
				RestoreJump();
				movement = val;
				if ((Object)(object)movement != (Object)null)
				{
					originalImpulse = movement.jumpImpulse;
				}
			}
			Keyboard current = Keyboard.current;
			if (current != null)
			{
				if (Pressed(current, helpKey.Value))
				{
					showHelp.Value = !showHelp.Value;
				}
				if (Pressed(current, toggleKey.Value))
				{
					jumpEnabled.Value = !jumpEnabled.Value;
					Notify(jumpEnabled.Value ? "增强跳跃已开启" : "已恢复正常跳跃");
				}
				if (Pressed(current, cycleKey.Value))
				{
					float value = jumpMultiplier.Value;
					float value2 = presets[0];
					float[] array = presets;
					foreach (float num in array)
					{
						if (num > value + 0.01f)
						{
							value2 = num;
							break;
						}
					}
					jumpMultiplier.Value = value2;
					Notify("跳跃力度倍率:" + value2.ToString("0.0") + "x");
				}
				if (Pressed(current, clearKey.Value))
				{
					ClearNegativeStatuses(localCharacter);
				}
			}
			if ((Object)(object)movement == (Object)null)
			{
				return;
			}
			if (jumpEnabled.Value)
			{
				if (hasApplied && !Mathf.Approximately(movement.jumpImpulse, appliedImpulse))
				{
					originalImpulse = movement.jumpImpulse;
				}
				else if (!hasApplied)
				{
					originalImpulse = movement.jumpImpulse;
				}
				appliedImpulse = originalImpulse * Mathf.Clamp(jumpMultiplier.Value, 1f, 4f);
				movement.jumpImpulse = appliedImpulse;
				hasApplied = true;
			}
			else
			{
				RestoreJump();
			}
		}

		private void ClearNegativeStatuses(Character player)
		{
			if ((Object)(object)player == (Object)null || !player.IsLocal || player.refs == null || (Object)(object)player.refs.afflictions == (Object)null)
			{
				Notify("进入游戏并生成角色后才能清理");
				return;
			}
			try
			{
				CharacterAfflictions afflictions = player.refs.afflictions;
				afflictions.ClearPoisonAfflictions();
				for (int num = afflictions.afflictionList.Count - 1; num >= 0; num--)
				{
					Affliction val = afflictions.afflictionList[num];
					Affliction_AdjustColdOverTime val2 = (Affliction_AdjustColdOverTime)(object)((val is Affliction_AdjustColdOverTime) ? val : null);
					Affliction_AdjustDrowsyOverTime val3 = (Affliction_AdjustDrowsyOverTime)(object)((val is Affliction_AdjustDrowsyOverTime) ? val : null);
					Affliction_AdjustStatusOverTime val4 = (Affliction_AdjustStatusOverTime)(object)((val is Affliction_AdjustStatusOverTime) ? val : null);
					if (val is Affliction_Exhaustion || val is Affliction_PreventPoisonHealing || val is Affliction_Blind || val is Affliction_Numb || (val2 != null && val2.statusPerSecond > 0f) || (val3 != null && val3.statusPerSecond > 0f) || (val4 != null && val4.statusPerSecond > 0f))
					{
						afflictions.RemoveAffliction(val, false, true);
					}
				}
				CharacterAfflictions.ClearAll();
				Notify("负面状态已清理;体力仍正常消耗");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
				Notify("清理未完成,请查看 BepInEx 日志");
			}
		}

		private void RestoreJump()
		{
			if (hasApplied && (Object)(object)movement != (Object)null && Mathf.Approximately(movement.jumpImpulse, appliedImpulse))
			{
				movement.jumpImpulse = originalImpulse;
			}
			hasApplied = false;
		}

		private void Notify(string text)
		{
			notice = text;
			noticeUntil = Time.unscaledTime + 4f;
		}

		private void OnGUI()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_0047: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00f1: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: 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)
			//IL_01c7: 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)
			if (!showHelp.Value && Time.unscaledTime >= noticeUntil)
			{
				return;
			}
			if (labelStyle == null)
			{
				labelStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 17,
					wordWrap = true
				};
				if ((Object)(object)uiFont != (Object)null)
				{
					labelStyle.font = uiFont;
				}
				labelStyle.normal.textColor = Color.white;
			}
			string text = (showHelp.Value ? ("跳跃与状态清理\n" + ((object)toggleKey.Value/*cast due to .constrained prefix*/).ToString() + ":增强跳跃 " + (jumpEnabled.Value ? "开" : "关") + "  |  " + ((object)cycleKey.Value/*cast due to .constrained prefix*/).ToString() + ":倍率 " + jumpMultiplier.Value.ToString("0.0") + "x\n" + ((object)clearKey.Value/*cast due to .constrained prefix*/).ToString() + ":清负面状态  |  " + ((object)helpKey.Value/*cast due to .constrained prefix*/).ToString() + ":隐藏提示\n体力正常消耗;倍率指起跳力度") : "");
			if (Time.unscaledTime < noticeUntil)
			{
				text = text + "\n" + notice;
			}
			GUI.Box(new Rect(16f, 16f, 450f, (float)(showHelp.Value ? 155 : 65)), "");
			GUI.Label(new Rect(28f, 25f, 426f, 140f), text, labelStyle);
		}

		private void OnDisable()
		{
			RestoreJump();
		}

		private void OnDestroy()
		{
			RestoreJump();
			if ((Object)(object)uiFont != (Object)null)
			{
				Object.Destroy((Object)(object)uiFont);
			}
		}
	}
}