Decompiled source of Spawn Specific Chest Command v1.0.0

SpawnSpecificChestCommand.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using Dungeonator;
using Gungeon;
using Microsoft.CodeAnalysis;
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("SpawnSpecificChestCommand")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("N/A")]
[assembly: AssemblyProduct("SpawnSpecificChestCommand")]
[assembly: AssemblyCopyright("Copyright © N/A 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fd5c9dc1-0fc1-46ba-b76c-b0c6e1375659")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 SpawnSpecificChestCommand
{
	[BepInPlugin("spapi.etg.spawnspecificchestcommand", "Spawn Specific Chest Command", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "spapi.etg.spawnspecificchestcommand";

		public const string NAME = "Spawn Specific Chest Command";

		public const string VERSION = "1.0.0";

		public void Awake()
		{
			ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
		}

		public void GMStart(GameManager gm)
		{
			ETGModConsole.Commands.AddUnit("spawnspecificchest", (Action<string[]>)SpawnSpecificChest, ETGModConsole.GiveAutocompletionSettings);
		}

		public static void SpawnSpecificChest(string[] args)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected I4, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			if (args.Length < 1)
			{
				ETGModConsole.Log((object)"Item not given!", false);
				return;
			}
			string text = args[0];
			if (!Game.Items.ContainsID(text))
			{
				ETGModConsole.Log((object)("Invalid item ID " + text + "!"), false);
				return;
			}
			if (!GameManager.HasInstance || (Object)(object)GameManager.Instance.PrimaryPlayer == (Object)null)
			{
				ETGModConsole.Log((object)"Player doesn't exist!", false);
				return;
			}
			RoomHandler currentRoom = GameManager.Instance.PrimaryPlayer.CurrentRoom;
			if (currentRoom != null)
			{
				PickupObject val = Game.Items[text];
				RewardManager rewardManager = GameManager.Instance.RewardManager;
				ItemQuality quality = val.quality;
				if (1 == 0)
				{
				}
				Chest val2 = (Chest)((quality - 1) switch
				{
					4 => rewardManager.S_Chest, 
					3 => rewardManager.A_Chest, 
					2 => rewardManager.B_Chest, 
					1 => rewardManager.C_Chest, 
					0 => rewardManager.D_Chest, 
					_ => rewardManager.D_Chest, 
				});
				if (1 == 0)
				{
				}
				Chest val3 = val2;
				IntVector2 bestRewardLocation = currentRoom.GetBestRewardLocation(new IntVector2(2, 1), (RewardLocationStyle)1, true);
				Chest val4 = Chest.Spawn(val3, bestRewardLocation, currentRoom, true);
				if (!((Object)(object)val4 == (Object)null))
				{
					val4.ForceUnlock();
					val4.forceContentIds = new List<int>(1) { val.PickupObjectId };
				}
			}
		}
	}
}