Decompiled source of KorokAntLion v1.0.2

KorokAntLion.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using KorokAntLion.MonoBehaviours;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MakeItCozy")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MakeItCozy")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("77b5b37b-5e69-4a0c-b025-5c3e5936c5a5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace KorokAntLion
{
	[BepInPlugin("com.pauwdah.KorokAntLion", "Pauwdah-KorokAntLion", "1.0.0")]
	public class KorokAntLionPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.pauwdah.KorokAntLion";

		public const string PluginName = "Pauwdah-KorokAntLion";

		private const string VersionString = "1.0.0";

		private static readonly Harmony Harmony = new Harmony("com.pauwdah.KorokAntLion");

		public static ManualLogSource Log = new ManualLogSource("Pauwdah-KorokAntLion");

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: Pauwdah-KorokAntLion, VersionString: 1.0.0 is loading...");
			Harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: Pauwdah-KorokAntLion, VersionString: 1.0.0 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
		}
	}
}
namespace KorokAntLion.Utils
{
	internal static class ModUtils
	{
	}
}
namespace KorokAntLion.Patches
{
	[HarmonyPatch(typeof(Antlion))]
	internal class AntlionPatch
	{
		public static Transform head;

		[HarmonyPatch(typeof(Antlion), "Start")]
		[HarmonyPrefix]
		public static bool Awake_Prefix(Antlion __instance)
		{
			KorokAntLionPlugin.Log.LogInfo((object)"AntlionPatch...");
			Transform child = ((Component)__instance).transform.GetChild(0).GetChild(0);
			SwapShit(child);
			AssingSFX(__instance);
			KorokAntLionPlugin.Log.LogInfo((object)"AntlionPatches ready.");
			return true;
		}

		public static void LoadKorok(Transform head)
		{
			GameObject val = Object.Instantiate<GameObject>(KorokAntLionComponent.korokPrefab);
			((Object)val).name = "HeadMeshKorok";
			val.transform.parent = head;
		}

		public static void SwapShit(Transform head)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(KorokAntLionComponent.korokPrefab);
			((Object)val).name = "HeadMeshKorok";
			val.transform.parent = ((Component)head.Find("HeadMesh")).GetComponent<Transform>();
			val.transform.localPosition = new Vector3(-1.7836f, -0.7944f, -1.0809f);
			val.transform.eulerAngles = new Vector3(0f, 100f, 0f);
			val.transform.localScale = new Vector3(5f, 5f, 5f);
			GameObject val2 = Object.Instantiate<GameObject>(KorokAntLionComponent.masterSwordPrefab);
			((Object)val2).name = "swordR";
			val2.transform.parent = ((Component)head.Find("AntlionPincerR").Find("Mesh")).GetComponent<Transform>();
			val2.transform.localPosition = new Vector3(0f, 0f, 0f);
			val2.transform.eulerAngles = new Vector3(47.911f, 149.9929f, 0f);
			val2.transform.localScale = new Vector3(3f, 3f, 3f);
			((Component)head.Find("HeadMesh")).GetComponent<MeshFilter>().mesh = null;
			((Component)head.Find("AntlionPincerL").Find("Mesh")).GetComponent<MeshFilter>().mesh = null;
			((Component)head.Find("AntlionPincerR").Find("Mesh")).GetComponent<MeshFilter>().mesh = null;
			Object.Destroy((Object)(object)((Component)((Component)head.Find("Jaws?")).GetComponent<Transform>()).gameObject);
		}

		public static void AssingSFX(Antlion __instance)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			Transform val = ((Component)__instance).transform.GetChild(0).GetChild(0).Find("AntlionSFX");
			for (int i = 0; i < val.childCount; i++)
			{
				if (((Object)val.GetChild(i)).name.Contains("AntlionSFX"))
				{
					SFX_Instance val2 = new SFX_Instance();
					((Object)val2).name = "MIC_SFX_Instance";
					val2.clips = MainMenuPatch.custom_antlion_clips;
					((Component)val.GetChild(i)).gameObject.GetComponent<SFX_PlayOneShot>().sfxs = (SFX_Instance[])(object)new SFX_Instance[1] { val2 };
				}
				else if (((Object)val.GetChild(i)).name.Contains("Audio Source"))
				{
					KorokAntLionPlugin.Log.LogInfo((object)("AntlionPatches: Found Audio Source: " + ((Object)val.GetChild(i)).name));
					((Component)val.GetChild(i)).gameObject.GetComponent<AudioSource>().clip = MainMenuPatch.custom_antlion_clips[0];
					KorokAntLionPlugin.Log.LogInfo((object)("AntlionPatches: Assgined new AntlionSFX " + ((Object)val.GetChild(i)).name));
				}
			}
		}

		[HarmonyPatch(typeof(Antlion), "Start")]
		[HarmonyPostfix]
		public static void Awake_Postfix(Antlion __instance)
		{
		}
	}
	[HarmonyPatch(typeof(MainMenu))]
	internal class MainMenuPatch
	{
		public static AudioClip[] custom_antlion_clips;

		[HarmonyPatch(typeof(MainMenu), "Start")]
		[HarmonyPrefix]
		public static bool Awake_Prefix(MainMenu __instance)
		{
			KorokAntLionPlugin.Log.LogInfo((object)"MainMenuPatch...");
			KorokAntLionComponent.LoadAssetBundle();
			LoadAudioClips();
			LoadKorok();
			Greeting();
			KorokAntLionPlugin.Log.LogInfo((object)"MainMenuPatch ready.");
			return true;
		}

		private static void Greeting()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("YAHAHA", new Type[1] { typeof(AudioSource) });
			val.GetComponent<AudioSource>().clip = custom_antlion_clips[0];
			val.transform.SetParent(((Component)MainCamera.instance).transform, false);
			val.transform.localPosition = Vector3.zero;
			val.GetComponent<AudioSource>().Play();
		}

		public static void LoadKorok()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<int, Vector3[]> dictionary = new Dictionary<int, Vector3[]>();
			dictionary.Add(1, (Vector3[])(object)new Vector3[2]
			{
				new Vector3(93.75f, 504.7833f, 839.5175f),
				new Vector3(0f, 180f, 340f)
			});
			dictionary.Add(2, (Vector3[])(object)new Vector3[2]
			{
				new Vector3(93.7517f, 503.7858f, 828.1384f),
				new Vector3(0f, 180f, 340f)
			});
			dictionary.Add(3, (Vector3[])(object)new Vector3[2]
			{
				new Vector3(67.5449f, 496.6694f, 836.6749f),
				new Vector3(355.9379f, 118.7319f, 7.7246f)
			});
			dictionary.Add(4, (Vector3[])(object)new Vector3[2]
			{
				new Vector3(40.9471f, 514.0787f, 858.8271f),
				new Vector3(355.9379f, 118.7319f, 7.7246f)
			});
			dictionary.Add(5, (Vector3[])(object)new Vector3[2]
			{
				new Vector3(50.731f, 501.9291f, 828.1708f),
				new Vector3(355.9379f, 118.7319f, 7.7246f)
			});
			int key = Random.Range(1, 5);
			GameObject val = Object.Instantiate<GameObject>(KorokAntLionComponent.korokPrefab);
			Vector3[] array = dictionary[key];
			((Object)val).name = "Korok";
			val.transform.position = array[0];
			val.transform.eulerAngles = array[1];
			val.transform.localScale = new Vector3(1f, 1f, 1f);
		}

		public static void LoadAudioClips()
		{
			string[] array = new string[1] { "1.ogg" };
			AudioClip val = AudioClip.Create("YAHAHA", 88200, 1, 44100, true);
			custom_antlion_clips = (AudioClip[])(object)new AudioClip[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				string text = Path.Combine(Paths.PluginPath, "Pauwdah-KorokAntLion", array[i]);
				if (File.Exists(text))
				{
					KorokAntLionPlugin.Log.LogInfo((object)"File Exists..");
					UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)14);
					audioClip.SendWebRequest();
					while (!audioClip.isDone)
					{
					}
					val = DownloadHandlerAudioClip.GetContent(audioClip);
					custom_antlion_clips[i] = val;
				}
				else
				{
					KorokAntLionPlugin.Log.LogFatal((object)"File does not exist!");
				}
			}
		}

		[HarmonyPatch(typeof(MainMenu), "Start")]
		[HarmonyPostfix]
		public static void Awake_Postfix(MainMenu __instance)
		{
		}
	}
}
namespace KorokAntLion.MonoBehaviours
{
	internal class KorokAntLionComponent : MonoBehaviour
	{
		public static GameObject korokPrefab;

		public static GameObject masterSwordPrefab;

		public static Shader shader;

		public static void LoadAssetBundle()
		{
			string text = Path.Combine(Paths.PluginPath, "Pauwdah-KorokAntLion");
			KorokAntLionPlugin.Log.LogInfo((object)("MainMenuPatch: " + text));
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(text, "yahaha"));
			if ((Object)(object)val != (Object)null)
			{
				GameObject val2 = val.LoadAsset<GameObject>("Korok");
				if ((Object)(object)val2 == (Object)null)
				{
					KorokAntLionPlugin.Log.LogError((object)"Prefab 'Korok' not found in bundle.");
					string[] allAssetNames = val.GetAllAssetNames();
					foreach (string text2 in allAssetNames)
					{
						KorokAntLionPlugin.Log.LogInfo((object)("Bundle contains: " + text2));
					}
					return;
				}
				GameObject val3 = val.LoadAsset<GameObject>("MasterSword");
				if ((Object)(object)val3 == (Object)null)
				{
					KorokAntLionPlugin.Log.LogError((object)"Prefab 'MasterSword' not found in bundle.");
					string[] allAssetNames2 = val.GetAllAssetNames();
					foreach (string text3 in allAssetNames2)
					{
						KorokAntLionPlugin.Log.LogInfo((object)("Bundle contains: " + text3));
					}
					return;
				}
				shader = Shader.Find("W/Character");
				if ((Object)(object)shader == (Object)null)
				{
					KorokAntLionPlugin.Log.LogError((object)"Foliage shader not found!");
				}
				else
				{
					MeshRenderer component = val2.GetComponent<MeshRenderer>();
					((Renderer)component).materials[0].shader = shader;
					((Renderer)component).materials[1].shader = shader;
					((Renderer)component).materials[2].shader = shader;
					((Renderer)component).materials[0].SetTexture("mainTexture", (Texture)(object)val.LoadAsset<Texture2D>("body.png"));
					((Renderer)component).materials[1].SetTexture("mainTexture", (Texture)(object)val.LoadAsset<Texture2D>("mask.png"));
					((Renderer)component).materials[2].SetTexture("mainTexture", (Texture)(object)val.LoadAsset<Texture2D>("nose.png"));
					MeshRenderer component2 = val3.GetComponent<MeshRenderer>();
					((Renderer)component2).material.shader = shader;
					((Renderer)component2).material.SetTexture("mainTexture", (Texture)(object)val.LoadAsset<Texture2D>("sword_albedo.png"));
				}
				korokPrefab = val2;
				masterSwordPrefab = val3;
			}
			else
			{
				KorokAntLionPlugin.Log.LogError((object)"Failed to load AssetBundle!");
			}
		}

		public void Awake()
		{
		}

		public void Start()
		{
		}

		public void Update()
		{
		}

		public void LateUpdate()
		{
		}
	}
}