Decompiled source of ARC Complex v1.0.1

BepInEx/plugins/ARC_Complex/Parry.dll

Decompiled a week 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("Parry")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Parry")]
[assembly: AssemblyTitle("Parry")]
[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;
		}
	}
}
namespace ParryPlugin
{
	[BepInPlugin("ParryPlugin", "ParryPlugin", "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("ParryPlugin.GUID.Harmony");
			_Harmony.PatchAll();
		}

		public override bool Unload()
		{
			_Harmony.UnpatchSelf();
			return ((BasePlugin)this).Unload();
		}
	}
	[HarmonyPatch]
	internal static 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;
		}
	}
}