summaryrefslogtreecommitdiff
path: root/Assembly_Firstpass/Steamworks/SteamInventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assembly_Firstpass/Steamworks/SteamInventory.cs')
-rw-r--r--Assembly_Firstpass/Steamworks/SteamInventory.cs276
1 files changed, 276 insertions, 0 deletions
diff --git a/Assembly_Firstpass/Steamworks/SteamInventory.cs b/Assembly_Firstpass/Steamworks/SteamInventory.cs
new file mode 100644
index 0000000..2ab501b
--- /dev/null
+++ b/Assembly_Firstpass/Steamworks/SteamInventory.cs
@@ -0,0 +1,276 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace Steamworks;
+
+public static class SteamInventory
+{
+ public static EResult GetResultStatus(SteamInventoryResult_t resultHandle)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_GetResultStatus(CSteamAPIContext.GetSteamInventory(), resultHandle);
+ }
+
+ public static bool GetResultItems(SteamInventoryResult_t resultHandle, SteamItemDetails_t[] pOutItemsArray, ref uint punOutItemsArraySize)
+ {
+ InteropHelp.TestIfAvailableClient();
+ if (pOutItemsArray != null && pOutItemsArray.Length != punOutItemsArraySize)
+ {
+ throw new ArgumentException("pOutItemsArray must be the same size as punOutItemsArraySize!");
+ }
+ return NativeMethods.ISteamInventory_GetResultItems(CSteamAPIContext.GetSteamInventory(), resultHandle, pOutItemsArray, ref punOutItemsArraySize);
+ }
+
+ public static bool GetResultItemProperty(SteamInventoryResult_t resultHandle, uint unItemIndex, string pchPropertyName, out string pchValueBuffer, ref uint punValueBufferSizeOut)
+ {
+ InteropHelp.TestIfAvailableClient();
+ IntPtr intPtr = Marshal.AllocHGlobal((int)punValueBufferSizeOut);
+ using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
+ bool flag = NativeMethods.ISteamInventory_GetResultItemProperty(CSteamAPIContext.GetSteamInventory(), resultHandle, unItemIndex, pchPropertyName2, intPtr, ref punValueBufferSizeOut);
+ pchValueBuffer = (flag ? InteropHelp.PtrToStringUTF8(intPtr) : null);
+ Marshal.FreeHGlobal(intPtr);
+ return flag;
+ }
+
+ public static uint GetResultTimestamp(SteamInventoryResult_t resultHandle)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_GetResultTimestamp(CSteamAPIContext.GetSteamInventory(), resultHandle);
+ }
+
+ public static bool CheckResultSteamID(SteamInventoryResult_t resultHandle, CSteamID steamIDExpected)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_CheckResultSteamID(CSteamAPIContext.GetSteamInventory(), resultHandle, steamIDExpected);
+ }
+
+ public static void DestroyResult(SteamInventoryResult_t resultHandle)
+ {
+ InteropHelp.TestIfAvailableClient();
+ NativeMethods.ISteamInventory_DestroyResult(CSteamAPIContext.GetSteamInventory(), resultHandle);
+ }
+
+ public static bool GetAllItems(out SteamInventoryResult_t pResultHandle)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_GetAllItems(CSteamAPIContext.GetSteamInventory(), out pResultHandle);
+ }
+
+ public static bool GetItemsByID(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t[] pInstanceIDs, uint unCountInstanceIDs)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_GetItemsByID(CSteamAPIContext.GetSteamInventory(), out pResultHandle, pInstanceIDs, unCountInstanceIDs);
+ }
+
+ public static bool SerializeResult(SteamInventoryResult_t resultHandle, byte[] pOutBuffer, out uint punOutBufferSize)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_SerializeResult(CSteamAPIContext.GetSteamInventory(), resultHandle, pOutBuffer, out punOutBufferSize);
+ }
+
+ public static bool DeserializeResult(out SteamInventoryResult_t pOutResultHandle, byte[] pBuffer, uint unBufferSize, bool bRESERVED_MUST_BE_FALSE = false)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_DeserializeResult(CSteamAPIContext.GetSteamInventory(), out pOutResultHandle, pBuffer, unBufferSize, bRESERVED_MUST_BE_FALSE);
+ }
+
+ public static bool GenerateItems(out SteamInventoryResult_t pResultHandle, SteamItemDef_t[] pArrayItemDefs, uint[] punArrayQuantity, uint unArrayLength)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_GenerateItems(CSteamAPIContext.GetSteamInventory(), out pResultHandle, pArrayItemDefs, punArrayQuantity, unArrayLength);
+ }
+
+ public static bool GrantPromoItems(out SteamInventoryResult_t pResultHandle)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_GrantPromoItems(CSteamAPIContext.GetSteamInventory(), out pResultHandle);
+ }
+
+ public static bool AddPromoItem(out SteamInventoryResult_t pResultHandle, SteamItemDef_t itemDef)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_AddPromoItem(CSteamAPIContext.GetSteamInventory(), out pResultHandle, itemDef);
+ }
+
+ public static bool AddPromoItems(out SteamInventoryResult_t pResultHandle, SteamItemDef_t[] pArrayItemDefs, uint unArrayLength)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_AddPromoItems(CSteamAPIContext.GetSteamInventory(), out pResultHandle, pArrayItemDefs, unArrayLength);
+ }
+
+ public static bool ConsumeItem(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t itemConsume, uint unQuantity)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_ConsumeItem(CSteamAPIContext.GetSteamInventory(), out pResultHandle, itemConsume, unQuantity);
+ }
+
+ public static bool ExchangeItems(out SteamInventoryResult_t pResultHandle, SteamItemDef_t[] pArrayGenerate, uint[] punArrayGenerateQuantity, uint unArrayGenerateLength, SteamItemInstanceID_t[] pArrayDestroy, uint[] punArrayDestroyQuantity, uint unArrayDestroyLength)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_ExchangeItems(CSteamAPIContext.GetSteamInventory(), out pResultHandle, pArrayGenerate, punArrayGenerateQuantity, unArrayGenerateLength, pArrayDestroy, punArrayDestroyQuantity, unArrayDestroyLength);
+ }
+
+ public static bool TransferItemQuantity(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t itemIdSource, uint unQuantity, SteamItemInstanceID_t itemIdDest)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_TransferItemQuantity(CSteamAPIContext.GetSteamInventory(), out pResultHandle, itemIdSource, unQuantity, itemIdDest);
+ }
+
+ public static void SendItemDropHeartbeat()
+ {
+ InteropHelp.TestIfAvailableClient();
+ NativeMethods.ISteamInventory_SendItemDropHeartbeat(CSteamAPIContext.GetSteamInventory());
+ }
+
+ public static bool TriggerItemDrop(out SteamInventoryResult_t pResultHandle, SteamItemDef_t dropListDefinition)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_TriggerItemDrop(CSteamAPIContext.GetSteamInventory(), out pResultHandle, dropListDefinition);
+ }
+
+ public static bool TradeItems(out SteamInventoryResult_t pResultHandle, CSteamID steamIDTradePartner, SteamItemInstanceID_t[] pArrayGive, uint[] pArrayGiveQuantity, uint nArrayGiveLength, SteamItemInstanceID_t[] pArrayGet, uint[] pArrayGetQuantity, uint nArrayGetLength)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_TradeItems(CSteamAPIContext.GetSteamInventory(), out pResultHandle, steamIDTradePartner, pArrayGive, pArrayGiveQuantity, nArrayGiveLength, pArrayGet, pArrayGetQuantity, nArrayGetLength);
+ }
+
+ public static bool LoadItemDefinitions()
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_LoadItemDefinitions(CSteamAPIContext.GetSteamInventory());
+ }
+
+ public static bool GetItemDefinitionIDs(SteamItemDef_t[] pItemDefIDs, ref uint punItemDefIDsArraySize)
+ {
+ InteropHelp.TestIfAvailableClient();
+ if (pItemDefIDs != null && pItemDefIDs.Length != punItemDefIDsArraySize)
+ {
+ throw new ArgumentException("pItemDefIDs must be the same size as punItemDefIDsArraySize!");
+ }
+ return NativeMethods.ISteamInventory_GetItemDefinitionIDs(CSteamAPIContext.GetSteamInventory(), pItemDefIDs, ref punItemDefIDsArraySize);
+ }
+
+ public static bool GetItemDefinitionProperty(SteamItemDef_t iDefinition, string pchPropertyName, out string pchValueBuffer, ref uint punValueBufferSizeOut)
+ {
+ InteropHelp.TestIfAvailableClient();
+ IntPtr intPtr = Marshal.AllocHGlobal((int)punValueBufferSizeOut);
+ using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
+ bool flag = NativeMethods.ISteamInventory_GetItemDefinitionProperty(CSteamAPIContext.GetSteamInventory(), iDefinition, pchPropertyName2, intPtr, ref punValueBufferSizeOut);
+ pchValueBuffer = (flag ? InteropHelp.PtrToStringUTF8(intPtr) : null);
+ Marshal.FreeHGlobal(intPtr);
+ return flag;
+ }
+
+ public static SteamAPICall_t RequestEligiblePromoItemDefinitionsIDs(CSteamID steamID)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return (SteamAPICall_t)NativeMethods.ISteamInventory_RequestEligiblePromoItemDefinitionsIDs(CSteamAPIContext.GetSteamInventory(), steamID);
+ }
+
+ public static bool GetEligiblePromoItemDefinitionIDs(CSteamID steamID, SteamItemDef_t[] pItemDefIDs, ref uint punItemDefIDsArraySize)
+ {
+ InteropHelp.TestIfAvailableClient();
+ if (pItemDefIDs != null && pItemDefIDs.Length != punItemDefIDsArraySize)
+ {
+ throw new ArgumentException("pItemDefIDs must be the same size as punItemDefIDsArraySize!");
+ }
+ return NativeMethods.ISteamInventory_GetEligiblePromoItemDefinitionIDs(CSteamAPIContext.GetSteamInventory(), steamID, pItemDefIDs, ref punItemDefIDsArraySize);
+ }
+
+ public static SteamAPICall_t StartPurchase(SteamItemDef_t[] pArrayItemDefs, uint[] punArrayQuantity, uint unArrayLength)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return (SteamAPICall_t)NativeMethods.ISteamInventory_StartPurchase(CSteamAPIContext.GetSteamInventory(), pArrayItemDefs, punArrayQuantity, unArrayLength);
+ }
+
+ public static SteamAPICall_t RequestPrices()
+ {
+ InteropHelp.TestIfAvailableClient();
+ return (SteamAPICall_t)NativeMethods.ISteamInventory_RequestPrices(CSteamAPIContext.GetSteamInventory());
+ }
+
+ public static uint GetNumItemsWithPrices()
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_GetNumItemsWithPrices(CSteamAPIContext.GetSteamInventory());
+ }
+
+ public static bool GetItemsWithPrices(SteamItemDef_t[] pArrayItemDefs, ulong[] pCurrentPrices, ulong[] pBasePrices, uint unArrayLength)
+ {
+ InteropHelp.TestIfAvailableClient();
+ if (pArrayItemDefs != null && pArrayItemDefs.Length != unArrayLength)
+ {
+ throw new ArgumentException("pArrayItemDefs must be the same size as unArrayLength!");
+ }
+ if (pCurrentPrices != null && pCurrentPrices.Length != unArrayLength)
+ {
+ throw new ArgumentException("pCurrentPrices must be the same size as unArrayLength!");
+ }
+ if (pBasePrices != null && pBasePrices.Length != unArrayLength)
+ {
+ throw new ArgumentException("pBasePrices must be the same size as unArrayLength!");
+ }
+ return NativeMethods.ISteamInventory_GetItemsWithPrices(CSteamAPIContext.GetSteamInventory(), pArrayItemDefs, pCurrentPrices, pBasePrices, unArrayLength);
+ }
+
+ public static bool GetItemPrice(SteamItemDef_t iDefinition, out ulong pCurrentPrice, out ulong pBasePrice)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_GetItemPrice(CSteamAPIContext.GetSteamInventory(), iDefinition, out pCurrentPrice, out pBasePrice);
+ }
+
+ public static SteamInventoryUpdateHandle_t StartUpdateProperties()
+ {
+ InteropHelp.TestIfAvailableClient();
+ return (SteamInventoryUpdateHandle_t)NativeMethods.ISteamInventory_StartUpdateProperties(CSteamAPIContext.GetSteamInventory());
+ }
+
+ public static bool RemoveProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName)
+ {
+ InteropHelp.TestIfAvailableClient();
+ using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
+ return NativeMethods.ISteamInventory_RemoveProperty(CSteamAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2);
+ }
+
+ public static bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, string pchPropertyValue)
+ {
+ InteropHelp.TestIfAvailableClient();
+ using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
+ using InteropHelp.UTF8StringHandle pchPropertyValue2 = new InteropHelp.UTF8StringHandle(pchPropertyValue);
+ return NativeMethods.ISteamInventory_SetPropertyString(CSteamAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, pchPropertyValue2);
+ }
+
+ public static bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, bool bValue)
+ {
+ InteropHelp.TestIfAvailableClient();
+ using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
+ return NativeMethods.ISteamInventory_SetPropertyBool(CSteamAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, bValue);
+ }
+
+ public static bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, long nValue)
+ {
+ InteropHelp.TestIfAvailableClient();
+ using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
+ return NativeMethods.ISteamInventory_SetPropertyInt64(CSteamAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, nValue);
+ }
+
+ public static bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, float flValue)
+ {
+ InteropHelp.TestIfAvailableClient();
+ using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
+ return NativeMethods.ISteamInventory_SetPropertyFloat(CSteamAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, flValue);
+ }
+
+ public static bool SubmitUpdateProperties(SteamInventoryUpdateHandle_t handle, out SteamInventoryResult_t pResultHandle)
+ {
+ InteropHelp.TestIfAvailableClient();
+ return NativeMethods.ISteamInventory_SubmitUpdateProperties(CSteamAPIContext.GetSteamInventory(), handle, out pResultHandle);
+ }
+
+ public static bool InspectItem(out SteamInventoryResult_t pResultHandle, string pchItemToken)
+ {
+ InteropHelp.TestIfAvailableClient();
+ using InteropHelp.UTF8StringHandle pchItemToken2 = new InteropHelp.UTF8StringHandle(pchItemToken);
+ return NativeMethods.ISteamInventory_InspectItem(CSteamAPIContext.GetSteamInventory(), out pResultHandle, pchItemToken2);
+ }
+}