Decompiled source of Iron Giant Old Bird Spotlight Reposition v1.0.0

IronGiantLightFix.dll

Decompiled 14 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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("IronGiantLightFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("IronGiantLightFix")]
[assembly: AssemblyTitle("IronGiantLightFix")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 IronGiantLightFix
{
	[BepInPlugin("dalekwho1963.lethalcompany.irongiantlightfix", "IronGiantLightFix", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "dalekwho1963.lethalcompany.irongiantlightfix";

		public const string Name = "IronGiantLightFix";

		public const string Version = "1.0.0";

		internal const string LightContainerPath = "MeshContainer/AnimContainer/metarig/TorsoContainer/Torso/LightContainer";

		internal static Plugin Instance;

		internal static ConfigEntry<float> OffsetX;

		internal static ConfigEntry<float> OffsetY;

		internal static ConfigEntry<float> OffsetZ;

		internal static ConfigEntry<float> DelaySeconds;

		private void Awake()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			OffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("LightContainer", "OffsetX", 2.25f, "Local X position of the Old Bird's LightContainer (moves the Spotlight and Pointlight together).");
			OffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("LightContainer", "OffsetY", 1.25f, "Local Y position of the Old Bird's LightContainer.");
			OffsetZ = ((BaseUnityPlugin)this).Config.Bind<float>("LightContainer", "OffsetZ", 0f, "Local Z position of the Old Bird's LightContainer.");
			DelaySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("LightContainer", "DelaySeconds", 1f, "Seconds to wait after the Old Bird spawns before moving the light, so the skin is applied first.");
			new Harmony("dalekwho1963.lethalcompany.irongiantlightfix").PatchAll(typeof(EnemyStartPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"IronGiantLightFix 1.0.0 loaded.");
		}

		internal static IEnumerator ApplyOffset(Transform root)
		{
			yield return (object)new WaitForSeconds(DelaySeconds.Value);
			if (!((Object)(object)root == (Object)null))
			{
				Transform container = root.Find("MeshContainer/AnimContainer/metarig/TorsoContainer/Torso/LightContainer");
				if ((Object)(object)container == (Object)null)
				{
					((BaseUnityPlugin)Instance).Logger.LogWarning((object)("LightContainer not found under " + ((Object)root).name + " (path: MeshContainer/AnimContainer/metarig/TorsoContainer/Torso/LightContainer)."));
					yield break;
				}
				container.localPosition = new Vector3(OffsetX.Value, OffsetY.Value, OffsetZ.Value);
				((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"Moved LightContainer on {((Object)root).name} to {container.localPosition}.");
			}
		}
	}
	[HarmonyPatch(typeof(EnemyAI), "Start")]
	internal static class EnemyStartPatch
	{
		[HarmonyPostfix]
		private static void Postfix(EnemyAI __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && ((Object)((Component)__instance).gameObject).name.StartsWith("RadMechEnemy"))
			{
				((MonoBehaviour)__instance).StartCoroutine(Plugin.ApplyOffset(((Component)__instance).transform));
			}
		}
	}
}