How would you add , filter item’s button , to the player inventory. Like the shop system does ?.
What do you have there already?
Functions, select filter and other connected to UI and events .
What I need to know is in the inventory, getting filtered items , (using array.Foreach would be easy to return but the challenge is getting some to enumerate over.) , Using a for loop is easy to enumerate over all items using GetSize() but returning an item in an IEnumerable function Is difficult.
I’ve only done parts of the couse, so I can only give you general ideas.
It kind of sounds like you’re doing it the hard way. It can depend on what kind of IEnumerable you’re working with (array, list, linked list etc), and what you need. If it’s a simple item in the IEnumerable, just write a method that goes through the data to return the first item that matches the filter.
If you need all the items that match the filter then:
The data that you’re trying to filter, how is it stored? In a list? Is that list then fed into what you need to show/interact? If so, a lambda function would be a rather simple way to deal with it. Send in the data, use your function to filter out what you need and it returns the filtered list. If you don’t know lambda functions, make a method, build a list (or whatever IEnumerable you need) and go through your items in a foreach, adding anything that matches to your list and return it.
Does that help?
Sorry to say , but it really doesn’t help.
What part isn’t helping? What’s the issue?
I’ll wait for Mr Brian.
Thank you very much, Mr brain. My Core is finally complete. Thank you!!
And Michael, I hope I didn’t offend you. What I was looking for is this
public IEnumerable<InventoryEntry> GetRawInventoryData()
{
for (int i = 0; i < inventorySize; i++)
{
InventoryEntry entry = new InventoryEntry
{
item = slots[i].item,
slot = i
};
yield return entry;
}
}
Thanks for replying.