isteamgameserverinventory.cs (30054B)
1 // This file is provided under The MIT License as part of Steamworks.NET. 2 // Copyright (c) 2013-2019 Riley Labrecque 3 // Please see the included LICENSE.txt for additional information. 4 5 // This file is automatically generated. 6 // Changes to this file will be reverted when you update Steamworks.NET 7 8 #if UNITY_ANDROID || UNITY_IOS || UNITY_TIZEN || UNITY_TVOS || UNITY_WEBGL || UNITY_WSA || UNITY_PS4 || UNITY_WII || UNITY_XBOXONE || UNITY_SWITCH 9 #define DISABLESTEAMWORKS 10 #endif 11 12 #if !DISABLESTEAMWORKS 13 14 using System.Runtime.InteropServices; 15 using IntPtr = System.IntPtr; 16 17 namespace Steamworks { 18 public static class SteamGameServerInventory { 19 /// <summary> 20 /// <para> INVENTORY ASYNC RESULT MANAGEMENT</para> 21 /// <para> Asynchronous inventory queries always output a result handle which can be used with</para> 22 /// <para> GetResultStatus, GetResultItems, etc. A SteamInventoryResultReady_t callback will</para> 23 /// <para> be triggered when the asynchronous result becomes ready (or fails).</para> 24 /// <para> Find out the status of an asynchronous inventory result handle. Possible values:</para> 25 /// <para> k_EResultPending - still in progress</para> 26 /// <para> k_EResultOK - done, result ready</para> 27 /// <para> k_EResultExpired - done, result ready, maybe out of date (see DeserializeResult)</para> 28 /// <para> k_EResultInvalidParam - ERROR: invalid API call parameters</para> 29 /// <para> k_EResultServiceUnavailable - ERROR: service temporarily down, you may retry later</para> 30 /// <para> k_EResultLimitExceeded - ERROR: operation would exceed per-user inventory limits</para> 31 /// <para> k_EResultFail - ERROR: unknown / generic error</para> 32 /// </summary> 33 public static EResult GetResultStatus(SteamInventoryResult_t resultHandle) { 34 InteropHelp.TestIfAvailableGameServer(); 35 return NativeMethods.ISteamInventory_GetResultStatus(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle); 36 } 37 38 /// <summary> 39 /// <para> Copies the contents of a result set into a flat array. The specific</para> 40 /// <para> contents of the result set depend on which query which was used.</para> 41 /// </summary> 42 public static bool GetResultItems(SteamInventoryResult_t resultHandle, SteamItemDetails_t[] pOutItemsArray, ref uint punOutItemsArraySize) { 43 InteropHelp.TestIfAvailableGameServer(); 44 if (pOutItemsArray != null && pOutItemsArray.Length != punOutItemsArraySize) { 45 throw new System.ArgumentException("pOutItemsArray must be the same size as punOutItemsArraySize!"); 46 } 47 return NativeMethods.ISteamInventory_GetResultItems(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle, pOutItemsArray, ref punOutItemsArraySize); 48 } 49 50 /// <summary> 51 /// <para> In combination with GetResultItems, you can use GetResultItemProperty to retrieve</para> 52 /// <para> dynamic string properties for a given item returned in the result set.</para> 53 /// <para> Property names are always composed of ASCII letters, numbers, and/or underscores.</para> 54 /// <para> Pass a NULL pointer for pchPropertyName to get a comma - separated list of available</para> 55 /// <para> property names.</para> 56 /// <para> If pchValueBuffer is NULL, *punValueBufferSize will contain the</para> 57 /// <para> suggested buffer size. Otherwise it will be the number of bytes actually copied</para> 58 /// <para> to pchValueBuffer. If the results do not fit in the given buffer, partial</para> 59 /// <para> results may be copied.</para> 60 /// </summary> 61 public static bool GetResultItemProperty(SteamInventoryResult_t resultHandle, uint unItemIndex, string pchPropertyName, out string pchValueBuffer, ref uint punValueBufferSizeOut) { 62 InteropHelp.TestIfAvailableGameServer(); 63 IntPtr pchValueBuffer2 = Marshal.AllocHGlobal((int)punValueBufferSizeOut); 64 using (var pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName)) { 65 bool ret = NativeMethods.ISteamInventory_GetResultItemProperty(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle, unItemIndex, pchPropertyName2, pchValueBuffer2, ref punValueBufferSizeOut); 66 pchValueBuffer = ret ? InteropHelp.PtrToStringUTF8(pchValueBuffer2) : null; 67 Marshal.FreeHGlobal(pchValueBuffer2); 68 return ret; 69 } 70 } 71 72 /// <summary> 73 /// <para> Returns the server time at which the result was generated. Compare against</para> 74 /// <para> the value of IClientUtils::GetServerRealTime() to determine age.</para> 75 /// </summary> 76 public static uint GetResultTimestamp(SteamInventoryResult_t resultHandle) { 77 InteropHelp.TestIfAvailableGameServer(); 78 return NativeMethods.ISteamInventory_GetResultTimestamp(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle); 79 } 80 81 /// <summary> 82 /// <para> Returns true if the result belongs to the target steam ID, false if the</para> 83 /// <para> result does not. This is important when using DeserializeResult, to verify</para> 84 /// <para> that a remote player is not pretending to have a different user's inventory.</para> 85 /// </summary> 86 public static bool CheckResultSteamID(SteamInventoryResult_t resultHandle, CSteamID steamIDExpected) { 87 InteropHelp.TestIfAvailableGameServer(); 88 return NativeMethods.ISteamInventory_CheckResultSteamID(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle, steamIDExpected); 89 } 90 91 /// <summary> 92 /// <para> Destroys a result handle and frees all associated memory.</para> 93 /// </summary> 94 public static void DestroyResult(SteamInventoryResult_t resultHandle) { 95 InteropHelp.TestIfAvailableGameServer(); 96 NativeMethods.ISteamInventory_DestroyResult(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle); 97 } 98 99 /// <summary> 100 /// <para> INVENTORY ASYNC QUERY</para> 101 /// <para> Captures the entire state of the current user's Steam inventory.</para> 102 /// <para> You must call DestroyResult on this handle when you are done with it.</para> 103 /// <para> Returns false and sets *pResultHandle to zero if inventory is unavailable.</para> 104 /// <para> Note: calls to this function are subject to rate limits and may return</para> 105 /// <para> cached results if called too frequently. It is suggested that you call</para> 106 /// <para> this function only when you are about to display the user's full inventory,</para> 107 /// <para> or if you expect that the inventory may have changed.</para> 108 /// </summary> 109 public static bool GetAllItems(out SteamInventoryResult_t pResultHandle) { 110 InteropHelp.TestIfAvailableGameServer(); 111 return NativeMethods.ISteamInventory_GetAllItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle); 112 } 113 114 /// <summary> 115 /// <para> Captures the state of a subset of the current user's Steam inventory,</para> 116 /// <para> identified by an array of item instance IDs. The results from this call</para> 117 /// <para> can be serialized and passed to other players to "prove" that the current</para> 118 /// <para> user owns specific items, without exposing the user's entire inventory.</para> 119 /// <para> For example, you could call GetItemsByID with the IDs of the user's</para> 120 /// <para> currently equipped cosmetic items and serialize this to a buffer, and</para> 121 /// <para> then transmit this buffer to other players upon joining a game.</para> 122 /// </summary> 123 public static bool GetItemsByID(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t[] pInstanceIDs, uint unCountInstanceIDs) { 124 InteropHelp.TestIfAvailableGameServer(); 125 return NativeMethods.ISteamInventory_GetItemsByID(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, pInstanceIDs, unCountInstanceIDs); 126 } 127 128 /// <summary> 129 /// <para> RESULT SERIALIZATION AND AUTHENTICATION</para> 130 /// <para> Serialized result sets contain a short signature which can't be forged</para> 131 /// <para> or replayed across different game sessions. A result set can be serialized</para> 132 /// <para> on the local client, transmitted to other players via your game networking,</para> 133 /// <para> and deserialized by the remote players. This is a secure way of preventing</para> 134 /// <para> hackers from lying about posessing rare/high-value items.</para> 135 /// <para> Serializes a result set with signature bytes to an output buffer. Pass</para> 136 /// <para> NULL as an output buffer to get the required size via punOutBufferSize.</para> 137 /// <para> The size of a serialized result depends on the number items which are being</para> 138 /// <para> serialized. When securely transmitting items to other players, it is</para> 139 /// <para> recommended to use "GetItemsByID" first to create a minimal result set.</para> 140 /// <para> Results have a built-in timestamp which will be considered "expired" after</para> 141 /// <para> an hour has elapsed. See DeserializeResult for expiration handling.</para> 142 /// </summary> 143 public static bool SerializeResult(SteamInventoryResult_t resultHandle, byte[] pOutBuffer, out uint punOutBufferSize) { 144 InteropHelp.TestIfAvailableGameServer(); 145 return NativeMethods.ISteamInventory_SerializeResult(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle, pOutBuffer, out punOutBufferSize); 146 } 147 148 /// <summary> 149 /// <para> Deserializes a result set and verifies the signature bytes. Returns false</para> 150 /// <para> if bRequireFullOnlineVerify is set but Steam is running in Offline mode.</para> 151 /// <para> Otherwise returns true and then delivers error codes via GetResultStatus.</para> 152 /// <para> The bRESERVED_MUST_BE_FALSE flag is reserved for future use and should not</para> 153 /// <para> be set to true by your game at this time.</para> 154 /// <para> DeserializeResult has a potential soft-failure mode where the handle status</para> 155 /// <para> is set to k_EResultExpired. GetResultItems() still succeeds in this mode.</para> 156 /// <para> The "expired" result could indicate that the data may be out of date - not</para> 157 /// <para> just due to timed expiration (one hour), but also because one of the items</para> 158 /// <para> in the result set may have been traded or consumed since the result set was</para> 159 /// <para> generated. You could compare the timestamp from GetResultTimestamp() to</para> 160 /// <para> ISteamUtils::GetServerRealTime() to determine how old the data is. You could</para> 161 /// <para> simply ignore the "expired" result code and continue as normal, or you</para> 162 /// <para> could challenge the player with expired data to send an updated result set.</para> 163 /// </summary> 164 public static bool DeserializeResult(out SteamInventoryResult_t pOutResultHandle, byte[] pBuffer, uint unBufferSize, bool bRESERVED_MUST_BE_FALSE = false) { 165 InteropHelp.TestIfAvailableGameServer(); 166 return NativeMethods.ISteamInventory_DeserializeResult(CSteamGameServerAPIContext.GetSteamInventory(), out pOutResultHandle, pBuffer, unBufferSize, bRESERVED_MUST_BE_FALSE); 167 } 168 169 /// <summary> 170 /// <para> INVENTORY ASYNC MODIFICATION</para> 171 /// <para> GenerateItems() creates one or more items and then generates a SteamInventoryCallback_t</para> 172 /// <para> notification with a matching nCallbackContext parameter. This API is only intended</para> 173 /// <para> for prototyping - it is only usable by Steam accounts that belong to the publisher group</para> 174 /// <para> for your game.</para> 175 /// <para> If punArrayQuantity is not NULL, it should be the same length as pArrayItems and should</para> 176 /// <para> describe the quantity of each item to generate.</para> 177 /// </summary> 178 public static bool GenerateItems(out SteamInventoryResult_t pResultHandle, SteamItemDef_t[] pArrayItemDefs, uint[] punArrayQuantity, uint unArrayLength) { 179 InteropHelp.TestIfAvailableGameServer(); 180 return NativeMethods.ISteamInventory_GenerateItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, pArrayItemDefs, punArrayQuantity, unArrayLength); 181 } 182 183 /// <summary> 184 /// <para> GrantPromoItems() checks the list of promotional items for which the user may be eligible</para> 185 /// <para> and grants the items (one time only). On success, the result set will include items which</para> 186 /// <para> were granted, if any. If no items were granted because the user isn't eligible for any</para> 187 /// <para> promotions, this is still considered a success.</para> 188 /// </summary> 189 public static bool GrantPromoItems(out SteamInventoryResult_t pResultHandle) { 190 InteropHelp.TestIfAvailableGameServer(); 191 return NativeMethods.ISteamInventory_GrantPromoItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle); 192 } 193 194 /// <summary> 195 /// <para> AddPromoItem() / AddPromoItems() are restricted versions of GrantPromoItems(). Instead of</para> 196 /// <para> scanning for all eligible promotional items, the check is restricted to a single item</para> 197 /// <para> definition or set of item definitions. This can be useful if your game has custom UI for</para> 198 /// <para> showing a specific promo item to the user.</para> 199 /// </summary> 200 public static bool AddPromoItem(out SteamInventoryResult_t pResultHandle, SteamItemDef_t itemDef) { 201 InteropHelp.TestIfAvailableGameServer(); 202 return NativeMethods.ISteamInventory_AddPromoItem(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, itemDef); 203 } 204 205 public static bool AddPromoItems(out SteamInventoryResult_t pResultHandle, SteamItemDef_t[] pArrayItemDefs, uint unArrayLength) { 206 InteropHelp.TestIfAvailableGameServer(); 207 return NativeMethods.ISteamInventory_AddPromoItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, pArrayItemDefs, unArrayLength); 208 } 209 210 /// <summary> 211 /// <para> ConsumeItem() removes items from the inventory, permanently. They cannot be recovered.</para> 212 /// <para> Not for the faint of heart - if your game implements item removal at all, a high-friction</para> 213 /// <para> UI confirmation process is highly recommended.</para> 214 /// </summary> 215 public static bool ConsumeItem(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t itemConsume, uint unQuantity) { 216 InteropHelp.TestIfAvailableGameServer(); 217 return NativeMethods.ISteamInventory_ConsumeItem(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, itemConsume, unQuantity); 218 } 219 220 /// <summary> 221 /// <para> ExchangeItems() is an atomic combination of item generation and consumption.</para> 222 /// <para> It can be used to implement crafting recipes or transmutations, or items which unpack</para> 223 /// <para> themselves into other items (e.g., a chest).</para> 224 /// <para> Exchange recipes are defined in the ItemDef, and explicitly list the required item</para> 225 /// <para> types and resulting generated type.</para> 226 /// <para> Exchange recipes are evaluated atomically by the Inventory Service; if the supplied</para> 227 /// <para> components do not match the recipe, or do not contain sufficient quantity, the</para> 228 /// <para> exchange will fail.</para> 229 /// </summary> 230 public static bool ExchangeItems(out SteamInventoryResult_t pResultHandle, SteamItemDef_t[] pArrayGenerate, uint[] punArrayGenerateQuantity, uint unArrayGenerateLength, SteamItemInstanceID_t[] pArrayDestroy, uint[] punArrayDestroyQuantity, uint unArrayDestroyLength) { 231 InteropHelp.TestIfAvailableGameServer(); 232 return NativeMethods.ISteamInventory_ExchangeItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, pArrayGenerate, punArrayGenerateQuantity, unArrayGenerateLength, pArrayDestroy, punArrayDestroyQuantity, unArrayDestroyLength); 233 } 234 235 /// <summary> 236 /// <para> TransferItemQuantity() is intended for use with items which are "stackable" (can have</para> 237 /// <para> quantity greater than one). It can be used to split a stack into two, or to transfer</para> 238 /// <para> quantity from one stack into another stack of identical items. To split one stack into</para> 239 /// <para> two, pass k_SteamItemInstanceIDInvalid for itemIdDest and a new item will be generated.</para> 240 /// </summary> 241 public static bool TransferItemQuantity(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t itemIdSource, uint unQuantity, SteamItemInstanceID_t itemIdDest) { 242 InteropHelp.TestIfAvailableGameServer(); 243 return NativeMethods.ISteamInventory_TransferItemQuantity(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, itemIdSource, unQuantity, itemIdDest); 244 } 245 246 /// <summary> 247 /// <para> TIMED DROPS AND PLAYTIME CREDIT</para> 248 /// <para> Deprecated. Calling this method is not required for proper playtime accounting.</para> 249 /// </summary> 250 public static void SendItemDropHeartbeat() { 251 InteropHelp.TestIfAvailableGameServer(); 252 NativeMethods.ISteamInventory_SendItemDropHeartbeat(CSteamGameServerAPIContext.GetSteamInventory()); 253 } 254 255 /// <summary> 256 /// <para> Playtime credit must be consumed and turned into item drops by your game. Only item</para> 257 /// <para> definitions which are marked as "playtime item generators" can be spawned. The call</para> 258 /// <para> will return an empty result set if there is not enough playtime credit for a drop.</para> 259 /// <para> Your game should call TriggerItemDrop at an appropriate time for the user to receive</para> 260 /// <para> new items, such as between rounds or while the player is dead. Note that players who</para> 261 /// <para> hack their clients could modify the value of "dropListDefinition", so do not use it</para> 262 /// <para> to directly control rarity.</para> 263 /// <para> See your Steamworks configuration to set playtime drop rates for individual itemdefs.</para> 264 /// <para> The client library will suppress too-frequent calls to this method.</para> 265 /// </summary> 266 public static bool TriggerItemDrop(out SteamInventoryResult_t pResultHandle, SteamItemDef_t dropListDefinition) { 267 InteropHelp.TestIfAvailableGameServer(); 268 return NativeMethods.ISteamInventory_TriggerItemDrop(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, dropListDefinition); 269 } 270 271 /// <summary> 272 /// <para> Deprecated. This method is not supported.</para> 273 /// </summary> 274 public static bool TradeItems(out SteamInventoryResult_t pResultHandle, CSteamID steamIDTradePartner, SteamItemInstanceID_t[] pArrayGive, uint[] pArrayGiveQuantity, uint nArrayGiveLength, SteamItemInstanceID_t[] pArrayGet, uint[] pArrayGetQuantity, uint nArrayGetLength) { 275 InteropHelp.TestIfAvailableGameServer(); 276 return NativeMethods.ISteamInventory_TradeItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, steamIDTradePartner, pArrayGive, pArrayGiveQuantity, nArrayGiveLength, pArrayGet, pArrayGetQuantity, nArrayGetLength); 277 } 278 279 /// <summary> 280 /// <para> ITEM DEFINITIONS</para> 281 /// <para> Item definitions are a mapping of "definition IDs" (integers between 1 and 1000000)</para> 282 /// <para> to a set of string properties. Some of these properties are required to display items</para> 283 /// <para> on the Steam community web site. Other properties can be defined by applications.</para> 284 /// <para> Use of these functions is optional; there is no reason to call LoadItemDefinitions</para> 285 /// <para> if your game hardcodes the numeric definition IDs (eg, purple face mask = 20, blue</para> 286 /// <para> weapon mod = 55) and does not allow for adding new item types without a client patch.</para> 287 /// <para> LoadItemDefinitions triggers the automatic load and refresh of item definitions.</para> 288 /// <para> Every time new item definitions are available (eg, from the dynamic addition of new</para> 289 /// <para> item types while players are still in-game), a SteamInventoryDefinitionUpdate_t</para> 290 /// <para> callback will be fired.</para> 291 /// </summary> 292 public static bool LoadItemDefinitions() { 293 InteropHelp.TestIfAvailableGameServer(); 294 return NativeMethods.ISteamInventory_LoadItemDefinitions(CSteamGameServerAPIContext.GetSteamInventory()); 295 } 296 297 /// <summary> 298 /// <para> GetItemDefinitionIDs returns the set of all defined item definition IDs (which are</para> 299 /// <para> defined via Steamworks configuration, and not necessarily contiguous integers).</para> 300 /// <para> If pItemDefIDs is null, the call will return true and *punItemDefIDsArraySize will</para> 301 /// <para> contain the total size necessary for a subsequent call. Otherwise, the call will</para> 302 /// <para> return false if and only if there is not enough space in the output array.</para> 303 /// </summary> 304 public static bool GetItemDefinitionIDs(SteamItemDef_t[] pItemDefIDs, ref uint punItemDefIDsArraySize) { 305 InteropHelp.TestIfAvailableGameServer(); 306 if (pItemDefIDs != null && pItemDefIDs.Length != punItemDefIDsArraySize) { 307 throw new System.ArgumentException("pItemDefIDs must be the same size as punItemDefIDsArraySize!"); 308 } 309 return NativeMethods.ISteamInventory_GetItemDefinitionIDs(CSteamGameServerAPIContext.GetSteamInventory(), pItemDefIDs, ref punItemDefIDsArraySize); 310 } 311 312 /// <summary> 313 /// <para> GetItemDefinitionProperty returns a string property from a given item definition.</para> 314 /// <para> Note that some properties (for example, "name") may be localized and will depend</para> 315 /// <para> on the current Steam language settings (see ISteamApps::GetCurrentGameLanguage).</para> 316 /// <para> Property names are always composed of ASCII letters, numbers, and/or underscores.</para> 317 /// <para> Pass a NULL pointer for pchPropertyName to get a comma - separated list of available</para> 318 /// <para> property names. If pchValueBuffer is NULL, *punValueBufferSize will contain the</para> 319 /// <para> suggested buffer size. Otherwise it will be the number of bytes actually copied</para> 320 /// <para> to pchValueBuffer. If the results do not fit in the given buffer, partial</para> 321 /// <para> results may be copied.</para> 322 /// </summary> 323 public static bool GetItemDefinitionProperty(SteamItemDef_t iDefinition, string pchPropertyName, out string pchValueBuffer, ref uint punValueBufferSizeOut) { 324 InteropHelp.TestIfAvailableGameServer(); 325 IntPtr pchValueBuffer2 = Marshal.AllocHGlobal((int)punValueBufferSizeOut); 326 using (var pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName)) { 327 bool ret = NativeMethods.ISteamInventory_GetItemDefinitionProperty(CSteamGameServerAPIContext.GetSteamInventory(), iDefinition, pchPropertyName2, pchValueBuffer2, ref punValueBufferSizeOut); 328 pchValueBuffer = ret ? InteropHelp.PtrToStringUTF8(pchValueBuffer2) : null; 329 Marshal.FreeHGlobal(pchValueBuffer2); 330 return ret; 331 } 332 } 333 334 /// <summary> 335 /// <para> Request the list of "eligible" promo items that can be manually granted to the given</para> 336 /// <para> user. These are promo items of type "manual" that won't be granted automatically.</para> 337 /// <para> An example usage of this is an item that becomes available every week.</para> 338 /// </summary> 339 public static SteamAPICall_t RequestEligiblePromoItemDefinitionsIDs(CSteamID steamID) { 340 InteropHelp.TestIfAvailableGameServer(); 341 return (SteamAPICall_t)NativeMethods.ISteamInventory_RequestEligiblePromoItemDefinitionsIDs(CSteamGameServerAPIContext.GetSteamInventory(), steamID); 342 } 343 344 /// <summary> 345 /// <para> After handling a SteamInventoryEligiblePromoItemDefIDs_t call result, use this</para> 346 /// <para> function to pull out the list of item definition ids that the user can be</para> 347 /// <para> manually granted via the AddPromoItems() call.</para> 348 /// </summary> 349 public static bool GetEligiblePromoItemDefinitionIDs(CSteamID steamID, SteamItemDef_t[] pItemDefIDs, ref uint punItemDefIDsArraySize) { 350 InteropHelp.TestIfAvailableGameServer(); 351 if (pItemDefIDs != null && pItemDefIDs.Length != punItemDefIDsArraySize) { 352 throw new System.ArgumentException("pItemDefIDs must be the same size as punItemDefIDsArraySize!"); 353 } 354 return NativeMethods.ISteamInventory_GetEligiblePromoItemDefinitionIDs(CSteamGameServerAPIContext.GetSteamInventory(), steamID, pItemDefIDs, ref punItemDefIDsArraySize); 355 } 356 357 /// <summary> 358 /// <para> Starts the purchase process for the given item definitions. The callback SteamInventoryStartPurchaseResult_t</para> 359 /// <para> will be posted if Steam was able to initialize the transaction.</para> 360 /// <para> Once the purchase has been authorized and completed by the user, the callback SteamInventoryResultReady_t</para> 361 /// <para> will be posted.</para> 362 /// </summary> 363 public static SteamAPICall_t StartPurchase(SteamItemDef_t[] pArrayItemDefs, uint[] punArrayQuantity, uint unArrayLength) { 364 InteropHelp.TestIfAvailableGameServer(); 365 return (SteamAPICall_t)NativeMethods.ISteamInventory_StartPurchase(CSteamGameServerAPIContext.GetSteamInventory(), pArrayItemDefs, punArrayQuantity, unArrayLength); 366 } 367 368 /// <summary> 369 /// <para> Request current prices for all applicable item definitions</para> 370 /// </summary> 371 public static SteamAPICall_t RequestPrices() { 372 InteropHelp.TestIfAvailableGameServer(); 373 return (SteamAPICall_t)NativeMethods.ISteamInventory_RequestPrices(CSteamGameServerAPIContext.GetSteamInventory()); 374 } 375 376 /// <summary> 377 /// <para> Returns the number of items with prices. Need to call RequestPrices() first.</para> 378 /// </summary> 379 public static uint GetNumItemsWithPrices() { 380 InteropHelp.TestIfAvailableGameServer(); 381 return NativeMethods.ISteamInventory_GetNumItemsWithPrices(CSteamGameServerAPIContext.GetSteamInventory()); 382 } 383 384 /// <summary> 385 /// <para> Returns item definition ids and their prices in the user's local currency.</para> 386 /// <para> Need to call RequestPrices() first.</para> 387 /// </summary> 388 public static bool GetItemsWithPrices(SteamItemDef_t[] pArrayItemDefs, ulong[] pCurrentPrices, ulong[] pBasePrices, uint unArrayLength) { 389 InteropHelp.TestIfAvailableGameServer(); 390 if (pArrayItemDefs != null && pArrayItemDefs.Length != unArrayLength) { 391 throw new System.ArgumentException("pArrayItemDefs must be the same size as unArrayLength!"); 392 } 393 if (pCurrentPrices != null && pCurrentPrices.Length != unArrayLength) { 394 throw new System.ArgumentException("pCurrentPrices must be the same size as unArrayLength!"); 395 } 396 if (pBasePrices != null && pBasePrices.Length != unArrayLength) { 397 throw new System.ArgumentException("pBasePrices must be the same size as unArrayLength!"); 398 } 399 return NativeMethods.ISteamInventory_GetItemsWithPrices(CSteamGameServerAPIContext.GetSteamInventory(), pArrayItemDefs, pCurrentPrices, pBasePrices, unArrayLength); 400 } 401 402 /// <summary> 403 /// <para> Retrieves the price for the item definition id</para> 404 /// <para> Returns false if there is no price stored for the item definition.</para> 405 /// </summary> 406 public static bool GetItemPrice(SteamItemDef_t iDefinition, out ulong pCurrentPrice, out ulong pBasePrice) { 407 InteropHelp.TestIfAvailableGameServer(); 408 return NativeMethods.ISteamInventory_GetItemPrice(CSteamGameServerAPIContext.GetSteamInventory(), iDefinition, out pCurrentPrice, out pBasePrice); 409 } 410 411 /// <summary> 412 /// <para> Create a request to update properties on items</para> 413 /// </summary> 414 public static SteamInventoryUpdateHandle_t StartUpdateProperties() { 415 InteropHelp.TestIfAvailableGameServer(); 416 return (SteamInventoryUpdateHandle_t)NativeMethods.ISteamInventory_StartUpdateProperties(CSteamGameServerAPIContext.GetSteamInventory()); 417 } 418 419 /// <summary> 420 /// <para> Remove the property on the item</para> 421 /// </summary> 422 public static bool RemoveProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName) { 423 InteropHelp.TestIfAvailableGameServer(); 424 using (var pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName)) { 425 return NativeMethods.ISteamInventory_RemoveProperty(CSteamGameServerAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2); 426 } 427 } 428 429 /// <summary> 430 /// <para> Accessor methods to set properties on items</para> 431 /// </summary> 432 public static bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, string pchPropertyValue) { 433 InteropHelp.TestIfAvailableGameServer(); 434 using (var pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName)) 435 using (var pchPropertyValue2 = new InteropHelp.UTF8StringHandle(pchPropertyValue)) { 436 return NativeMethods.ISteamInventory_SetProperty(CSteamGameServerAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, pchPropertyValue2); 437 } 438 } 439 440 public static bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, bool bValue) { 441 InteropHelp.TestIfAvailableGameServer(); 442 using (var pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName)) { 443 return NativeMethods.ISteamInventory_SetProperty0(CSteamGameServerAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, bValue); 444 } 445 } 446 447 public static bool SetProperty1(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, long nValue) { 448 InteropHelp.TestIfAvailableGameServer(); 449 using (var pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName)) { 450 return NativeMethods.ISteamInventory_SetProperty1(CSteamGameServerAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, nValue); 451 } 452 } 453 454 public static bool SetProperty2(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, float flValue) { 455 InteropHelp.TestIfAvailableGameServer(); 456 using (var pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName)) { 457 return NativeMethods.ISteamInventory_SetProperty2(CSteamGameServerAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, flValue); 458 } 459 } 460 461 /// <summary> 462 /// <para> Submit the update request by handle</para> 463 /// </summary> 464 public static bool SubmitUpdateProperties(SteamInventoryUpdateHandle_t handle, out SteamInventoryResult_t pResultHandle) { 465 InteropHelp.TestIfAvailableGameServer(); 466 return NativeMethods.ISteamInventory_SubmitUpdateProperties(CSteamGameServerAPIContext.GetSteamInventory(), handle, out pResultHandle); 467 } 468 } 469 } 470 471 #endif // !DISABLESTEAMWORKS