Decompiled source of SampleTextModpack ReReborn v0.69.105

BepInEx/plugins/MaskedFixes/MaskedFixes.dll

Decompiled a day 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 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("VirusTLNR")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("MaskedFixes")]
[assembly: AssemblyTitle("MaskedFixes")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 MaskedFixes
{
	[BepInPlugin("VirusTLNR.MaskedFixes", "MaskedFixes", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public static bool MaskedInvisibilityFix = true;

		public static Plugin Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Logger = ((BaseUnityPlugin)this).Logger;
			Patch();
			Logger.LogInfo((object)"VirusTLNR.MaskedFixes v0.0.1 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("VirusTLNR.MaskedFixes");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	internal static class PluginInfo
	{
		public const string PLUGIN_GUID = "VirusTLNR.MaskedFixes";

		public const string PLUGIN_NAME = "MaskedFixes";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}
namespace MaskedFixes.Patches
{
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	public class MaskedPlayerEnemyPatch
	{
		[HarmonyPatch("SetVisibilityOfMaskedEnemy")]
		[HarmonyPrefix]
		private static bool MaskedInvisibilityFixPrefix(MaskedPlayerEnemy __instance)
		{
			if (!Plugin.MaskedInvisibilityFix)
			{
				return true;
			}
			if (__instance.allowSpawningWithoutPlayer)
			{
				if ((Object)(object)__instance.mimickingPlayer != (Object)null && (Object)(object)__instance.mimickingPlayer.deadBody != (Object)null && !__instance.mimickingPlayer.deadBody.deactivated)
				{
					if (__instance.enemyEnabled)
					{
						__instance.enemyEnabled = false;
						((EnemyAI)__instance).EnableEnemyMesh(false, false);
						Plugin.Logger.LogDebug((object)"(InvisFix)NonMimickedMasked-MaskedMadeInvisible");
						return false;
					}
				}
				else if (!__instance.enemyEnabled)
				{
					__instance.enemyEnabled = true;
					((EnemyAI)__instance).EnableEnemyMesh(true, false);
					Plugin.Logger.LogDebug((object)"(InvisFix)NonMimickedMasked-MaskedMadeVisible");
				}
				return false;
			}
			if ((Object)(object)__instance.mimickingPlayer == (Object)null)
			{
				if (__instance.enemyEnabled)
				{
					__instance.enemyEnabled = false;
					((EnemyAI)__instance).EnableEnemyMesh(false, false);
					Plugin.Logger.LogDebug((object)"(InvisFix)MimickedMasked-MaskedMadeInvisible");
				}
				return false;
			}
			if (!__instance.enemyEnabled)
			{
				__instance.enemyEnabled = true;
				((EnemyAI)__instance).EnableEnemyMesh(true, false);
				Plugin.Logger.LogDebug((object)"(InvisFix)MimickedMasked-MaskedMadeVisible");
			}
			return false;
		}
	}
}