Decompiled source of MinecraftStrongholdLevelFix v0.2.0

patchers/MinecraftStrongholdLevelFix.Patcher.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;

[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("MinecraftStrongholdLevelFix.Patcher")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MinecraftStrongholdLevelFix.Patcher")]
[assembly: AssemblyTitle("MinecraftStrongholdLevelFix.Patcher")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
	[CompilerGenerated]
	[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 MinecraftStrongholdLevelFix.Patcher
{
	public static class ValuableVolumeVisualizerPatcher
	{
		public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" };

		public static void Patch(AssemblyDefinition assembly)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			ModuleDefinition mainModule = assembly.MainModule;
			if (mainModule.GetType("ValuableVolumeVisualizer") == null)
			{
				AssemblyNameReference val = ((IEnumerable<AssemblyNameReference>)mainModule.AssemblyReferences).First((AssemblyNameReference reference) => reference.Name == "UnityEngine.CoreModule");
				TypeReference val2 = new TypeReference("UnityEngine", "MonoBehaviour", mainModule, (IMetadataScope)(object)val);
				TypeDefinition val3 = new TypeDefinition(string.Empty, "ValuableVolumeVisualizer", (TypeAttributes)1048577, val2);
				MethodDefinition val4 = new MethodDefinition(".ctor", (MethodAttributes)6150, mainModule.TypeSystem.Void);
				MethodReference val5 = new MethodReference(".ctor", mainModule.TypeSystem.Void, val2)
				{
					HasThis = true
				};
				val4.Body.GetILProcessor().Append(Instruction.Create(OpCodes.Ldarg_0));
				val4.Body.GetILProcessor().Append(Instruction.Create(OpCodes.Call, val5));
				val4.Body.GetILProcessor().Append(Instruction.Create(OpCodes.Ret));
				val3.Methods.Add(val4);
				mainModule.Types.Add(val3);
			}
		}
	}
}

plugins/MinecraftStrongholdLevelFix.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
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: AssemblyCompany("nezzy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0")]
[assembly: AssemblyProduct("MinecraftStrongholdLevelFix")]
[assembly: AssemblyTitle("MinecraftStrongholdLevelFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
	[CompilerGenerated]
	[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 MinecraftStrongholdLevelFix
{
	[BepInPlugin("nezzy.MinecraftStrongholdLevelFix", "Minecraft Stronghold Level Fix", "0.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll();
		}

		internal static bool IsStrongholdLevel()
		{
			if ((Object)(object)RunManager.instance != (Object)null && (Object)(object)RunManager.instance.levelCurrent != (Object)null)
			{
				return ((Object)RunManager.instance.levelCurrent).name.IndexOf("Stronghold", StringComparison.OrdinalIgnoreCase) >= 0;
			}
			return false;
		}

		[Conditional("DEBUG")]
		internal static void DebugLog(string message)
		{
			Log.LogInfo((object)message);
		}
	}
	internal sealed class MinecartReplacementMarker : MonoBehaviour
	{
	}
	internal sealed class MinecartReplacementController : MonoBehaviour
	{
		private const string SmallCartResourcePath = "Items/Item Cart Small";

		internal static void Replace(GameObject legacyCart)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			MinecartReplacementController minecartReplacementController = Object.FindObjectOfType<MinecartReplacementController>();
			if ((Object)(object)minecartReplacementController == (Object)null)
			{
				minecartReplacementController = new GameObject("Stronghold Minecart Replacement").AddComponent<MinecartReplacementController>();
				Object.DontDestroyOnLoad((Object)(object)((Component)minecartReplacementController).gameObject);
			}
			((MonoBehaviour)minecartReplacementController).StartCoroutine(minecartReplacementController.ReplaceRoutine(legacyCart));
		}

		private IEnumerator ReplaceRoutine(GameObject legacyCart)
		{
			if ((Object)(object)legacyCart == (Object)null)
			{
				yield break;
			}
			Vector3 position = legacyCart.transform.position;
			Quaternion rotation = legacyCart.transform.rotation;
			legacyCart.SetActive(false);
			Plugin.Log.LogInfo((object)"Replacing Stronghold Minecart with the current vanilla small-cart physics prefab.");
			GameObject replacement = null;
			if (SemiFunc.IsMultiplayer())
			{
				if (PhotonNetwork.IsMasterClient)
				{
					replacement = PhotonNetwork.InstantiateRoomObject("Items/Item Cart Small", position, rotation, (byte)0, (object[])null);
				}
			}
			else
			{
				GameObject val = Resources.Load<GameObject>("Items/Item Cart Small");
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Log.LogError((object)"Could not load vanilla small cart at 'Items/Item Cart Small'.");
					yield break;
				}
				replacement = Object.Instantiate<GameObject>(val, position, rotation);
			}
			int frame = 0;
			while ((Object)(object)replacement == (Object)null && frame < 600)
			{
				ItemAttributes val2 = null;
				float num = float.MaxValue;
				ItemAttributes[] array = Object.FindObjectsOfType<ItemAttributes>();
				foreach (ItemAttributes val3 in array)
				{
					if (((Component)val3).gameObject.activeInHierarchy && ((Object)val3).name.StartsWith("Item Cart Small", StringComparison.Ordinal) && Vector3.SqrMagnitude(((Component)val3).transform.position - position) < num)
					{
						val2 = val3;
						num = Vector3.SqrMagnitude(((Component)val3).transform.position - position);
					}
				}
				if ((Object)(object)val2 != (Object)null && num <= 25f)
				{
					replacement = ((Component)val2).gameObject;
				}
				if ((Object)(object)replacement == (Object)null)
				{
					yield return null;
				}
				frame++;
			}
			if ((Object)(object)replacement == (Object)null)
			{
				Plugin.Log.LogError((object)"Vanilla small cart replacement did not spawn; the old Minecart remains disabled to prevent the error flood.");
				yield break;
			}
			replacement.AddComponent<MinecartReplacementMarker>();
			RenameMinecart(replacement);
			ApplyMinecartVisual(replacement, legacyCart);
			Plugin.Log.LogInfo((object)"Stronghold Minecart replacement is ready.");
		}

		private static void ApplyMinecartVisual(GameObject replacement, GameObject legacyCart)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)replacement.transform.Find("Stronghold Minecart Visual") != (Object)null)
			{
				return;
			}
			Material fallbackMaterial = null;
			MeshRenderer[] componentsInChildren = replacement.GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer val in componentsInChildren)
			{
				if ((Object)(object)((Renderer)val).sharedMaterial != (Object)null && (Object)(object)((Renderer)val).sharedMaterial.shader != (Object)null)
				{
					fallbackMaterial = ((Renderer)val).sharedMaterial;
					break;
				}
			}
			MeshRenderer val2 = Array.Find(legacyCart.GetComponentsInChildren<MeshRenderer>(true), (MeshRenderer candidate) => ((Object)candidate).name == "Cart Mesh");
			MeshFilter val3 = (((Object)(object)val2 == (Object)null) ? null : ((Component)val2).GetComponent<MeshFilter>());
			if ((Object)(object)val3 == (Object)null || (Object)(object)val3.sharedMesh == (Object)null)
			{
				Plugin.Log.LogError((object)"Could not find the original Minecart Cart Mesh; Small Cart will keep its vanilla appearance.");
				return;
			}
			GameObject val4 = new GameObject("Stronghold Minecart Visual");
			val4.transform.SetParent(replacement.transform, false);
			val4.transform.localPosition = legacyCart.transform.InverseTransformPoint(((Component)val2).transform.position);
			val4.transform.localRotation = Quaternion.Inverse(legacyCart.transform.rotation) * ((Component)val2).transform.rotation;
			val4.transform.localScale = ((Component)val2).transform.localScale;
			val4.AddComponent<MeshFilter>().sharedMesh = val3.sharedMesh;
			MeshRenderer val5 = val4.AddComponent<MeshRenderer>();
			((Renderer)val5).sharedMaterials = CompatibleMaterials(((Renderer)val2).sharedMaterials, fallbackMaterial);
			((Renderer)val5).shadowCastingMode = ((Renderer)val2).shadowCastingMode;
			((Renderer)val5).receiveShadows = ((Renderer)val2).receiveShadows;
			Renderer[] componentsInChildren2 = replacement.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val6 in componentsInChildren2)
			{
				if ((Object)(object)((Component)val6).gameObject != (Object)(object)val4)
				{
					val6.enabled = false;
				}
			}
			Canvas[] componentsInChildren3 = replacement.GetComponentsInChildren<Canvas>(true);
			foreach (Canvas val7 in componentsInChildren3)
			{
				((Behaviour)val7).enabled = false;
			}
		}

		private static Material[] CompatibleMaterials(Material[] materials, Material? fallbackMaterial)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			Material[] array = (Material[])(object)new Material[materials.Length];
			for (int i = 0; i < materials.Length; i++)
			{
				Material val = materials[i];
				if ((Object)(object)val == (Object)null || (Object)(object)val.shader != (Object)null || (Object)(object)fallbackMaterial == (Object)null || (Object)(object)fallbackMaterial.shader == (Object)null)
				{
					array[i] = val;
					continue;
				}
				Material val2 = new Material(fallbackMaterial.shader)
				{
					mainTexture = val.mainTexture,
					color = val.color
				};
				array[i] = val2;
			}
			return array;
		}

		private static void RenameMinecart(GameObject replacement)
		{
			ItemAttributes component = replacement.GetComponent<ItemAttributes>();
			if (!((Object)(object)component == (Object)null) && !((Object)(object)component.item == (Object)null))
			{
				Item val = Object.Instantiate<Item>(component.item);
				((Object)val).name = "Item Minecart";
				val.itemName = "Minecart";
				val.itemNameLocalized = null;
				component.item = val;
				((Object)replacement).name = "Item Minecart";
			}
		}
	}
	[HarmonyPatch(typeof(PhysGrabCart), "Start")]
	internal static class StrongholdMinecartReplacementPatch
	{
		private static bool Prefix(PhysGrabCart __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<MinecartReplacementMarker>() != (Object)null)
			{
				return true;
			}
			if (!Plugin.IsStrongholdLevel() || ((Object)((Component)__instance).gameObject).name.IndexOf("Minecart", StringComparison.OrdinalIgnoreCase) < 0)
			{
				return true;
			}
			MinecartReplacementController.Replace(((Component)__instance).gameObject);
			return false;
		}
	}
	[HarmonyPatch]
	internal static class StrongholdWeaponPhotonRepairPatch
	{
		private static MethodBase? TargetMethod()
		{
			return AccessTools.Method(typeof(PhotonView), "Awake", (Type[])null, (Type[])null);
		}

		private static void Prefix(PhotonView __instance)
		{
			if (IsAffectedWeapon(((Object)((Component)__instance).gameObject).name))
			{
				__instance.ObservedComponents.RemoveAll((Component component) => component is ItemMelee);
			}
		}

		private static bool IsAffectedWeapon(string name)
		{
			if (!name.StartsWith("MC Item Iron Pickaxe", StringComparison.Ordinal) && !name.StartsWith("MC Item Iron Sword", StringComparison.Ordinal))
			{
				return name.StartsWith("MC Item Diamond Sword", StringComparison.Ordinal);
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal static class StrongholdKinematicInventoryItemPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool LinearVelocityPrefix(Rigidbody __instance)
		{
			return !IsLegacyStrongholdInventoryBody(__instance);
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool AngularVelocityPrefix(Rigidbody __instance)
		{
			return !IsLegacyStrongholdInventoryBody(__instance);
		}

		private static bool IsLegacyStrongholdInventoryBody(Rigidbody body)
		{
			if (Plugin.IsStrongholdLevel() && body.isKinematic)
			{
				return (Object)(object)((Component)body).GetComponent<ItemEquippable>() != (Object)null;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(ItemAttributes), "Start")]
	internal static class StrongholdCarvedPumpkinIconPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemAttributes __instance)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Expected O, but got Unknown
			if (!Plugin.IsStrongholdLevel() || (Object)(object)__instance.icon != (Object)null || !((Object)((Component)__instance).gameObject).name.StartsWith("Item Carved Pumpkin", StringComparison.Ordinal))
			{
				return;
			}
			SemiIconMaker val = ((Component)__instance).GetComponentInChildren<SemiIconMaker>(true);
			if ((Object)(object)val == (Object)null)
			{
				GameObject val2 = new GameObject("Stronghold Pumpkin Icon Maker");
				val2.transform.SetParent(((Component)__instance).transform, false);
				val = val2.AddComponent<SemiIconMaker>();
			}
			Bounds? val3 = CalculateRenderableBounds(((Component)__instance).transform);
			if (!val3.HasValue)
			{
				Plugin.Log.LogError((object)"Carved Pumpkin icon repair could not find a renderable mesh.");
				return;
			}
			Camera val4 = val.iconCamera;
			if ((Object)(object)val4 == (Object)null)
			{
				GameObject val5 = new GameObject("Icon Camera");
				val5.transform.SetParent(((Component)val).transform, false);
				val4 = (val.iconCamera = val5.AddComponent<Camera>());
			}
			((Component)val4).transform.SetParent(((Component)val).transform, false);
			val4.orthographic = true;
			val4.clearFlags = (CameraClearFlags)2;
			val4.backgroundColor = new Color(0f, 0f, 0f, 0f);
			val4.cullingMask = -1;
			val4.nearClipPlane = 0.01f;
			val4.farClipPlane = 100f;
			Transform transform = ((Component)__instance).transform;
			Bounds value = val3.Value;
			Vector3 val6 = transform.InverseTransformPoint(((Bounds)(ref value)).center);
			value = val3.Value;
			Vector3 size = ((Bounds)(ref value)).size;
			((Component)val4).transform.localPosition = val6 + Vector3.back * (Mathf.Max(new float[3] { size.x, size.y, size.z }) + 1f);
			((Component)val4).transform.localRotation = Quaternion.identity;
			val4.orthographicSize = Mathf.Max(new float[3]
			{
				size.y * 0.6f,
				size.x * 0.6f,
				0.5f
			});
			if ((Object)(object)val.renderTexture == (Object)null)
			{
				val.renderTexture = new RenderTexture(256, 256, 16, (RenderTextureFormat)0)
				{
					name = "Stronghold Pumpkin Icon RenderTexture"
				};
			}
			val.ambientLight = Color.white;
			val.iconCameraPlacementDone = true;
			((Component)val).gameObject.SetActive(false);
			Plugin.Log.LogInfo((object)"Repaired the Carved Pumpkin inventory icon renderer.");
		}

		private static Bounds? CalculateRenderableBounds(Transform root)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			Bounds value = default(Bounds);
			Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!(val is ParticleSystemRenderer) && !((Object)((Component)val).gameObject).name.Contains("Icon", StringComparison.Ordinal))
				{
					if (!flag)
					{
						value = val.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref value)).Encapsulate(val.bounds);
					}
				}
			}
			if (!flag)
			{
				return null;
			}
			return value;
		}
	}
	[HarmonyPatch(typeof(AudioSource), "Play", new Type[] { })]
	internal static class StrongholdEmptyAudioPatch
	{
		private static bool Prefix(AudioSource __instance)
		{
			if (Plugin.IsStrongholdLevel())
			{
				return (Object)(object)__instance.clip != (Object)null;
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal static class StrongholdJukeboxMixerPatch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			Type type = AccessTools.TypeByName("REPOLib.Extensions.AudioSourceExtensions");
			MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "FixAudioMixerGroup", new Type[1] { typeof(AudioSource) }, (Type[])null));
			MethodInfo sourceAndObject = ((type == null) ? null : AccessTools.Method(type, "FixAudioMixerGroup", new Type[2]
			{
				typeof(AudioSource),
				typeof(GameObject)
			}, (Type[])null));
			if (methodInfo != null)
			{
				yield return methodInfo;
			}
			if (sourceAndObject != null)
			{
				yield return sourceAndObject;
			}
		}

		private static bool Prefix(AudioSource __0)
		{
			if ((Object)(object)__0.outputAudioMixerGroup != (Object)null || !IsLegacyJukeboxAudio(__0))
			{
				return true;
			}
			AudioSource[] array = Resources.FindObjectsOfTypeAll<AudioSource>();
			foreach (AudioSource val in array)
			{
				if ((Object)(object)val.outputAudioMixerGroup != (Object)null && ((Object)val.outputAudioMixerGroup).name == "Sound Effects")
				{
					__0.outputAudioMixerGroup = val.outputAudioMixerGroup;
					return false;
				}
			}
			return true;
		}

		private static bool IsLegacyJukeboxAudio(AudioSource source)
		{
			Transform val = ((Component)source).transform;
			while ((Object)(object)val != (Object)null)
			{
				if (((Object)val).name == "Valuable Jukebox 13" || ((Object)val).name == "Valuable Jukebox Cat" || ((Object)val).name == "Valuable Jukebox OS")
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}
	}
}