/// <summary> /// Called to finalize any changes made using SetProperty /// </summary> public bool SubmitProperties() { if (updateHandle == 0) { throw new Exception("SubmitProperties called without updating properties"); } try { SteamNative.SteamInventoryResult_t result = -1; if (!Inventory.inventory.SubmitUpdateProperties(updateHandle, ref result)) { return(false); } Inventory.inventory.DestroyResult(result); return(true); } finally { updateHandle = 0; } }
/// <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 Result Consume(int amount = 1) { SteamNative.SteamInventoryResult_t resultHandle = -1; if (!Inventory.inventory.ConsumeItem(ref resultHandle, Id, (uint)amount)) { return(null); } return(new Result(Inventory, resultHandle, true)); }
/// <summary> /// Split stack into two items /// </summary> public Result SplitStack(int quantity = 1) { SteamNative.SteamInventoryResult_t resultHandle = -1; if (!Inventory.inventory.TransferItemQuantity(ref resultHandle, Id, (uint)quantity, ulong.MaxValue)) { return(null); } return(new Result(Inventory, resultHandle, true)); }
public unsafe Result Deserialize(byte[] data, int dataLength = -1) { 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); } return(new Result(this, resultHandle)); } }
/// <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; } // Pending if (LocalPlayerRequest != null) { return; } SteamNative.SteamInventoryResult_t request = 0; if (!inventory.GetAllItems(ref request) || request == -1) { Console.WriteLine("GetAllItems failed!?"); return; } LocalPlayerRequest = new Result(this, request); }
/// <summary> /// Trigger an item drop. Call this when it's a good time to award /// an item drop to a player. This won't automatically result in giving /// an item to a player. Just call it every minute or so, or on launch. /// ItemDefinition is usually a generator /// </summary> public void TriggerItemDrop() { SteamNative.SteamInventoryResult_t result = 0; inventory.TriggerItemDrop(ref result, Id); inventory.DestroyResult(result); }