Decompiled source of LifeLink v1.1.0

LifeLink.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Agents;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using EEC.CustomAbilities.Bleed;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LifeLink")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LifeLink")]
[assembly: AssemblyTitle("LifeLink")]
[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 LifeLink
{
	internal static class BleedLinkPatch
	{
		public const string PLUGIN_GUID = "GTFO.EECustomization";

		public static readonly bool HasEEC;

		private static bool _inPatch;

		static BleedLinkPatch()
		{
			HasEEC = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("GTFO.EECustomization");
		}

		[HarmonyPatch(typeof(BleedManager), "DoBleed")]
		[HarmonyPrefix]
		private static bool ShareBleed(BleedingData data)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			if (_inPatch)
			{
				return true;
			}
			List<PlayerAgent> playerAgentsInLevel = PlayerManager.PlayerAgentsInLevel;
			int num = 0;
			Enumerator<PlayerAgent> enumerator = playerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				num += ((!current.Owner.IsBot) ? 1 : 0);
			}
			if (num == 0)
			{
				return true;
			}
			_inPatch = true;
			data.damage /= num;
			enumerator = playerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current2 = enumerator.Current;
				if (!current2.Owner.IsBot)
				{
					BleedManager.DoBleed(current2, data);
				}
			}
			_inPatch = false;
			return false;
		}
	}
	[HarmonyPatch]
	internal class LifeLinkPatch
	{
		private static bool patchHasRun;

		private static bool _inInfect;

		[HarmonyPatch(typeof(Dam_SyncedDamageBase), "SendSetHealth")]
		[HarmonyPrefix]
		public static bool ShareDamage(float health)
		{
			if (patchHasRun || !SNet.IsMaster)
			{
				return true;
			}
			patchHasRun = true;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				((Dam_SyncedDamageBase)enumerator.Current.Damage).SendSetHealth(health);
			}
			patchHasRun = false;
			return false;
		}

		[HarmonyPatch(typeof(Dam_PlayerDamageBase), "OnIncomingDamage")]
		[HarmonyPostfix]
		public static void ResetRegen(Dam_PlayerDamageBase __instance, bool __result)
		{
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (__result)
				{
					PlayerChatManager.WantToSentTextMessage(__instance.Owner, "took a fatal blow and caused a team wipe!", (PlayerAgent)null);
					((Dam_SyncedDamageBase)current.Damage).SendSetDead(true);
				}
				if (((Agent)current).IsLocallyOwned)
				{
					current.Damage.m_nextRegen = Clock.Time + current.PlayerData.healthRegenStartDelayAfterDamage;
				}
				else
				{
					current.Damage.m_nextRegen = float.MaxValue;
				}
			}
		}

		[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ModifyInfection")]
		[HarmonyPostfix]
		public static void ShareInfection(Dam_PlayerDamageBase __instance, bool sync, pInfection data)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!sync || _inInfect)
			{
				return;
			}
			_inInfect = true;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (!(((Il2CppObjectBase)current).Pointer == ((Il2CppObjectBase)__instance.Owner).Pointer))
				{
					current.Damage.ModifyInfection(data, true, true);
				}
			}
			_inInfect = false;
		}
	}
	[BepInPlugin("com.Brandonious.LifeLink", "LifeLink", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Loader : BasePlugin
	{
		public const string MODNAME = "LifeLink";

		public const string AUTHOR = "Brandonious";

		public const string GUID = "com.Brandonious.LifeLink";

		public const string VERSION = "1.0.0";

		public static ManualLogSource Logger;

		public override void Load()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			Harmony val = new Harmony("LifeLink");
			val.PatchAll();
			if (BleedLinkPatch.HasEEC)
			{
				val.PatchAll(typeof(BleedLinkPatch));
			}
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(15, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("LifeLink");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Loaded!");
			}
			log.LogWarning(val2);
		}
	}
}