using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; 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; using UnityEngine.Video; using com.github.zehsteam.TakeySausageBox.Helpers; using com.github.zehsteam.TakeySausageBox.Managers; using com.github.zehsteam.TakeySausageBox.MonoBehaviours; using com.github.zehsteam.TakeySausageBox.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Zehs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2026 Zehs")] [assembly: AssemblyDescription("Replaces various valuables sounds and visuals with Takerst's sausage song.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f7c0172e45b4e8929ddb9853c3ca8e908cddcdbc")] [assembly: AssemblyProduct("TakeySausageBox")] [assembly: AssemblyTitle("com.github.zehsteam.TakeySausageBox")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlyArray : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => _items.Length; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Length; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return ((ICollection)_items).Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { ((ICollection)_items).CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return ((IList)_items).IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } 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 com.github.zehsteam.TakeySausageBox { internal static class Assets { public static readonly string AssetBundleFileName = "takeysausagebox_assets"; public static AssetBundle AssetBundle { get; private set; } public static bool IsLoaded { get; private set; } public static GameObject MusicBoxControllerPrefab { get; private set; } public static GameObject TVControllerPrefab { get; private set; } public static AudioClip TakeySausageSong { get; private set; } public static void Load() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = Path.Combine(directoryName, AssetBundleFileName); if (!File.Exists(text)) { Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text + "\". Make sure the \"" + AssetBundleFileName + "\" file is in the same folder as the mod's DLL file."); } else { AssetBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)AssetBundle == (Object)null) { Logger.LogFatal("Failed to load assets. AssetBundle is null."); return; } OnAssetBundleLoaded(AssetBundle); IsLoaded = true; } } private static void OnAssetBundleLoaded(AssetBundle assetBundle) { MusicBoxControllerPrefab = LoadAsset("MusicBoxController", assetBundle); TVControllerPrefab = LoadAsset("TVController", assetBundle); TakeySausageSong = LoadAsset("TakeySausageSong", assetBundle); } private static T LoadAsset(string name, AssetBundle assetBundle) where T : Object { if (string.IsNullOrWhiteSpace(name)) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace."); return default(T); } if ((Object)(object)assetBundle == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null."); return default(T); } T val = assetBundle.LoadAsset(name); if ((Object)(object)val == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name."); return default(T); } return val; } private static bool TryLoadAsset(string name, AssetBundle assetBundle, out T asset) where T : Object { asset = LoadAsset(name, assetBundle); return (Object)(object)asset != (Object)null; } } internal static class Logger { public static ManualLogSource ManualLogSource { get; private set; } public static bool IsExtendedLoggingEnabled => ConfigManager.Misc_ExtendedLogging?.Value ?? false; public static void Initialize(ManualLogSource manualLogSource) { ManualLogSource = manualLogSource; } public static void LogDebug(object data) { Log((LogLevel)32, data); } public static void LogInfo(object data, bool extended = false) { Log((LogLevel)16, data, extended); } public static void LogMessage(object data, bool extended = false) { Log((LogLevel)8, data, extended); } public static void LogWarning(object data, bool extended = false) { Log((LogLevel)4, data, extended); } public static void LogError(object data, bool extended = false) { Log((LogLevel)2, data, extended); } public static void LogFatal(object data, bool extended = false) { Log((LogLevel)1, data, extended); } public static void Log(LogLevel logLevel, object data, bool extended = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!extended || IsExtendedLoggingEnabled) { ManualLogSource manualLogSource = ManualLogSource; if (manualLogSource != null) { manualLogSource.Log(logLevel, data); } } } } [BepInPlugin("com.github.zehsteam.TakeySausageBox", "TakeySausageBox", "1.0.0")] internal class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("com.github.zehsteam.TakeySausageBox"); internal static Plugin Instance { get; private set; } private void Awake() { Instance = this; Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.TakeySausageBox")); Logger.LogInfo("TakeySausageBox has awoken!"); _harmony.PatchAll(typeof(MusicBoxTrap_Patches)); _harmony.PatchAll(typeof(TrapRadio_Patches)); _harmony.PatchAll(typeof(TrapGramophone_Patches)); _harmony.PatchAll(typeof(TrapTV_Patches)); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); Assets.Load(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.zehsteam.TakeySausageBox"; public const string PLUGIN_NAME = "TakeySausageBox"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace com.github.zehsteam.TakeySausageBox.Patches { [HarmonyPatch(typeof(MusicBoxTrap))] internal static class MusicBoxTrap_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch(ref MusicBoxTrap __instance) { if (ConfigManager.Replacements_MusicBox.Value) { Object.Instantiate(Assets.MusicBoxControllerPrefab, ((Component)__instance).transform); } } } [HarmonyPatch(typeof(TrapGramophone))] internal static class TrapGramophone_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch(ref TrapGramophone __instance) { if (ConfigManager.Replacements_Gramophone.Value) { ReplaceMusic(__instance); } } private static void ReplaceMusic(TrapGramophone trapGramophone) { if (!((Object)(object)trapGramophone == (Object)null)) { trapGramophone.GramophoneMusic.Sounds = (AudioClip[])(object)new AudioClip[1] { Assets.TakeySausageSong }; trapGramophone.GramophoneMusic.Volume = 1f; } } } [HarmonyPatch(typeof(TrapRadio))] internal static class TrapRadio_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch(ref TrapRadio __instance) { if (ConfigManager.Replacements_Radio.Value) { ReplaceLoopSFX(__instance); } } private static void ReplaceLoopSFX(TrapRadio trapRadio) { if (!((Object)(object)trapRadio == (Object)null)) { trapRadio.RadioLoop.Sounds = (AudioClip[])(object)new AudioClip[1] { Assets.TakeySausageSong }; trapRadio.RadioLoop.Volume = 1f; } } } [HarmonyPatch(typeof(TrapTV))] internal static class TrapTV_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Patch(TrapTV __instance) { if (ConfigManager.Replacements_Television.Value) { Object.Instantiate(Assets.TVControllerPrefab, ((Component)__instance).transform); } } [HarmonyPatch("Update")] [HarmonyTranspiler] private static IEnumerable Update_Transpiler(IEnumerable instructions) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (!ConfigManager.Replacements_Television.Value) { return instructions; } MethodInfo methodInfo = AccessTools.Method(typeof(Trap), "Update", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(TrapTV_Patches), "OnUpdate", (Type[])null, (Type[])null); return new <>z__ReadOnlyArray((CodeInstruction[])(object)new CodeInstruction[8] { new CodeInstruction(OpCodes.Nop, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo), new CodeInstruction(OpCodes.Nop, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo2), new CodeInstruction(OpCodes.Nop, (object)null), new CodeInstruction(OpCodes.Ret, (object)null) }); } public static void OnUpdate(TrapTV trapTV) { if (((Trap)trapTV).trapStart) { trapTV.TrapActivate(); } if (((Trap)trapTV).trapActive) { ((Trap)trapTV).enemyInvestigate = true; if (trapTV.TVStart) { trapTV.TVStart = false; ((Component)trapTV).GetComponentInChildren()?.Play(); } } } [HarmonyPatch("TrapStop")] [HarmonyPostfix] private static void TrapStop_Patch(TrapTV __instance) { if (ConfigManager.Replacements_Television.Value) { TVController componentInChildren = ((Component)__instance).GetComponentInChildren(); if (!((Object)(object)componentInChildren == (Object)null)) { componentInChildren.Stop(); ((Trap)__instance).trapActive = false; } } } } } namespace com.github.zehsteam.TakeySausageBox.MonoBehaviours { public class GramophoneController : MonoBehaviour { } public class MusicBoxController : MonoBehaviour { [Serializable] public class Variant { public GameObject DancerPrefab; [Range(0f, 100f)] public int Rarity; } [SerializeField] private List _variants = new List(); [SerializeField] private AudioClip _music; private Variant _currentVariant; private GameObject _variantObject; private MusicBoxTrap _musicBoxTrap; private Random _random; private void Awake() { _musicBoxTrap = ((Component)((Component)this).transform.parent).GetComponent(); } private void Start() { ReplaceMusic(); SetRandomFromPosition(); SetRandomVariant(); } private void SetRandomFromPosition() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) int num = (int)Mathf.Floor(((Component)this).transform.position.x); int num2 = (int)Mathf.Floor(((Component)this).transform.position.z); _random = new Random(num + num2); } private void ReplaceMusic() { _musicBoxTrap.MusicBoxMusic.Sounds = (AudioClip[])(object)new AudioClip[1] { _music }; _musicBoxTrap.MusicBoxMusic.Volume = 1f; } private void SetRandomVariant() { int randomIndexFromWeightList = Utils.GetRandomIndexFromWeightList(_random, _variants.Select((Variant x) => x.Rarity).ToList()); if (randomIndexFromWeightList != -1) { SetVariant(randomIndexFromWeightList); } } private void SetVariant(int index) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_variantObject != (Object)null) { Object.Destroy((Object)(object)_variantObject); } _currentVariant = _variants[index]; _variantObject = Object.Instantiate(_currentVariant.DancerPrefab, _musicBoxTrap.MusicBoxDancer); _variantObject.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); Renderer val = default(Renderer); if (((Component)_musicBoxTrap.MusicBoxDancer).TryGetComponent(ref val)) { val.enabled = false; } } } public class TVController : MonoBehaviour { [SerializeField] private VideoPlayer _videoPlayer; [SerializeField] private AudioSource _TVAudio; [SerializeField] private GameObject _TVScreen; [SerializeField] public GameObject _TVStatic; private TrapTV _trapTV; private void Awake() { _trapTV = ((Component)((Component)this).transform.parent).GetComponent(); _trapTV.TVScreen.SetActive(false); FixTVAudioMixerGroup(); _TVScreen.SetActive(false); _TVStatic.SetActive(false); } private void FixTVAudioMixerGroup() { _TVAudio.outputAudioMixerGroup = _trapTV.LoopSound.Source.outputAudioMixerGroup; } public void Play() { Logger.LogInfo("[TVController] Play()", extended: true); _TVScreen.SetActive(true); _videoPlayer.Play(); } public void Stop() { Logger.LogInfo("[TVController] Stop()", extended: true); _TVScreen.SetActive(false); _videoPlayer.Stop(); } } } namespace com.github.zehsteam.TakeySausageBox.Managers { internal static class ConfigManager { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry Misc_ExtendedLogging { get; private set; } public static ConfigEntry Replacements_MusicBox { get; private set; } public static ConfigEntry Replacements_Radio { get; private set; } public static ConfigEntry Replacements_Gramophone { get; private set; } public static ConfigEntry Replacements_Television { get; private set; } public static void Initialize(ConfigFile configFile) { ConfigFile = configFile; BindConfigs(); } private static void BindConfigs() { Misc_ExtendedLogging = ConfigFile.Bind("Misc", "ExtendedLogging", false, "Enable extended logging."); Replacements_MusicBox = ConfigFile.Bind("Replacements", "MusicBox", true, "Replaces the music box music and dancers."); Replacements_Radio = ConfigFile.Bind("Replacements", "Radio", true, "Replaces the radio sound."); Replacements_Gramophone = ConfigFile.Bind("Replacements", "Gramophone", true, "Replaces the gramophone music."); Replacements_Television = ConfigFile.Bind("Replacements", "Television", true, "Replaces the television visuals and sound."); } } } namespace com.github.zehsteam.TakeySausageBox.Helpers { internal static class Utils { public static bool RollPercentChance(float percent) { if (percent <= 0f) { return false; } if (percent >= 100f) { return true; } return Random.value * 100f <= percent; } public static bool RollPercentChance(Random random, float percent) { if (percent <= 0f) { return false; } if (percent >= 100f) { return true; } return random.NextDouble() * 100.0 <= (double)percent; } public static int GetRandomIndexFromWeightList(List weightList) { List<(int, int)> list = new List<(int, int)>(); for (int i = 0; i < weightList.Count; i++) { int num = weightList[i]; if (num > 0) { list.Add((i, num)); } } int num2 = 0; foreach (var item4 in list) { int item = item4.Item2; num2 += item; } if (num2 == 0) { return -1; } int num3 = Random.Range(0, num2); int num4 = 0; foreach (var item5 in list) { int item2 = item5.Item1; int item3 = item5.Item2; num4 += item3; if (num3 < num4) { return item2; } } throw new InvalidOperationException("Weights are not properly specified."); } public static int GetRandomIndexFromWeightList(Random random, List weightList) { List<(int, int)> list = new List<(int, int)>(); for (int i = 0; i < weightList.Count; i++) { int num = weightList[i]; if (num > 0) { list.Add((i, num)); } } int num2 = 0; foreach (var item4 in list) { int item = item4.Item2; num2 += item; } if (num2 == 0) { return -1; } int num3 = random.Next(0, num2); int num4 = 0; foreach (var item5 in list) { int item2 = item5.Item1; int item3 = item5.Item2; num4 += item3; if (num3 < num4) { return item2; } } throw new InvalidOperationException("Weights are not properly specified."); } } } namespace com.github.zehsteam.TakeySausageBox.Extensions { internal static class TransformExtensions { public static void SetLossyScale(this Transform transform, Vector3 scale) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)transform.parent == (Object)null) { transform.localScale = scale; return; } Vector3 lossyScale = transform.parent.lossyScale; transform.localScale = new Vector3((lossyScale.x != 0f) ? (scale.x / lossyScale.x) : scale.x, (lossyScale.y != 0f) ? (scale.y / lossyScale.y) : scale.y, (lossyScale.z != 0f) ? (scale.z / lossyScale.z) : scale.z); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }