Decompiled source of Hardcore v1.0.0

plugins/Hardcore.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Hardcore;

public static class ConfigElements
{
	public static ConfigEntry<float> deathpercentage;

	public static void Init(ConfigFile config)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		deathpercentage = config.Bind<float>("Hardcore Death Chance", "Percentage (%)", 100f, new ConfigDescription("The percentage chance of character loss on death. (Vanilla = 20%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[0]));
	}
}
[BepInPlugin("johbenji.hardcore", "Hardcore", "1.0.0")]
public class HardcorePlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(DefeatScenariosManager), "ActivateDefeatScenario")]
	public class GuaranteedHardCoreDeath
	{
		private static bool Prefix(DefeatScenariosManager __instance, DefeatScenario _scenario)
		{
			__instance.LastActivationNetworkTime = (float)PhotonNetwork.time;
			if (Object.op_Implicit((Object)(object)_scenario))
			{
				if (!_scenario.DontIncreasePlayerDefeatCount && !SceneManagerHelper.ActiveSceneName.ToLower().Contains("tutorial"))
				{
					for (int i = 0; i < CharacterManager.Instance.PlayerCharacters.Count; i++)
					{
						Character character = CharacterManager.Instance.GetCharacter(CharacterManager.Instance.PlayerCharacters.Values[i]);
						if (Object.op_Implicit((Object)(object)character) && character.IsLocalPlayer)
						{
							int totalDefeatCount = character.TotalDefeatCount;
							character.TotalDefeatCount = totalDefeatCount + 1;
						}
					}
				}
				if (CharacterManager.Instance.HardcoreMode && _scenario.SupportHardcore && (float)Random.Range(0, 100) < ConfigElements.deathpercentage.Value)
				{
					((MonoBehaviour)__instance).photonView.RPC("DefeatHardcoreDeath", (PhotonTargets)0, Array.Empty<object>());
					return false;
				}
				__instance.m_activeDefeatScenarioID = _scenario.ID;
				((AreaEvent)_scenario).Activate();
				((MonoBehaviour)__instance).photonView.RPC("DefeatScenarioActivated", (PhotonTargets)0, new object[3] { _scenario.ID, false, __instance.LastActivationNetworkTime });
			}
			else
			{
				__instance.FailSafeDefeat();
			}
			__instance.m_notRealDefeat = false;
			return false;
		}
	}

	public const string GUID = "johbenji.hardcore";

	public const string NAME = "Hardcore";

	public const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	public static ConfigEntry<bool> ExampleConfig;

	internal void Awake()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		ConfigElements.Init(((BaseUnityPlugin)this).Config);
		new Harmony("johbenji.hardcore").PatchAll();
	}

	internal void Update()
	{
	}
}