using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using InControl;
using Landfall.TABS;
using Landfall.TABS_Input;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Parkour")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("Parkour")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
namespace Parkour;
[BepInPlugin("GeeztJeez.Parkour", "Parkour", "1.0.3")]
internal class Loader : BaseUnityPlugin
{
private static ConfigEntry<float> configJumpForce;
private static ConfigEntry<bool> configEnableMod;
public float moveMultiplier = 12000f;
public float dashCooldown = 4f;
private PlayerActions playerActions;
public float dashMultiplier = 1750f;
public float jumpMultiplier = 15000f;
private bool m_toggledPause;
private bool m_toggledSlowmo;
private bool m_toggledSuperSlowmo;
private bool canJump = true;
private bool canDash = true;
private bool wait;
private Unit currentUnit;
private Rigidbody[] cachedRigidbodies;
private GeneralInput cachedInput;
private ParticlePlayer cachedParticles;
private SoundPlayer cachedSound;
private Transform cachedCam;
private void Awake()
{
((MonoBehaviour)this).StartCoroutine(Call());
}
private IEnumerator Call()
{
yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
playerActions = PlayerActions.Instance;
cachedParticles = ServiceLocator.GetService<ParticlePlayer>();
cachedSound = ServiceLocator.GetService<SoundPlayer>();
new Harmony("Parkour").PatchAll();
((MonoBehaviour)this).StartCoroutine(GenerateSettings());
Debug.Log((object)"Parkour Mod Loaded!");
}
private IEnumerator GenerateSettings()
{
configJumpForce = ((BaseUnityPlugin)this).Config.Bind<float>("General", "JumpForce", 1f, "Jump force multiplier.");
configEnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable Parkour Mod");
GlobalSettingsHandler service = null;
yield return (object)new WaitUntil((Func<bool>)(() => Object.op_Implicit((Object)(object)(service = ServiceLocator.GetService<GlobalSettingsHandler>()))));
List<SettingsInstance> list = service.GameplaySettings.ToList();
SettingsInstance val2 = new SettingsInstance();
val2.settingsType = (SettingsType)0;
val2.options = new string[2] { "On", "Off" };
val2.currentValue = ((!configEnableMod.Value) ? 1 : 0);
val2.m_settingsKey = "Use Parkour";
SettingsInstance val3 = val2;
val3.OnValueChanged += delegate(int val)
{
configEnableMod.Value = val == 0;
};
list.Add(val3);
FieldInfo field = ((object)service).GetType().GetField("m_gameplaySettings", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(service, list.ToArray());
}
}
private void Update()
{
if (!configEnableMod.Value || playerActions == null)
{
return;
}
try
{
MainCam instance = MainCam.instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
CameraAbilityPossess componentInParent = ((Component)instance).GetComponentInParent<CameraAbilityPossess>();
if ((Object)(object)componentInParent == (Object)null || !Object.op_Implicit((Object)(object)componentInParent.currentUnit))
{
return;
}
Unit val = componentInParent.currentUnit;
cachedCam = ((Component)instance).transform;
if ((Object)(object)val != (Object)(object)currentUnit)
{
currentUnit = val;
cachedRigidbodies = val.data.allRigs.AllRigs;
cachedInput = val.Input;
canJump = true;
canDash = true;
wait = false;
((MonoBehaviour)this).StopAllCoroutines();
}
UpdateTimeScale();
if (Object.op_Implicit((Object)(object)cachedInput) && cachedInput.hasControl && !val.data.Dead && Object.op_Implicit((Object)(object)val.data.targetData))
{
val.data.takeFallDamage = false;
val.data.cantFallForSeconds = 1f;
DynamicMovement(val, moveMultiplier * Time.deltaTime);
if (canDash && ((OneAxisInputControl)playerActions.m_moveFast).IsPressed)
{
canDash = false;
Dash(val, dashMultiplier);
}
else if (!canDash && !wait)
{
wait = true;
((MonoBehaviour)this).StartCoroutine(DashCooldown(val, dashCooldown));
}
HandleCombat(val, componentInParent, val.data.targetData.mainRig);
if (val.data.isGrounded && ((OneAxisInputControl)playerActions.m_flyUp).IsPressed && canJump)
{
canJump = false;
((MonoBehaviour)this).StartCoroutine(JumpRoutine(val, jumpMultiplier * configJumpForce.Value));
}
}
}
catch (Exception ex)
{
Debug.LogError((object)("Parkour Update Error: " + ex.Message));
}
}
public void Dash(Unit unit, float force)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((TwoAxisInputControl)playerActions.m_move).X * unit.data.characterForwardObject.right + ((TwoAxisInputControl)playerActions.m_move).Y * unit.data.characterForwardObject.forward;
((Vector3)(ref val)).Normalize();
if (val == Vector3.zero)
{
val = unit.data.characterForwardObject.forward;
}
Rigidbody[] array = cachedRigidbodies;
foreach (Rigidbody val2 in array)
{
val2.AddForce(val * force, (ForceMode)5);
cachedParticles.PlayEffect(1, val2.position, Vector3.up, (SkinnedMeshRenderer)null);
}
cachedSound.PlaySoundEffect("Effects/Log", 1.5f, unit.data.mainRig.position, (MaterialType)0, (Transform)null, 0.7f);
}
public void DynamicMovement(Unit unit, float forwardForce)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((TwoAxisInputControl)playerActions.m_move).X * unit.data.characterForwardObject.right * (forwardForce / 3f) + ((TwoAxisInputControl)playerActions.m_move).Y * unit.data.characterForwardObject.forward * forwardForce;
Rigidbody[] array = cachedRigidbodies;
foreach (Rigidbody val2 in array)
{
val2.AddForce(val / val2.mass, (ForceMode)5);
}
}
private void UpdateTimeScale()
{
bool wasPressed = ((OneAxisInputControl)playerActions.m_toggleTime).WasPressed;
bool wasPressed2 = ((OneAxisInputControl)playerActions.m_toggleSlowMotion).WasPressed;
bool wasPressed3 = ((OneAxisInputControl)playerActions.m_toggleSuperSlow).WasPressed;
if (wasPressed || wasPressed2 || wasPressed3)
{
if (wasPressed)
{
m_toggledPause = !m_toggledPause;
m_toggledSlowmo = (m_toggledSuperSlowmo = false);
}
else if (wasPressed2)
{
m_toggledSlowmo = !m_toggledSlowmo;
m_toggledPause = (m_toggledSuperSlowmo = false);
}
else if (wasPressed3)
{
m_toggledSuperSlowmo = !m_toggledSuperSlowmo;
m_toggledPause = (m_toggledSlowmo = false);
}
if (m_toggledPause)
{
Time.timeScale = 0f;
}
else if (m_toggledSlowmo)
{
Time.timeScale = 0.1f;
}
else if (m_toggledSuperSlowmo)
{
Time.timeScale = 0.01f;
}
else
{
Time.timeScale = 1f;
}
}
}
public IEnumerator JumpRoutine(Unit unit, float jumpForce)
{
if (!Object.op_Implicit((Object)(object)unit) || (Object)(object)unit != (Object)(object)currentUnit)
{
canJump = true;
yield break;
}
ApplyGlobalForce(Vector3.down * (jumpForce / 4f), showParticles: false);
if (Object.op_Implicit((Object)(object)cachedSound))
{
cachedSound.PlaySoundEffect("Effects/Log", 1f, unit.data.mainRig.position, (MaterialType)0, (Transform)null, 0.5f);
}
yield return (object)new WaitForSeconds(0.15f);
if (!Object.op_Implicit((Object)(object)unit) || (Object)(object)unit != (Object)(object)currentUnit)
{
canJump = true;
yield break;
}
ApplyGlobalForce(Vector3.up * jumpForce, showParticles: true);
if (Object.op_Implicit((Object)(object)cachedSound))
{
cachedSound.PlaySoundEffect("Effects/Log", 1.5f, unit.data.mainRig.position, (MaterialType)0, (Transform)null, 0.7f);
}
yield return (object)new WaitForSeconds(0.5f);
canJump = true;
}
private void ApplyGlobalForce(Vector3 force, bool showParticles)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
if (cachedRigidbodies == null || cachedRigidbodies.Length == 0)
{
return;
}
Rigidbody[] array = cachedRigidbodies?.ToArray();
foreach (Rigidbody val in array)
{
if (Object.op_Implicit((Object)(object)val))
{
val.AddForce(force / val.mass, (ForceMode)5);
if (showParticles && Object.op_Implicit((Object)(object)cachedParticles))
{
cachedParticles.PlayEffect(1, val.position, Vector3.up, (SkinnedMeshRenderer)null);
}
}
}
}
public IEnumerator DashCooldown(Unit unit, float cooldown)
{
yield return (object)new WaitForSeconds(cooldown);
cachedSound.PlaySoundEffect("Effects/Candlehead", 1.5f, unit.data.mainRig.position, (MaterialType)0, (Transform)null, 0.7f);
Rigidbody[] array = cachedRigidbodies;
foreach (Rigidbody val in array)
{
cachedParticles.PlayEffect(2, val.position, Vector3.up, (SkinnedMeshRenderer)null);
}
wait = false;
canDash = true;
}
private void HandleCombat(Unit unit, CameraAbilityPossess possess, Rigidbody targetRig)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
WeaponHandler componentInChildren = ((Component)unit).GetComponentInChildren<WeaponHandler>();
if ((Object)(object)componentInChildren == (Object)null)
{
return;
}
float num = 2f;
PossesionCamera componentInChildren2 = ((Component)unit).GetComponentInChildren<PossesionCamera>();
if (((OneAxisInputControl)playerActions.m_possessAttack1).IsPressed)
{
if (Object.op_Implicit((Object)(object)componentInChildren.leftWeapon))
{
num = componentInChildren.leftWeapon.maxRange;
}
componentInChildren.Attack(((Component)componentInChildren2).transform.position + cachedCam.forward * num, targetRig, cachedCam.forward, (ForceWeapon)1);
}
if (((OneAxisInputControl)playerActions.m_possessAttack2).IsPressed)
{
if (Object.op_Implicit((Object)(object)componentInChildren.rightWeapon))
{
num = componentInChildren.rightWeapon.maxRange;
}
componentInChildren.Attack(((Component)componentInChildren2).transform.position + cachedCam.forward * num, targetRig, cachedCam.forward, (ForceWeapon)2);
}
if (!((OneAxisInputControl)playerActions.m_possessAttack3).IsPressed)
{
return;
}
ConditionalEvent[] componentsInChildren = ((Component)unit).GetComponentsInChildren<ConditionalEvent>();
foreach (ConditionalEvent val in componentsInChildren)
{
if (val.controllableByPlayer)
{
val.CheckConditionsUpdate(false);
}
}
}
}