Decompiled source of ForestGiantTitan v1.0.0

CTitanGiant.dll

Decompiled 10 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 CTitanGiant.Patches;
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: AssemblyTitle("CTitanGiant")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CTitanGiant")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("88b2673e-3f9d-444c-9c96-7e42cff5223a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CTitanGiant
{
	[BepInPlugin("Ex.CTitanGiant", "Ex Colossal Titan Forest Giant Replacement Mod", "1.0.0")]
	public class TitanGiantBase : BaseUnityPlugin
	{
		private const string modGUID = "Ex.CTitanGiant";

		private const string modName = "Ex Colossal Titan Forest Giant Replacement Mod";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Ex.CTitanGiant");

		private static TitanGiantBase Instance;

		internal ManualLogSource mls;

		public static GameObject titanGiantModel;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Ex.CTitanGiant");
			mls.LogInfo((object)"Titan Giant Replacement mod has initiated");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			string text = "CTitanGiant.dll";
			string text2 = location.TrimEnd(text.ToCharArray());
			string text3 = text2 + "titangiant";
			AssetBundle val = AssetBundle.LoadFromFile(text3);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load assets!");
				return;
			}
			titanGiantModel = val.LoadAsset<GameObject>("Assets/Titan2.prefab");
			SkinnedMeshRenderer[] componentsInChildren = titanGiantModel.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val2 in array)
			{
				((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
			}
			harmony.PatchAll(typeof(TitanGiantBase));
			harmony.PatchAll(typeof(GiantPatch));
			mls.LogInfo((object)"Wir sind die jäger!");
		}
	}
}
namespace CTitanGiant.Patches
{
	[HarmonyPatch(typeof(ForestGiantAI))]
	internal class GiantPatch : MonoBehaviour
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void GiantPreLoadPatch(FlowermanAI __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)__instance).transform.Find("FGiantModelContainer");
			SkinnedMeshRenderer val2 = ((val != null) ? ((Component)val.Find("BodyLOD0")).GetComponent<SkinnedMeshRenderer>() : null);
			object obj;
			if (val == null)
			{
				obj = null;
			}
			else
			{
				Transform obj2 = val.Find("AnimContainer");
				obj = ((obj2 != null) ? obj2.Find("metarig") : null);
			}
			Transform val3 = (Transform)obj;
			Debug.Log((object)("Titan Instance " + (object)val3));
			if (!((Object)(object)val2 == (Object)null) && ((Renderer)val2).enabled)
			{
				((Renderer)val2).enabled = false;
				Renderer[] componentsInChildren = ((Component)val3).gameObject.GetComponentsInChildren<Renderer>();
				Renderer[] array = componentsInChildren;
				foreach (Renderer val4 in array)
				{
					Debug.Log((object)val4);
					Debug.Log((object)val2);
					val4.enabled = false;
				}
				GameObject val5 = Object.Instantiate<GameObject>(TitanGiantBase.titanGiantModel);
				val5.transform.SetParent(val);
				val5.transform.localPosition = Vector3.zero;
				val5.transform.localRotation = Quaternion.identity;
				val5.transform.localScale = Vector3.one;
				Debug.Log((object)("Titan Instance " + (object)val5));
				Transform val6 = val5.transform.Find("Mesh_0069_rip");
				Debug.Log((object)("Titan Instance " + (object)val6));
				Transform val7 = val5.transform.Find("AnimContainer/metarig");
				Debug.Log((object)("Titan Instance " + (object)val7));
				val7.SetParent(val3.parent, true);
				((Component)val7).transform.localScale = ((Component)val3).transform.localScale;
				((Component)val7).transform.localRotation = ((Component)val3).transform.localRotation;
				((Component)val7).transform.localPosition = ((Component)val3).transform.localPosition;
				SkinnedMeshRenderer component = ((Component)val6).GetComponent<SkinnedMeshRenderer>();
				component.rootBone = val7;
				Debug.Log((object)("Titan Instance " + (object)component.rootBone));
				((Object)val3).name = "old-metarig";
			}
		}
	}
}