using System;
using System.Diagnostics;
using System.IO;
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 HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using Microsoft.CodeAnalysis;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("scooxstad.elevatorstuck")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("Elevatorstuck")]
[assembly: AssemblyTitle("scooxstad.elevatorstuck")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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.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]
[Microsoft.CodeAnalysis.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]
[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 Elevatorstuck
{
[BepInPlugin("scooxstad.elevatorstuck", "Elevatorstuck", "1.0.2")]
public class Elevatorstuck : BaseUnityPlugin
{
internal static AudioClip ElevatorAudio;
internal static ConfigEntry<bool> RandomizePlayback;
public static Elevatorstuck Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
LoadElevatorstuck();
InitializeConfiguration();
Patch();
Logger.LogInfo((object)"scooxstad.elevatorstuck v1.0.2 has loaded!");
}
internal void InitializeConfiguration()
{
RandomizePlayback = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Randomize Playback", true, "Begin playback at one of four fixed timestamps. Leave disabled for playback to resume where it last stopped.");
try
{
InitializeLethalConfigIntegration();
}
catch (FileNotFoundException)
{
Logger.LogInfo((object)"LethalConfig.dll not found");
}
}
internal void InitializeLethalConfigIntegration()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(RandomizePlayback, false));
}
private void LoadElevatorstuck()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "elevatorstuck"));
ElevatorAudio = val.LoadAsset<AudioClip>("elevatorstuck");
ElevatorAudio.LoadAudioData();
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("scooxstad.elevatorstuck");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "scooxstad.elevatorstuck";
public const string PLUGIN_NAME = "Elevatorstuck";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace Elevatorstuck.Patches
{
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
public static Random Random;
[HarmonyPatch("StartGame")]
[HarmonyPostfix]
internal static void ApplySeed(StartOfRound __instance)
{
Random = new Random(__instance.randomMapSeed);
}
}
[HarmonyPatch(typeof(MineshaftElevatorController))]
internal class MineshaftElevatorControllerPatch
{
internal static float PlaybackPosition = 0f;
internal static readonly float[] Timestamps = new float[4] { 2.3f, 11f, 28.6f, 46f };
[HarmonyPatch("SetElevatorMusicClientRpc")]
[HarmonyPrefix]
internal static void SetRandomTimestamp(MineshaftElevatorController __instance, bool setOn)
{
if (setOn)
{
if (Elevatorstuck.RandomizePlayback.Value && StartOfRoundPatch.Random != null)
{
int num = StartOfRoundPatch.Random.Next(0, Timestamps.Length);
__instance.elevatorJingleMusic.time = Timestamps[num];
}
else
{
__instance.elevatorJingleMusic.time = PlaybackPosition;
}
}
else
{
PlaybackPosition = __instance.elevatorJingleMusic.time;
}
}
[HarmonyPatch("OnEnable")]
[HarmonyPostfix]
internal static void ReplaceElevatorMusic(MineshaftElevatorController __instance)
{
if (StartOfRoundPatch.Random == null)
{
Elevatorstuck.Logger.LogWarning((object)"PSNG failed to initialize, disabling randomized playback");
}
Elevatorstuck.Logger.LogInfo((object)"Elevator jingle replaced");
__instance.elevatorJingleMusic.clip = Elevatorstuck.ElevatorAudio;
}
}
}