Decompiled source of Hatsune Miku Scrybe v1.0.1

leshy_gone.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using UnityEngine;

[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.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("leshy_gone")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("where is leshy?")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("leshy_gone")]
[assembly: AssemblyTitle("leshy_gone")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace leshy_gone
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "leshy_gone";

		public const string PLUGIN_NAME = "leshy_gone";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MyFirstPlugin
{
	[BepInPlugin("org.lily.inscryption.leshy_gone", "Leshy gone", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal class Tools
		{
			private static Assembly _assembly;

			public static Assembly CurrentAssembly => _assembly ?? (_assembly = Assembly.GetExecutingAssembly());
		}

		internal static ManualLogSource Log;

		private const string PluginVersion = "1.0.0";

		public static string Directory;

		public static AssetBundle assetBundle;

		public static List<AudioClip> addedSfx = new List<AudioClip>();

		public static Texture2D raccoon;

		public static Sprite raccoonSprite;

		public static List<Face> P03ReplacedFaces = new List<Face>
		{
			(Face)3,
			(Face)11,
			(Face)5,
			(Face)14,
			(Face)36,
			(Face)0,
			(Face)38,
			(Face)35,
			(Face)37,
			(Face)4,
			(Face)44,
			(Face)25,
			(Face)21,
			(Face)23,
			(Face)49,
			(Face)45,
			(Face)46,
			(Face)47,
			(Face)48,
			(Face)12,
			(Face)13,
			(Face)26,
			(Face)24,
			(Face)15,
			(Face)32,
			(Face)1,
			(Face)6
		};

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded leshy gone mod! - Made by Lily");
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("org.lily.inscryption.leshy_gone");
			val.PatchAll();
			raccoon = GetTexture("ScrybeImage.png");
			raccoonSprite = Sprite.Create(raccoon, new Rect(0f, 0f, (float)((Texture)raccoon).width, (float)((Texture)raccoon).height), new Vector2(0.5f, 0.5f));
			bool flag = false;
			int num = 0;
			while (!flag)
			{
				num++;
				string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Sounds/", $"ScrybeSound{num}.wav");
				if (File.Exists(path))
				{
					((MonoBehaviour)this).StartCoroutine(LoadSongCoroutine(path, $"ScrybeSound{num}"));
				}
				else
				{
					flag = true;
				}
			}
		}

		private void Update()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			if (SaveManager.SaveFile.IsPart1)
			{
				GameObject val = GameObject.Find("Head");
				if ((Object)(object)val != (Object)null && (Object)(object)GameObject.Find("ImagePlane") == (Object)null)
				{
					val.SetActive(false);
					CreateRaccoonImage();
				}
			}
			else
			{
				GameObject val2 = GameObject.Find("GrimoraAnimController");
				if ((Object)(object)val2 != (Object)null && (Object)(object)GameObject.Find("ImagePlane") == (Object)null)
				{
					val2.transform.position = new Vector3(0f, -100f, 0f);
					CreateRaccoonImage();
				}
			}
			if (SaveManager.SaveFile.IsPart3 && (int)P03AnimationController.Instance.CurrentFace != 16 && P03ReplacedFaces.Contains(P03AnimationController.Instance.CurrentFace))
			{
				GameObject val3 = P03AnimationController.Instance.SwitchToFace((Face)16, true, true);
				val3.GetComponent<SpriteRenderer>().sprite = raccoonSprite;
			}
		}

		public static void CreateRaccoonImage()
		{
			//IL_0029: 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)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)4);
			((Object)val).name = "ImagePlane";
			val.transform.position = new Vector3(0f, 7.75f, 7f);
			val.transform.localScale = new Vector3(-0.6f, 0.8f, -0.6f);
			val.transform.rotation = Quaternion.Euler(-90f, val.transform.rotation.y, val.transform.rotation.z);
			Material val2 = new Material(Shader.Find("Diffuse"));
			val2.mainTexture = (Texture)(object)raccoon;
			val.GetComponent<Renderer>().material = val2;
		}

		public Texture2D GetTexture(string path)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			byte[] array = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Artwork/", path));
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			((Texture)val).filterMode = (FilterMode)0;
			return val;
		}

		private IEnumerator LoadSongCoroutine(string path, string clipName)
		{
			WWW www = new WWW(path);
			yield return www;
			AudioClip audioclip = www.GetAudioClip(false, false);
			((Object)audioclip).name = clipName;
			addedSfx.Add(audioclip);
		}
	}
	[HarmonyPatch]
	public class patches
	{
		[HarmonyPatch(typeof(AudioController), "GetAudioClip")]
		[HarmonyPrefix]
		public static void AddAudios(AudioController __instance, string soundId)
		{
			__instance.SFX.AddRange(Plugin.addedSfx.Where((AudioClip x) => !__instance.SFX.Contains(x)));
		}

		[HarmonyPatch(typeof(AudioController), "GetLoopSource")]
		[HarmonyPrefix]
		public static void AddLoops(AudioController __instance)
		{
			__instance.Loops.AddRange(Plugin.addedSfx.Where((AudioClip x) => !__instance.Loops.Contains(x)));
		}

		[HarmonyPatch(typeof(AudioController), "GetLoop")]
		[HarmonyPrefix]
		public static void AddLoops2(AudioController __instance, ref string loopName)
		{
			__instance.Loops.AddRange(Plugin.addedSfx.Where((AudioClip x) => !__instance.Loops.Contains(x)));
		}

		[HarmonyPatch(typeof(TextDisplayer), "PlayVoiceSound")]
		[HarmonyPrefix]
		public static bool PlayVoiceSound_Prefix(ref TextDisplayer __instance, ref Emotion emotion)
		{
			//IL_0039: 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_003d: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected I4, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			if ((Object)(object)__instance.currentAudio != (Object)null)
			{
				AudioController.Instance.FadeSourceVolume(__instance.currentAudio, 0f, 0.15f, true);
			}
			string text = "voice_calm";
			Emotion val = emotion;
			Emotion val2 = val;
			switch (val2 - 1)
			{
			case 0:
				text = "voice_laughing";
				break;
			case 1:
				text = "voice_frustrated";
				break;
			case 4:
				text = "voice_curious";
				break;
			}
			text = __instance.voiceSoundIdPrefix + text;
			float voiceVolume = __instance.voiceVolume;
			if (__instance.voiceSoundIdPrefix == "" || __instance.voiceSoundIdPrefix == "p03" || __instance.voiceSoundIdPrefix == "grimora")
			{
				Random random = new Random();
				text = $"ScrybeSound{random.Next(1, Plugin.addedSfx.Count + 1)}";
				Plugin.Log.LogInfo((object)text);
			}
			__instance.currentAudio = AudioController.Instance.PlaySound2D(text, (MixerGroup)6, voiceVolume, 0f, (Pitch)null, (Repetition)null, new Randomization(true), (Distortion)null, false);
			if ((Object)(object)__instance.currentAudio != (Object)null)
			{
				__instance.currentAudio.reverbZoneMix = 0f;
			}
			return false;
		}
	}
}