using System;
using System.Diagnostics;
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 Microsoft.CodeAnalysis;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("HalloweenElevator")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Restores the Halloween aesthetics for the mineshaft elevator")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f4986fdd3883113993f10883f74b02be2aa30849")]
[assembly: AssemblyProduct("HalloweenElevator")]
[assembly: AssemblyTitle("HalloweenElevator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 HalloweenElevator
{
[BepInPlugin("butterystancakes.lethalcompany.halloweenelevator", "Halloween Elevator", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string PLUGIN_GUID = "butterystancakes.lethalcompany.halloweenelevator";
private const string PLUGIN_NAME = "Halloween Elevator";
private const string PLUGIN_VERSION = "1.0.0";
internal static ManualLogSource Logger;
internal static ConfigEntry<float> configChance;
internal static ConfigEntry<bool> configEclipse;
internal static ConfigEntry<bool> configFog;
private void Awake()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
configChance = ((BaseUnityPlugin)this).Config.Bind<float>("Criteria", "Chance", 0f, new ConfigDescription("The percentage chance for the elevator to be spookified any day. (0 = never, 1 = guaranteed, or anything in between - 0.5 = 50% chance)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
configEclipse = ((BaseUnityPlugin)this).Config.Bind<bool>("Criteria", "Eclipses", true, "Spookify the elevator when it's eclipsed.");
configFog = ((BaseUnityPlugin)this).Config.Bind<bool>("Criteria", "Indoor Fog", true, "Spookify the elevator when the \"spooky fog\" event is active.");
new Harmony("butterystancakes.lethalcompany.halloweenelevator").PatchAll();
Logger.LogInfo((object)"Halloween Elevator v1.0.0 loaded");
}
}
[HarmonyPatch]
internal class ClassicElevatorPatches
{
private static bool halloween;
private static bool done;
private static Random musicRandom = new Random();
private static AudioClip elevatorClip;
[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
[HarmonyPostfix]
private static void RoundManager_Post_FinishGeneratingNewLevelClientRpc(RoundManager __instance)
{
if ((Object)(object)__instance.currentMineshaftElevator == (Object)null || done)
{
return;
}
done = true;
if ((Object)(object)elevatorClip == (Object)null)
{
AudioSource elevatorJingleMusic = __instance.currentMineshaftElevator.elevatorJingleMusic;
if ((Object)(object)((elevatorJingleMusic != null) ? elevatorJingleMusic.clip : null) != (Object)null)
{
AudioSource elevatorJingleMusic2 = __instance.currentMineshaftElevator.elevatorJingleMusic;
elevatorClip = ((elevatorJingleMusic2 != null) ? elevatorJingleMusic2.clip : null);
Plugin.Logger.LogDebug((object)"Cached original elevator music");
}
}
halloween = Spookify();
Transform obj = ((Component)__instance.currentMineshaftElevator).transform.Find("AnimContainer/NeonLights/Point Light");
Light val = ((obj != null) ? ((Component)obj).GetComponent<Light>() : null);
if ((Object)(object)val != (Object)null)
{
val.colorTemperature = (halloween ? 4131f : 6217f);
}
if (halloween)
{
musicRandom = new Random(StartOfRound.Instance.randomMapSeed);
}
}
private static bool Spookify()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Invalid comparison between Unknown and I4
if (Plugin.configEclipse.Value && (int)StartOfRound.Instance.currentLevel.currentWeather == 5)
{
return true;
}
if (Plugin.configFog.Value && ((Component)RoundManager.Instance.indoorFog).gameObject.activeSelf)
{
return true;
}
float value = Plugin.configChance.Value;
float num = (float)new Random(StartOfRound.Instance.randomMapSeed).NextDouble();
Plugin.Logger.LogDebug((object)$"RNG: {num}");
if (value > 0f && (value >= 1f || num < value))
{
return true;
}
DateTime utcNow = DateTime.UtcNow;
if (utcNow.Month == 10 && (utcNow.Day > 30 || utcNow.Day == 22 || utcNow.Day == 23))
{
return true;
}
return false;
}
[HarmonyPatch(typeof(MineshaftElevatorController), "SetElevatorMusicClientRpc")]
[HarmonyPostfix]
private static void MineshaftElevatorController_Post_SetElevatorMusicClientRpc(MineshaftElevatorController __instance, bool setOn)
{
if (!setOn)
{
return;
}
bool isPlaying = __instance.elevatorJingleMusic.isPlaying;
__instance.elevatorJingleMusic.Stop();
if (halloween)
{
if (__instance.elevatorMovingDown)
{
__instance.elevatorJingleMusic.clip = __instance.elevatorHalloweenClips[musicRandom.Next(__instance.elevatorHalloweenClips.Length)];
}
else
{
__instance.elevatorJingleMusic.clip = __instance.elevatorHalloweenClipsLoop[musicRandom.Next(__instance.elevatorHalloweenClipsLoop.Length)];
}
}
else if ((Object)(object)elevatorClip != (Object)null)
{
__instance.elevatorJingleMusic.clip = elevatorClip;
}
if (isPlaying)
{
__instance.elevatorJingleMusic.Play();
}
}
[HarmonyPatch(typeof(MineshaftElevatorController), "OnDisable")]
[HarmonyPostfix]
private static void MineshaftElevatorController_Post_OnDisable(MineshaftElevatorController __instance)
{
done = false;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "HalloweenElevator";
public const string PLUGIN_NAME = "HalloweenElevator";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}