Decompiled source of Dog Asset Lib v1.5.4

FinalDragonDog.dll

Decompiled 6 months ago
using System;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FinalDragonDog")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Replace eyeless dog with dragon.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0+36ef6433010cb67e36004f557a61bc71a9f07397")]
[assembly: AssemblyProduct("FinalDragonDog")]
[assembly: AssemblyTitle("FinalDragonDog")]
[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 FinalDragonDog
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FinalDragonDog";

		public const string PLUGIN_NAME = "FinalDragonDog";

		public const string PLUGIN_VERSION = "1.0.0.0";
	}
}
namespace EyelessDragon
{
	public static class PluginInfo
	{
		public const string modGUID = "SloppyClock.EyelessDragon";

		public const string modName = "EyelessDragon";

		public const string modVers = "1.0.0.0";
	}
	[BepInPlugin("SloppyClock.EyelessDragon", "EyelessDragon", "1.0.0.0")]
	public class ModBase : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("SloppyClock.EyelessDragon");

		public static ModBase instance;

		public static AssetBundle eyelessDragonBundle;

		public static AssetBundle dearBrackenBundle;

		public static GameObject dragonObj;

		public static GameObject deerObj;

		public static ManualLogSource mls = Logger.CreateLogSource("SloppyClock.EyelessDragon");

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls.LogInfo((object)"Plugin EyelessDragon is loaded! (The dragon awakes.)");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			eyelessDragonBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "dragondog"));
			if ((Object)(object)eyelessDragonBundle == (Object)null)
			{
				mls.LogError((object)"Failed to load custom assets.");
				return;
			}
			dragonObj = eyelessDragonBundle.LoadAsset<GameObject>("DragonDog.prefab");
			SkinnedMeshRenderer[] componentsInChildren = dragonObj.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer[] array = componentsInChildren;
			SkinnedMeshRenderer[] array2 = array;
			foreach (SkinnedMeshRenderer val in array2)
			{
				((Component)val).gameObject.layer = LayerMask.NameToLayer("Enemies");
			}
			if ((Object)(object)dragonObj == (Object)null)
			{
				mls.LogError((object)"I wasn't able to load my own dragondog prefab..");
			}
			dearBrackenBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "radium"));
			if ((Object)(object)dearBrackenBundle == (Object)null)
			{
				mls.LogError((object)"Failed to load custom assets.");
				return;
			}
			deerObj = dearBrackenBundle.LoadAsset<GameObject>("radiumdesu.prefab");
			if ((Object)(object)dragonObj == (Object)null)
			{
				mls.LogError((object)"I wasn't able to load my own dragondog prefab..");
			}
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}
}
namespace EyelessDragon.Patches
{
	[HarmonyPatch(typeof(MouthDogAI), "Start")]
	public class MouthdogPatch
	{
		public static ManualLogSource mls = Logger.CreateLogSource("SloppyClock.EyelessDragon");

		public void Update()
		{
		}

		[HarmonyPostfix]
		public static void EyelessDragonSwap(MouthDogAI __instance)
		{
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			mls.LogInfo((object)"Swapping Dog.");
			if ((Object)(object)ModBase.dragonObj == (Object)null)
			{
				mls.LogError((object)"Could not find new dog model!");
				return;
			}
			Transform val = ((Component)__instance).transform.Find("MouthDogModel");
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Could not get the MouthDogModel!");
				return;
			}
			Transform val2 = val.Find("AnimContainer").Find("Armature");
			if ((Object)(object)val2 == (Object)null)
			{
				mls.LogError((object)"Could not get the armature!");
				return;
			}
			Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>();
			foreach (Renderer val3 in componentsInChildren)
			{
				val3.enabled = false;
			}
			GameObject val4 = Object.Instantiate<GameObject>(ModBase.dragonObj);
			mls.LogInfo((object)"New dog loaded.");
			val4.transform.SetParent(val);
			val4.transform.localPosition = Vector3.zero;
			val4.transform.localRotation = Quaternion.identity;
			val4.transform.localScale = Vector3.one;
			Transform[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren<Transform>();
			Transform[] componentsInChildren3 = val4.GetComponentsInChildren<Transform>();
			string[] source = new string[2] { "Neck1", "Neck2" };
			Transform[] array = componentsInChildren2;
			foreach (Transform val5 in array)
			{
				Transform[] array2 = componentsInChildren3;
				foreach (Transform val6 in array2)
				{
					if (((Object)val6).name == ((Object)val5).name)
					{
						val6.SetParent(val5, true);
						if (source.Contains(((Object)val6).name))
						{
							val6.position += val6.up * 0.5f;
						}
						break;
					}
				}
			}
		}
	}
}
namespace EyelessDragon.BrackenPatches
{
	[HarmonyPatch(typeof(FlowermanAI), "Start")]
	public class BrackenPatch
	{
		public static ManualLogSource mls = Logger.CreateLogSource("SloppyClock.EyelessDragon");

		[HarmonyPostfix]
		private static void BrackenSwap(FlowermanAI __instance)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(ModBase.deerObj);
			Transform[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Transform>();
			foreach (Transform val2 in componentsInChildren)
			{
				if (((Object)val2).name == "Head1")
				{
					val.transform.SetParent(val2, true);
					break;
				}
			}
			val.transform.localPosition = new Vector3(0f, 0.67f, 0.7f);
			mls.LogInfo((object)"Your Deer Friend ;)");
		}
	}
}