Decompiled source of common v1.0.0

com.xaymar.lethalcompany.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalExpansion;
using UnityEngine;
using com.xaymar.lethalcompany.patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("com.xaymar.lethalcompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Xaymar")]
[assembly: AssemblyProduct("com.xaymar.lethalcompany")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8bd5fa4f-5536-48be-b8c0-3e5772653d8c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public class LadderGenerator : MonoBehaviour
{
	private GameObject parent;

	private ArrayList ladderSegments = new ArrayList();

	public GameObject bottomPos;

	public GameObject topPos;

	public GameObject horizontalPos;

	public GameObject playerPos;

	public GameObject trigger;

	public GameObject ladderSegment;

	protected ManualLogSource Logger = new ManualLogSource("com.xaymar.lethalcompany." + typeof(LadderGenerator).Name);

	private void Start()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		parent = ((Component)this).gameObject;
		float y = parent.transform.localScale.y;
		float y2 = ladderSegment.transform.localScale.y;
		long num = (long)Math.Ceiling(y / y2);
		float num2 = y / ((float)num * y2);
		parent.transform.localScale = new Vector3(1f, 1f, 1f);
		for (long num3 = 1L; num3 < num; num3++)
		{
			GameObject val = Object.Instantiate<GameObject>(ladderSegment, parent.transform);
			ladderSegments.Add(val);
			Vector3 localPosition = val.transform.localPosition;
			localPosition.y += (float)num3 * (y2 * num2);
			val.transform.localPosition = localPosition;
			Logger.LogInfo((object)$"<{typeof(LadderGenerator).Name}> Segment {num3} generated.");
		}
		Vector3 localPosition2 = topPos.transform.localPosition;
		localPosition2.y += y;
		topPos.transform.localPosition = localPosition2;
		Vector3 localPosition3 = trigger.transform.localPosition;
		localPosition3.y = (float)((double)y / 2.0 + (double)y2 / 2.0);
		trigger.transform.localPosition = localPosition3;
		Vector3 localScale = trigger.transform.localScale;
		localScale.y = y + y2;
		trigger.transform.localScale = localScale;
		Logger.LogInfo((object)"Completed");
	}
}
internal class PlugInInfo
{
	public const string GUID = "8bd5fa4f-5536-48be-b8c0-3e5772653d8c";

	public const string Name = "com.xaymar.lethalcompany";

	public const string Version = "1.0.0.0";
}
namespace com.xaymar.lethalcompany
{
	[BepInPlugin("8bd5fa4f-5536-48be-b8c0-3e5772653d8c", "com.xaymar.lethalcompany", "1.0.0.0")]
	internal class PlugIn : BaseUnityPlugin
	{
		private static readonly Harmony harmony = new Harmony("8bd5fa4f-5536-48be-b8c0-3e5772653d8c");

		public static List<Type> lethalExpansionWhitelist = new List<Type> { typeof(LadderGenerator) };

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PlugIn com.xaymar.lethalcompany (Guid: 8bd5fa4f-5536-48be-b8c0-3e5772653d8c) v1.0.0.0 is loading...");
			try
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Applying patch to Lethal Expansion...");
				harmony.PatchAll(typeof(LethalExpansionPatcher));
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogFatal((object)$"Failed to apply patch: {arg}");
				Application.Quit(1);
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded successfully.");
		}
	}
}
namespace com.xaymar.lethalcompany.patches
{
	[HarmonyPatch(typeof(LethalExpansion))]
	internal class LethalExpansionPatcher
	{
		[HarmonyPatch("CheckAndRemoveIllegalComponents")]
		[HarmonyPrefix]
		private static bool CheckAndRemoveIllegalComponents_Prefix(LethalExpansion __instance, Transform root)
		{
			try
			{
				Component[] components = ((Component)root).GetComponents<Component>();
				foreach (Component comp in components)
				{
					if (PlugIn.lethalExpansionWhitelist.Any((Type type) => ((object)comp).GetType() == type))
					{
						return false;
					}
				}
				return true;
			}
			catch (Exception)
			{
				return true;
			}
		}
	}
}