Exemplo n.º 1
0
        public unsafe Result Deserialize(byte[] data, int dataLength = -1)
        {
            if (data == null)
            {
                throw new ArgumentException("data should nto be null");
            }

            if (dataLength == -1)
            {
                dataLength = data.Length;
            }

            SteamNative.SteamInventoryResult_t resultHandle = -1;

            fixed(byte *ptr = data)
            {
                var result = inventory.DeserializeResult(ref resultHandle, (IntPtr)ptr, (uint)dataLength, false);

                if (!result || resultHandle == -1)
                {
                    return(null);
                }

                var r = new Result(this, resultHandle, false);

                r.Fill();
                return(r);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is used to consume a specific item from the user inventory.
        /// </summary>
        public Result ConsumeItem(Item item, int amount)
        {
            SteamNative.SteamInventoryResult_t resultHandle = -1;
            if (!inventory.ConsumeItem(ref resultHandle, item.Id, (uint)amount))
            {
                return(null);
            }

            return(new Result(this, resultHandle, true));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Split stack into two items
        /// </summary>
        public Result SplitStack(Item item, int quantity = 1)
        {
            SteamNative.SteamInventoryResult_t resultHandle = -1;
            if (!inventory.TransferItemQuantity(ref resultHandle, item.Id, (uint)quantity, ulong.MaxValue))
            {
                return(null);
            }

            return(new Result(this, resultHandle, true));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Stack source item onto dest item
        /// </summary>
        public Result Stack(Item source, Item dest, int quantity = 1)
        {
            SteamNative.SteamInventoryResult_t resultHandle = -1;
            if (!inventory.TransferItemQuantity(ref resultHandle, source.Id, (uint)quantity, dest.Id))
            {
                return(null);
            }

            return(new Result(this, resultHandle, true));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Call this to retrieve the items.
        /// Note that if this has already been called it won't
        /// trigger a call to OnUpdate unless the items have changed
        /// </summary>
        public void Refresh()
        {
            if (IsServer)
            {
                return;
            }

            SteamNative.SteamInventoryResult_t request = 0;
            if (!inventory.GetAllItems(ref request) || request == -1)
            {
                Console.WriteLine("GetAllItems failed!?");
                return;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// This is used to grant a specific item to the user. This should
        /// only be used for development prototyping, from a trusted server,
        /// or if you don't care about hacked clients granting arbitrary items.
        /// This call can be disabled by a setting on Steamworks.
        /// </summary>
        public Result GenerateItem(Definition target, int amount)
        {
            SteamNative.SteamInventoryResult_t resultHandle = -1;

            var newItems = new SteamNative.SteamItemDef_t[] { new SteamNative.SteamItemDef_t()
                                                              {
                                                                  Value = target.Id
                                                              } };
            var newItemC = new uint[] { (uint)amount };

            if (!inventory.GenerateItems(ref resultHandle, newItems, newItemC, 1))
            {
                return(null);
            }

            return(new Result(this, resultHandle, true));
        }
Exemplo n.º 7
0
        /// <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.
        /// </summary>
        public Result CraftItem(Item.Amount[] list, Definition target)
        {
            SteamNative.SteamInventoryResult_t resultHandle = -1;

            var newItems = new SteamNative.SteamItemDef_t[] { new SteamNative.SteamItemDef_t()
                                                              {
                                                                  Value = target.Id
                                                              } };
            var newItemC = new uint[] { 1 };

            var takeItems  = list.Select(x => (SteamNative.SteamItemInstanceID_t)x.Item.Id).ToArray();
            var takeItemsC = list.Select(x => (uint)x.Quantity).ToArray();

            if (!inventory.ExchangeItems(ref resultHandle, newItems, newItemC, 1, takeItems, takeItemsC, (uint)takeItems.Length))
            {
                return(null);
            }

            return(new Result(this, resultHandle, true));
        }
 // uint
 public uint GetResultTimestamp(SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/)
 {
     return(platform.ISteamInventory_GetResultTimestamp(resultHandle.Value));
 }
 // Result
 public Result GetResultStatus(SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/)
 {
     return(platform.ISteamInventory_GetResultStatus(resultHandle.Value));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Trigger an item drop for this user. This is for timed drops. For promo
 /// drops use TriggerPromoDrop.
 /// </summary>
 public void TriggerItemDrop(int definitionId)
 {
     SteamNative.SteamInventoryResult_t result = 0;
     inventory.TriggerItemDrop(ref result, definitionId);
     inventory.DestroyResult(result);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Grant all promotional items the user is eligible for.
 /// </summary>
 public void GrantAllPromoItems()
 {
     SteamNative.SteamInventoryResult_t result = 0;
     inventory.GrantPromoItems(ref result);
     inventory.DestroyResult(result);
 }
 // void
 public void DestroyResult(SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/)
 {
     platform.ISteamInventory_DestroyResult(resultHandle.Value);
 }
 // bool
 public bool GrantPromoItems(ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/)
 {
     return(platform.ISteamInventory_GrantPromoItems(ref pResultHandle.Value));
 }
 // bool
 public bool ConsumeItem(ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemInstanceID_t itemConsume /*SteamItemInstanceID_t*/, uint unQuantity /*uint32*/)
 {
     return(platform.ISteamInventory_ConsumeItem(ref pResultHandle.Value, itemConsume.Value, unQuantity));
 }
 // bool
 public bool TradeItems(ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, CSteamID steamIDTradePartner /*class CSteamID*/, SteamItemInstanceID_t[] pArrayGive /*const SteamItemInstanceID_t **/, uint[] pArrayGiveQuantity /*const uint32 **/, uint nArrayGiveLength /*uint32*/, SteamItemInstanceID_t[] pArrayGet /*const SteamItemInstanceID_t **/, uint[] pArrayGetQuantity /*const uint32 **/, uint nArrayGetLength /*uint32*/)
 {
     return(platform.ISteamInventory_TradeItems(ref pResultHandle.Value, steamIDTradePartner.Value, pArrayGive.Select(x => x.Value).ToArray(), pArrayGiveQuantity, nArrayGiveLength, pArrayGet.Select(x => x.Value).ToArray(), pArrayGetQuantity, nArrayGetLength));
 }
 // bool
 public bool SerializeResult(SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/, IntPtr pOutBuffer /*void **/, out uint punOutBufferSize /*uint32 **/)
 {
     return(platform.ISteamInventory_SerializeResult(resultHandle.Value, (IntPtr)pOutBuffer, out punOutBufferSize));
 }
 // bool
 public bool GenerateItems(ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t[] pArrayItemDefs /*const SteamItemDef_t **/, uint[] punArrayQuantity /*const uint32 **/, uint unArrayLength /*uint32*/)
 {
     return(platform.ISteamInventory_GenerateItems(ref pResultHandle.Value, pArrayItemDefs.Select(x => x.Value).ToArray(), punArrayQuantity, unArrayLength));
 }
 // bool
 public bool AddPromoItem(ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t itemDef /*SteamItemDef_t*/)
 {
     return(platform.ISteamInventory_AddPromoItem(ref pResultHandle.Value, itemDef.Value));
 }
 // bool
 public bool TriggerItemDrop(ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t dropListDefinition /*SteamItemDef_t*/)
 {
     return(platform.ISteamInventory_TriggerItemDrop(ref pResultHandle.Value, dropListDefinition.Value));
 }
 // bool
 public bool TransferItemQuantity(ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemInstanceID_t itemIdSource /*SteamItemInstanceID_t*/, uint unQuantity /*uint32*/, SteamItemInstanceID_t itemIdDest /*SteamItemInstanceID_t*/)
 {
     return(platform.ISteamInventory_TransferItemQuantity(ref pResultHandle.Value, itemIdSource.Value, unQuantity, itemIdDest.Value));
 }
 // bool
 public bool GetItemsByID(ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemInstanceID_t[] pInstanceIDs /*const SteamItemInstanceID_t **/, uint unCountInstanceIDs /*uint32*/)
 {
     return(platform.ISteamInventory_GetItemsByID(ref pResultHandle.Value, pInstanceIDs.Select(x => x.Value).ToArray(), unCountInstanceIDs));
 }
 // bool
 public bool DeserializeResult(ref SteamInventoryResult_t pOutResultHandle /*SteamInventoryResult_t **/, IntPtr pBuffer /*const void **/, uint unBufferSize /*uint32*/, bool bRESERVED_MUST_BE_FALSE /*bool*/)
 {
     return(platform.ISteamInventory_DeserializeResult(ref pOutResultHandle.Value, (IntPtr)pBuffer, unBufferSize, bRESERVED_MUST_BE_FALSE));
 }
 // bool
 public bool AddPromoItems(ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t[] pArrayItemDefs /*const SteamItemDef_t **/, uint unArrayLength /*uint32*/)
 {
     return(platform.ISteamInventory_AddPromoItems(ref pResultHandle.Value, pArrayItemDefs.Select(x => x.Value).ToArray(), unArrayLength));
 }
 // bool
 public bool SubmitUpdateProperties(SteamInventoryUpdateHandle_t handle /*SteamInventoryUpdateHandle_t*/, ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/)
 {
     return(platform.ISteamInventory_SubmitUpdateProperties(handle.Value, ref pResultHandle.Value));
 }
 // bool
 public bool CheckResultSteamID(SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/, CSteamID steamIDExpected /*class CSteamID*/)
 {
     return(platform.ISteamInventory_CheckResultSteamID(resultHandle.Value, steamIDExpected.Value));
 }
 // bool
 public bool ExchangeItems(ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t[] pArrayGenerate /*const SteamItemDef_t **/, uint[] punArrayGenerateQuantity /*const uint32 **/, uint unArrayGenerateLength /*uint32*/, SteamItemInstanceID_t[] pArrayDestroy /*const SteamItemInstanceID_t **/, uint[] punArrayDestroyQuantity /*const uint32 **/, uint unArrayDestroyLength /*uint32*/)
 {
     return(platform.ISteamInventory_ExchangeItems(ref pResultHandle.Value, pArrayGenerate.Select(x => x.Value).ToArray(), punArrayGenerateQuantity, unArrayGenerateLength, pArrayDestroy.Select(x => x.Value).ToArray(), punArrayDestroyQuantity, unArrayDestroyLength));
 }