Decompiled source of LC Peorb v1.0.1

BepInEx/plugins/LC-Peorb.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LC_Peorb;
using MoreCompany;
using MoreCompany.Utils;
using PeoBase.Patches;
using UnityEngine;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LC-Peorb")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LC-Peorb")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f7da2287-355b-47a7-a5d0-63353e263f78")]
[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 LC_Peorb
{
	[BepInPlugin("Ferno.LCPeorb", "LCPeorb", "1.0.0")]
	public class PeoBase : BaseUnityPlugin
	{
		private const string modGUID = "Ferno.LCPeorb";

		private const string modName = "LCPeorb";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Ferno.LCPeorb");

		private static PeoBase Instance;

		public static ManualLogSource mls;

		public static AudioClip angerVoice;

		public static AudioClip neckSnap;

		public static GameObject peorb;

		public static VideoClip peovid;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Ferno.LCPeorb");
			mls.LogInfo((object)"Peorb loaded.");
			LoadAssets(BundleUtilities.LoadBundleFromInternalAssembly("lc-peoorb.assets", Assembly.GetExecutingAssembly()));
			SkinnedMeshRenderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Component)componentsInChildren[i]).gameObject.layer = LayerMask.NameToLayer("Enemies");
			}
			harmony.PatchAll(typeof(PeoBase));
			harmony.PatchAll(typeof(EnemyTypes));
			harmony.PatchAll(typeof(TerminalPatches));
		}

		private static void LoadAssets(AssetBundle bundle)
		{
			if (Object.op_Implicit((Object)(object)bundle))
			{
				angerVoice = AssetBundleExtension.LoadPersistentAsset<AudioClip>(bundle, "Assets/CutePeoBGM.mp3");
				neckSnap = AssetBundleExtension.LoadPersistentAsset<AudioClip>(bundle, "Assets/YOUDEAD.mp3");
				peorb = AssetBundleExtension.LoadPersistentAsset<GameObject>(bundle, "Assets/peoorb.prefab");
				peovid = AssetBundleExtension.LoadPersistentAsset<VideoClip>(bundle, "Assets/peorb1.mp4");
				MainClass.StaticLogger.LogInfo((object)("Loaded: " + ((Object)bundle).name));
				bundle.Unload(false);
			}
		}
	}
}
namespace PeoBase.Patches
{
	[HarmonyPatch]
	internal class EnemyTypes
	{
		[HarmonyPatch(typeof(FlowermanAI), "Start")]
		[HarmonyPostfix]
		public static void SummonRemi(FlowermanAI __instance)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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)
			if ((Object)(object)LC_Peorb.PeoBase.peorb == (Object)null)
			{
				return;
			}
			Transform val = ((Component)__instance).transform.Find("FlowermanModel");
			object obj;
			if (val == null)
			{
				obj = null;
			}
			else
			{
				Transform obj2 = val.Find("LOD1");
				obj = ((obj2 != null) ? ((Component)obj2).GetComponent<SkinnedMeshRenderer>() : null);
			}
			SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)obj;
			object obj3;
			if (val == null)
			{
				obj3 = null;
			}
			else
			{
				Transform obj4 = val.Find("AnimContainer");
				obj3 = ((obj4 != null) ? obj4.Find("metarig") : null);
			}
			Transform val3 = (Transform)obj3;
			if (!((Object)(object)val2 == (Object)null) && ((Renderer)val2).enabled)
			{
				((Renderer)val2).enabled = false;
				Renderer[] componentsInChildren = ((Component)val3).gameObject.GetComponentsInChildren<Renderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].enabled = false;
				}
				GameObject obj5 = Object.Instantiate<GameObject>(LC_Peorb.PeoBase.peorb);
				obj5.transform.SetParent(val);
				obj5.transform.localPosition = Vector3.zero;
				obj5.transform.localRotation = Quaternion.identity;
				obj5.transform.localScale = Vector3.one;
				__instance.crackNeckSFX = LC_Peorb.PeoBase.neckSnap;
				__instance.creatureAngerVoice.clip = LC_Peorb.PeoBase.angerVoice;
			}
		}
	}
	[HarmonyPatch]
	internal class TerminalPatches
	{
		[HarmonyPatch(typeof(Terminal), "Awake")]
		[HarmonyPostfix]
		public static void EditTerminal(Terminal __instance)
		{
			__instance.enemyFiles[1].displayVideo = LC_Peorb.PeoBase.peovid;
		}
	}
}