Decompiled source of Lasso Restored v1.0.1

RestoreLasso.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("RestoreLasso")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Restores lasso man")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RestoreLasso")]
[assembly: AssemblyTitle("RestoreLasso")]
[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 RestoreLasso
{
	internal static class LobbyCompatibility
	{
		internal static void Init()
		{
			PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.restorelasso", Version.Parse("1.0.0"), (CompatibilityLevel)2, (VersionStrictness)0);
		}
	}
	[BepInPlugin("butterystancakes.lethalcompany.restorelasso", "Restore Lasso", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal const string PLUGIN_GUID = "butterystancakes.lethalcompany.restorelasso";

		internal const string PLUGIN_NAME = "Restore Lasso";

		internal const string PLUGIN_VERSION = "1.0.0";

		internal static ManualLogSource Logger;

		private const string GUID_LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility";

		internal static ConfigEntry<float> damageSpeedMultiplier;

		private void Awake()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected");
				LobbyCompatibility.Init();
			}
			damageSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "Damage Speed Multiplier", 1f, new ConfigDescription("How quickly Lasso is allowed to deal 40 damage. A value of 1 means every 0.5s, the intended amount. (0.9 would mean 0.56s cooldown, 1.1 is 0.45s, etc.) Set to 0 to disable damage entirely, like vanilla's broken behavior.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			new Harmony("butterystancakes.lethalcompany.restorelasso").PatchAll();
			Logger.LogInfo((object)"Restore Lasso v1.0.0 loaded");
		}
	}
	[HarmonyPatch]
	internal static class RestoreLassoPatches
	{
		private static float cooldownRate = 1f;

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_Awake(StartOfRound __instance)
		{
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Expected O, but got Unknown
			EnemyType val = null;
			try
			{
				SelectableLevel[] levels = __instance.levels;
				foreach (SelectableLevel val2 in levels)
				{
					foreach (List<SpawnableEnemyWithRarity> item in new List<List<SpawnableEnemyWithRarity>> { val2.Enemies, val2.OutsideEnemies, val2.DaytimeEnemies })
					{
						foreach (SpawnableEnemyWithRarity item2 in item)
						{
							if (((Object)item2.enemyType).name == "LassoMan" && (Object)(object)item2.enemyType.enemyPrefab != (Object)null)
							{
								Plugin.Logger.LogDebug((object)"Discovered Lasso");
								val = item2.enemyType;
								break;
							}
						}
						if ((Object)(object)val != (Object)null)
						{
							break;
						}
					}
					if ((Object)(object)val != (Object)null)
					{
						break;
					}
				}
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Failed to discover Lasso due to an exception:\n{arg}");
			}
			if ((Object)(object)val != (Object)null)
			{
				if (val.spawningDisabled || val.spawnInGroupsOf < 1)
				{
					val.spawningDisabled = false;
					val.spawnInGroupsOf = 1;
					Plugin.Logger.LogDebug((object)"Re-enabled Lasso's spawn capability");
				}
				LassoManAI component = val.enemyPrefab.GetComponent<LassoManAI>();
				if ((Object)(object)component != (Object)null && (((EnemyAI)component).enemyBehaviourStates == null || ((EnemyAI)component).enemyBehaviourStates.Length < 2))
				{
					((EnemyAI)component).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[2]
					{
						new EnemyBehaviourState
						{
							name = "searching"
						},
						new EnemyBehaviourState
						{
							name = "chasing"
						}
					};
					Plugin.Logger.LogDebug((object)"Fixed Lasso states");
				}
				cooldownRate = Plugin.damageSpeedMultiplier.Value;
			}
		}

		[HarmonyPatch(typeof(LassoManAI), "Update")]
		[HarmonyPostfix]
		private static void LassoManAI_Post_Update(LassoManAI __instance)
		{
			if (cooldownRate > 0f)
			{
				__instance.timeSinceHittingPlayer += Time.deltaTime * cooldownRate;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "RestoreLasso";

		public const string PLUGIN_NAME = "RestoreLasso";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}