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.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Lightbug.CharacterControllerPro.Core;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("DashMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DashingMod")]
[assembly: AssemblyTitle("DashMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 DashMod
{
[BepInPlugin("DashMod", "DashingMod", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private bool isOnCD = false;
private ConfigEntry<KeyboardShortcut> DashKey { get; set; }
private ConfigEntry<float> DashDistance { get; set; }
private ConfigEntry<float> DashCooldown { get; set; }
private ConfigEntry<float> DashStaminaCost { get; set; }
private void Awake()
{
//IL_0019: 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)
//IL_0063: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
DashKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Config", "Dash Hotkey", new KeyboardShortcut((KeyCode)119, Array.Empty<KeyCode>()), (ConfigDescription)null);
DashDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Config", "Dash Distance", 15f, new ConfigDescription("Dash distance description", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>()));
DashCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Config", "Dash Cooldown", 3f, new ConfigDescription("Dash cooldown description", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
DashStaminaCost = ((BaseUnityPlugin)this).Config.Bind<float>("Config", "Dash Stamina Cost", 25f, new ConfigDescription("Stamina consumed per dash", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin DashMod is loaded!");
}
public static List<PlayerNetworking> GetAllPlayers()
{
return new List<PlayerNetworking>(Object.FindObjectsByType<PlayerNetworking>((FindObjectsSortMode)0));
}
public static PlayerNetworking GetLocalPlayer()
{
return ((IEnumerable<PlayerNetworking>)GetAllPlayers()).FirstOrDefault((Func<PlayerNetworking, bool>)((PlayerNetworking p) => ((NetworkBehaviour)p).IsLocalPlayer));
}
private void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = DashKey.Value;
if (!Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey) || isOnCD)
{
return;
}
PlayerNetworking localPlayer = GetLocalPlayer();
if (!((Object)(object)localPlayer != (Object)null))
{
return;
}
CharacterActor val = ((Component)localPlayer).GetComponent<CharacterActor>();
if ((Object)(object)val == (Object)null)
{
val = ((Component)localPlayer).GetComponentInParent<CharacterActor>();
}
if ((Object)(object)val != (Object)null)
{
if (val.CurrentStamina < DashStaminaCost.Value)
{
return;
}
val.ExpendStamina(DashStaminaCost.Value);
}
isOnCD = true;
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(HandleCooldown());
Vector3 forward = ((Component)localPlayer).transform.forward;
forward.y = 0f;
((Vector3)(ref forward)).Normalize();
Vector3 val2 = ((GameEntityBase)localPlayer).Position + forward * DashDistance.Value;
RaycastHit[] array = Physics.RaycastAll(((GameEntityBase)localPlayer).Position, forward, DashDistance.Value, -5, (QueryTriggerInteraction)1);
if (array.Length != 0)
{
Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
RaycastHit[] array2 = array;
for (int num = 0; num < array2.Length; num++)
{
RaycastHit val3 = array2[num];
if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null))
{
string text = ((Object)((Component)((RaycastHit)(ref val3)).collider).gameObject).name.ToLower();
if (!((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponent("GrassRenderer") != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponent("NatureMeshFilter") != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponent("GrassQualitySettings") != (Object)null))
{
val2 = ((RaycastHit)(ref val3)).point - forward * 0.5f;
break;
}
}
}
}
((GameEntityBase)localPlayer).Teleport(val2);
localPlayer.ForceNotRagdoll();
}
private IEnumerator HandleCooldown()
{
if (isOnCD)
{
yield return (object)new WaitForSeconds(DashCooldown.Value);
isOnCD = false;
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DashMod";
public const string PLUGIN_NAME = "DashingMod";
public const string PLUGIN_VERSION = "1.0.0";
}
}