mirror of
https://github.com/Pathoschild/SMAPI.git
synced 2026-10-12 02:08:51 +00:00
update rewriters for 1.6.9
This commit is contained in:
@@ -13,7 +13,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
|
||||
*********/
|
||||
public Building getBuilding()
|
||||
{
|
||||
return base.GetContainingBuilding();
|
||||
return base.ParentBuilding; // new in 1.6.9
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
|
||||
default:
|
||||
for (int i = 0; i < base.Items.Count; i++)
|
||||
{
|
||||
if (base.Items[i] is SObject obj && obj.parentSheetIndex == index)
|
||||
if (base.Items[i] is SObject obj && obj.parentSheetIndex.Value == index)
|
||||
{
|
||||
if (obj.Stack > stack)
|
||||
{
|
||||
@@ -274,7 +274,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
|
||||
|
||||
public void revealGiftTaste(NPC npc, SObject item)
|
||||
{
|
||||
if (!item.bigCraftable)
|
||||
if (!item.bigCraftable.Value)
|
||||
base.revealGiftTaste(npc.Name, item.ItemId);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Netcode;
|
||||
using StardewModdingAPI.Framework.ModLoading.Framework;
|
||||
using StardewValley;
|
||||
using StardewValley.Audio;
|
||||
using StardewValley.Buildings;
|
||||
using StardewValley.Extensions;
|
||||
using StardewValley.Objects;
|
||||
using xTile.Dimensions;
|
||||
@@ -28,6 +29,12 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
|
||||
return base.characters;
|
||||
}
|
||||
|
||||
/// <remarks>Changed in Stardew Valley 1.6.9.</remarks>
|
||||
public Building GetContainingBuilding()
|
||||
{
|
||||
return base.ParentBuilding;
|
||||
}
|
||||
|
||||
public virtual int getExtraMillisecondsPerInGameMinuteForThisLocation()
|
||||
{
|
||||
return base.ExtraMillisecondsPerInGameMinute;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using StardewModdingAPI.Framework.ModLoading.Framework;
|
||||
using StardewValley;
|
||||
using StardewValley.GameData.Shops;
|
||||
using StardewValley.Menus;
|
||||
|
||||
namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
|
||||
@@ -23,16 +25,35 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
|
||||
/*********
|
||||
** Public methods
|
||||
*********/
|
||||
/// <remarks>Changed in 1.6.0.</remarks>
|
||||
public static ShopMenu Constructor(Dictionary<ISalable, int[]> itemPriceAndStock, int currency = 0, string? who = null, Func<ISalable, Farmer, int, bool>? on_purchase = null, Func<ISalable, bool>? on_sell = null, string? context = null)
|
||||
{
|
||||
return new ShopMenu(ShopMenuFacade.GetShopId(context), ShopMenuFacade.ToItemStockInformation(itemPriceAndStock), currency, who, on_purchase, on_sell, playOpenSound: true);
|
||||
return new ShopMenu(ShopMenuFacade.GetShopId(context), ShopMenuFacade.ToItemStockInformation(itemPriceAndStock), currency, who, ToOnPurchaseDelegate(on_purchase), on_sell, playOpenSound: true);
|
||||
}
|
||||
|
||||
/// <remarks>Changed in 1.6.0.</remarks>
|
||||
public static ShopMenu Constructor(List<ISalable> itemsForSale, int currency = 0, string? who = null, Func<ISalable, Farmer, int, bool>? on_purchase = null, Func<ISalable, bool>? on_sell = null, string? context = null)
|
||||
{
|
||||
return new ShopMenu(ShopMenuFacade.GetShopId(context), itemsForSale, currency, who, on_purchase, on_sell, playOpenSound: true);
|
||||
return new ShopMenu(ShopMenuFacade.GetShopId(context), itemsForSale, currency, who, ToOnPurchaseDelegate(on_purchase), on_sell, playOpenSound: true);
|
||||
}
|
||||
|
||||
/// <remarks>Changed in 1.6.9.</remarks>
|
||||
public static ShopMenu Constructor(string shopId, ShopData shopData, ShopOwnerData ownerData, NPC? owner = null, Func<ISalable, Farmer, int, bool>? onPurchase = null, Func<ISalable, bool>? onSell = null, bool playOpenSound = true)
|
||||
{
|
||||
return new ShopMenu(shopId, shopData, ownerData, owner, ToOnPurchaseDelegate(onPurchase), onSell, playOpenSound: true);
|
||||
}
|
||||
|
||||
/// <remarks>Changed in 1.6.9.</remarks>
|
||||
public static ShopMenu Constructor(string shopId, Dictionary<ISalable, ItemStockInformation> itemPriceAndStock, int currency = 0, string? who = null, Func<ISalable, Farmer, int, bool>? on_purchase = null, Func<ISalable, bool>? on_sell = null, bool playOpenSound = true)
|
||||
{
|
||||
return new ShopMenu(shopId, itemPriceAndStock, currency, who, ToOnPurchaseDelegate(on_purchase), on_sell, playOpenSound);
|
||||
}
|
||||
|
||||
/// <remarks>Changed in 1.6.9.</remarks>
|
||||
public static ShopMenu Constructor(string shopId, List<ISalable> itemsForSale, int currency = 0, string? who = null, Func<ISalable, Farmer, int, bool>? on_purchase = null, Func<ISalable, bool>? on_sell = null, bool playOpenSound = true)
|
||||
{
|
||||
return new ShopMenu(shopId, itemsForSale, currency, who, ToOnPurchaseDelegate(on_purchase), on_sell, playOpenSound);
|
||||
}
|
||||
|
||||
/*********
|
||||
** Private methods
|
||||
@@ -62,5 +83,15 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
|
||||
|
||||
return stock;
|
||||
}
|
||||
|
||||
/// <summary>Convert a pre-1.6.9 <see cref="ShopMenu.onPurchase"/> callback into its new delegate type.</summary>
|
||||
/// <param name="onPurchase">The callback to convert.</param>
|
||||
[return: NotNullIfNotNull(nameof(onPurchase))]
|
||||
private static ShopMenu.OnPurchaseDelegate? ToOnPurchaseDelegate(Func<ISalable, Farmer, int, bool>? onPurchase)
|
||||
{
|
||||
return onPurchase != null
|
||||
? (item, who, countTaken, _) => onPurchase(item, who, countTaken)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user