/// <summary> /// Grant all promotional items the user is eligible for. /// </summary> public static async Task <InventoryResult?> GrantPromoItemsAsync() { var sresult = Defines.k_SteamInventoryResultInvalid; if (!Internal.GrantPromoItems(ref sresult)) { return(null); } return(await InventoryResult.GetAsync(sresult)); }
/// <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> /// Split stack into two items /// </summary> public async Task <InventoryResult?> SplitStackAsync(int quantity = 1) { var sresult = default(SteamInventoryResult_t); if (!SteamInventory.Internal.TransferItemQuantity(ref sresult, Id, (uint)quantity, ulong.MaxValue)) { 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)); }
/// <summary> /// Grant all promotional items the user is eligible for /// </summary> public static async Task <InventoryResult?> GrantPromoItemsAsync() { var sresult = default(SteamInventoryResult_t); if (!Internal.GrantPromoItems(ref sresult)) { return(null); } return(await InventoryResult.GetAsync(sresult)); }
/// <summary> /// Add x units of the target item to this item /// </summary> public async Task <InventoryResult?> AddAsync(InventoryItem add, int quantity = 1) { var sresult = default(SteamInventoryResult_t); if (!SteamInventory.Internal.TransferItemQuantity(ref sresult, add.Id, (uint)quantity, Id)) { return(null); } return(await InventoryResult.GetAsync(sresult)); }
/// <summary> /// Consumes items from a user's inventory. If the quantity of the given item goes to zero, it is permanently removed. /// Once an item is removed it cannot be recovered.This is not for the faint of heart - if your game implements item removal at all, /// a high-friction UI confirmation process is highly recommended.ConsumeItem can be restricted to certain item definitions or fully /// blocked via the Steamworks website to minimize support/abuse issues such as the classic "my brother borrowed my laptop and deleted all of my rare items". /// </summary> public async Task <InventoryResult?> ConsumeAsync(int amount = 1) { var sresult = default(SteamInventoryResult_t); if (!SteamInventory.Internal.ConsumeItem(ref sresult, Id, (uint)amount)) { return(null); } return(await InventoryResult.GetAsync(sresult)); }
/// <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?> GetAllItemsAsync() { InventoryResult? async; SteamInventoryResult_t steamInventoryResultT = new SteamInventoryResult_t(); if (SteamInventory.Internal.GetAllItems(ref steamInventoryResultT)) { async = await InventoryResult.GetAsync(steamInventoryResultT); } else { async = null; } return(async); }
public async Task <InventoryResult?> ConsumeAsync(int amount = 1) { InventoryResult? async; SteamInventoryResult_t steamInventoryResultT = new SteamInventoryResult_t(); if (SteamInventory.Internal.ConsumeItem(ref steamInventoryResultT, this.Id, (uint)amount)) { async = await InventoryResult.GetAsync(steamInventoryResultT); } else { async = null; } return(async); }
public async Task <InventoryResult?> AddAsync(InventoryItem add, int quantity = 1) { InventoryResult? async; SteamInventoryResult_t steamInventoryResultT = new SteamInventoryResult_t(); if (SteamInventory.Internal.TransferItemQuantity(ref steamInventoryResultT, add.Id, (uint)quantity, this.Id)) { async = await InventoryResult.GetAsync(steamInventoryResultT); } else { async = null; } return(async); }
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 async Task <InventoryResult?> SplitStackAsync(int quantity = 1) { InventoryResult? async; SteamInventoryResult_t steamInventoryResultT = new SteamInventoryResult_t(); if (SteamInventory.Internal.TransferItemQuantity(ref steamInventoryResultT, this.Id, (uint)quantity, (long)-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> 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)); }
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)); }
/// <summary> /// Deserializes a result set and verifies the signature bytes. /// This call has a potential soft-failure mode where the Result is expired, it will /// still succeed in this mode.The "expired" /// result could indicate that the data may be out of date - not just due to timed /// expiration( one hour ), but also because one of the items in the result set may /// have been traded or consumed since the result set was generated.You could compare /// the timestamp from GetResultTimestamp to ISteamUtils::GetServerRealTime to determine /// how old the data is. You could simply ignore the "expired" result code and /// continue as normal, or you could request the player with expired data to send /// an updated result set. /// You should call CheckResultSteamID on the result handle when it completes to verify /// that a remote player is not pretending to have a different user's inventory. /// </summary> static async Task <InventoryResult?> DeserializeAsync(byte[] data, int dataLength = -1) { if (data == null) { throw new ArgumentException("data should nto be null"); } if (dataLength == -1) { dataLength = data.Length; } var sresult = DeserializeResult(data, dataLength); if (!sresult.HasValue) { return(null); } return(await InventoryResult.GetAsync(sresult.Value)); }