Decompiled source of BetterPrimordialTeleporter v1.0.2

BetterPrimordialTeleporter.dll

Decompiled 3 months ago
using System;
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 BepInEx.Logging;
using IL.EntityStates.LunarTeleporter;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("BetterPrimordialTeleporter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterPrimordialTeleporter")]
[assembly: AssemblyTitle("BetterPrimordialTeleporter")]
[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 BetterPrimordialTeleporter
{
	[BepInPlugin("HIFU.BetterPrimordialTeleporter", "BetterPrimordialTeleporter", "1.0.1")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "HIFU.BetterPrimordialTeleporter";

		public const string PluginAuthor = "HIFU";

		public const string PluginName = "BetterPrimordialTeleporter";

		public const string PluginVersion = "1.0.1";

		public static ManualLogSource bptLogger;

		public static InteractableSpawnCard primordialTeleporter;

		public static ConfigEntry<int> minimumStage { get; set; }

		public void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			bptLogger = ((BaseUnityPlugin)this).Logger;
			minimumStage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Minimum Stage", 5, "The minimum stage count required for the Primordial Teleporter to appear.");
			primordialTeleporter = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/Teleporters/iscLunarTeleporter.asset").WaitForCompletion();
			LunarTeleporterBaseState.FixedUpdate += new Manipulator(LunarTeleporterBaseState_FixedUpdate);
			SceneDirector.onPrePopulateSceneServer += SceneDirector_onPrePopulateSceneServer;
		}

		private void SceneDirector_onPrePopulateSceneServer(SceneDirector sd)
		{
			if (Object.op_Implicit((Object)(object)Run.instance) && Run.instance.stageClearCount >= minimumStage.Value - 1 && Object.op_Implicit((Object)(object)sd.teleporterSpawnCard))
			{
				sd.teleporterSpawnCard = (SpawnCard)(object)primordialTeleporter;
			}
		}

		private void LunarTeleporterBaseState_FixedUpdate(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0)
			}))
			{
				int index = val.Index;
				val.Index = index + 1;
				val.EmitDelegate<Func<int, int>>((Func<int, int>)((int useless) => 2));
			}
		}
	}
}