/// <summary>
        /// Trigger a promo item drop. You can call this at startup, it won't
        /// give users multiple promo drops.
        /// </summary>
        public static async Task <InventoryResult?> AddPromoItemAsync(InventoryDefId id)
        {
            var sresult = Defines.k_SteamInventoryResultInvalid;

            if (!Internal.AddPromoItem(ref sresult, id))
            {
                return(null);
            }

            return(await InventoryResult.GetAsync(sresult));
        }
        /// <summary>
        /// Trigger an item drop for this user. This is for timed drops.
        /// </summary>
        public static async Task <InventoryResult?> TriggerItemDropAsync(InventoryDefId id)
        {
            var sresult = Defines.k_SteamInventoryResultInvalid;

            if (!Internal.TriggerItemDrop(ref sresult, id))
            {
                return(null);
            }

            return(await InventoryResult.GetAsync(sresult));
        }
Esempio n. 3
0
        /// <summary>
        /// Try to find the definition that matches this definition ID.
        /// Uses a dictionary so should be about as fast as possible.
        /// </summary>
        public static InventoryDef FindDefinition(InventoryDefId defId)
        {
            if (_defMap == null)
            {
                return(null);
            }

            if (_defMap.TryGetValue(defId, out var val))
            {
                return(val);
            }

            return(null);
        }
Esempio n. 4
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 static async Task <InventoryResult?> GenerateItemAsync(InventoryDef target, int amount)
        {
            var sresult = Defines.k_SteamInventoryResultInvalid;

            var defs = new InventoryDefId[] { target.Id };
            var cnts = new uint[] { (uint)amount };

            if (!Internal.GenerateItems(ref sresult, defs, cnts, 1))
            {
                return(null);
            }

            return(await InventoryResult.GetAsync(sresult));
        }
        public static async Task <InventoryResult?> AddPromoItemAsync(InventoryDefId id)
        {
            InventoryResult?       async;
            SteamInventoryResult_t steamInventoryResultT = new SteamInventoryResult_t();

            if (SteamInventory.Internal.AddPromoItem(ref steamInventoryResultT, id))
            {
                async = await InventoryResult.GetAsync(steamInventoryResultT);
            }
            else
            {
                async = null;
            }
            return(async);
        }
        public static async Task <InventoryDef[]> GetDefinitionsWithPricesAsync()
        {
            InventoryDef[] array;
            bool           flag;
            string         currency;
            SteamInventoryRequestPricesResult_t?nullable = await SteamInventory.Internal.RequestPrices();

            SteamInventoryRequestPricesResult_t?nullable1 = nullable;

            nullable = null;
            flag     = (!nullable1.HasValue ? true : nullable1.Value.Result != Result.OK);
            if (!flag)
            {
                ref Nullable nullablePointer = ref nullable1;
                if (nullablePointer.HasValue)
                {
                    currency = nullablePointer.GetValueOrDefault().Currency;
                }
                else
                {
                    currency = null;
                }
                SteamInventory.Currency = currency;
                uint numItemsWithPrices = SteamInventory.Internal.GetNumItemsWithPrices();
                if (numItemsWithPrices != 0)
                {
                    InventoryDefId[] inventoryDefIdArray = new InventoryDefId[numItemsWithPrices];
                    ulong[]          numArray            = new UInt64[numItemsWithPrices];
                    ulong[]          numArray1           = new UInt64[numItemsWithPrices];
                    if (SteamInventory.Internal.GetItemsWithPrices(inventoryDefIdArray, numArray, numArray1, numItemsWithPrices))
                    {
                        InventoryDefId[] inventoryDefIdArray1 = inventoryDefIdArray;
                        array = (
                            from x in (IEnumerable <InventoryDefId>) inventoryDefIdArray1
                            select new InventoryDef(x)).ToArray <InventoryDef>();
                    }
                    else
                    {
                        array = null;
                    }
                }
                else
                {
                    array = null;
                }
            }
        public static async Task <InventoryResult?> GenerateItemAsync(InventoryDef target, int amount)
        {
            InventoryResult?       async;
            SteamInventoryResult_t steamInventoryResultT = new SteamInventoryResult_t();

            InventoryDefId[] id       = new InventoryDefId[] { target.Id };
            uint[]           numArray = new UInt32[] { amount };
            if (SteamInventory.Internal.GenerateItems(ref steamInventoryResultT, id, numArray, 1))
            {
                async = await InventoryResult.GetAsync(steamInventoryResultT);
            }
            else
            {
                async = null;
            }
            return(async);
        }
        /// <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));
        }
Esempio n. 9
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. This assumes all the items passed in aren't stacked.
        /// </summary>
        public static async Task <InventoryResult?> CraftItemAsync(InventoryItem.Amount[] list, InventoryDef target)
        {
            var sresult = Defines.k_SteamInventoryResultInvalid;

            var give  = new InventoryDefId[] { target.Id };
            var givec = new uint[] { 1 };

            var sell  = list.Select(x => x.Item.Id).ToArray();
            var sellc = list.Select(x => (uint)x.Quantity).ToArray();

            if (!Internal.ExchangeItems(ref sresult, give, givec, 1, sell, sellc, (uint)sell.Length))
            {
                return(null);
            }

            return(await InventoryResult.GetAsync(sresult));
        }
Esempio n. 10
0
        internal static InventoryDef[] GetDefinitions()
        {
            uint num = 0;

            if (!Internal.GetItemDefinitionIDs(null, ref num))
            {
                return(null);
            }

            var defs = new InventoryDefId[num];

            if (!Internal.GetItemDefinitionIDs(defs, ref num))
            {
                return(null);
            }

            return(defs.Select(x => new InventoryDef(x)).ToArray());
        }
        public static InventoryDef FindDefinition(InventoryDefId defId)
        {
            InventoryDef inventoryDef;
            InventoryDef inventoryDef1;

            if (SteamInventory._defMap == null)
            {
                inventoryDef1 = null;
            }
            else if (!SteamInventory._defMap.TryGetValue(defId, out inventoryDef))
            {
                inventoryDef1 = null;
            }
            else
            {
                inventoryDef1 = inventoryDef;
            }
            return(inventoryDef1);
        }
Esempio n. 12
0
        /// <summary>
        /// Try to find the definition that matches this definition ID.
        /// Call LoadItemDefinitions before using to skip validation.
        /// Uses a dictionary so should be about as fast as possible.
        /// </summary>
        public static InventoryDef FindDefinition(InventoryDefId defId)
        {
            if (_defMap.TryGetValue(defId, out var val))                  //can be replaced with Definitions.TryGetValue in .NET Framework 4.7.2+ and _defMap deleted
            {
                return(val);
            }

            //add missing def for ex. with id above 1000000
            var notLoaded       = new InventoryDef(defId);
            var notLoadedExists = !string.IsNullOrEmpty(notLoaded.Type);

            if (notLoadedExists)
            {
                _defMap[defId] = notLoaded;
                Definitions.Add(notLoaded);
                return(notLoaded);
            }

            return(null);
        }
Esempio n. 13
0
 public InventoryDef(InventoryDefId defId)
 {
     this._id = defId;
 }
 internal bool AddPromoItem(ref SteamInventoryResult_t pResultHandle, InventoryDefId itemDef)
 {
     return(_AddPromoItem(Self, ref pResultHandle, itemDef));
 }
Esempio n. 15
0
 internal bool TriggerItemDrop(ref SteamInventoryResult_t pResultHandle, InventoryDefId dropListDefinition)
 {
     return(this._TriggerItemDrop(this.Self, ref pResultHandle, dropListDefinition));
 }
        internal bool GetItemPrice(InventoryDefId iDefinition, ref ulong pCurrentPrice, ref ulong pBasePrice)
        {
            var returnValue = _GetItemPrice(Self, iDefinition, ref pCurrentPrice, ref pBasePrice);

            return(returnValue);
        }
 internal bool GetItemDefinitionProperty(InventoryDefId iDefinition, string pchPropertyName, StringBuilder pchValueBuffer, ref uint punValueBufferSizeOut)
 {
     return(_GetItemDefinitionProperty(Self, iDefinition, pchPropertyName, pchValueBuffer, ref punValueBufferSizeOut));
 }
 private static extern bool _GetItemDefinitionProperty(IntPtr self, InventoryDefId iDefinition, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string pchPropertyName, IntPtr pchValueBuffer, ref uint punValueBufferSizeOut);
 private static extern bool _GetItemPrice(IntPtr self, InventoryDefId iDefinition, ref ulong pCurrentPrice, ref ulong pBasePrice);
 private static extern bool _TriggerItemDrop(IntPtr self, ref SteamInventoryResult_t pResultHandle, InventoryDefId dropListDefinition);
        /// <summary>
        /// Playtime credit must be consumed and turned into item drops by your game.
        /// </summary>
        internal bool TriggerItemDrop(ref SteamInventoryResult_t pResultHandle, InventoryDefId dropListDefinition)
        {
            var returnValue = _TriggerItemDrop(Self, ref pResultHandle, dropListDefinition);

            return(returnValue);
        }
        internal bool AddPromoItem(ref SteamInventoryResult_t pResultHandle, InventoryDefId itemDef)
        {
            var returnValue = _AddPromoItem(Self, ref pResultHandle, itemDef);

            return(returnValue);
        }
 private static extern bool _AddPromoItem(IntPtr self, ref SteamInventoryResult_t pResultHandle, InventoryDefId itemDef);
 internal bool GetItemPrice(InventoryDefId iDefinition, ref ulong pCurrentPrice, ref ulong pBasePrice)
 {
     return(_GetItemPrice(Self, iDefinition, ref pCurrentPrice, ref pBasePrice));
 }
Esempio n. 25
0
 internal bool GetItemDefinitionProperty(InventoryDefId iDefinition, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string pchPropertyName, StringBuilder pchValueBuffer, ref uint punValueBufferSizeOut)
 {
     return(_GetItemDefinitionProperty(Self, iDefinition, pchPropertyName, pchValueBuffer, ref punValueBufferSizeOut));
 }
 public InventoryDef(InventoryDefId defId)
 {
     _id = defId;
 }