Decompiled source of Isla Company v1.3.0

BepInEx/plugins/SuitLightFix/SuitLightFix.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
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: 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 SuitLightFix
{
	[BepInPlugin("isla.suitlightfix", "SuitLightFix", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			GameObject val = new GameObject("SuitLightFixRunner");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<Runner>();
		}
	}
	public class Runner : MonoBehaviour
	{
		private float next;

		private static bool IsSuitLight(Transform t)
		{
			int num = 0;
			while ((Object)(object)t != (Object)null && num < 8)
			{
				Component[] components = ((Component)t).GetComponents<Component>();
				foreach (Component val in components)
				{
					if ((Object)(object)val != (Object)null && ((object)val).GetType().Assembly.GetName().Name == "ModelReplacementAPI")
					{
						return true;
					}
				}
				num++;
				t = t.parent;
			}
			return false;
		}

		private void Update()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			if (Time.unscaledTime < next)
			{
				return;
			}
			next = Time.unscaledTime + 1f;
			Light[] array = Object.FindObjectsOfType<Light>();
			foreach (Light val in array)
			{
				if (((Behaviour)val).enabled && (int)val.type == 1 && IsSuitLight(((Component)val).transform))
				{
					((Behaviour)val).enabled = false;
					Plugin.Log.LogInfo((object)("Disabled stray suit light: " + ((Object)((Component)val).transform.root).name + "/" + ((Object)val).name));
				}
			}
		}
	}
}