Decompiled source of ARC Complex v1.1.1

BepInEx/plugins/ARC_Complex/DOOM Plugin.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Agents;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using FX_EffectSystem;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using Player;
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("DOOM Plugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d621a6a00efb9d53f665b20b99110fce09970410")]
[assembly: AssemblyProduct("DOOM Plugin")]
[assembly: AssemblyTitle("DOOM Plugin")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace DOOMPlugin
{
	[BepInPlugin("DOOMPlugin", "DOOMPlugin", "1.0.0")]
	internal class EntryPoint : BasePlugin
	{
		private Harmony _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
			_Harmony = new Harmony("DOOMPlugin.GUID.Harmony");
			_Harmony.PatchAll();
		}

		public override bool Unload()
		{
			_Harmony.UnpatchSelf();
			return ((BasePlugin)this).Unload();
		}
	}
	[HarmonyPatch]
	internal class Patch
	{
		private const float PARRYDURATION = 0.3f;

		public static bool parryEnabled = true;

		public static float parryHealMulti = 1f;

		public static float parryMainAmmoMulti = 1f;

		public static float parrySpecAmmoMulti = 1f;

		public static float parryToolMulti = 1f;

		private static float shoveTime;

		private static bool SuccessfullyParry(pMediumDamageData damageData, bool isTentacle)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			if (!parryEnabled)
			{
				return true;
			}
			PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
			localPlayerAgent.Sound.Post(1256202815u, true);
			float num = ((UFloat16)(ref damageData.damage)).Get(1f);
			localPlayerAgent.GiveHealth(localPlayerAgent, num * parryHealMulti);
			localPlayerAgent.GiveAmmoRel(localPlayerAgent, num * parryMainAmmoMulti / 5f, num * parrySpecAmmoMulti / 5f, num * parryToolMulti / 5f);
			Agent val = default(Agent);
			((pAgent)(ref damageData.source)).TryGet(ref val);
			if ((Object)(object)val != (Object)null && isTentacle)
			{
				DoExplosionDamage(val.Position, 2f, 30.1f, 1500f);
			}
			else
			{
				WeaponHitData val2 = new WeaponHitData
				{
					randomSpread = 0f,
					maxRayDist = 100f
				};
				Vector3 position = localPlayerAgent.FPSCamera.Position;
				WeaponHitData obj = val2;
				Vector3 val3 = localPlayerAgent.FPSCamera.CameraRayPos - position;
				obj.fireDir = ((Vector3)(ref val3)).normalized;
				val2.owner = localPlayerAgent;
				val2.damage = 150.1f;
				val2.staggerMulti = 1f;
				val2.precisionMulti = 1f;
				val2.damageFalloff = new Vector2(40f, 100f);
				if (Weapon.CastWeaponRay(((Component)localPlayerAgent.FPSCamera).transform, ref val2, position, -1))
				{
					BulletWeapon.BulletHit(val2, true, 0f, 0u, true);
					RaycastHit rayHit = val2.rayHit;
					FX_Manager.EffectTargetPosition = ((RaycastHit)(ref rayHit)).point;
				}
				else
				{
					FX_Manager.EffectTargetPosition = localPlayerAgent.FPSCamera.CameraRayPos;
				}
				FX_Manager.PlayLocalVersion = false;
				((FX_EffectBase)BulletWeapon.s_tracerPool.AquireEffect()).Play((FX_Trigger)null, ((Agent)localPlayerAgent).EyePosition, Quaternion.LookRotation(val2.fireDir));
			}
			return false;
		}

		public static void DoExplosionDamage(Vector3 sourcePos, float radius, float damage, float explosionForce)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: 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)
			int num = Physics.OverlapSphereNonAlloc(sourcePos, radius, DamageUtil.s_tempColliders, LayerManager.MASK_EXPLOSION_TARGETS);
			if (num < 1)
			{
				return;
			}
			DamageUtil.IncrementSearchID();
			RaycastHit val3 = default(RaycastHit);
			for (int i = 0; i < num; i++)
			{
				Collider val = ((Il2CppArrayBase<Collider>)(object)DamageUtil.s_tempColliders)[i];
				if (Object.op_Implicit((Object)(object)((Component)val).GetComponent<Dam_PlayerDamageLocal>()))
				{
					continue;
				}
				Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.AddExplosionForce(explosionForce, sourcePos, radius, 3f);
				}
				IDamageable component2 = ((Component)val).GetComponent<IDamageable>();
				if (component2 == null)
				{
					continue;
				}
				IDamageable baseDamagable = component2.GetBaseDamagable();
				if (baseDamagable != null && baseDamagable.TempSearchID != DamageUtil.SearchID)
				{
					Vector3 val2 = component2.DamageTargetPos - sourcePos;
					if (!Physics.Raycast(sourcePos, ((Vector3)(ref val2)).normalized, ref val3, ((Vector3)(ref val2)).magnitude, LayerManager.MASK_EXPLOSION_BLOCKERS) || (Object)(object)((RaycastHit)(ref val3)).collider == (Object)(object)val)
					{
						baseDamagable.TempSearchID = DamageUtil.SearchID;
						component2.ExplosionDamage(damage, sourcePos, Vector3.up * explosionForce, 0u);
					}
				}
			}
		}

		[HarmonyPatch(typeof(MWS_Push), "Enter")]
		[HarmonyPostfix]
		public static void ParryEnter()
		{
			shoveTime = Clock.Time;
		}

		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveShooterProjectileDamage")]
		[HarmonyPrefix]
		public static bool ParryShooterProjectileDamage(pMediumDamageData data)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			float time = Clock.Time;
			if (time > shoveTime && time - shoveTime < 0.3f)
			{
				return SuccessfullyParry(data, isTentacle: false);
			}
			return true;
		}

		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveTentacleAttackDamage")]
		[HarmonyPrefix]
		public static bool ParryTentacleAttackDamage(pMediumDamageData data)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			float time = Clock.Time;
			if (time > shoveTime && time - shoveTime < 0.3f)
			{
				return SuccessfullyParry(data, isTentacle: true);
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal class Meathook
	{
		private static float lastGrapple = 0f;

		public static float grappleCD = 2f;

		[HarmonyPatch(typeof(PlayerInventoryLocal), "CheckInput")]
		[HarmonyPrefix]
		public static bool ActivateMeathook(PlayerInventoryLocal __instance)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			if (InputMapper.GetButtonDownKeyMouseGamepad((InputAction)31, ((PlayerInventoryBase)__instance).Owner.InputFilter))
			{
				float time = Clock.Time;
				if (time - lastGrapple > grappleCD)
				{
					lastGrapple = time;
					PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
					WeaponHitData val = new WeaponHitData
					{
						randomSpread = 0f,
						maxRayDist = 100f
					};
					Vector3 position = localPlayerAgent.FPSCamera.Position;
					WeaponHitData obj = val;
					Vector3 val2 = localPlayerAgent.FPSCamera.CameraRayPos - position;
					obj.fireDir = ((Vector3)(ref val2)).normalized;
					val.owner = localPlayerAgent;
					if (Weapon.CastWeaponRay(((Component)localPlayerAgent.FPSCamera).transform, ref val, position, -1))
					{
						BulletWeapon.BulletHit(val, false, 0f, 0u, true);
						RaycastHit rayHit = val.rayHit;
						if (((Component)((RaycastHit)(ref rayHit)).collider).gameObject.GetComponent<IDamageable>() != null)
						{
							localPlayerAgent.Sound.Post(220841553u, true);
							Vector3 position2 = ((Agent)localPlayerAgent).Position;
							rayHit = val.rayHit;
							Vector3 val3 = position2 - ((RaycastHit)(ref rayHit)).point;
							float magnitude = ((Vector3)(ref val3)).magnitude;
							Vector3 val4 = val3 / magnitude;
							Vector3 val5 = val4 * -1.5f * magnitude;
							Vector3 val6 = Vector3.up * 0.25f * magnitude;
							localPlayerAgent.Locomotion.AddExternalPushForce(val5);
							if (((Agent)localPlayerAgent).Alive)
							{
								localPlayerAgent.Locomotion.ChangeState((PLOC_State)3, true);
								localPlayerAgent.Locomotion.VerticalVelocity = val5 + val6 + Vector3.up * 10f;
							}
						}
						else
						{
							localPlayerAgent.Sound.Post(401606156u, true);
						}
						rayHit = val.rayHit;
						FX_Manager.EffectTargetPosition = ((RaycastHit)(ref rayHit)).point;
					}
					else
					{
						FX_Manager.EffectTargetPosition = localPlayerAgent.FPSCamera.CameraRayPos;
					}
					FX_Manager.PlayLocalVersion = false;
					((FX_EffectBase)BulletWeapon.s_tracerPool.AquireEffect()).Play((FX_Trigger)null, ((Agent)localPlayerAgent).EyePosition, Quaternion.LookRotation(val.fireDir));
				}
				return false;
			}
			return true;
		}
	}
}