Decompiled source of BigBirdCoilhead v1.0.0

BigBirdCoilhead.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;
using UnityEngine.Animations;
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("BigBirdCoilhead")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BigBirdCoilhead")]
[assembly: AssemblyTitle("BigBirdCoilhead")]
[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 BigBirdCoilhead
{
	[BepInPlugin("BigBirdCoilhead", "Big Bird Coilhead", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("BigBirdCoilhead");

		public static GameObject model;

		public static ManualLogSource logger;

		public static VideoClip birdVideo;

		private void Awake()
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "bigbird.asset"));
			Object[] array = val.LoadAllAssets();
			foreach (Object val2 in array)
			{
				((BaseUnityPlugin)this).Logger.LogMessage((object)val2);
			}
			model = val.LoadAsset<GameObject>("assets/bigbird.prefab");
			birdVideo = val.LoadAsset<VideoClip>("assets/bigbird.mp4");
			logger = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Big Bird Coilhead is loaded!");
			harmony.PatchAll();
		}
	}
}
namespace BigBirdCoilhead.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	public class CoilheadPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void ReplaceCoilhead(EnemyAI __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			if (((object)__instance).GetType() == typeof(SpringManAI))
			{
				__instance = (EnemyAI)(SpringManAI)__instance;
				Transform val = ((Component)__instance).transform.Find("SpringManModel");
				Plugin.logger.LogMessage((object)"Found springman model");
				Object.Destroy((Object)(object)((Component)val.Find("Body")).gameObject);
				Object.Destroy((Object)(object)((Component)val.Find("Head")).gameObject);
				GameObject val2 = Object.Instantiate<GameObject>(Plugin.model, val);
				GameObject gameObject = ((Component)val2.transform.Find("Head")).gameObject;
				val2.transform.localPosition = new Vector3(0f, 1.5727f, 0f);
				val2.transform.localRotation = Quaternion.identity;
				val2.transform.Find("Body").SetParent(val);
				Plugin.logger.LogMessage((object)"Set parent of Body to SpringManModel");
				val2.transform.Find("Head").SetParent(val);
				Plugin.logger.LogMessage((object)"Set parent of Head to SpringManModel");
				gameObject.AddComponent<PositionConstraint>();
				gameObject.AddComponent<RotationConstraint>();
				ConstraintSource val3 = default(ConstraintSource);
				((ConstraintSource)(ref val3)).sourceTransform = gameObject.transform;
				ConstraintSource val4 = val3;
				gameObject.GetComponent<PositionConstraint>().AddSource(val4);
				gameObject.GetComponent<PositionConstraint>().constraintActive = true;
				gameObject.GetComponent<RotationConstraint>().AddSource(val4);
				gameObject.GetComponent<RotationConstraint>().constraintActive = true;
				Transform val5 = val.Find("AnimContainer").Find("metarig");
				Plugin.logger.LogMessage((object)"Found old rig");
				Transform val6 = val2.transform.Find("Armature").Find("mixamorig:Hips");
				Plugin.logger.LogMessage((object)"Got new rig");
				val6.SetParent(val5.parent);
				val6.localPosition = new Vector3(0f, 1.5f, 0f);
				val6.Find("mixamorig:LeftUpLeg").SetParent(val5.parent.Find("Rig 1").Find("LeftLeg").Find("LeftLeg_target"));
				Plugin.logger.LogMessage((object)"Set left leg");
				val6.Find("mixamorig:RightUpLeg").SetParent(val5.parent.Find("Rig 1").Find("RightLeg").Find("RightLeg_target"));
				Plugin.logger.LogMessage((object)"Set right leg");
				val6.SetParent(val5.Find("spine"));
				Plugin.logger.LogMessage((object)"Set Spine");
				val6.Find("mixamorig:Spine").SetParent(val5.Find("spine").Find("spine.001"));
				Plugin.logger.LogMessage((object)"Set Spine 1");
				val6 = val5.Find("spine").Find("spine.001");
				val6.Find("mixamorig:Spine").Find("mixamorig:Spine1").SetParent(val6.Find("spine.002"));
				Plugin.logger.LogMessage((object)"Set Spine 2");
				Transform val7 = val6.Find("spine.002").Find("mixamorig:Spine1").Find("mixamorig:Spine2");
				Plugin.logger.LogMessage((object)"Found Spine 2");
				val6 = val5.Find("spine").Find("spine.001").Find("spine.002")
					.Find("spine.003");
				Transform val8 = val6;
				val7.SetParent(val8);
				Plugin.logger.LogMessage((object)"Set Spine 3");
				val7.Find("mixamorig:LeftShoulder").SetParent(val8.Find("shoulder.L"));
				Plugin.logger.LogMessage((object)"Set Left Shoulder");
				val7.Find("mixamorig:RightShoulder").SetParent(val8.Find("shoulder.R"));
				Plugin.logger.LogMessage((object)"Set Right Shoulder");
				val7.Find("mixamorig:Neck").Find("mixamorig:Head").SetParent(val8.Find("springBone").Find("springBone.001").Find("springBone.002")
					.Find("HeadTarget"));
				((Component)__instance).GetComponentInChildren<ScanNodeProperties>().headerText = "Big Bird";
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void TerminalFix(Terminal __instance)
		{
			for (int i = 0; i < __instance.enemyFiles.Count; i++)
			{
				Plugin.logger.LogMessage((object)__instance.enemyFiles[i].creatureName);
				if (__instance.enemyFiles[i].creatureName.Equals("Coil-heads"))
				{
					__instance.enemyFiles[i].creatureName = "Big-Bird";
					__instance.enemyFiles[i].displayText = "The Forsaken Avian of Sesame Street\n\nBIG BIRD\n\nSigurd's danger level: 80%\n\nSpecies: Bird\n\nAn 8'2\" yellow bird who lives on Sesame Street.\n\nThis monstrous bird, once a beacon of joy and laughter in the neighborhood, fell victim to a mysterious and malevolent force that descended upon Sesame Street. One harrowing night, an unknown entity invaded its tranquil world, leaving behind a trail of chaos and destruction. In a desperate attempt to protect its home, the bird confronted the intruder. The battle that ensued was brutal and unrelenting, resulting in the bird's gruesome injuries - its right eye mercilessly gouged out, and both arms severed in the melee.\n\nNow, this once-friendly bird roams the desolate streets, driven by a mix of confusion, pain, and a lingering sense of guardianship over the now-abandoned Sesame Street. It exhibits a shy demeanor when observed, a remnant of its former self. However, in the absence of watchful eyes, it moves with an eerie, unsettling agility, driven by an unknown purpose.\n\n";
					__instance.enemyFiles[i].displayVideo = Plugin.birdVideo;
					Plugin.logger.LogMessage((object)"Changed creature description");
					break;
				}
			}
			for (int j = 0; j < __instance.terminalNodes.allKeywords.Length; j++)
			{
				Plugin.logger.LogMessage((object)__instance.terminalNodes.allKeywords[j]);
				if (__instance.terminalNodes.allKeywords[j].word.Equals("coil-heads"))
				{
					__instance.terminalNodes.allKeywords[j].word = "big bird";
					Plugin.logger.LogMessage((object)"Changed terminal keyword to big bird");
					break;
				}
			}
		}
	}
}