Decompiled source of AutoChangeSellPrice v1.0.0

BepInEx/plugins/AutoChangeSellPrice.dll

Decompiled 3 days ago
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 HarmonyLib;
using Unity.Netcode;
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("AutoChangeSellPrice")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AutoChangeSellPrice")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("28bf9089-b919-4632-a8ff-517d68b15e39")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(GameManager))]
[HarmonyPatch("OnTimelineChanged")]
public static class AutoChangeSellPricePatch
{
	private static readonly FieldInfo _itemId = AccessTools.Field(typeof(Item), "itemId");

	[HarmonyPostfix]
	public static void Postfix(GameManager __instance, float current)
	{
		if (current <= 6f || current >= 6.03f)
		{
			return;
		}
		List<Item> list = Resources.FindObjectsOfTypeAll<Item>().ToList();
		int yesterday = __instance.GetDayValue() - 1;
		List<long> list2 = new List<long>();
		for (int i = 0; i < list.Count; i++)
		{
			if (!((Object)(object)list[i].itemSO != (Object)null) || !list[i].onStand.Value)
			{
				continue;
			}
			NetworkVariable<long> val = (NetworkVariable<long>)_itemId.GetValue(list[i]);
			ItemSO itemById = __instance.GetItemById(val.Value);
			if (!((NetworkBehaviour)list[i]).IsServer)
			{
				continue;
			}
			ProductSO val2 = (ProductSO)(object)((itemById is ProductSO) ? itemById : null);
			if ((Object)(object)val2 != (Object)null)
			{
				int sellingPriceServer = GameManager.Instance.GetSellingPriceServer(val2);
				int num = RecommendedPrice(val2, yesterday, __instance);
				int recommendedPrice = GameManager.Instance.GetRecommendedPrice(val2);
				if (sellingPriceServer == num && recommendedPrice != num && !list2.Contains(val.Value))
				{
					list[i].sellingPriceForTag.Value = recommendedPrice;
					__instance.UpdatePriceServerRpc(((ItemSO)val2).id, recommendedPrice);
					list2.Add(val.Value);
				}
			}
		}
	}

	public static int RecommendedPrice(ProductSO productSO, int yesterday, GameManager gameManager)
	{
		float num = (float)(100 + productSO.recommendedProfitPercentage) / 100f;
		return Mathf.RoundToInt((float)gameManager.GetWholesalePrice(productSO, yesterday) * num);
	}
}
[BepInPlugin("com.lan.AutoChangeSellPrice", "自动更改商品售价", "1.0.0")]
public class Patcher : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("com.lan.AutoChangeSellPrice");
		val.PatchAll();
		Debug.LogWarning((object)"自动更改商品售价 --作者:她说缝上都不给我");
	}
}