Decompiled source of FixAcridYump v1.2.1

AcridYump.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using EntityStates;
using EntityStates.Croco;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using On.EntityStates.Croco;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KriperIVI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AcridYump")]
[assembly: AssemblyTitle("AcridYump")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 AcridYump
{
	[BepInPlugin("Kriper1111.AcridYump", "AcridYump", "1.2.1")]
	public class AcridYump : BaseUnityPlugin
	{
		public const string PluginGUID = "Kriper1111.AcridYump";

		public const string PluginAuthor = "Kriper1111";

		public const string PluginName = "AcridYump";

		public const string PluginVersion = "1.2.1";

		private readonly Dictionary<int, BaseLeapMixin> _mixins = new Dictionary<int, BaseLeapMixin>();

		public void Awake()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			BaseLeap.OnEnter += new hook_OnEnter(BaseLeapOnOnEnter);
			BaseLeap.OnExit += new hook_OnExit(BaseLeapOnOnExit);
		}

		private void BaseLeapOnOnEnter(orig_OnEnter orig, BaseLeap self)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			orig.Invoke(self);
			int instanceID = ((Object)((EntityState)self).gameObject).GetInstanceID();
			if (((EntityState)self).isAuthority && !_mixins.ContainsKey(instanceID))
			{
				BaseLeapMixin baseLeapMixin = new BaseLeapMixin(self);
				((EntityState)self).characterMotor.onMovementHit += new MovementHitDelegate(baseLeapMixin.OnMovementHit);
				_mixins[instanceID] = baseLeapMixin;
			}
		}

		private void BaseLeapOnOnExit(orig_OnExit orig, BaseLeap self)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			int instanceID = ((Object)((EntityState)self).gameObject).GetInstanceID();
			if (((EntityState)self).isAuthority && _mixins.ContainsKey(instanceID))
			{
				BaseLeapMixin baseLeapMixin = _mixins[instanceID];
				((EntityState)self).characterMotor.onMovementHit -= new MovementHitDelegate(baseLeapMixin.OnMovementHit);
				_mixins.Remove(instanceID);
			}
			orig.Invoke(self);
		}

		public void OnDestroy()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			BaseLeap.OnEnter -= new hook_OnEnter(BaseLeapOnOnEnter);
			BaseLeap.OnExit -= new hook_OnExit(BaseLeapOnOnExit);
		}
	}
	public class BaseLeapMixin
	{
		private readonly BaseLeap _self;

		private bool _isDangerous;

		public BaseLeapMixin(BaseLeap other)
		{
			_self = other;
			_isDangerous = false;
		}

		public void OnMovementHit(ref MovementHitInfo info)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (((EntityState)_self).isAuthority && !_isDangerous)
			{
				_isDangerous |= IsFallDamageDangerous(((EntityState)_self).characterBody, info);
				if (!_isDangerous)
				{
					_self.detonateNextFrame = true;
				}
			}
		}

		private static bool IsFallDamageDangerous(CharacterBody body, MovementHitInfo info)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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)
			if (!(info.velocity.y < 0f))
			{
				return false;
			}
			float num = Mathf.Abs(info.velocity.y);
			if (!(Mathf.Max(num - (body.jumpPower + 20f), 0f) > 0f))
			{
				return false;
			}
			KinematicCharacterMotor motor = ((BaseCharacterController)body.characterMotor).Motor;
			float magnitude = ((Vector3)(ref info.velocity)).magnitude;
			RaycastHit val = default(RaycastHit);
			if (info.hitCollider.Raycast(new Ray(body.footPosition, Vector3.down), ref val, magnitude))
			{
				return Vector3.Angle(motor._characterUp, ((RaycastHit)(ref val)).normal) <= motor.MaxStableSlopeAngle;
			}
			return true;
		}
	}
}