using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks.Data;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DaXcess")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Removes the short delay when jumping")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+1657d6ee16b9942ccb353a63215a911ae0bd7d70")]
[assembly: AssemblyProduct("NoJumpDelay")]
[assembly: AssemblyTitle("NoJumpDelay")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/DaXcess/NoJumpDelay")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 NoJumpDelay
{
[HarmonyPatch]
internal static class HostAuthoritativePatches
{
[HarmonyPatch(typeof(StartOfRound), "Start")]
[HarmonyPostfix]
private static void OnGameEnter(StartOfRound __instance)
{
//IL_0038: 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)
Plugin.EnableNoJumpDelay(enabled: false);
bool flag = ((NetworkBehaviour)__instance).NetworkManager.IsHost || ((NetworkBehaviour)__instance).NetworkManager.IsServer;
Lobby? currentLobby = GameNetworkManager.Instance.currentLobby;
if (currentLobby.HasValue)
{
Lobby valueOrDefault = currentLobby.GetValueOrDefault();
if (flag)
{
Plugin.EnableNoJumpDelay(enabled: true);
((Lobby)(ref valueOrDefault)).SetData("NoJumpDelayPresent", "true");
}
else if (!(((Lobby)(ref valueOrDefault)).GetData("NoJumpDelayPresent") != "true"))
{
Plugin.EnableNoJumpDelay(enabled: true);
}
}
else
{
Plugin.EnableNoJumpDelay(enabled: true);
}
}
}
[HarmonyPatch]
internal static class NoJumpDelayPatches
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> NoJumpDelayPatch(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Newobj, (object)AccessTools.Constructor(typeof(WaitForSeconds), new Type[1] { typeof(float) }, false), (string)null)
}).Advance(-2).RemoveInstructions(4)
.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Newobj, (object)AccessTools.Constructor(typeof(WaitForSeconds), new Type[1] { typeof(float) }, false), (string)null)
})
.Advance(-2)
.RemoveInstructions(4)
.InstructionEnumeration();
}
}
[BepInPlugin("io.daxcess.nojumpdelay", "NoJumpDelay", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
private const string PLUGIN_GUID = "io.daxcess.nojumpdelay";
private const string PLUGIN_NAME = "NoJumpDelay";
private const string PLUGIN_VERSION = "1.1.0";
private static readonly Harmony HostAuthoritativePatcher = new Harmony("io.daxcess.nojumpdelay-hostauthoritative");
private static readonly Harmony NoJumpDelayPatcher = new Harmony("io.daxcess.nojumpdelay-nojumpdelay");
private void Awake()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
new PatchClassProcessor(HostAuthoritativePatcher, typeof(HostAuthoritativePatches)).Patch();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Boing boing!");
}
internal static void EnableNoJumpDelay(bool enabled)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (!enabled)
{
NoJumpDelayPatcher.UnpatchSelf();
}
else
{
new PatchClassProcessor(NoJumpDelayPatcher, typeof(NoJumpDelayPatches)).Patch();
}
}
}
}