Decompiled source of Veteran Rambo v1.0.0

Veteran-Rambo.dll

Decompiled 18 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Veteran-Rambo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Veteran-Rambo")]
[assembly: AssemblyTitle("Veteran-Rambo")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace VeteranRambo
{
	[BepInPlugin("com.gchallenger.veteranrambo", "Veteran-Rambo", "1.0.0")]
	public class VeteranRamboPlugin : BaseUnityPlugin
	{
		public static VeteranRamboPlugin Instance;

		public static ManualLogSource Log;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			ModConfig.Init(((BaseUnityPlugin)this).Config);
			_harmony = new Harmony("com.gchallenger.veteranrambo");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			Log.LogInfo((object)$"Veteran-Rambo 1.0.0 loaded. Enabled={ModConfig.Enabled.Value}");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public static class ModConfig
	{
		public static ConfigEntry<bool> Enabled;

		public static void Init(ConfigFile file)
		{
			Enabled = file.Bind<bool>("General", "Enabled", true, "Включить мгновенную смерть игрока от любого удара моба (false — мод выключен)");
		}
	}
}
namespace VeteranRambo.Patches
{
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	public static class OneHitDeathPatch
	{
		private const float Lethal = 100000000f;

		[HarmonyPrefix]
		public static void Prefix(Character __instance, HitData hit)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			if (!ModConfig.Enabled.Value || !(__instance is Player) || hit == null)
			{
				return;
			}
			Character attacker = hit.GetAttacker();
			if (!((Object)(object)attacker == (Object)null) && !(attacker is Player) && (int)attacker.GetFaction() != 12 && !(((Object)attacker).name == "TrainingDummy") && !(attacker.m_name == "TrainingDummy"))
			{
				hit.m_damage.m_damage = 100000000f;
				hit.m_damage.m_blunt = 100000000f;
				hit.m_damage.m_slash = 100000000f;
				hit.m_damage.m_pierce = 100000000f;
				hit.m_damage.m_chop = 100000000f;
				hit.m_damage.m_pickaxe = 100000000f;
				hit.m_damage.m_fire = 100000000f;
				hit.m_damage.m_frost = 100000000f;
				hit.m_damage.m_lightning = 100000000f;
				hit.m_damage.m_poison = 100000000f;
				hit.m_damage.m_spirit = 100000000f;
				ManualLogSource log = VeteranRamboPlugin.Log;
				if (log != null)
				{
					log.LogInfo((object)("[OneHit] " + attacker.m_name + " ударил игрока — смертельный урон"));
				}
			}
		}
	}
}