Decompiled source of ElmoBracken v1.0.0

ElmoBracken.dll

Decompiled 11 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;
using UnityEngine.Video;

[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("ElmoBracken")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ElmoBracken")]
[assembly: AssemblyTitle("ElmoBracken")]
[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 ElmoBracken
{
	[BepInPlugin("ElmoBracken", "Elmo Bracken", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("ElmoBracken");

		public static GameObject elmoModel;

		public static VideoClip elmoVideo;

		public static AudioClip elmoAngry;

		public static AudioClip elmoVoice;

		public static ManualLogSource logger;

		private void Awake()
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "elmo.asset"));
			elmoModel = val.LoadAsset<GameObject>("assets/elmo.prefab");
			elmoVideo = val.LoadAsset<VideoClip>("assets/vid.mp4");
			elmoAngry = val.LoadAsset<AudioClip>("assets/elmoAngry.mp3");
			elmoVoice = val.LoadAsset<AudioClip>("assets/elmoVoice.mp3");
			logger = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Elmo Bracken is loaded!");
			harmony.PatchAll();
		}
	}
}
namespace ElmoBracken.Patches
{
	[HarmonyPatch(typeof(FlowermanAI))]
	public class BrackenPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void ReplaceBracken(FlowermanAI __instance)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)__instance).transform.Find("FlowermanModel");
			Plugin.logger.LogMessage((object)"Found flowermanmodel");
			Object.Destroy((Object)(object)((Component)val.Find("LOD1")).gameObject.GetComponent<SkinnedMeshRenderer>());
			Plugin.logger.LogMessage((object)"Destroyed LOD1");
			Transform val2 = val.Find("AnimContainer").Find("metarig");
			Plugin.logger.LogMessage((object)"Found oldrig");
			GameObject val3 = Object.Instantiate<GameObject>(Plugin.elmoModel, val);
			Plugin.logger.LogMessage((object)"Instantiated elmo");
			val3.transform.localPosition = Vector3.zero;
			val3.transform.localRotation = Quaternion.identity;
			val3.transform.localScale = Vector3.one;
			Plugin.logger.LogMessage((object)"Changed elmo values");
			Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>();
			foreach (Renderer val4 in componentsInChildren)
			{
				val4.enabled = false;
			}
			Plugin.logger.LogMessage((object)"disabled oldrig renderers");
			Transform val5 = val3.transform.Find("Armature").Find("mixamorig:Hips");
			val5.SetParent(val2.parent, true);
			val5.localPosition = val2.localPosition;
			val5.localRotation = Quaternion.Euler(90f, 0f, 0f);
			val5.localScale = new Vector3(70f, 70f, 70f);
			Plugin.logger.LogMessage((object)"rig = oldrig");
			__instance.rightHandGrip = val5.Find("mixamorig:Spine").Find("mixamorig:Spine1").Find("mixamorig:Spine2")
				.Find("mixamorig:RightShoulder")
				.Find("mixamorig:RightArm")
				.Find("mixamorig:RightForeArm")
				.Find("mixamorig:RightHand");
			Plugin.logger.LogMessage((object)__instance.rightHandGrip);
			val5.Find("mixamorig:LeftUpLeg").Find("mixamorig:LeftLeg").SetParent(val2.Find("Torso1").Find("UpperLeg1.L").Find("UpperLeg2.L")
				.Find("UpperLeg3.L")
				.Find("UpperLeg4.L")
				.Find("LowerLeg1.L"));
			val5.Find("mixamorig:LeftUpLeg").SetParent(val2.Find("Torso1").Find("UpperLeg1.L"));
			val5.Find("mixamorig:RightUpLeg").Find("mixamorig:RightLeg").SetParent(val2.Find("Torso1").Find("UpperLeg1.R").Find("UpperLeg2.R")
				.Find("UpperLeg3.R")
				.Find("UpperLeg4.R")
				.Find("LowerLeg1.R"));
			val5.Find("mixamorig:RightUpLeg").SetParent(val2.Find("Torso1").Find("UpperLeg1.R"));
			Transform val6 = val5.Find("mixamorig:Spine").Find("mixamorig:Spine1").Find("mixamorig:Spine2");
			Transform val7 = val2.Find("Torso1").Find("Torso2").Find("Torso3")
				.Find("Arm1.L")
				.Find("Arm2.L")
				.Find("Arm3.L")
				.Find("Hand1.L")
				.Find("Thumb.L");
			Transform val8 = val6.Find("mixamorig:LeftShoulder").Find("mixamorig:LeftArm").Find("mixamorig:LeftHand")
				.Find("mixamorig:LeftHandThumb1");
			val8.SetParent(val7);
			val8.parent.SetParent(val7.parent);
			val8.parent.parent.SetParent(val7.parent.parent);
			val8.parent.parent.parent.SetParent(val7.parent.parent.parent.parent);
			Transform val9 = val6.Find("mixamorig:RightShoulder").Find("mixamorig:RightArm").Find("mixamorig:RightHand")
				.Find("mixamorig:RightHandThumb1");
			Transform val10 = val2.Find("Torso1").Find("Torso2").Find("Torso3")
				.Find("Arm1.R")
				.Find("Arm2.R")
				.Find("Arm3.R")
				.Find("Hand1.R")
				.Find("Thumb.R");
			val9.SetParent(val10);
			val9.parent.SetParent(val10.parent);
			val9.parent.parent.SetParent(val10.parent.parent);
			val9.parent.parent.parent.SetParent(val10.parent.parent.parent.parent);
			Plugin.logger.LogMessage((object)"================================================");
			Plugin.logger.LogMessage((object)"Whoever is reading this code im so fucking sorry");
			Plugin.logger.LogMessage((object)"================================================");
			__instance.creatureAngerVoice.clip = Plugin.elmoAngry;
			((EnemyAI)__instance).creatureSFX.clip = Plugin.elmoVoice;
			((Component)((Component)__instance).transform).GetComponentInChildren<ScanNodeProperties>().headerText = "Elmo";
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void TerminalFix(Terminal __instance)
		{
			for (int i = 0; i < __instance.enemyFiles.Count; i++)
			{
				if (__instance.enemyFiles[i].creatureName.Equals("Brackens"))
				{
					__instance.enemyFiles[i].creatureName = "Elmo";
					__instance.enemyFiles[i].displayText = "ELMO\n\nSigurd's danger level: 1000%\n\nSpecies: Gudava\n\nFurry red monster who speaks in a high-pitched falsetto voice and frequently refers to himself in the third person.\n\n";
					__instance.enemyFiles[i].displayVideo = Plugin.elmoVideo;
					Plugin.logger.LogMessage((object)"Changed creature description");
					break;
				}
			}
			for (int j = 0; j < __instance.terminalNodes.allKeywords.Length; j++)
			{
				if (__instance.terminalNodes.allKeywords[j].word.Equals("brackens"))
				{
					__instance.terminalNodes.allKeywords[j].word = "elmo";
					Plugin.logger.LogMessage((object)"Changed terminal keyword to elmo");
					break;
				}
			}
		}
	}
}