Decompiled source of UltraRareBuff v1.0.0

plugins/UltraRareBuff.dll

Decompiled 19 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
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("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b02b47e0-868d-46fc-840e-b5b3046b62f4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.jair.ultrararebuff", "Ultra Rare Buff", "1.1.0")]
public class UltraRareBuff : BaseUnityPlugin
{
	public static ManualLogSource Log;

	public static ConfigEntry<int> UltraRareAmount;

	private void Awake()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		UltraRareAmount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "UltraRareAmount", 3, "Cantidad de cajas UltraRare por partida");
		Harmony val = new Harmony("com.jair.ultrararebuff");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Ultra Rare Buff cargado!");
	}
}
[HarmonyPatch(typeof(ValuableDirector), "SetupHost")]
public class ValuableDirectorPatch
{
	private static void Postfix(ValuableDirector __instance)
	{
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		UltraRareBuff.Log.LogInfo((object)"Forzando spawn de UltraRare...");
		try
		{
			CosmeticWorldObjectSetup ultraRareSetup = __instance.cosmeticWorldObjectSetups[3];
			List<ValuableVolume> list = (from v in Object.FindObjectsOfType<ValuableVolume>(false)
				where v.VolumeType == ultraRareSetup.volume
				orderby Random.value
				select v).ToList();
			if (list.Count == 0)
			{
				UltraRareBuff.Log.LogWarning((object)"No se encontraron volumes válidos");
				return;
			}
			PrefabRef prefab = ultraRareSetup.prefab;
			int num = Mathf.Min(UltraRareBuff.UltraRareAmount.Value, list.Count);
			for (int i = 0; i < num; i++)
			{
				ValuableVolume val = list[0];
				list.RemoveAt(0);
				if (GameManager.instance.gameMode == 0)
				{
					Object.Instantiate<GameObject>(prefab.Prefab, ((Component)val).transform.position, ((Component)val).transform.rotation);
				}
				else
				{
					PhotonNetwork.InstantiateRoomObject(prefab.ResourcePath, ((Component)val).transform.position, ((Component)val).transform.rotation, (byte)0, (object[])null);
				}
				UltraRareBuff.Log.LogInfo((object)$"UltraRare #{i + 1} spawn en {((Object)val).name}");
			}
			UltraRareBuff.Log.LogInfo((object)$"Spawn completado: {num} UltraRare");
		}
		catch (Exception ex)
		{
			UltraRareBuff.Log.LogError((object)ex);
		}
	}
}