Decompiled source of VSModFlowermanToDeliriaSomnia v1.0.1

FlowermanToDeliriaSomnia.dll

Decompiled 10 months ago
using System;
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;

[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("FlowermanToDeliriaSomnia")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("FlowermanToDeliriaSomnia")]
[assembly: AssemblyTitle("FlowermanToDeliriaSomnia")]
[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 LethalCompanyTemplate
{
	[HarmonyPatch(typeof(FlowermanAI), "Start")]
	public class BrackenPatch
	{
		private static void Postfix(FlowermanAI __instance)
		{
			Plugin.Instance.Log.LogInfo((object)"Flowerman Spawned");
			Transform val = ((Component)__instance).transform.Find("FlowermanModel");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Instance.Log.LogInfo((object)"Could not find model");
				return;
			}
			SkinnedMeshRenderer component = ((Component)val.Find("LOD1")).GetComponent<SkinnedMeshRenderer>();
			LogIfNull<SkinnedMeshRenderer>("skinnedMeshRenderer", component);
			((Renderer)component).enabled = false;
			Renderer[] componentsInChildren = ((Component)component).gameObject.GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			Transform val2 = val.Find("AnimContainer/metarig");
			LogIfNull<Transform>("flowermanRig", val2);
			componentsInChildren = ((Component)val2).gameObject.GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			GameObject obj = Object.Instantiate<GameObject>(Plugin.Instance.Assets.VTuberModel, val);
			Transform val3 = obj.transform.Find("Target/Container/metarig");
			LogIfNull<Transform>("newRig", val3);
			((Object)val2).name = "old-metarig";
			val3.SetParent(val2.parent, true);
			SkinnedMeshRenderer component2 = ((Component)obj.transform.Find("vtuber")).GetComponent<SkinnedMeshRenderer>();
			LogIfNull<SkinnedMeshRenderer>("newSkinnedRenderer", component2);
			component2.rootBone = val3;
			__instance.rightHandGrip = val3.Find("Torso1/Torso2/Torso3/Arm1.R/Arm2.R/Arm3.R/Hand1.R/HandGripPosition");
		}

		private static void LogIfNull<T>(string name, T toTest)
		{
			Plugin.Instance.Log.LogInfo((object)$"{name} is null: {toTest == null}");
		}
	}
	[BepInPlugin("0123456789ABCDEF-FlowermanToDeliriaSomnia", "FlowermanToDeliriaSomnia", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance { get; private set; }

		public PluginAssets Assets { get; private set; }

		public ManualLogSource Log => ((BaseUnityPlugin)this).Logger;

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				return;
			}
			Instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin FlowermanToDeliriaSomnia is loaded!");
			Assets = new PluginAssets(((BaseUnityPlugin)this).Logger);
			if (!Assets.TryLoadAssets())
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Aborting");
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded bundle, unbundling...");
			if (!Assets.TryRegisterAssets())
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Aborting");
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Unbundled, patching...");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}
	public class PluginAssets
	{
		public GameObject VTuberModel;

		public AudioClip OnKill;

		public AudioClip OnAgro;

		private const string ASSET_BUNDLE_FILE_NAME = "FlowermanToDeliriaSomnia.bundle";

		private AssetBundle _PluginAssetBundle;

		private ManualLogSource _Logger;

		public PluginAssets(ManualLogSource logger)
		{
			_Logger = logger;
		}

		public bool TryLoadAssets()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "FlowermanToDeliriaSomnia.bundle");
			_Logger.LogInfo((object)"Trying to load assets from file");
			_Logger.LogInfo((object)text);
			_PluginAssetBundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)_PluginAssetBundle == (Object)null)
			{
				_Logger.LogError((object)"Could not load assets from file.");
				return false;
			}
			return true;
		}

		internal bool TryRegisterAssets()
		{
			if (LoadAndCheckIfNull<GameObject>("Assets/Model 2.prefab", ref VTuberModel))
			{
				return false;
			}
			return true;
		}

		private bool LoadAndCheckIfNull<T>(string path, ref T loadTarget) where T : Object
		{
			loadTarget = _PluginAssetBundle.LoadAsset<T>(path);
			if ((Object)(object)loadTarget == (Object)null)
			{
				_Logger.LogError((object)("Couldn't unbundle asset '" + path + "' from bundle"));
			}
			return (Object)(object)loadTarget == (Object)null;
		}
	}
	public static class PluginData
	{
		public const string PLUGIN_GUID = "0123456789ABCDEF-FlowermanToDeliriaSomnia";

		public const string PLUGIN_NAME = "FlowermanToDeliriaSomnia";

		public const string PLUGIN_VERS = "0.0.1";
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FlowermanToDeliriaSomnia";

		public const string PLUGIN_NAME = "FlowermanToDeliriaSomnia";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}