Exemple #1
0
    private void OnLootboxResultReady(SteamInventoryResultReady_t pCallback)
    {
        Debug.Log("@OnLootboxResultReady called, callback params: " + pCallback.m_handle + ", " + pCallback.m_result);

        LootboxResult = pCallback.m_handle;
        uint size = 0;

        SteamItemDetails_t[] items;
        bool result = SteamInventory.GetResultItems(LootboxResult, null, ref size);

        if (result && size > 0)
        {
            items  = new SteamItemDetails_t[size];
            result = SteamInventory.GetResultItems(LootboxResult, items, ref size);
            Debug.LogWarning("@OnLootboxResultReady: Get lootbox result: " + result + " with items num: " + items.Length);

            UpdateInventory(items, display: true);

            /// Dispose results and update
            Debug.Log("Disposing resources");
            SteamInventory.DestroyResult(LootboxResult);
            _lootboxesRequested -= items.Length;
            if (_lootboxesRequested <= 0)
            {
                m_LootboxResultReady.Dispose();
            }
        }
    }
Exemple #2
0
    private void OnInventoryResultReady(SteamInventoryResultReady_t pCallback)
    {
        Debug.Log("@OnInventoryResultReady called, callback params: " + pCallback.m_handle + ", " + pCallback.m_result);

        InventoryResult = pCallback.m_handle;
        uint size = 0;

        SteamItemDetails_t[] items;
        bool result = SteamInventory.GetResultItems(InventoryResult, null, ref size);

        if (result && size > 0)
        {
            items = new SteamItemDetails_t[size];
            bool ret = SteamInventory.GetResultItems(InventoryResult, items, ref size);
            Debug.LogWarning("@OnInventoryResultReady: Inventory fetch result: " + ret + " with items num: " + items.Length);

            /// Add anew
            UpdateInventory(items, display: false);
        }
        else
        {
            Debug.LogWarning("@OnInventoryResultReady: InventoryResult = " + InventoryResult.m_SteamInventoryResult + ", Size = " + size + ". Could not get result items, problem may be in:\n" +
                             "- InventoryResult оказался недействительным, либо дескриптор результата действий с инвентарём оказался не готов.\n" +
                             "- Массив не уместился в pOutItemsArray.\n" +
                             "- У пользователя нет предметов.");
        }

        /// Dispose result
        SteamInventory.DestroyResult(InventoryResult);
    }
        // Token: 0x06003066 RID: 12390 RVA: 0x0013E85C File Offset: 0x0013CC5C
        public void commitModifiedDynamicProps()
        {
            if (this.modifiedItems.Count < 1)
            {
                return;
            }
            SteamInventoryUpdateHandle_t handle = SteamInventory.StartUpdateProperties();

            foreach (ushort itemID in this.modifiedItems)
            {
                ulong value;
                if (Characters.getPackageForItemID(itemID, out value))
                {
                    EStatTrackerType type;
                    int num;
                    if (this.getStatTrackerValue(itemID, out type, out num))
                    {
                        string statTrackerPropertyName = Provider.provider.economyService.getStatTrackerPropertyName(type);
                        if (!string.IsNullOrEmpty(statTrackerPropertyName))
                        {
                            SteamInventory.SetProperty(handle, new SteamItemInstanceID_t(value), statTrackerPropertyName, (long)num);
                        }
                    }
                }
            }
            SteamInventory.SubmitUpdateProperties(handle, out Provider.provider.economyService.commitResult);
        }
        public IEconomyRequestHandle exchangeItems(IEconomyItemInstance[] inputItemInstanceIDs, uint[] inputItemQuantities, IEconomyItemDefinition[] outputItemDefinitionIDs, uint[] outputItemQuantities, EconomyRequestReadyCallback inventoryRequestReadyCallback)
        {
            if (inputItemInstanceIDs.Length != inputItemQuantities.Length)
            {
                throw new ArgumentException("Input item arrays need to be the same length.", "inputItemQuantities");
            }
            if (outputItemDefinitionIDs.Length != outputItemQuantities.Length)
            {
                throw new ArgumentException("Output item arrays need to be the same length.", "outputItemQuantities");
            }
            SteamItemInstanceID_t[] array = new SteamItemInstanceID_t[inputItemInstanceIDs.Length];
            for (int i = 0; i < inputItemInstanceIDs.Length; i++)
            {
                SteamworksEconomyItemInstance steamworksEconomyItemInstance = (SteamworksEconomyItemInstance)inputItemInstanceIDs[i];
                array[i] = steamworksEconomyItemInstance.steamItemInstanceID;
            }
            SteamItemDef_t[] array2 = new SteamItemDef_t[outputItemDefinitionIDs.Length];
            for (int j = 0; j < outputItemDefinitionIDs.Length; j++)
            {
                SteamworksEconomyItemDefinition steamworksEconomyItemDefinition = (SteamworksEconomyItemDefinition)outputItemDefinitionIDs[j];
                array2[j] = steamworksEconomyItemDefinition.steamItemDef;
            }
            SteamInventoryResult_t steamInventoryResult;

            SteamInventory.ExchangeItems(ref steamInventoryResult, array2, outputItemQuantities, (uint)array2.Length, array, inputItemQuantities, (uint)array.Length);
            return(this.addInventoryRequestHandle(steamInventoryResult, inventoryRequestReadyCallback));
        }
    private void Update()
    {
        if (!Global.isSteamActive || !m_waitForResult)
        {
            return;
        }
        EResult resultStatus = SteamInventory.GetResultStatus(m_resultHandle);

        switch (resultStatus)
        {
        case EResult.k_EResultPending:
            return;

        case EResult.k_EResultOK:
        {
            uint punOutItemsArraySize = 0u;
            if (SteamInventory.GetResultItems(m_resultHandle, null, ref punOutItemsArraySize) && punOutItemsArraySize != 0)
            {
                SteamItemDetails_t[] array = new SteamItemDetails_t[punOutItemsArraySize];
                SteamInventory.GetResultItems(m_resultHandle, array, ref punOutItemsArraySize);
                m_itemDetails.AddRange(array);
            }
            EquipSteamInventoryItems();
            break;
        }

        default:
            Debug.Log("SteamInventoryHandler.cs: Couldn't get inventory: " + resultStatus);
            break;
        }
        SteamInventory.DestroyResult(m_resultHandle);
        m_waitForResult = false;
    }
        // Token: 0x06001802 RID: 6146 RVA: 0x00088970 File Offset: 0x00086D70
        public IEconomyRequestHandle requestInventory(EconomyRequestReadyCallback inventoryRequestReadyCallback)
        {
            SteamInventoryResult_t steamInventoryResult;

            SteamInventory.GetAllItems(out steamInventoryResult);
            return(this.addInventoryRequestHandle(steamInventoryResult, inventoryRequestReadyCallback));
        }
Exemple #7
0
 private void Update()
 {
     if (Global.isSteamActive && this.m_waitForResult)
     {
         EResult resultStatus = SteamInventory.GetResultStatus(this.m_resultHandle);
         if (resultStatus != EResult.k_EResultPending)
         {
             if (resultStatus == EResult.k_EResultOK)
             {
                 uint num = 0U;
                 if (SteamInventory.GetResultItems(this.m_resultHandle, null, ref num) && num > 0U)
                 {
                     SteamItemDetails_t[] array = new SteamItemDetails_t[num];
                     SteamInventory.GetResultItems(this.m_resultHandle, array, ref num);
                     this.m_itemDetails.AddRange(array);
                 }
                 this.EquipSteamInventoryItems();
             }
             else
             {
                 Debug.Log("SteamInventoryHandler.cs: Couldn't get inventory: " + resultStatus.ToString());
             }
             SteamInventory.DestroyResult(this.m_resultHandle);
             this.m_waitForResult = false;
         }
     }
 }
Exemple #8
0
 // Token: 0x06001749 RID: 5961 RVA: 0x000861FE File Offset: 0x000845FE
 public void refreshInventory()
 {
     if (!SteamInventory.GetAllItems(out this.inventoryResult))
     {
         Provider.isLoadingInventory = false;
     }
 }
Exemple #9
0
 // Token: 0x06001746 RID: 5958 RVA: 0x000860C0 File Offset: 0x000844C0
 public void exchangeInventory(int generate, params ulong[] destroy)
 {
     Debug.Log("Exchange these item instances for " + generate);
     foreach (ulong num in destroy)
     {
         int inventoryItem = this.getInventoryItem(num);
         Debug.Log(string.Concat(new object[]
         {
             inventoryItem,
             " [",
             num,
             "]"
         }));
     }
     SteamItemDef_t[] array  = new SteamItemDef_t[1];
     uint[]           array2 = new uint[1];
     array[0]  = (SteamItemDef_t)generate;
     array2[0] = 1u;
     SteamItemInstanceID_t[] array3 = new SteamItemInstanceID_t[destroy.Length];
     uint[] array4 = new uint[destroy.Length];
     for (int j = 0; j < destroy.Length; j++)
     {
         array3[j] = (SteamItemInstanceID_t)destroy[j];
         array4[j] = 1u;
     }
     SteamInventory.ExchangeItems(out this.exchangeResult, array, array2, (uint)array.Length, array3, array4, (uint)array3.Length);
 }
Exemple #10
0
        // Token: 0x06001745 RID: 5957 RVA: 0x00086080 File Offset: 0x00084480
        public void consumeItem(ulong instance)
        {
            Terminal.print("Consume item: " + instance, null, Provider.STEAM_IC, Provider.STEAM_DC, true);
            SteamInventoryResult_t steamInventoryResult_t;

            SteamInventory.ConsumeItem(out steamInventoryResult_t, (SteamItemInstanceID_t)instance, 1u);
        }
        /// <summary>
        /// <para>Instructs the Steam backend to start a purchase for this item and the quantity indicated</para>
        /// <para>Note that this process is tightly integrated with the item definition as configured on your Steam partner backend. It is keenly important that you have set up proper priceses for your times before this method will work correctly.</para>
        /// <para>If the purchase is successful e.g. if the user competes the purchase then a results ready message will be processed and handled by the Heathen Steam Inventory system updating the item instances and quantities available of the items purchased.</para>
        /// </summary>
        /// <param name="quantity"></param>
        public void StartPurchase(uint quantity)
        {
            SteamItemDef_t[] items        = { DefinitionID };
            uint[]           itemQuantity = { quantity };

            SteamInventory.StartPurchase(items, itemQuantity, 1);
        }
        public IEconomyRequestHandle requestPromo(EconomyRequestReadyCallback inventoryRequestReadyCallback)
        {
            SteamInventoryResult_t steamInventoryResult;

            SteamInventory.GrantPromoItems(ref steamInventoryResult);
            return(this.addInventoryRequestHandle(steamInventoryResult, inventoryRequestReadyCallback));
        }
 private void Start()
 {
     m_client = (LidClient)Object.FindObjectOfType(typeof(LidClient));
     if (Global.isSteamActive)
     {
         m_waitForResult = SteamInventory.GetAllItems(out m_resultHandle);
     }
 }
 private void GetPromoItem()
 {
     if (Global.isSteamActive && PlayerPrefs.GetInt("prefGotPromoItemVetHat", 0) == 0)
     {
         this.m_waitForResult = SteamInventory.GrantPromoItems(out this.m_itemDropHandle);
         PlayerPrefs.SetInt("prefGotPromoItemVetHat", 1);
     }
 }
Exemple #15
0
        public string getPropertyValue(string key)
        {
            uint   num = 1024u;
            string result;

            SteamInventory.GetItemDefinitionProperty(this.steamItemDef, key, ref result, ref num);
            return(result);
        }
Exemple #16
0
 private void RequestSteamInventory()
 {
     if (Global.isSteamActive && Time.time > this.m_nextPossibleRequestTime)
     {
         this.m_waitForResult           = SteamInventory.GetAllItems(out this.m_resultHandle);
         this.m_completeRefresh         = true;
         this.m_nextPossibleRequestTime = Time.time + 10f;
     }
 }
Exemple #17
0
 void DestroyResult()
 {
     if (m_SteamInventoryResult != SteamInventoryResult_t.Invalid)
     {
         SteamInventory.DestroyResult(m_SteamInventoryResult);
         print("SteamInventory.DestroyResult(" + m_SteamInventoryResult + ")");
         m_SteamInventoryResult = SteamInventoryResult_t.Invalid;
     }
 }
Exemple #18
0
 // Token: 0x06001747 RID: 5959 RVA: 0x000861BD File Offset: 0x000845BD
 public void updateInventory()
 {
     if (Time.realtimeSinceStartup - this.lastHeartbeat < 30f)
     {
         return;
     }
     this.lastHeartbeat = Time.realtimeSinceStartup;
     SteamInventory.SendItemDropHeartbeat();
 }
        string GetResultItemProperty(int index, string key)
        {
            string value;
            uint   valLength = STRING_BUFFER_SIZE;

            if (!SteamInventory.GetResultItemProperty(currentResult, (uint)index, key, out value, ref valLength))
            {
                return(null);
            }
            return(value);
        }
Exemple #20
0
    void OnSteamInventoryEligiblePromoItemDefIDs(SteamInventoryEligiblePromoItemDefIDs_t pCallback, bool bIOFailure)
    {
        Debug.Log("[" + SteamInventoryEligiblePromoItemDefIDs_t.k_iCallback + " - SteamInventoryEligiblePromoItemDefIDs] - " + pCallback.m_result + " -- " + pCallback.m_steamID + " -- " + pCallback.m_numEligiblePromoItemDefs + " -- " + pCallback.m_bCachedData);

        uint ItemDefIDsArraySize = (uint)pCallback.m_numEligiblePromoItemDefs;

        SteamItemDef_t[] ItemDefIDs = new SteamItemDef_t[ItemDefIDsArraySize];
        bool             ret        = SteamInventory.GetEligiblePromoItemDefinitionIDs(pCallback.m_steamID, ItemDefIDs, ref ItemDefIDsArraySize);

        print("SteamInventory.GetEligiblePromoItemDefinitionIDs(pCallback.m_steamID, ItemDefIDs, ref ItemDefIDsArraySize) - " + ret + " -- " + ItemDefIDsArraySize);
    }
        string GetItemDefinitionProperty(SteamItemDef_t definition, string key)
        {
            string value;
            uint   valLength = STRING_BUFFER_SIZE;

            if (!SteamInventory.GetItemDefinitionProperty(definition, key, out value, ref valLength))
            {
                return(null);
            }
            return(value);
        }
Exemple #22
0
    void Generate()
    {
        SteamInventoryResult_t InventoryResult;

        SteamInventory.GetAllItems(out InventoryResult);
        SteamItemDef_t[] itemDef_t = new SteamItemDef_t[1];
        itemDef_t[0].m_SteamItemDef = 5;
        SteamInventory.GenerateItems(out InventoryResult, itemDef_t, null, 1);
        Debug.Log(InventoryResult.m_SteamInventoryResult);
        SteamInventory.DestroyResult(InventoryResult);
    }
 void EnsureStatusOK()
 {
     if (currentResult == SteamInventoryResult_t.Invalid)
     {
         throw new InvalidOperationException("There is no current operation ongoing.");
     }
     if (SteamInventory.GetResultStatus(currentResult) != EResult.k_EResultOK)
     {
         throw new InvalidOperationException($"Result status is not OK. It is {SteamInventory.GetResultStatus(currentResult)}.");
     }
 }
 void EndDemo()
 {
     if (currentResult != SteamInventoryResult_t.Invalid)
     {
         SteamInventory.DestroyResult(currentResult);
         currentResult = SteamInventoryResult_t.Invalid;
     }
     nextAction     = null;
     currentDetails = null;
     IsDemoComplete = true;
 }
    private void HandleDropResult()
    {
        if (!m_waitForResult || !Global.isSteamActive)
        {
            return;
        }
        bool    flag         = false;
        EResult resultStatus = SteamInventory.GetResultStatus(m_itemDropHandle);

        switch (resultStatus)
        {
        case EResult.k_EResultPending:
            return;

        case EResult.k_EResultOK:
        {
            uint punOutItemsArraySize = 0u;
            if (!SteamInventory.GetResultItems(m_itemDropHandle, null, ref punOutItemsArraySize))
            {
                break;
            }
            SteamItemDetails_t[] array = new SteamItemDetails_t[punOutItemsArraySize];
            if (punOutItemsArraySize != 0)
            {
                SteamInventory.GetResultItems(m_itemDropHandle, array, ref punOutItemsArraySize);
                for (int i = 0; i < array.Length; i++)
                {
                    if ((array[i].m_unFlags & 0x100) == 0)
                    {
                        m_itemPopupGui.ShowGui(true, array[i].m_iDefinition.m_SteamItemDef);
                        break;
                    }
                }
            }
            else
            {
                flag = true;
            }
            break;
        }

        default:
            Debug.Log("RemoteCharacter.cs: Couldn't get item drop: " + resultStatus);
            break;
        }
        SteamInventory.DestroyResult(m_itemDropHandle);
        m_waitForResult = false;
        if (flag)
        {
            GetPromoItem();
        }
    }
Exemple #26
0
 IEnumerator TriggerDrop()
 {
     while (gameObject != null)
     {
         SteamInventoryResult_t InventoryResult;
         SteamItemDef_t         Item;
         Item.m_SteamItemDef = 5;
         bool res = SteamInventory.TriggerItemDrop(out InventoryResult, Item);
         Debug.Log(InventoryResult + " " + res);
         SteamInventory.DestroyResult(InventoryResult);
         yield return(new WaitForSeconds(5f));
     }
 }
        private void onSteamInventoryResultReady(SteamInventoryResultReady_t callback)
        {
            SteamworksEconomyRequestHandle steamworksEconomyRequestHandle = this.findSteamworksEconomyRequestHandles(callback.m_handle);

            if (steamworksEconomyRequestHandle == null)
            {
                return;
            }
            IEconomyRequestResult inventoryRequestResult = this.createInventoryRequestResult(steamworksEconomyRequestHandle.steamInventoryResult);

            steamworksEconomyRequestHandle.triggerInventoryRequestReadyCallback(inventoryRequestResult);
            SteamInventory.DestroyResult(steamworksEconomyRequestHandle.steamInventoryResult);
        }
        public void RunDemo()
        {
            // Demo 1: get all items
            EnsureNoOngoingOperation();
            IsDemoComplete = false;

            SteamInventoryResult_t result;

            if (!SteamInventory.GetAllItems(out result))
            {
                throw new InvalidOperationException("Failed to get all items. You're probably running this as a server.");
            }
            currentResult = result;
            nextAction    = LoadItemDetails;
        }
Exemple #29
0
    public void GetInventory()
    {
        if (C.LOG_DM)
        {
            Debug.Log("Updating inventory");
        }

        if (SteamInventory.GetAllItems(out InventoryResult))
        {
            if (C.LOG_DM)
            {
                Debug.Log("Inventory available, InventoryResult: " + InventoryResult.m_SteamInventoryResult);
            }
        }
    }
 private void Update()
 {
     UpdateInventory();
     if (!m_waitForResult && !m_caseOpenGui.InProgress() && m_caseOpenFlag)
     {
         UpdateInventoryDisplay();
         m_caseOpenFlag = false;
     }
     if (!Input.GetKeyDown(KeyCode.P))
     {
         return;
     }
     if (Global.isSteamActive)
     {
         if ("vidiludi" == m_client.GetPlayerName() || "Ethan" == m_client.GetPlayerName() || "Editor" == m_client.GetPlayerName())
         {
             SteamItemDef_t[] array  = new SteamItemDef_t[4];
             uint[]           array2 = new uint[4];
             array[0].m_SteamItemDef = 2004;
             array[1].m_SteamItemDef = 2004;
             array[2].m_SteamItemDef = 3000;
             array[3].m_SteamItemDef = 3000;
             array2[0]         = 1u;
             array2[1]         = 1u;
             array2[2]         = 1u;
             array2[3]         = 1u;
             m_waitForResult   = SteamInventory.GenerateItems(out m_resultHandle, array, null, 4u);
             m_completeRefresh = false;
         }
     }
     else
     {
         SteamItemDetails_t item = default(SteamItemDetails_t);
         item.m_iDefinition.m_SteamItemDef = 2004;
         item.m_unQuantity = 1;
         m_itemDetails.Add(item);
         for (int i = 0; i < 10; i++)
         {
             item.m_iDefinition.m_SteamItemDef = 20000 + i;
             item.m_unQuantity = 1;
             m_itemDetails.Add(item);
         }
         item.m_iDefinition.m_SteamItemDef = 2004;
         item.m_unQuantity = 1;
         m_itemDetails.Add(item);
         UpdateInventoryDisplay();
     }
 }