Forum rules - please read before posting.

GetDocumentsInCategory

Hello,
I've just realised that there's a public function to get all inventoryItems that fall into a particular categoryID, but nothing similar for documents. I think it's a pretty simple implementation (I've done it myself) that could improve the quality of life of fellow developers using AC, so I'm dropping here the code snippet that I've added to InventoryManager.cs (it's basically the same thing as GetItemsInCategory, really)

public Document[] GetDocumentsInCategory(int categoryID) { List<Document> documentsList = new List<Document>(); foreach (Document document in documents) { if (document.binID == categoryID) { documentsList.Add(document); } } return documentsList.ToArray(); }

Comments

  • I don't know why the code markdown hates me :cry:

  • Formatted:

    public Document[] GetDocumentsInCategory(int categoryID)
    {
        List<Document> documentsList = new List<Document>();
        foreach (Document document in documents)
        {
            if (document.binID == categoryID)
            {
                documentsList.Add(document);
            }
        }
        return documentsList.ToArray();
    }
    

    And it's a good suggestion. Thanks, I'll include it in the next update.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.