Decompiled source of CoughingBaby v1.1.0

plugins/CoughingBaby/bitmotte.CoughingBaby.dll

Decompiled 12 hours ago
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.AddressableAssets;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("bitmotte.CoughingBaby")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+17aa5289ccbf186c28d398761d52b7a390bb2d56")]
[assembly: AssemblyProduct("CoughingBaby")]
[assembly: AssemblyTitle("bitmotte.CoughingBaby")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 CoughingBaby
{
	[BepInPlugin("bitmotte.CoughingBaby", "CoughingBaby", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static string sceneName;

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin bitmotte.CoughingBaby is loaded!");
			Harmony val = new Harmony("bitmotte.CoughingBaby");
			val.PatchAll();
			Replace.Global();
			SceneManager.sceneLoaded += OnSceneLoad;
		}

		private void OnSceneLoad(Scene scene, LoadSceneMode mode)
		{
			sceneName = ((Scene)(ref scene)).name;
		}
	}
	internal class RandomRotation : MonoBehaviour
	{
		private void Awake()
		{
			SlowUpdate();
		}

		private void SlowUpdate()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).Invoke("SlowUpdate", 0.5f);
			((Component)this).transform.rotation = new Quaternion(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f));
		}
	}
	public static class Replace
	{
		public struct MatchedReplacement
		{
			public Transform replacer;

			public Transform match;

			public bool isExactMatch;

			public MatchedReplacement(Transform replacer, Transform match)
			{
				isExactMatch = false;
				this.replacer = replacer;
				this.match = match;
			}
		}

		public static void Global()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			AssetBundle val = BundleTool.Load("baby.bundle");
			string text = "Assets/Materials/Environment/Paintings/045.mat";
			Material val2 = Addressables.LoadAssetAsync<Material>((object)text).WaitForCompletion();
			val2.mainTexture = val.LoadAsset<Texture>("Assets/045.png");
			string text2 = "Assets/Materials/Environment/Paintings/101.mat";
			Material val3 = Addressables.LoadAssetAsync<Material>((object)text2).WaitForCompletion();
			val3.mainTexture = val.LoadAsset<Texture>("Assets/101.png");
			string text3 = "Assets/Materials/Environment/Paintings/118.mat";
			Material val4 = Addressables.LoadAssetAsync<Material>((object)text3).WaitForCompletion();
			val4.mainTexture = val.LoadAsset<Texture>("Assets/118.png");
			string text4 = "Assets/Materials/Environment/Paintings/161.mat";
			Material val5 = Addressables.LoadAssetAsync<Material>((object)text4).WaitForCompletion();
			val5.mainTexture = val.LoadAsset<Texture>("Assets/161.png");
			string text5 = "Assets/Materials/Environment/Paintings/166.mat";
			Material val6 = Addressables.LoadAssetAsync<Material>((object)text5).WaitForCompletion();
			val6.mainTexture = val.LoadAsset<Texture>("Assets/166.png");
			string text6 = "Assets/Materials/Environment/Paintings/203.mat";
			Material val7 = Addressables.LoadAssetAsync<Material>((object)text6).WaitForCompletion();
			val7.mainTexture = val.LoadAsset<Texture>("Assets/203.png");
			string text7 = "Assets/Materials/Environment/Paintings/208.mat";
			Material val8 = Addressables.LoadAssetAsync<Material>((object)text7).WaitForCompletion();
			val8.mainTexture = val.LoadAsset<Texture>("Assets/208.png");
			string text8 = "Assets/Materials/Environment/Paintings/209.mat";
			Material val9 = Addressables.LoadAssetAsync<Material>((object)text8).WaitForCompletion();
			val9.mainTexture = val.LoadAsset<Texture>("Assets/209.png");
			string text9 = "Assets/Materials/Environment/Paintings/210.mat";
			Material val10 = Addressables.LoadAssetAsync<Material>((object)text9).WaitForCompletion();
			val10.mainTexture = val.LoadAsset<Texture>("Assets/210.png");
			string text10 = "Assets/Materials/Environment/Paintings/223.mat";
			Material val11 = Addressables.LoadAssetAsync<Material>((object)text10).WaitForCompletion();
			val11.mainTexture = val.LoadAsset<Texture>("Assets/223.png");
			string text11 = "Assets/Materials/Environment/Paintings/226.mat";
			Material val12 = Addressables.LoadAssetAsync<Material>((object)text11).WaitForCompletion();
			val12.mainTexture = val.LoadAsset<Texture>("Assets/226.png");
			string text12 = "Assets/Materials/Environment/Paintings/285.mat";
			Material val13 = Addressables.LoadAssetAsync<Material>((object)text12).WaitForCompletion();
			val13.mainTexture = val.LoadAsset<Texture>("Assets/285.png");
			string text13 = "Assets/Materials/Environment/Paintings/286.mat";
			Material val14 = Addressables.LoadAssetAsync<Material>((object)text13).WaitForCompletion();
			val14.mainTexture = val.LoadAsset<Texture>("Assets/286.png");
			string text14 = "Assets/Materials/Environment/Paintings/287.mat";
			Material val15 = Addressables.LoadAssetAsync<Material>((object)text14).WaitForCompletion();
			val15.mainTexture = val.LoadAsset<Texture>("Assets/287.png");
			string text15 = "Assets/Models/Objects/Apartment/ArchangelNamePlateMichael.mat";
			Material val16 = Addressables.LoadAssetAsync<Material>((object)text15).WaitForCompletion();
			val16.mainTexture = val.LoadAsset<Texture>("Assets/ArchangelNamePlateMichael_png.png");
			string text16 = "Assets/Models/Objects/Apartment/ArchangelNamePlateRaphael.mat";
			Material val17 = Addressables.LoadAssetAsync<Material>((object)text16).WaitForCompletion();
			val17.mainTexture = val.LoadAsset<Texture>("Assets/ArchangelNamePlateRaphael_png.png");
			string text17 = "Assets/Models/Objects/Apartment/ArchangelNamePlateGabriel.mat";
			Material val18 = Addressables.LoadAssetAsync<Material>((object)text17).WaitForCompletion();
			val18.mainTexture = val.LoadAsset<Texture>("Assets/ArchangelNamePlateGabriel_png.png");
			string text18 = "Assets/Models/Objects/Apartment/ArchangelNamePlatePhanuel.mat";
			Material val19 = Addressables.LoadAssetAsync<Material>((object)text18).WaitForCompletion();
			val19.mainTexture = val.LoadAsset<Texture>("Assets/ArchangelNamePlatePhanuel_png.png");
			string text19 = "Assets/Materials/Environment/Layer 8/Supermarket/Ad_Clothes.mat";
			string text20 = "Assets/Materials/Environment/Layer 8/Supermarket/Ad_Clothes NoFog.mat";
			Material val20 = Addressables.LoadAssetAsync<Material>((object)text19).WaitForCompletion();
			Material val21 = Addressables.LoadAssetAsync<Material>((object)text20).WaitForCompletion();
			val20.mainTexture = val.LoadAsset<Texture>("Assets/ad_clothes 1.png");
			val21.mainTexture = val.LoadAsset<Texture>("Assets/ad_clothes 1.png");
			string text21 = "Assets/Materials/Environment/Layer 8/Supermarket/Ad_Fox.mat";
			string text22 = "Assets/Materials/Environment/Layer 8/Supermarket/Ad_Fox NoFog.mat";
			Material val22 = Addressables.LoadAssetAsync<Material>((object)text21).WaitForCompletion();
			Material val23 = Addressables.LoadAssetAsync<Material>((object)text22).WaitForCompletion();
			val22.mainTexture = val.LoadAsset<Texture>("Assets/ad_fox 1.png");
			val23.mainTexture = val.LoadAsset<Texture>("Assets/ad_fox 1.png");
			string text23 = "Assets/Materials/Environment/Layer 8/Supermarket/Ad_Wing.mat";
			string text24 = "Assets/Materials/Environment/Layer 8/Supermarket/Ad_Wing NoFog.mat";
			Material val24 = Addressables.LoadAssetAsync<Material>((object)text23).WaitForCompletion();
			Material val25 = Addressables.LoadAssetAsync<Material>((object)text24).WaitForCompletion();
			val24.mainTexture = val.LoadAsset<Texture>("Assets/ad_wing 1.png");
			val25.mainTexture = val.LoadAsset<Texture>("Assets/ad_wing 1.png");
			string text25 = "Assets/Materials/Environment/Paintings/CityoftheDeadSunPoster.mat";
			Material val26 = Addressables.LoadAssetAsync<Material>((object)text25).WaitForCompletion();
			val26.mainTexture = val.LoadAsset<Texture>("Assets/CityoftheDeadSunPoster.png");
			val.Unload(false);
		}

		public static void HurtbreakWonderland()
		{
			AssetBundle val = BundleTool.Load("baby.bundle");
			GameObject val2 = val.LoadAsset<GameObject>("Assets/ManualReplace/8_1/8_1.prefab");
			SceneReplaceFromPrefab(val2.transform);
			val.Unload(false);
		}

		public static void ThroughTheMirror()
		{
			AssetBundle val = BundleTool.Load("baby.bundle");
			GameObject val2 = val.LoadAsset<GameObject>("Assets/ManualReplace/8_2/8_2.prefab");
			SceneReplaceFromPrefab(val2.transform);
			GameObject val3 = val.LoadAsset<GameObject>("Assets/ManualReplace/8_2/8_2_add.prefab");
			SceneAddFromPrefab(val3.transform);
			val.Unload(false);
		}

		public static void DisintegrationLoop()
		{
			AssetBundle val = BundleTool.Load("baby.bundle");
			GameObject val2 = val.LoadAsset<GameObject>("Assets/ManualReplace/8_3/8_3.prefab");
			SceneReplaceFromPrefab(val2.transform);
			GameObject val3 = val.LoadAsset<GameObject>("Assets/ManualReplace/8_3/8_3_add.prefab");
			SceneAddFromPrefab(val3.transform);
			val.Unload(false);
		}

		public static void SceneReplaceFromPrefab(Transform reference)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)"replacing");
			Scene activeScene = SceneManager.GetActiveScene();
			List<GameObject> list = new List<GameObject>();
			((Scene)(ref activeScene)).GetRootGameObjects(list);
			Transform[] array = Array.Empty<Transform>();
			foreach (GameObject item in list)
			{
				Transform[] array2 = array;
				int num = 0;
				Transform[] array3 = (Transform[])(object)new Transform[1 + array2.Length];
				ReadOnlySpan<Transform> readOnlySpan = new ReadOnlySpan<Transform>(array2);
				readOnlySpan.CopyTo(new Span<Transform>(array3).Slice(num, readOnlySpan.Length));
				num += readOnlySpan.Length;
				array3[num] = item.transform;
				array = array3;
			}
			MatchedReplacement[] array4 = ReplaceTools.FindMatchesInChildrenRecursive(ReplaceTools.GetChildren(reference), array);
			MatchedReplacement[] array5 = Array.Empty<MatchedReplacement>();
			MatchedReplacement[] array6 = array4;
			for (int i = 0; i < array6.Length; i++)
			{
				MatchedReplacement matchedReplacement = array6[i];
				if (matchedReplacement.isExactMatch)
				{
					MatchedReplacement[] array7 = array5;
					int num = 0;
					MatchedReplacement[] array8 = new MatchedReplacement[1 + array7.Length];
					ReadOnlySpan<MatchedReplacement> readOnlySpan2 = new ReadOnlySpan<MatchedReplacement>(array7);
					readOnlySpan2.CopyTo(new Span<MatchedReplacement>(array8).Slice(num, readOnlySpan2.Length));
					num += readOnlySpan2.Length;
					array8[num] = matchedReplacement;
					array5 = array8;
				}
			}
			MatchedReplacement[] array9 = array5;
			for (int j = 0; j < array9.Length; j++)
			{
				MatchedReplacement matchedReplacement2 = array9[j];
				GameObject val = Object.Instantiate<GameObject>(((Component)matchedReplacement2.replacer).gameObject);
				val.transform.parent = matchedReplacement2.match.parent;
				val.transform.position = matchedReplacement2.match.position;
				val.transform.rotation = matchedReplacement2.match.rotation;
				string name = ((Object)matchedReplacement2.match).name;
				if (name == "PlanetSphere" || name == "Eyeball" || name == "Eyeball (1)")
				{
					GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
					((Renderer)gameObject.GetComponent<MeshRenderer>()).material.shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Dev/FadeToWhite.mat").WaitForCompletion().shader;
					gameObject.AddComponent<RandomRotation>();
				}
				else
				{
					SetupResource.FixShader(val);
				}
				Object.Destroy((Object)(object)((Component)matchedReplacement2.match).gameObject);
			}
		}

		public static void SceneAddFromPrefab(Transform reference)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)"adding");
			Scene activeScene = SceneManager.GetActiveScene();
			List<GameObject> list = new List<GameObject>();
			((Scene)(ref activeScene)).GetRootGameObjects(list);
			Transform[] array = Array.Empty<Transform>();
			foreach (GameObject item in list)
			{
				Transform[] array2 = array;
				int num = 0;
				Transform[] array3 = (Transform[])(object)new Transform[1 + array2.Length];
				ReadOnlySpan<Transform> readOnlySpan = new ReadOnlySpan<Transform>(array2);
				readOnlySpan.CopyTo(new Span<Transform>(array3).Slice(num, readOnlySpan.Length));
				num += readOnlySpan.Length;
				array3[num] = item.transform;
				array = array3;
			}
			MatchedReplacement[] array4 = ReplaceTools.FindMatchesInChildrenRecursive(ReplaceTools.GetChildren(reference), array);
			MatchedReplacement[] array5 = Array.Empty<MatchedReplacement>();
			MatchedReplacement[] array6 = array4;
			for (int i = 0; i < array6.Length; i++)
			{
				MatchedReplacement matchedReplacement = array6[i];
				if (matchedReplacement.isExactMatch)
				{
					MatchedReplacement[] array7 = array5;
					int num = 0;
					MatchedReplacement[] array8 = new MatchedReplacement[1 + array7.Length];
					ReadOnlySpan<MatchedReplacement> readOnlySpan2 = new ReadOnlySpan<MatchedReplacement>(array7);
					readOnlySpan2.CopyTo(new Span<MatchedReplacement>(array8).Slice(num, readOnlySpan2.Length));
					num += readOnlySpan2.Length;
					array8[num] = matchedReplacement;
					array5 = array8;
				}
			}
			MatchedReplacement[] array9 = array5;
			for (int j = 0; j < array9.Length; j++)
			{
				MatchedReplacement matchedReplacement2 = array9[j];
				Transform[] children = ReplaceTools.GetChildren(matchedReplacement2.replacer);
				Transform[] array10 = children;
				foreach (Transform val in array10)
				{
					GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject);
					Vector3 position = val2.transform.position;
					val2.transform.parent = matchedReplacement2.match;
					val2.transform.position = position;
					if (((Object)val2).name.Contains("Baby"))
					{
						GameObject gameObject = val2.gameObject;
						((Renderer)gameObject.GetComponent<MeshRenderer>()).material.shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Dev/FadeToWhite.mat").WaitForCompletion().shader;
						gameObject.AddComponent<RandomRotation>();
					}
					else
					{
						SetupResource.FixShader(val2);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(HellMap), "Start")]
	internal class SpecificPatch
	{
		private static void Postfix()
		{
			if (Plugin.sceneName == "ab5460c767500b748a7f5497682ffc63")
			{
				Replace.HurtbreakWonderland();
			}
			if (Plugin.sceneName == "45addc6c3730dae418321e00af1116c5")
			{
				Replace.ThroughTheMirror();
			}
			if (Plugin.sceneName == "4d0787cb97dbde141b6957720788c4dd")
			{
				Replace.DisintegrationLoop();
			}
		}
	}
	public static class BundleTool
	{
		public static AssetBundle Load(string fileName)
		{
			return AssetBundle.LoadFromMemory(EmbeddedAccess.AccessFile(fileName));
		}
	}
	public static class EmbeddedAccess
	{
		public static byte[] AccessFile(string fileName)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			byte[] array;
			using (Stream stream = executingAssembly.GetManifestResourceStream("CoughingBaby.resources." + fileName))
			{
				if (stream == null)
				{
					return null;
				}
				array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
			}
			return array;
		}
	}
	public static class ReplaceTools
	{
		public static void ReplaceMatTexOnObject(GameObject gameObject, AssetBundle bundleToLoadFrom, string pathInBundle)
		{
			Renderer componentInChildren = gameObject.GetComponentInChildren<Renderer>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				componentInChildren.material.mainTexture = bundleToLoadFrom.LoadAsset<Texture>(pathInBundle);
			}
		}

		public static void ReplaceMatTexOnObject(Transform gameObject, AssetBundle bundleToLoadFrom, string pathInBundle)
		{
			Renderer componentInChildren = ((Component)gameObject).GetComponentInChildren<Renderer>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				componentInChildren.material.mainTexture = bundleToLoadFrom.LoadAsset<Texture>(pathInBundle);
			}
		}

		public static Transform[] GetChildren(Transform gameObject)
		{
			Transform[] array = Array.Empty<Transform>();
			for (int i = 0; i < gameObject.childCount; i++)
			{
				Transform[] array2 = array;
				int num = 0;
				Transform[] array3 = (Transform[])(object)new Transform[1 + array2.Length];
				ReadOnlySpan<Transform> readOnlySpan = new ReadOnlySpan<Transform>(array2);
				readOnlySpan.CopyTo(new Span<Transform>(array3).Slice(num, readOnlySpan.Length));
				num += readOnlySpan.Length;
				array3[num] = gameObject.GetChild(i);
				array = array3;
			}
			return array;
		}

		public static Replace.MatchedReplacement[] FindMatchesInChildrenRecursive(Transform[] rootReplacements, Transform[] rootTarget)
		{
			Replace.MatchedReplacement[] array = Array.Empty<Replace.MatchedReplacement>();
			foreach (Transform val in rootTarget)
			{
				foreach (Transform val2 in rootReplacements)
				{
					if (((Object)val).name == ((Object)val2).name)
					{
						Plugin.Logger.LogInfo((object)(((Object)val).name + " = " + ((Object)val2).name));
						Replace.MatchedReplacement matchedReplacement = new Replace.MatchedReplacement(val2, val);
						Replace.MatchedReplacement[] array2;
						Replace.MatchedReplacement[] array3;
						ReadOnlySpan<Replace.MatchedReplacement> readOnlySpan;
						int num;
						if (((Component)matchedReplacement.replacer).CompareTag("Spider"))
						{
							matchedReplacement.isExactMatch = true;
							array2 = array;
							num = 0;
							array3 = new Replace.MatchedReplacement[1 + array2.Length];
							readOnlySpan = new ReadOnlySpan<Replace.MatchedReplacement>(array2);
							readOnlySpan.CopyTo(new Span<Replace.MatchedReplacement>(array3).Slice(num, readOnlySpan.Length));
							num += readOnlySpan.Length;
							array3[num] = matchedReplacement;
							array = array3;
							continue;
						}
						array3 = array;
						num = 0;
						array2 = new Replace.MatchedReplacement[1 + array3.Length];
						readOnlySpan = new ReadOnlySpan<Replace.MatchedReplacement>(array3);
						readOnlySpan.CopyTo(new Span<Replace.MatchedReplacement>(array2).Slice(num, readOnlySpan.Length));
						num += readOnlySpan.Length;
						array2[num] = matchedReplacement;
						array = array2;
						array2 = array;
						array3 = FindMatchesInChildrenRecursive(GetChildren(matchedReplacement.replacer), GetChildren(matchedReplacement.match));
						num = 0;
						Replace.MatchedReplacement[] array4 = new Replace.MatchedReplacement[array2.Length + array3.Length];
						readOnlySpan = new ReadOnlySpan<Replace.MatchedReplacement>(array2);
						readOnlySpan.CopyTo(new Span<Replace.MatchedReplacement>(array4).Slice(num, readOnlySpan.Length));
						num += readOnlySpan.Length;
						ReadOnlySpan<Replace.MatchedReplacement> readOnlySpan2 = new ReadOnlySpan<Replace.MatchedReplacement>(array3);
						readOnlySpan2.CopyTo(new Span<Replace.MatchedReplacement>(array4).Slice(num, readOnlySpan2.Length));
						num += readOnlySpan2.Length;
						array = array4;
					}
					else
					{
						Plugin.Logger.LogInfo((object)(((Object)val).name + " != " + ((Object)val2).name));
					}
				}
			}
			return array;
		}
	}
	public static class SetupResource
	{
		public static GameObject FixShader(GameObject gameObject)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Shader shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Environment/Metal/Pattern 1/Metal Pattern 1 8.mat").WaitForCompletion().shader;
			SkinnedMeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				Material[] materials = ((Renderer)val).materials;
				foreach (Material val2 in materials)
				{
					val2.shader = shader;
				}
			}
			MeshRenderer[] componentsInChildren2 = gameObject.GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val3 in componentsInChildren2)
			{
				Material[] materials2 = ((Renderer)val3).materials;
				foreach (Material val4 in materials2)
				{
					val4.shader = shader;
				}
			}
			return gameObject;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "bitmotte.CoughingBaby";

		public const string PLUGIN_NAME = "CoughingBaby";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}