Decompiled source of GiveMeMyBoombox v1.0.0

GiveMeMyBoombox.dll

Decompiled a year ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("GiveMeMyBoombox")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GiveMeMyBoombox")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("acdc1e44-f25f-418b-8f4e-20ee9125b685")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GiveMeMyBoombox;

[BepInPlugin("hox.givememyboombox", "GiveMeMyBoombox", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private const string modGUID = "hox.givememyboombox";

	private const string modName = "GiveMeMyBoombox";

	private const string modVersion = "1.0.0";

	private InputAction spawnKey;

	private void Awake()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin loaded!");
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		spawnKey = new InputAction("LeftArrow", (InputActionType)0, "<Mouse>/backButton", "Press", (string)null, (string)null);
		spawnKey.Enable();
		spawnKey.performed += onSpawnKeyPressed;
	}

	private void onSpawnKeyPressed(CallbackContext context)
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
		{
			string text = "Boombox";
			List<Item> itemsList = StartOfRound.Instance.allItemsList.itemsList;
			foreach (Item item in itemsList)
			{
				if (((Object)item).name == text)
				{
					Vector3 position = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position;
					if (!GameNetworkManager.Instance.localPlayerController.isPlayerDead)
					{
						GameObject val = Object.Instantiate<GameObject>(item.spawnPrefab, position, Quaternion.identity);
						val.GetComponent<GrabbableObject>().fallTime = 0f;
						val.GetComponent<NetworkObject>().Spawn(false);
						((BaseUnityPlugin)this).Logger.LogInfo((object)"Spawned Boombox");
					}
					else
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)"Cant spawn Boombox because the player is dead");
					}
					return;
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Item " + text + " not found"));
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Cant spawn Boombox because the player is not the host");
		}
	}
}