Decompiled source of EarlySpawnBoost v1.1.1

EarlySpawnBoost.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
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("EarlySpawnBoost")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3b0ab6dd7695d2016f26f41b410dac17986ad718")]
[assembly: AssemblyProduct("EarlySpawnBoost")]
[assembly: AssemblyTitle("EarlySpawnBoost")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EarlySpawnBoost
{
	[BepInPlugin("com.Nuxlar.EarlySpawnBoost", "EarlySpawnBoost", "1.1.1")]
	public class EarlySpawnBoost : BaseUnityPlugin
	{
		public static ConfigEntry<float> percentIncrease;

		public static ConfigEntry<bool> shouldAffectTP;

		private static ConfigFile ESBConfig { get; set; }

		public void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			ESBConfig = new ConfigFile(Paths.ConfigPath + "\\com.Nuxlar.EarlySpawnBoost.cfg", true);
			percentIncrease = ESBConfig.Bind<float>("General", "Percent Increase", 0.15f, "How many extra credits should the director get in percent?");
			shouldAffectTP = ESBConfig.Bind<bool>("General", "Affect TP Spawns", false, "Should the boost affect teleporter spawn rate?");
			WipeConfig(ESBConfig);
			CombatDirector.Awake += new hook_Awake(CombatDirector_Awake);
		}

		private void CombatDirector_Awake(orig_Awake orig, CombatDirector self)
		{
			if (Object.op_Implicit((Object)(object)Run.instance) && (((Object)Run.instance).name == "ClassicRun(Clone)" || ((Object)Run.instance).name == "EclipseRun(Clone)") && (((Object)self).name == "Director" || (shouldAffectTP.Value && ((Object)self).name == "Teleporter1(Clone)")) && Run.instance.stageClearCount < 2)
			{
				self.creditMultiplier *= 1f + percentIncrease.Value;
			}
			orig.Invoke(self);
		}

		private void WipeConfig(ConfigFile configFile)
		{
			((Dictionary<ConfigDefinition, string>)typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(configFile)).Clear();
			configFile.Save();
		}
	}
}