Decompiled source of More Defibro v1.0.0

MoreDefibro.dll

Decompiled 2 days ago
using System.Diagnostics;
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.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DefibroShopMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DefibroShopMod")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e7c7e88a-5b6c-4d4a-9b5e-7f8d9e0c1a2b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreDefibro;

[BepInPlugin("toored.moredefibro", "MoreDefibro", "1.0.0")]
public class MoreDefibro : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ShopManager), "ShopInitialize")]
	private static class ShopManager_ShopInitialize_Patch
	{
		private static void Postfix(ShopManager __instance)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.RunIsShop() || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (_minSpawnCount.Value < 0 || _maxSpawnCount.Value < 0)
			{
				Log.LogWarning((object)"生成数量不能为负数");
			}
			else if (_minPrice.Value <= 1000 || _maxPrice.Value <= 1000)
			{
				Log.LogWarning((object)"价格不得小于等于1000");
			}
			else
			{
				if (!StatsManager.instance.itemDictionary.TryGetValue("Item ReviveItem", out var value))
				{
					return;
				}
				Transform extractionPoint = __instance.extractionPoint;
				if ((Object)(object)extractionPoint == (Object)null)
				{
					return;
				}
				value.value.valueMin = (float)_minPrice.Value / 4f;
				value.value.valueMax = (float)_maxPrice.Value / 4f;
				Vector3 val = Vector3.ProjectOnPlane(extractionPoint.forward, Vector3.up);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				Vector3 val2 = Vector3.Cross(normalized, Vector3.up);
				bool flag = SemiFunc.IsMultiplayer();
				int num = Random.Range(_minSpawnCount.Value, _maxSpawnCount.Value + 1);
				if (num <= 0)
				{
					Log.LogInfo((object)"生成数量为0直接跳过");
					return;
				}
				Log.LogInfo((object)$"正在生成{num}个除颤器...");
				for (int i = 0; i < num; i++)
				{
					float num2 = 2f + (float)(i % 2) * 1.5f;
					float num3 = ((i / 2 % 2 != 0) ? 1 : (-1)) * (i / 2 + 1);
					Vector3 val3 = extractionPoint.position + normalized * num2 + val2 * num3;
					val3.y = 0.5f;
					PrefabRef prefab = value.prefab;
					if ((Object)(object)((prefab != null) ? prefab.Prefab : null) != (Object)null)
					{
						if (flag)
						{
							PhotonNetwork.InstantiateRoomObject(value.prefab.ResourcePath, val3, Quaternion.identity, (byte)0, (object[])null);
						}
						else
						{
							Object.Instantiate<GameObject>(value.prefab.Prefab, val3, Quaternion.identity);
						}
					}
				}
				Log.LogInfo((object)"生成完毕");
			}
		}
	}

	private Harmony _harmony;

	internal static ManualLogSource Log;

	private static ConfigEntry<int> _minSpawnCount;

	private static ConfigEntry<int> _maxSpawnCount;

	private static ConfigEntry<int> _minPrice;

	private static ConfigEntry<int> _maxPrice;

	private void Awake()
	{
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		_minSpawnCount = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "MinSpawnCount", 1, "最小数量");
		_maxSpawnCount = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "MaxSpawnCount", 4, "最大数量");
		_minPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "MinPrice", 2000, "最低价格");
		_maxPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "MaxPrice", 8000, "最高价格");
		_harmony = new Harmony("toored.moredefibro");
		_harmony.PatchAll();
		Log.LogInfo((object)"加载完毕");
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "toored.moredefibro";

	public const string PLUGIN_NAME = "MoreDefibro";

	public const string PLUGIN_VERSION = "1.0.0";
}