mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 06:05:46 +03:00
CraftItem
This commit is contained in:
parent
f91b01d195
commit
2260b222f5
@ -236,13 +236,13 @@ internal bool ConsumeItem( ref SteamInventoryResult_t pResultHandle, InventoryIt
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FExchangeItems( IntPtr self, ref SteamInventoryResult_t pResultHandle, ref InventoryDefId pArrayGenerate, ref uint punArrayGenerateQuantity, uint unArrayGenerateLength, ref InventoryItemId pArrayDestroy, ref uint punArrayDestroyQuantity, uint unArrayDestroyLength );
|
||||
private delegate bool FExchangeItems( IntPtr self, ref SteamInventoryResult_t pResultHandle, [In,Out] InventoryDefId[] pArrayGenerate, [In,Out] uint[] punArrayGenerateQuantity, uint unArrayGenerateLength, [In,Out] InventoryItemId[] pArrayDestroy, [In,Out] uint[] punArrayDestroyQuantity, uint unArrayDestroyLength );
|
||||
private FExchangeItems _ExchangeItems;
|
||||
|
||||
#endregion
|
||||
internal bool ExchangeItems( ref SteamInventoryResult_t pResultHandle, ref InventoryDefId pArrayGenerate, ref uint punArrayGenerateQuantity, uint unArrayGenerateLength, ref InventoryItemId pArrayDestroy, ref uint punArrayDestroyQuantity, uint unArrayDestroyLength )
|
||||
internal bool ExchangeItems( ref SteamInventoryResult_t pResultHandle, [In,Out] InventoryDefId[] pArrayGenerate, [In,Out] uint[] punArrayGenerateQuantity, uint unArrayGenerateLength, [In,Out] InventoryItemId[] pArrayDestroy, [In,Out] uint[] punArrayDestroyQuantity, uint unArrayDestroyLength )
|
||||
{
|
||||
return _ExchangeItems( Self, ref pResultHandle, ref pArrayGenerate, ref punArrayGenerateQuantity, unArrayGenerateLength, ref pArrayDestroy, ref punArrayDestroyQuantity, unArrayDestroyLength );
|
||||
return _ExchangeItems( Self, ref pResultHandle, pArrayGenerate, punArrayGenerateQuantity, unArrayGenerateLength, pArrayDestroy, punArrayDestroyQuantity, unArrayDestroyLength );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
@ -283,13 +283,13 @@ internal bool TriggerItemDrop( ref SteamInventoryResult_t pResultHandle, Invento
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FTradeItems( IntPtr self, ref SteamInventoryResult_t pResultHandle, SteamId steamIDTradePartner, ref InventoryItemId pArrayGive, ref uint pArrayGiveQuantity, uint nArrayGiveLength, ref InventoryItemId pArrayGet, ref uint pArrayGetQuantity, uint nArrayGetLength );
|
||||
private delegate bool FTradeItems( IntPtr self, ref SteamInventoryResult_t pResultHandle, SteamId steamIDTradePartner, [In,Out] InventoryItemId[] pArrayGive, [In,Out] uint[] pArrayGiveQuantity, uint nArrayGiveLength, [In,Out] InventoryItemId[] pArrayGet, [In,Out] uint[] pArrayGetQuantity, uint nArrayGetLength );
|
||||
private FTradeItems _TradeItems;
|
||||
|
||||
#endregion
|
||||
internal bool TradeItems( ref SteamInventoryResult_t pResultHandle, SteamId steamIDTradePartner, ref InventoryItemId pArrayGive, ref uint pArrayGiveQuantity, uint nArrayGiveLength, ref InventoryItemId pArrayGet, ref uint pArrayGetQuantity, uint nArrayGetLength )
|
||||
internal bool TradeItems( ref SteamInventoryResult_t pResultHandle, SteamId steamIDTradePartner, [In,Out] InventoryItemId[] pArrayGive, [In,Out] uint[] pArrayGiveQuantity, uint nArrayGiveLength, [In,Out] InventoryItemId[] pArrayGet, [In,Out] uint[] pArrayGetQuantity, uint nArrayGetLength )
|
||||
{
|
||||
return _TradeItems( Self, ref pResultHandle, steamIDTradePartner, ref pArrayGive, ref pArrayGiveQuantity, nArrayGiveLength, ref pArrayGet, ref pArrayGetQuantity, nArrayGetLength );
|
||||
return _TradeItems( Self, ref pResultHandle, steamIDTradePartner, pArrayGive, pArrayGiveQuantity, nArrayGiveLength, pArrayGet, pArrayGetQuantity, nArrayGetLength );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
|
@ -167,5 +167,26 @@ internal static InventoryDef[] GetDefinitions()
|
||||
return await InventoryResult.GetAsync( sresult );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Crafting! Uses the passed items to buy the target item.
|
||||
/// You need to have set up the appropriate exchange rules in your item
|
||||
/// definitions. This assumes all the items passed in aren't stacked.
|
||||
/// </summary>
|
||||
static async Task<InventoryResult?> CraftItem( InventoryItem[] list, InventoryDef target )
|
||||
{
|
||||
var sresult = default( SteamInventoryResult_t );
|
||||
|
||||
var give = new InventoryDefId[] { target.Id };
|
||||
var givec = new uint[] { 1 };
|
||||
|
||||
var sell = list.Select( x => x.Id ).ToArray();
|
||||
var sellc = list.Select( x => (uint)1 ).ToArray();
|
||||
|
||||
if ( !Internal.ExchangeItems( ref sresult, give, givec, 1, sell, sellc, (uint)sell.Length ) )
|
||||
return null;
|
||||
|
||||
return await InventoryResult.GetAsync( sresult );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -67,14 +67,14 @@ public virtual bool IsVector
|
||||
if ( VarName == "psteamIDClans" ) return true;
|
||||
if ( VarName == "pScoreDetails" ) return true;
|
||||
if ( VarName == "prgUsers" ) return true;
|
||||
if ( VarName == "punArrayQuantity" ) return true;
|
||||
if ( VarName == "pArrayItemDefs" ) return true;
|
||||
if ( VarName == "pBasePrices" ) return true;
|
||||
if ( VarName == "pCurrentPrices" ) return true;
|
||||
if ( VarName == "pItemDefIDs" ) return true;
|
||||
if ( VarName == "pDetails" && Func == "GetDownloadedLeaderboardEntry" ) return true;
|
||||
if ( VarName == "pData" && NativeType.EndsWith( "*" ) && Func.StartsWith( "GetGlobalStatHistory" ) ) return true;
|
||||
if ( NativeType.EndsWith( "**" ) ) return true;
|
||||
if ( VarName.StartsWith( "pArray" ) ) return true;
|
||||
if ( VarName.StartsWith( "punArray" ) ) return true;
|
||||
|
||||
if ( NativeType.EndsWith( "*" ) )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user