Decompiled source of More Vengeance v2.1.0

MoreVengence.dll

Decompiled a week ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using On.RoR2.Artifacts;
using R2API;
using RoR2;
using RoR2.Artifacts;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MoreVengence")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreVengence")]
[assembly: AssemblyTitle("MoreVengence")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreVengeance;

[BepInPlugin("com.FortressForce.MoreVengeance", "More Vengeance", "2.1.0")]
public class MoreVengeancePlugin : BaseUnityPlugin
{
	private static ConfigEntry<int> IntervalConfig;

	public void Awake()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		IntervalConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Game", "Interval", 300, "Sets the period for Vengeance spawns in seconds. Default is 300 (5 mins). Lower = Harder.");
		DoppelgangerInvasionManager.GetCurrentInvasionCycle += new hook_GetCurrentInvasionCycle(GetCustomInvasionCycle);
		UpdateVengeanceDescription();
		Run.onRunStartGlobal += delegate
		{
			UpdateVengeanceDescription();
		};
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"MoreVengeance loaded! Interval set to {IntervalConfig.Value} seconds.");
		UpdateVengeanceDescription();
	}

	private static void UpdateVengeanceDescription()
	{
		_ = Artifacts.ShadowClone;
		int num = IntervalConfig.Value;
		if (num <= 0)
		{
			num = 300;
		}
		int num2 = num / 60;
		int num3 = num % 60;
		string text = ((num2 > 0 && num3 > 0) ? string.Format("{0} minute{1} and {2} second{3}", num2, (num2 == 1) ? "" : "s", num3, (num3 == 1) ? "" : "s") : ((num2 <= 0) ? string.Format("{0} second{1}", num3, (num3 == 1) ? "" : "s") : string.Format("{0} minute{1}", num2, (num2 == 1) ? "" : "s")));
		LanguageAPI.Add("ARTIFACT_SHADOWCLONE_DESCRIPTION", "Your relentless doppelganger will invade every " + text + ".", "en");
	}

	private int GetCustomInvasionCycle(orig_GetCurrentInvasionCycle orig, DoppelgangerInvasionManager self)
	{
		int num = IntervalConfig.Value;
		if (num <= 0)
		{
			num = 300;
		}
		return Mathf.FloorToInt(Run.instance.GetRunStopwatch() / (float)num);
	}

	[ConCommand(/*Could not decode attribute arguments.*/)]
	private static void SetVengeancePeriod(ConCommandArgs args)
	{
		if (((ConCommandArgs)(ref args)).Count > 0 && int.TryParse(((ConCommandArgs)(ref args))[0], out var result))
		{
			if (result > 0)
			{
				IntervalConfig.Value = result;
				Debug.Log((object)$"Vengeance Frequency updated to {result} seconds.");
				UpdateVengeanceDescription();
			}
			else
			{
				Debug.Log((object)"Time must be greater than 0.");
			}
		}
		else
		{
			Debug.Log((object)"Invalid input. Usage: set_vengeance_period [seconds]");
		}
	}
}