Decompiled source of LifeLink v1.0.0

LifeLink.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Agents;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;

[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("LifeLink")]
[assembly: AssemblyConfiguration("Debug")]
[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
{
	[HarmonyPatch]
	internal class LifeLinkPatch
	{
		private static bool patchHasRun;

		private static bool patchHasDie;

		[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())
			{
				PlayerAgent current = enumerator.Current;
				((Dam_SyncedDamageBase)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, __instance.Owner.PlayerName + " 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;
				}
			}
		}
	}
	[BepInPlugin("com.Brandonious.LifeLink", "LifeLink", "1.0.0")]
	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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			Harmony val = new Harmony("LifeLink");
			val.PatchAll();
			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);
		}
	}
}