splinedrew
Member
I was wondering if it was possible to reset the indexes on an Item Collection/Inventory. The basic idea of what I am doing is creating random inventories in the world that display a menu for when you search them. Here is my basic logic:
The only problem I have is that when the display menu pops open for the first time, the item grid that is drawn uses the original indexes before generating the random inventory. This will leave some blank gaps in the display menu between items. Is there some code I can run that resets the Indexes after I add the random items to the list? I know on the Inventory Grid there I can turn off UseGridIndex, but everytime it opens it resets indexes.
C#:
protected override void Start()
{
base.Start();
if (m_randomAmounts)
{
m_ItemAmountProbabilityTable = new ItemAmountProbabilityTable((m_StorageInventory.MainItemCollection.GetAllItemStacks(), 0));
var randomItemAmounts = m_ItemAmountProbabilityTable.GetRandomItemAmounts(m_MinAmount, m_MaxAmount);
m_StorageInventory.MainItemCollection.RemoveAll();
for (int i = 0; i < randomItemAmounts.Count; i++)
{
if (randomItemAmounts[i].Amount > 0)
{
m_StorageInventory.MainItemCollection.AddItems(randomItemAmounts[i]);
}
}
}
}
The only problem I have is that when the display menu pops open for the first time, the item grid that is drawn uses the original indexes before generating the random inventory. This will leave some blank gaps in the display menu between items. Is there some code I can run that resets the Indexes after I add the random items to the list? I know on the Inventory Grid there I can turn off UseGridIndex, but everytime it opens it resets indexes.