Decompiled source of ApparatusFix v0.0.1

ApparatusFix.dll

Decompiled 6 months ago
using System;
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.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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("ApparatusFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("ApparatusFix")]
[assembly: AssemblyTitle("ApparatusFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 ApparatusFix
{
	[BepInPlugin("ApparatusFix", "ApparatusFix", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource logger;

		internal static Harmony harmony = new Harmony("ApparatusFix");

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ApparatusFix is loaded!");
		}
	}
	internal class LobbyCompatibilityCompatibility
	{
		public static void Init()
		{
			Plugin.logger.LogWarning((object)"LobbyCompatibility detected, registering plugin with LobbyCompatibility.");
			Version version = Version.Parse("0.0.1");
			PluginHelper.RegisterPlugin("LethalRichPresence", version, (CompatibilityLevel)3, (VersionStrictness)0);
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	public class Patch
	{
		private static bool ShouldReturn(GrabbableObject item)
		{
			if (!item.isInShipRoom)
			{
				Plugin.logger.LogDebug((object)(item.__getTypeName() + " is not in ship room"));
				return true;
			}
			if (item.__getTypeName() != "LungProp")
			{
				Plugin.logger.LogDebug((object)(item.__getTypeName() + " is not a predefined type"));
				return true;
			}
			return false;
		}

		public static void Disable(GrabbableObject item)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (!ShouldReturn(item) && "LungProp" == item.__getTypeName())
			{
				Plugin.logger.LogDebug((object)"Disabling sound of LungProp");
				LungProp val = (LungProp)item;
				val.isLungDocked = false;
				val.isLungDockedInElevator = false;
				val.isLungPowered = false;
				((Component)val).GetComponent<AudioSource>().Stop();
			}
		}

		[HarmonyPatch("DiscardItemClientRpc")]
		[HarmonyPostfix]
		public static void DiscardItemClientRpc(GrabbableObject __instance)
		{
			Plugin.logger.LogDebug((object)("DiscardItemClientRpc " + __instance.itemProperties.itemName));
			if (__instance.isInShipRoom)
			{
				Disable(__instance);
			}
		}

		[HarmonyPatch("DiscardItemOnClient")]
		[HarmonyPostfix]
		public static void DiscardItemOnClient(GrabbableObject __instance)
		{
			Plugin.logger.LogDebug((object)("DiscardItemOnClient " + __instance.itemProperties.itemName));
			if (__instance.isInShipRoom)
			{
				Disable(__instance);
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ApparatusFix";

		public const string PLUGIN_NAME = "ApparatusFix";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}