Decompiled source of DoorEnemyFix v1.0.0

Localia.DoorEnemyFix.dll

Decompiled a year 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 BepInEx.Unity.IL2CPP;
using HarmonyLib;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using SNetwork;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DoorEnemyFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DoorEnemyFix")]
[assembly: AssemblyTitle("DoorEnemyFix")]
[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 DoorEnemyFix
{
	[BepInPlugin("Localia.DoorEnemyFix", "DoorEnemyFix", "1.0.0")]
	public class EntryPoint : BasePlugin
	{
		private Harmony m_Harmony;

		public override void Load()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			m_Harmony = new Harmony("Localia.DoorEnemyFix");
			m_Harmony.PatchAll();
			Logs.Info("OK");
		}
	}
	internal static class Logs
	{
		private static readonly ManualLogSource _logger;

		static Logs()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_logger = new ManualLogSource("Localia.DoorEnemyFix");
			Logger.Sources.Add((ILogSource)(object)_logger);
		}

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(object data)
		{
			_logger.LogMessage((object)Format(data));
		}

		public static void Verbose(object data)
		{
			_logger.LogDebug((object)Format(data));
		}

		public static void Debug(object data)
		{
			_logger.LogDebug((object)Format(data));
		}

		public static void Error(object data)
		{
			_logger.LogError((object)Format(data));
		}
	}
	[HarmonyPatch(typeof(MineDeployerInstance_Detect_Laser))]
	internal static class Patch_MineDeployerInstance_Detect_Laser
	{
		[HarmonyPatch("UpdateDetection")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MineDeployerInstance_Detect_Laser_UpdateDetection(MineDeployerInstance_Detect_Laser __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			if ((int)__instance.m_core.Mode != 2 && (int)__instance.m_core.Mode != 1)
			{
				return true;
			}
			RaycastHit val = default(RaycastHit);
			if (__instance.m_maxLineDistance > 0f && Physics.SphereCast(__instance.m_lineRendererAlign.position, 0.1f, __instance.m_lineRendererAlign.forward, ref val, __instance.m_maxLineDistance, __instance.m_scanMask) && CustomExtensions.IsInLayerMask(__instance.m_enemyMask, ((Component)((RaycastHit)(ref val)).collider).gameObject))
			{
				Dam_EnemyDamageLimb component = ((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent<Dam_EnemyDamageLimb>();
				if ((Object)(object)component != (Object)null && (Object)(object)component.m_base.Owner != (Object)null)
				{
					if (UFuncs.hasHitDoor(__instance.m_lineRendererAlign.position, ((Component)component.m_base.Owner).transform.position) || UFuncs.hasHitDoor(((RaycastHit)(ref val)).point, ((Component)component.m_base.Owner).transform.position))
					{
						float num = __instance.m_maxLineDistance;
						if (Physics.SphereCast(__instance.m_lineRendererAlign.position, 0.1f, __instance.m_lineRendererAlign.forward, ref val, __instance.m_maxLineDistance, __instance.m_scanMask & ~LayerManager.MASK_ENEMY_DAMAGABLE) && ((RaycastHit)(ref val)).distance < num)
						{
							num = ((RaycastHit)(ref val)).distance;
						}
						if (num != __instance.DetectionRange)
						{
							__instance.UpdateDetectionRange(num);
						}
						return false;
					}
				}
				else
				{
					Logs.Error("mine cast a enemy no Dam_EnemyDamageLimb " + ((Object)((RaycastHit)(ref val)).collider).name);
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GlueGunProjectile))]
	internal static class Patch_GlueGunProjectile
	{
		[HarmonyPatch("CollisionCheck")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void GlueGunProjectile_CollisionCheck(GlueGunProjectile __instance, ref bool __result, bool __0)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			if (!__result || (Object)(object)((StickingProjectileBase)__instance).m_projLastRayHitCollider == (Object)null || (Object)(object)((Component)((StickingProjectileBase)__instance).m_projLastRayHitCollider).gameObject == (Object)null || ((Component)((StickingProjectileBase)__instance).m_projLastRayHitCollider).gameObject.layer != LayerManager.LAYER_ENEMY_DAMAGABLE)
			{
				return;
			}
			Vector3 val = ((StickingProjectileBase)__instance).m_projVelocity * Time.fixedDeltaTime;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.SphereCast(((StickingProjectileBase)__instance).m_projTargetPos, __instance.m_sphereCastRadius, val, ref val2, 1f, LayerManager.MASK_GLUEGUN_TARGETS & ~LayerManager.MASK_ENEMY_DAMAGABLE))
			{
				((StickingProjectileBase)__instance).m_projLastRayHitPoint = ((RaycastHit)(ref val2)).point;
				((StickingProjectileBase)__instance).m_projLastRayHitNormal = ((RaycastHit)(ref val2)).normal;
				((StickingProjectileBase)__instance).m_projLastRayHitCollider = ((RaycastHit)(ref val2)).collider;
				return;
			}
			Dam_EnemyDamageLimb component = ((Component)((StickingProjectileBase)__instance).m_projLastRayHitCollider).gameObject.GetComponent<Dam_EnemyDamageLimb>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.m_base.Owner != (Object)null)
			{
				if (UFuncs.hasHitDoor(((StickingProjectileBase)__instance).m_projTargetPos, ((Component)component.m_base.Owner).transform.position))
				{
					__result = false;
				}
			}
			else
			{
				Logs.Error("glue cast a enemy no Dam_EnemyDamageLimb " + ((Object)((StickingProjectileBase)__instance).m_projLastRayHitCollider).name);
			}
		}

		[HarmonyPatch("OnTriggerEnter")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool GlueGunProjectile_OnTriggerEnterbool(GlueGunProjectile __instance, Collider __0)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.m_landedOnEnemy || !SNet.IsMaster)
			{
				return true;
			}
			if ((int)__instance.m_collisionLandingType == 4)
			{
				return false;
			}
			Dam_EnemyDamageLimb component = ((Component)__0).gameObject.GetComponent<Dam_EnemyDamageLimb>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.m_base.Owner != (Object)null)
			{
				if (UFuncs.hasHitDoor(((StickingProjectileBase)__instance).m_projTargetPos, ((Component)component.m_base.Owner).transform.position))
				{
					return false;
				}
			}
			else
			{
				Logs.Error("glue cast a enemy no Dam_EnemyDamageLimb " + ((Object)__0).name);
			}
			return true;
		}
	}
	public static class UFuncs
	{
		internal static bool hasHitDoor(Vector3 start_pos, Vector3 target_pos)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			target_pos.y += 1.5f;
			start_pos.y = target_pos.y;
			Vector3 val = target_pos - start_pos;
			float magnitude = ((Vector3)(ref val)).magnitude;
			val = ((Vector3)(ref val)).normalized;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(start_pos, val, ref val2, magnitude, 1 << LayerManager.LAYER_DYNAMIC, (QueryTriggerInteraction)0) && (Object)(object)((RaycastHit)(ref val2)).collider != (Object)null)
			{
				GameObject gameObject = ((Component)((RaycastHit)(ref val2)).collider).gameObject;
				if ((Object)(object)gameObject != (Object)null)
				{
					LG_WeakDoor_Destruction componentInParent = gameObject.GetComponentInParent<LG_WeakDoor_Destruction>();
					if ((Object)(object)componentInParent != (Object)null)
					{
						if (!componentInParent.m_isDestroyed)
						{
							return true;
						}
					}
					else
					{
						LG_SecurityDoor componentInParent2 = gameObject.GetComponentInParent<LG_SecurityDoor>();
						if ((Object)(object)componentInParent2 != (Object)null && componentInParent2.InAnimation)
						{
							return true;
						}
					}
				}
			}
			return false;
		}
	}
}