Decompiled source of OnlyPresents v1.0.1

com.github.zehsteam.OnlyPresents.dll

Decompiled 10 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using com.github.zehsteam.OnlyPresents.Patches;

[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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.zehsteam.OnlyPresents")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Moons will only spawn gift boxes. (Server-side)")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("OnlyPresents")]
[assembly: AssemblyTitle("com.github.zehsteam.OnlyPresents")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 com.github.zehsteam.OnlyPresents
{
	[BepInPlugin("com.github.zehsteam.OnlyPresents", "OnlyPresents", "1.0.1")]
	public class OnlyPresentsBase : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("com.github.zehsteam.OnlyPresents");

		internal static OnlyPresentsBase Instance;

		internal static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("com.github.zehsteam.OnlyPresents");
			mls.LogInfo((object)"OnlyPresents has awoken!");
			harmony.PatchAll(typeof(RoundManagerPatch));
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.OnlyPresents";

		public const string PLUGIN_NAME = "OnlyPresents";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace com.github.zehsteam.OnlyPresents.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		private static List<SpawnableItemWithRarity> previousSpawnableScrap;

		[HarmonyPatch("SpawnScrapInLevel")]
		[HarmonyPrefix]
		[HarmonyPriority(int.MinValue)]
		private static void SpawnScrapInLevelPrefixPatch(ref SelectableLevel ___currentLevel)
		{
			OnlyPresentsBase.mls.LogInfo((object)"Setting spawnable scrap to be only gift boxes.");
			previousSpawnableScrap = ___currentLevel.spawnableScrap;
			List<SpawnableItemWithRarity> _newSpawnableScrap = new List<SpawnableItemWithRarity>();
			___currentLevel.spawnableScrap.ForEach(delegate(SpawnableItemWithRarity spawnable)
			{
				string text = spawnable.spawnableItem.itemName.ToLower();
				if (text.Contains("gift"))
				{
					_newSpawnableScrap.Add(spawnable);
				}
			});
			___currentLevel.spawnableScrap = _newSpawnableScrap;
		}

		[HarmonyPatch("SpawnScrapInLevel")]
		[HarmonyPostfix]
		[HarmonyPriority(int.MaxValue)]
		private static void SpawnScrapInLevelPostfixPatch(ref SelectableLevel ___currentLevel)
		{
			___currentLevel.spawnableScrap = previousSpawnableScrap;
			OnlyPresentsBase.mls.LogInfo((object)"Restoring spawnable scrap to be normal.");
		}
	}
}