using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Configgy;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[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("SlamStorageAssist")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.5.2.0")]
[assembly: AssemblyInformationalVersion("0.5.2")]
[assembly: AssemblyProduct("SlamStorageAssist")]
[assembly: AssemblyTitle("SlamStorageAssist")]
[assembly: AssemblyVersion("0.5.2.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 SlamStorageAssist
{
[BepInPlugin("mastoor144.slamstorageassist", "Slam Storage Assist", "0.5.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private ConfigBuilder config;
private Harmony harmony;
[Configgable("General", "Enable Assist", 0, "Enables or disables SSA's assisted landing jump. The game's native movement mechanics remain available.")]
private static ConfigToggle enableAssist = new ConfigToggle(true);
[Configgable("Practice", "Show Logs", 0, "Writes an informational message to the BepInEx log when SSA attempts an assisted landing jump.")]
private static ConfigToggle showFeedback = new ConfigToggle(true);
[Configgable("Practice", "Landing Window", 1, "Time in seconds that a jump press remains valid after being captured during slam storage.")]
private static FloatSlider landingWindow = new FloatSlider(0.1f, 0f, 1f);
private static ManualLogSource log;
private static FieldInfo slamStorageField;
private static MethodInfo jumpMethod;
private static bool jumpQueued;
private static float jumpExpiresAt;
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Expected O, but got Unknown
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Expected O, but got Unknown
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Expected O, but got Unknown
log = ((BaseUnityPlugin)this).Logger;
config = new ConfigBuilder("mastoor144.slamstorageassist", "Slam Storage Assist");
config.BuildAll();
SceneManager.sceneLoaded += OnSceneLoaded;
Type type = AccessTools.TypeByName("NewMovement");
if (type == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"SSA could not find NewMovement. Gameplay patches were not installed.");
return;
}
MethodInfo methodInfo = AccessTools.Method(type, "JumpPerformed", (Type[])null, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(type, "LandingImpact", (Type[])null, (Type[])null);
slamStorageField = AccessTools.Field(type, "slamStorage");
jumpMethod = AccessTools.Method(type, "Jump", Type.EmptyTypes, (Type[])null);
if (methodInfo == null || methodInfo2 == null || slamStorageField == null || jumpMethod == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"SSA could not find all required movement members. Gameplay patches were not installed.");
return;
}
harmony = new Harmony("mastoor144.slamstorageassist");
harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin).GetMethod("OnJumpPressed", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("OnLanding", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"SSA 0.5.2 loaded successfully.");
}
private static void OnJumpPressed(object __instance)
{
if (!((ConfigValueElement<bool>)(object)enableAssist).Value)
{
return;
}
float value = ((ConfigValueElement<float>)(object)landingWindow).Value;
if (value <= 0f)
{
return;
}
try
{
object value2 = slamStorageField.GetValue(__instance);
bool flag = default(bool);
int num;
if (value2 is bool)
{
flag = (bool)value2;
num = 1;
}
else
{
num = 0;
}
if (((uint)num & (flag ? 1u : 0u)) != 0)
{
jumpQueued = true;
jumpExpiresAt = Time.time + value;
}
}
catch (Exception ex)
{
log.LogError((object)("SSA could not capture jump input: " + ex.Message));
jumpQueued = false;
}
}
private static void OnLanding(object __instance)
{
if (!jumpQueued)
{
return;
}
bool flag = Time.time <= jumpExpiresAt;
jumpQueued = false;
if (!((ConfigValueElement<bool>)(object)enableAssist).Value || !flag)
{
return;
}
try
{
jumpMethod.Invoke(__instance, null);
if (((ConfigValueElement<bool>)(object)showFeedback).Value)
{
log.LogInfo((object)"SSA attempted an assisted landing jump.");
}
}
catch (Exception ex)
{
log.LogError((object)("SSA landing attempt failed: " + ex.Message));
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
jumpQueued = false;
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
if (harmony != null)
{
harmony.UnpatchSelf();
harmony = null;
}
jumpQueued = false;
}
}
}