using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
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: AssemblyTitle("ShesDefrosting")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShesDefrosting")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b7905a51-9f8e-4094-9145-2e2f6bcb1ad5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ShesDefrosting
{
[BepInPlugin("simonciott.ultrakill.shesdefrosting", "ShesDefrosting", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string MyGUID = "simonciott.ultrakill.shesdefrosting";
private const string PluginName = "ShesDefrosting";
private const string VersionString = "1.0.0";
private static readonly Harmony Harmony = new Harmony("simonciott.ultrakill.shesdefrosting");
public static ManualLogSource Log = new ManualLogSource("ShesDefrosting");
internal static Assembly thisAssembly = Assembly.GetExecutingAssembly();
internal static AssetBundle bundle;
public static AudioClip introAudio;
public static AudioClip loopAudio;
public static bool isSisyphusLevel = false;
public static AssetBundle LoadBundle(string name)
{
try
{
using Stream stream = thisAssembly.GetManifestResourceStream(name);
if (stream == null)
{
Debug.LogError((object)"Bundle stream is null!!!");
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
return AssetBundle.LoadFromMemory(array);
}
catch (Exception ex)
{
Log.LogError((object)("Couldn't load bundle!!! " + ex));
return null;
}
}
private void Awake()
{
bool flag = false;
((BaseUnityPlugin)this).Logger.LogInfo((object)"ShesDefrosting is loading...");
bundle = LoadBundle("ShesDefrosting.shesdefrosting.bundle");
if ((Object)(object)bundle == (Object)null)
{
Log.LogInfo((object)"Bundle is null!");
flag = true;
}
introAudio = bundle.LoadAsset<AudioClip>("intro.ogg");
loopAudio = bundle.LoadAsset<AudioClip>("loop.ogg");
if (flag)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Couldn't load ShesDefrosting. Patches won't be applied.");
}
Harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"ShesDefrosting is loaded.");
Log = ((BaseUnityPlugin)this).Logger;
}
}
}
namespace ShesDefrosting.Patches
{
[HarmonyPatch(typeof(LeaderboardController))]
internal class LeaderboardControllerPatches
{
[HarmonyPatch("SubmitLevelScore")]
[HarmonyPrefix]
public static bool SubmitLevelScorePrefix(LeaderboardController __instance, string levelName)
{
if (levelName == "Level 4-2")
{
Plugin.Log.LogMessage((object)("Aborting level submit because the level is '" + levelName + "'"));
return false;
}
return true;
}
}
[HarmonyPatch(typeof(SceneHelper))]
internal class SceneHelperPatches
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__0_0;
internal void <OnSceneLoadedPrefix>b__0_0()
{
MonoSingleton<MusicManager>.Instance.battleTheme.clip = Plugin.loopAudio;
}
}
[HarmonyPatch("OnSceneLoaded")]
[HarmonyPostfix]
public static void OnSceneLoadedPrefix()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Expected O, but got Unknown
string currentScene = SceneHelper.CurrentScene;
if (currentScene != "Level 4-2")
{
Plugin.isSisyphusLevel = false;
return;
}
Plugin.isSisyphusLevel = true;
GameObject val = null;
Scene activeScene = SceneManager.GetActiveScene();
GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
foreach (GameObject val2 in rootGameObjects)
{
if (((Object)val2).name.Equals("7 - Boss Arena"))
{
val = val2;
break;
}
}
if ((Object)(object)val == (Object)null)
{
Plugin.Log.LogError((object)"Couldn't find root gameobject");
return;
}
Transform val3 = val.transform.Find("7 Nonstuff/Speakers/Cube");
AudioSource component = ((Component)val3.Find("Audio Source")).gameObject.GetComponent<AudioSource>();
ObjectActivator component2 = ((Component)val3.Find("Delay 2")).gameObject.GetComponent<ObjectActivator>();
component.clip = Plugin.introAudio;
component.loop = false;
MusicManager instance = MonoSingleton<MusicManager>.Instance;
component2.delay = Plugin.introAudio.length - 0.5f;
UnityEvent onActivate = component2.events.onActivate;
object obj = <>c.<>9__0_0;
if (obj == null)
{
UnityAction val4 = delegate
{
MonoSingleton<MusicManager>.Instance.battleTheme.clip = Plugin.loopAudio;
};
<>c.<>9__0_0 = val4;
obj = (object)val4;
}
onActivate.AddListener((UnityAction)obj);
}
}
[HarmonyPatch(typeof(SeasonalHats))]
internal class SeasonalHatsPatches
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPostfix(SeasonalHats __instance)
{
if (__instance.christmas.activeSelf || !Plugin.isSisyphusLevel)
{
return;
}
Sisyphus componentInParent = ((Component)__instance).GetComponentInParent<Sisyphus>();
if (!((Object)(object)componentInParent == (Object)null))
{
int month = __instance.time.Month;
if ((month >= 11 && month < 12) || (month == 1 && __instance.time.Day <= 6))
{
__instance.christmas.SetActive(true);
}
}
}
}
}