Decompiled source of TakeySausageBox v1.1.0

BepInEx/plugins/com.github.zehsteam.TakeySausageBox.dll

Decompiled 3 weeks ago
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.Extensions;
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.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+9a7d69aa2fcd64bac78eb9b431fb62c9ea6cccaf")]
[assembly: AssemblyProduct("TakeySausageBox")]
[assembly: AssemblyTitle("com.github.zehsteam.TakeySausageBox")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	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<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.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<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.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 GameObject SausageScythePrefab { get; private set; }

		public static GameObject SausageBaseballBatPrefab { 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<GameObject>("MusicBoxController", assetBundle);
			TVControllerPrefab = LoadAsset<GameObject>("TVController", assetBundle);
			SausageScythePrefab = LoadAsset<GameObject>("SausageScythe", assetBundle);
			SausageBaseballBatPrefab = LoadAsset<GameObject>("SausageBaseballBat", assetBundle);
			TakeySausageSong = LoadAsset<AudioClip>("TakeySausageSong", assetBundle);
		}

		private static T LoadAsset<T>(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<T>(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<T>(string name, AssetBundle assetBundle, out T asset) where T : Object
		{
			asset = LoadAsset<T>(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.1.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!");
			ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
			_harmony.PatchAll(typeof(MusicBoxTrap_Patches));
			_harmony.PatchAll(typeof(TrapRadio_Patches));
			_harmony.PatchAll(typeof(TrapGramophone_Patches));
			_harmony.PatchAll(typeof(TrapTV_Patches));
			_harmony.PatchAll(typeof(ValuableBoombox_Patches));
			_harmony.PatchAll(typeof(EnemyRunner_Patches));
			_harmony.PatchAll(typeof(ItemMelee_Patches));
			_harmony.PatchAll(typeof(ItemAttributes_Patches));
			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.1.0";
	}
}
namespace com.github.zehsteam.TakeySausageBox.Patches
{
	[HarmonyPatch(typeof(EnemyRunner))]
	internal static class EnemyRunner_Patches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Awake_Patch(EnemyRunner __instance)
		{
			if (ConfigManager.EnemyReplacements_Reaper.Value)
			{
				Transform transform = ((Component)__instance.animator).transform;
				TrailRenderer[] componentsInChildren = ((Component)transform).GetComponentsInChildren<TrailRenderer>(true);
				TrailRenderer[] array = componentsInChildren;
				foreach (TrailRenderer trailRenderer in array)
				{
					ReplaceScythe(trailRenderer);
				}
			}
		}

		private static void ReplaceScythe(TrailRenderer trailRenderer)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Component)trailRenderer).transform.parent;
			if (parent.TryFindFirst(new <>z__ReadOnlyArray<string>(new string[2] { "mesh scythe_L", "mesh scythe_R" }), out var result))
			{
				GameObject val = Object.Instantiate<GameObject>(Assets.SausageScythePrefab, result);
				val.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
				MeshRenderer val2 = default(MeshRenderer);
				if (((Component)result).TryGetComponent<MeshRenderer>(ref val2))
				{
					((Renderer)val2).enabled = false;
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemAttributes))]
	internal static class ItemAttributes_Patches
	{
		[HarmonyPatch("GetItemNameLocalized")]
		[HarmonyPrefix]
		private static bool GetItemNameLocalized_Patch(ItemAttributes __instance, ref string __result)
		{
			if (TryGetItemNameForBaseballBat(__instance, out var itemName))
			{
				__result = itemName;
				return false;
			}
			return true;
		}

		private static bool TryGetItemNameForBaseballBat(ItemAttributes itemAttributes, out string itemName)
		{
			if (!ConfigManager.ItemReplacements_BaseballBat.Value || (Object)(object)itemAttributes == (Object)null)
			{
				itemName = string.Empty;
				return false;
			}
			if (!itemAttributes.item.IsBaseballBat())
			{
				itemName = string.Empty;
				return false;
			}
			itemName = "Sausage";
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemMelee))]
	internal static class ItemMelee_Patches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start_Patch(ItemMelee __instance)
		{
			TryReplaceBaseballBat(__instance);
		}

		private static void TryReplaceBaseballBat(ItemMelee itemMelee)
		{
			//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)
			ItemAttributes val = default(ItemAttributes);
			if (ConfigManager.ItemReplacements_BaseballBat.Value && !((Object)(object)itemMelee == (Object)null) && ((Component)itemMelee).TryGetComponent<ItemAttributes>(ref val) && val.item.IsBaseballBat() && ((Component)itemMelee).transform.TryFind("Mesh Healthy", out var result))
			{
				GameObject val2 = Object.Instantiate<GameObject>(Assets.SausageBaseballBatPrefab, result);
				val2.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
				MeshRenderer val3 = default(MeshRenderer);
				if (((Component)result).TryGetComponent<MeshRenderer>(ref val3))
				{
					((Renderer)val3).enabled = false;
				}
			}
		}
	}
	[HarmonyPatch(typeof(MusicBoxTrap))]
	internal static class MusicBoxTrap_Patches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start_Patch(ref MusicBoxTrap __instance)
		{
			if (ConfigManager.ValuableReplacements_MusicBox.Value)
			{
				((Trap)(object)__instance).ApplyDebugSettingsIfEnabled();
				Object.Instantiate<GameObject>(Assets.MusicBoxControllerPrefab, ((Component)__instance).transform);
			}
		}
	}
	[HarmonyPatch(typeof(TrapGramophone))]
	internal static class TrapGramophone_Patches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start_Patch(ref TrapGramophone __instance)
		{
			if (ConfigManager.ValuableReplacements_Gramophone.Value)
			{
				((Trap)(object)__instance).ApplyDebugSettingsIfEnabled();
				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 Start_Patch(ref TrapRadio __instance)
		{
			if (ConfigManager.ValuableReplacements_Radio.Value)
			{
				((Trap)(object)__instance).ApplyDebugSettingsIfEnabled();
				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.ValuableReplacements_Television.Value)
			{
				((Trap)(object)__instance).ApplyDebugSettingsIfEnabled();
				Object.Instantiate<GameObject>(Assets.TVControllerPrefab, ((Component)__instance).transform);
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			ConfigEntry<bool> valuableReplacements_Television = ConfigManager.ValuableReplacements_Television;
			if (valuableReplacements_Television != null && !valuableReplacements_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>((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<TVController>()?.Play();
				}
			}
		}

		[HarmonyPatch("TrapStop")]
		[HarmonyPostfix]
		private static void TrapStop_Patch(TrapTV __instance)
		{
			if (ConfigManager.ValuableReplacements_Television.Value)
			{
				TVController componentInChildren = ((Component)__instance).GetComponentInChildren<TVController>();
				if (!((Object)(object)componentInChildren == (Object)null))
				{
					componentInChildren.Stop();
					((Trap)__instance).trapActive = false;
				}
			}
		}
	}
	[HarmonyPatch(typeof(ValuableBoombox))]
	internal static class ValuableBoombox_Patches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start_Patch(ValuableBoombox __instance)
		{
			if (ConfigManager.ValuableReplacements_Boombox.Value)
			{
				__instance.soundBoomboxMusic.Sounds = (AudioClip[])(object)new AudioClip[1] { Assets.TakeySausageSong };
				__instance.soundBoomboxMusic.Volume = 1f;
			}
		}
	}
}
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<Variant> _variants = new List<Variant>();

		[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<MusicBoxTrap>();
		}

		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<GameObject>(_currentVariant.DancerPrefab, _musicBoxTrap.MusicBoxDancer);
			_variantObject.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
			Renderer val = default(Renderer);
			if (((Component)_musicBoxTrap.MusicBoxDancer).TryGetComponent<Renderer>(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>();
			_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<bool> Misc_ExtendedLogging { get; private set; }

		public static ConfigEntry<bool> ValuableReplacements_MusicBox { get; private set; }

		public static ConfigEntry<bool> ValuableReplacements_Radio { get; private set; }

		public static ConfigEntry<bool> ValuableReplacements_Gramophone { get; private set; }

		public static ConfigEntry<bool> ValuableReplacements_Television { get; private set; }

		public static ConfigEntry<bool> ValuableReplacements_Boombox { get; private set; }

		public static ConfigEntry<bool> ItemReplacements_BaseballBat { get; private set; }

		public static ConfigEntry<bool> EnemyReplacements_Reaper { get; private set; }

		public static ConfigEntry<bool> Debug_OverrideTrapActivateRarityLevel { get; private set; }

		public static void Initialize(ConfigFile configFile)
		{
			ConfigFile = configFile;
			BindConfigs();
		}

		private static void BindConfigs()
		{
			Misc_ExtendedLogging = ConfigFile.Bind<bool>("Misc", "ExtendedLogging", false, "Enable extended logging.");
			ValuableReplacements_MusicBox = ConfigFile.Bind<bool>("Valuable Replacements", "MusicBox", true, "Replaces the music box music and dancers.");
			ValuableReplacements_Radio = ConfigFile.Bind<bool>("Valuable Replacements", "Radio", true, "Replaces the radio sound.");
			ValuableReplacements_Gramophone = ConfigFile.Bind<bool>("Valuable Replacements", "Gramophone", true, "Replaces the gramophone music.");
			ValuableReplacements_Television = ConfigFile.Bind<bool>("Valuable Replacements", "Television", true, "Replaces the television visuals and sound.");
			ValuableReplacements_Boombox = ConfigFile.Bind<bool>("Valuable Replacements", "Boombox", true, "Replaces the boombox music.");
			ItemReplacements_BaseballBat = ConfigFile.Bind<bool>("Item Replacements", "BaseballBat", true, "Replaces the visuals on the baseball bat item.");
			EnemyReplacements_Reaper = ConfigFile.Bind<bool>("Enemy Replacements", "Reaper", true, "Replaces some visuals on the reaper enemy.");
			Debug_OverrideTrapActivateRarityLevel = ConfigFile.Bind<bool>("Debug", "OverrideTrapActivateRarityLevel", false, "Will make trap valuables that have replacements easier to activate.");
		}
	}
}
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<int> 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<int> 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 ItemExtensions
	{
		public static bool IsBaseballBat(this Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			return item.itemName.Equals("Baseball Bat", StringComparison.OrdinalIgnoreCase);
		}
	}
	internal static class TransformExtensions
	{
		public static bool TryFind(this Transform transform, string name, out Transform result)
		{
			result = transform.Find(name);
			return (Object)(object)result != (Object)null;
		}

		public static bool TryFind(this Transform transform, string name, out Transform result, TransformFindOptions options)
		{
			result = transform.Find(name);
			return options.SatisfiesConditions(result);
		}

		public static bool TryFindFirst(this Transform transform, IEnumerable<string> names, out Transform result)
		{
			return transform.TryFindFirst(names, out result, new TransformFindOptions());
		}

		public static bool TryFindFirst(this Transform transform, IEnumerable<string> names, out Transform result, TransformFindOptions options)
		{
			result = transform.Find(names, options).FirstOrDefault();
			return (Object)(object)result != (Object)null;
		}

		public static List<Transform> Find(this Transform transform, IEnumerable<string> names)
		{
			return transform.Find(names, new TransformFindOptions());
		}

		public static List<Transform> Find(this Transform transform, IEnumerable<string> names, TransformFindOptions options)
		{
			List<Transform> list = new List<Transform>();
			foreach (Transform child in transform.GetChildren(options))
			{
				if (names.Contains<string>(((Object)((Component)child).gameObject).name, StringComparer.OrdinalIgnoreCase))
				{
					list.Add(child);
				}
			}
			return list;
		}

		public static List<Transform> GetChildren(this Transform transform)
		{
			return transform.GetChildren(new TransformFindOptions());
		}

		public static List<Transform> GetChildren(this Transform transform, TransformFindOptions options)
		{
			List<Transform> list = new List<Transform>();
			for (int i = 0; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				if (options.SatisfiesConditions(child))
				{
					list.Add(child);
				}
			}
			return list;
		}

		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);
		}

		public static string GetHierarchyPath(this Transform transform)
		{
			if ((Object)(object)transform == (Object)null)
			{
				return "Transform is null";
			}
			string text = ((Object)transform).name;
			Transform val = transform;
			while ((Object)(object)val.parent != (Object)null)
			{
				val = val.parent;
				text = ((Object)val).name + "/" + text;
			}
			return text;
		}
	}
	internal struct TransformFindOptions
	{
		public bool OnlyEnabled { get; set; }

		public int[] IncludeLayers { get; set; }

		public int[] ExcludeLayers { get; set; }

		public TransformFindOptions()
		{
			OnlyEnabled = false;
			IncludeLayers = Array.Empty<int>();
			ExcludeLayers = Array.Empty<int>();
		}

		public TransformFindOptions(bool onlyEnabled, int[] includeLayers = null, int[] excludeLayers = null)
		{
			OnlyEnabled = onlyEnabled;
			IncludeLayers = includeLayers ?? Array.Empty<int>();
			ExcludeLayers = excludeLayers ?? Array.Empty<int>();
		}

		public readonly bool SatisfiesConditions(Transform transform)
		{
			if ((Object)(object)transform == (Object)null)
			{
				return false;
			}
			if (OnlyEnabled && !((Component)transform).gameObject.activeSelf)
			{
				return false;
			}
			int layer = ((Component)transform).gameObject.layer;
			if (IncludeLayers.Length != 0 && !IncludeLayers.Contains(layer))
			{
				return false;
			}
			if (ExcludeLayers.Contains(layer))
			{
				return false;
			}
			return true;
		}
	}
	internal static class TrapExtensions
	{
		public static void ApplyDebugSettingsIfEnabled(this Trap trap)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)trap == (Object)null) && ConfigManager.Debug_OverrideTrapActivateRarityLevel.Value)
			{
				trap.trapActivateRarityLevel = (TrapActivateRarityLevel)1;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}