using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("GTFO.SkipDrop")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f3be50b3b0837cffd6e021024f5a8c4db4ff166a")] [assembly: AssemblyProduct("GTFO.SkipDrop")] [assembly: AssemblyTitle("GTFO.SkipDrop")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 GTFO.SkipDrop { [BepInPlugin("MindAttic.GTFO.SkipDrop", "GTFO.SkipDrop", "19.0.0")] [BepInProcess("GTFO.exe")] public class Plugin : BasePlugin { public const string GUID = "MindAttic.GTFO.SkipDrop"; public const string NAME = "GTFO.SkipDrop"; public const string VERSION = "19.0.0"; private static readonly (string Field, float Value)[] RideTimings = new(string, float)[3] { ("m_startDelay", 0f), ("m_engineStartDelay", 0f), ("m_endDur", 0.1f) }; private static ManualLogSource _log = null; private static MethodInfo _skipPreRelease = null; private static PropertyInfo _fastElevator = null; private static PropertyInfo _minTimeLooping = null; private static PropertyInfo _current = null; private static PropertyInfo _rideInProgress = null; private static readonly List _rideTimings = new List(); private static object? _savedFastElevator; private static readonly Stopwatch _dropTimer = new Stopwatch(); private static double _phaseStart; private static string? _phase; public override void Load() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_01ff: 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) //IL_021f: Expected O, but got Unknown //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Expected O, but got Unknown //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Expected O, but got Unknown //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown _log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; if (!((BasePlugin)this).Config.Bind("0. Mod", "Enabled", true, "Turn the whole mod on or off. When false, the mod loads nothing: no patches, and the drop plays at the game's normal speed.").Value) { ManualLogSource log = ((BasePlugin)this).Log; val = new BepInExInfoLogInterpolatedStringHandler(64, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("GTFO.SkipDrop"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is switched off in its config ([0. Mod] Enabled) - not loading."); } log.LogInfo(val); return; } Type type = AccessTools.TypeByName("ElevatorRide"); MethodInfo methodInfo = AccessTools.Method(type, "StartPreReleaseSequence", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "StartElevatorRide", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(type, "StopElevatorRide", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(type, "ChangeState", (Type[])null, (Type[])null); MethodInfo methodInfo5 = AccessTools.Method(type, "Cleanup", (Type[])null, (Type[])null); _rideInProgress = AccessTools.Property(type, "ElevatorRideInProgress"); _skipPreRelease = AccessTools.Method(type, "SkipPreReleaseSequence", (Type[])null, (Type[])null); _minTimeLooping = AccessTools.Property(type, "MinTimeLooping"); _current = AccessTools.Property(type, "Current"); _fastElevator = AccessTools.Property(AccessTools.TypeByName("Globals.Global"), "FastElevator"); (string, float)[] rideTimings = RideTimings; for (int i = 0; i < rideTimings.Length; i++) { string item = rideTimings[i].Item1; _rideTimings.Add(AccessTools.Property(type, item)); } if (new object[10] { methodInfo, methodInfo2, methodInfo3, methodInfo4, methodInfo5, _rideInProgress, _skipPreRelease, _minTimeLooping, _fastElevator, _current }.Concat(_rideTimings).Any((object m) => m == null)) { ((BasePlugin)this).Log.LogError((object)"Elevator members not found - game update? Drop will not be skipped."); return; } Harmony val2 = new Harmony("MindAttic.GTFO.SkipDrop"); val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "SkipPreRelease", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Plugin), "SpeedUpDrop", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "RestoreAfterDrop", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)methodInfo4, new HarmonyMethod(typeof(Plugin), "LogPhase", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "RestoreAfterAbortedDrop", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ManualLogSource log2 = ((BasePlugin)this).Log; val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("GTFO.SkipDrop"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("19.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded."); } log2.LogInfo(val); } private static void SkipPreRelease() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown try { _skipPreRelease.Invoke(null, null); } catch (Exception ex) { ManualLogSource log = _log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Couldn't skip the opening animation: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } private static void SpeedUpDrop() { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown _dropTimer.Restart(); _phaseStart = 0.0; _phase = null; try { if (_savedFastElevator == null) { _savedFastElevator = _fastElevator.GetValue(null); } _fastElevator.SetValue(null, true); _minTimeLooping.SetValue(null, Convert.ChangeType(0, _minTimeLooping.PropertyType)); object value = _current.GetValue(null); if (value == null) { _log.LogWarning((object)"ElevatorRide.Current is null - ride delays not cut."); return; } for (int i = 0; i < RideTimings.Length; i++) { _rideTimings[i].SetValue(value, Convert.ChangeType(RideTimings[i].Value, _rideTimings[i].PropertyType)); } } catch (Exception ex) { ManualLogSource log = _log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(48, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Couldn't speed up the drop, leaving it vanilla: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } private static void LogPhase(object __0) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (!_dropTimer.IsRunning) { return; } bool flag = default(bool); try { double totalSeconds = _dropTimer.Elapsed.TotalSeconds; if (_phase != null) { ManualLogSource log = _log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Drop phase "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_phase); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(totalSeconds - _phaseStart, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s"); } log.LogInfo(val); } _phase = __0?.ToString(); _phaseStart = totalSeconds; } catch (Exception ex) { ManualLogSource log2 = _log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Couldn't log drop phase: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } private static void RestoreAfterDrop() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown bool flag = default(bool); try { if (_savedFastElevator != null) { _fastElevator.SetValue(null, _savedFastElevator); } _savedFastElevator = null; } catch (Exception ex) { ManualLogSource log = _log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(31, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Couldn't restore FastElevator: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } if (_dropTimer.IsRunning) { ManualLogSource log2 = _log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(12, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Drop took "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(_dropTimer.Elapsed.TotalSeconds, "0.0"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("s."); } log2.LogInfo(val2); } _dropTimer.Reset(); } private static void RestoreAfterAbortedDrop() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown try { if (_savedFastElevator != null) { object value = _rideInProgress.GetValue(null); if (!(value is bool) || !(bool)value) { _fastElevator.SetValue(null, _savedFastElevator); _savedFastElevator = null; _dropTimer.Reset(); _log.LogInfo((object)"Drop was cut short - fast elevator flag restored."); } } } catch (Exception ex) { ManualLogSource log = _log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Couldn't restore FastElevator after a cut-short drop: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } } }