using System; using System.Collections.Generic; 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [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("BadToTheBone")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BadToTheBone")] [assembly: AssemblyTitle("BadToTheBone")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] 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; } } } namespace BadToTheBone { [BepInPlugin("BadToTheBone", "BadToTheBone", "1.0.0")] public class BadToTheBone : BaseUnityPlugin { public static List Tiles = new List(); public static Image Foxy; public static AudioSource Sounder; public static AudioClip Sound; public static int CurrentFrame = 14; public static float TimeSinceJump = 2.1474836E+09f; public static int floorvalue = 0; public static int Rng = 5000; public static bool CrashWindow = false; public static bool started = false; public static float vol = 1.2f; public static BadToTheBone Instance { get; private set; } = null; internal static ManualLogSource Log { get; private set; } = null; internal static Harmony Harmony { get; set; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Instance = this; Patch(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BadToTheBone loaded!"); SceneManager.sceneLoaded += delegate { if (SceneHelper.CurrentScene == "Main Menu") { FindCanvas.Create(); } }; } internal static void Patch() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("BadToTheBone"); } Harmony.PatchAll(); } } public class FindCanvas { public static void Create() { if (!BadToTheBone.started) { BadToTheBone.started = true; string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = Path.Combine(directoryName, "badtothebone"); AssetBundle val = AssetBundle.LoadFromFile(text); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile000.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile001.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile002.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile003.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile004.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile005.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile006.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile007.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile008.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile009.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile010.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile011.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile012.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/tile013.png")); BadToTheBone.Tiles.Add(val.LoadAsset("Assets/blank.png")); string path = Path.Combine(directoryName, "jumpscare.wav"); if (File.Exists(path)) { BadToTheBone.Log.LogInfo((object)"Loading custom audio from jumpscare.wav"); byte[] wav = File.ReadAllBytes(path); BadToTheBone.Sound = WavUtility.ToAudioClip(wav); } else { BadToTheBone.Log.LogInfo((object)"No jumpscare.wav found, loading from bundle"); BadToTheBone.Sound = val.LoadAsset("Assets/sound.mp3"); } GameObject val2 = val.LoadAsset("Assets/Canvas.prefab"); GameObject val3 = Object.Instantiate(val2, (Transform)null); Object.DontDestroyOnLoad((Object)(object)val3); val3.GetComponent().sortingOrder = 2599; BadToTheBone.Sounder = val3.GetComponentInChildren(); BadToTheBone.Foxy = val3.GetComponentInChildren(); BadToTheBone.Foxy.sprite = BadToTheBone.Tiles[14]; ((Behaviour)BadToTheBone.Foxy).enabled = false; BadToTheBone.vol = MonoSingleton.Instance.GetFloat("allVolume", 1f) * 1.2f; } } } public static class WavUtility { public static AudioClip ToAudioClip(byte[] wav) { int num = BitConverter.ToInt16(wav, 22); int num2 = BitConverter.ToInt32(wav, 24); int num3 = 44; int num4 = (wav.Length - num3) / 2; float[] array = new float[num4]; for (int i = 0; i < num4; i++) { short num5 = BitConverter.ToInt16(wav, num3 + i * 2); array[i] = (float)num5 / 32768f; } AudioClip val = AudioClip.Create("jumpscare", num4 / num, num, num2, false); val.SetData(array, 0); return val; } } [HarmonyPatch(typeof(StatsManager))] public class Jumper { [HarmonyPatch("Update")] [HarmonyPrefix] private static void Jumpscare() { if (BadToTheBone.floorvalue < Mathf.FloorToInt(Time.realtimeSinceStartup)) { int num = Random.Range(1, BadToTheBone.Rng); if (num == 1) { BadToTheBone.CurrentFrame = 0; BadToTheBone.TimeSinceJump = Time.realtimeSinceStartup; BadToTheBone.CrashWindow = true; } } BadToTheBone.floorvalue = Mathf.FloorToInt(Time.realtimeSinceStartup); if ((double)Time.realtimeSinceStartup > (double)BadToTheBone.TimeSinceJump + (double)BadToTheBone.CurrentFrame * 0.05928571429) { if (BadToTheBone.CurrentFrame == 0) { BadToTheBone.Sounder.PlayOneShot(BadToTheBone.Sound, BadToTheBone.vol); } BadToTheBone.Foxy.sprite = BadToTheBone.Tiles[Mathf.Clamp(BadToTheBone.CurrentFrame, 0, 14)]; if (!((BadToTheBone.CurrentFrame == 13) & ((double)Time.realtimeSinceStartup > (double)BadToTheBone.TimeSinceJump + 1.2))) { BadToTheBone.CurrentFrame = Mathf.Clamp(BadToTheBone.CurrentFrame + 1, 0, 14); } if (BadToTheBone.CurrentFrame == 14) { ((Behaviour)BadToTheBone.Foxy).enabled = false; BadToTheBone.CrashWindow = false; } else { ((Behaviour)BadToTheBone.Foxy).enabled = true; } } } } [HarmonyPatch(typeof(PrefsManager))] public class VolumeControl { [HarmonyPatch("Start")] [HarmonyPrefix] private static void VolumeManager(PrefsManager __instance) { BadToTheBone.vol = __instance.GetFloat("allVolume", 1f) * 1.2f; } } [HarmonyPatch(typeof(PrefsManager))] public class VolumeControl2 { [HarmonyPatch("SetFloat")] [HarmonyPrefix] private static void VolumeManager2(PrefsManager __instance) { BadToTheBone.vol = __instance.GetFloat("allVolume", 1f) * 1.2f; } } }