Decompiled source of EZDamage v1.0.0

EZDamage.dll

Decompiled 3 weeks 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 EZDamage.Controllers;
using EZDamage.Data;
using GameNetcodeStuff;
using HarmonyLib;
using LethalNetworkAPI;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EZDamage")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EZDamage")]
[assembly: AssemblyTitle("EZDamage")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 EZDamage
{
	public static class API
	{
		public static void DamagePlayers(Vector3 center, float radius = 1f, int damage = 1, CauseOfDeath causeOfDeath = 0)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			PlayerDamageData playerDamageData = default(PlayerDamageData);
			playerDamageData.center = new SVector3(center);
			playerDamageData.radius = radius;
			playerDamageData.damage = damage;
			playerDamageData.causeOfDeath = ((object)(CauseOfDeath)(ref causeOfDeath)).ToString();
			PlayerDamageData playerDamageData2 = playerDamageData;
			EZDamage.PlayerDamageMessage.SendServer(playerDamageData2);
		}

		public static void DamageEnemies(Vector3 center, float radius = 1f, int damage = 1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			DamageController.DamageOrKillEnemiesInRadius(center, radius, damage);
		}

		public static void KillPlayers(Vector3 center, float radius = 1f, CauseOfDeath causeOfDeath = 0)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			PlayerDamageData playerDamageData = default(PlayerDamageData);
			playerDamageData.center = new SVector3(center);
			playerDamageData.radius = radius;
			playerDamageData.damage = -1;
			playerDamageData.causeOfDeath = ((object)(CauseOfDeath)(ref causeOfDeath)).ToString();
			PlayerDamageData playerDamageData2 = playerDamageData;
			EZDamage.PlayerDamageMessage.SendServer(playerDamageData2);
		}

		public static void KillEnemies(Vector3 center, float radius = 1f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			DamageController.DamageOrKillEnemiesInRadius(center, radius, -1);
		}

		public static void DamageEverything(Vector3 center, float radius = 1f, int damage = 1, CauseOfDeath causeOfDeath = 0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			DamagePlayers(center, radius, damage, causeOfDeath);
			DamageEnemies(center, radius, damage);
		}

		public static void KillEverything(Vector3 center, float radius = 1f, CauseOfDeath causeOfDeath = 0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			DamagePlayers(center, radius, -1, causeOfDeath);
			DamageEnemies(center, radius, -1);
		}
	}
	[BepInPlugin("com.jacobot5.EZDamage", "EZDamage", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class EZDamage : BaseUnityPlugin
	{
		public const string GUID = "com.jacobot5.EZDamage";

		public const string NAME = "EZDamage";

		public const string VERSION = "1.0.0";

		private readonly Harmony harmony = new Harmony("com.jacobot5.EZDamage");

		internal static ManualLogSource Log;

		internal static LNetworkMessage<PlayerDamageData> PlayerDamageMessage { get; private set; }

		private void Awake()
		{
			Log = Logger.CreateLogSource("com.jacobot5.EZDamage");
			Log.LogInfo((object)"EZDamage has awoken.");
			PlayerDamageMessage = LNetworkMessage<PlayerDamageData>.Connect("EZDamage_Strike", (Action<PlayerDamageData, ulong>)null, (Action<PlayerDamageData>)null, (Action<PlayerDamageData, ulong>)null);
			PlayerDamageMessage.OnServerReceived += OnDamageServer;
			PlayerDamageMessage.OnClientReceived += OnDamageClient;
		}

		private void OnDamageServer(PlayerDamageData data, ulong sender)
		{
			PlayerDamageMessage.SendClients(data);
		}

		private void OnDamageClient(PlayerDamageData data)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			DamageController.DamageOrKillPlayersInRadius(data.center.ToVector3(), data.radius, data.damage, data.causeOfDeath);
		}
	}
}
namespace EZDamage.Data
{
	[Serializable]
	public struct SVector3
	{
		public float x;

		public float y;

		public float z;

		public SVector3(Vector3 v)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			x = v.x;
			y = v.y;
			z = v.z;
		}

		public Vector3 ToVector3()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(x, y, z);
		}
	}
	[Serializable]
	public struct PlayerDamageData
	{
		public SVector3 center;

		public float radius;

		public int damage;

		public string causeOfDeath;
	}
}
namespace EZDamage.Controllers
{
	public class DamageController
	{
		public static int combinedLayers = 1084754248;

		public static void DamageOrKillPlayersInRadius(Vector3 center, float radius, int damage, string deathString)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			CauseOfDeath result;
			CauseOfDeath val = ((!Enum.TryParse<CauseOfDeath>(deathString, out result)) ? ((CauseOfDeath)0) : result);
			Collider[] array = Physics.OverlapSphere(center, radius, combinedLayers, (QueryTriggerInteraction)2);
			Collider[] array2 = array;
			foreach (Collider val2 in array2)
			{
				PlayerControllerB component = ((Component)val2).GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && (Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					if (damage == -1)
					{
						component.KillPlayer(Vector3.down * 17f, true, val, 0, default(Vector3));
					}
					else
					{
						component.DamagePlayer(damage, true, true, val, 0, false, Vector3.down * 17f);
					}
				}
			}
		}

		public static void DamageOrKillEnemiesInRadius(Vector3 center, float radius, int damage)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(center, radius, combinedLayers, (QueryTriggerInteraction)2);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				EnemyAICollisionDetect component = ((Component)val).GetComponent<EnemyAICollisionDetect>();
				if (!((Object)(object)component != (Object)null) || !((Object)(object)component.mainScript != (Object)null))
				{
					continue;
				}
				EnemyAI mainScript = component.mainScript;
				if (!((NetworkBehaviour)mainScript).IsOwner || mainScript.isEnemyDead || !mainScript.enemyType.canDie)
				{
					continue;
				}
				if (damage == -1)
				{
					mainScript.KillEnemyOnOwnerClient(false);
					continue;
				}
				IHittable val2 = (IHittable)(object)((mainScript is IHittable) ? mainScript : null);
				if (val2 != null)
				{
					int num = Mathf.Clamp(damage / 25, 1, 5);
					val2.Hit(num, Vector3.down, GameNetworkManager.Instance.localPlayerController, true, -1);
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}