forked from Pathoschild/StardewMods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIStorage.cs
64 lines (57 loc) · 3.07 KB
/
IStorage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace Pathoschild.Stardew.Automate
{
/// <summary>Manages access to items in the underlying containers.</summary>
public interface IStorage
{
/*********
** Public methods
*********/
/// <summary>Get all items from the given pipes.</summary>
IEnumerable<ITrackedStack> GetItems();
/****
** TryGetIngredient
****/
/// <summary>Get an ingredient needed for a recipe.</summary>
/// <param name="predicate">Returns whether an item should be matched.</param>
/// <param name="count">The number of items to find.</param>
/// <param name="consumable">The matching consumables.</param>
/// <returns>Returns whether the requirement is met.</returns>
bool TryGetIngredient(Func<ITrackedStack, bool> predicate, int count, [NotNullWhen(true)] out IConsumable? consumable);
/// <summary>Get an ingredient needed for a recipe.</summary>
/// <param name="id">The item or category ID.</param>
/// <param name="count">The number of items to find.</param>
/// <param name="consumable">The matching consumables.</param>
/// <param name="type">The item type to find, or <c>null</c> to match any.</param>
/// <returns>Returns whether the requirement is met.</returns>
bool TryGetIngredient(int id, int count, [NotNullWhen(true)] out IConsumable? consumable, ItemType? type = ItemType.Object);
/// <summary>Get an ingredient needed for a recipe.</summary>
/// <param name="recipes">The items to match.</param>
/// <param name="consumable">The matching consumables.</param>
/// <param name="recipe">The matched requisition.</param>
/// <returns>Returns whether the requirement is met.</returns>
bool TryGetIngredient(IRecipe[] recipes, [NotNullWhen(true)] out IConsumable? consumable, [NotNullWhen(true)] out IRecipe? recipe);
/****
** TryConsume
****/
/// <summary>Consume an ingredient needed for a recipe.</summary>
/// <param name="predicate">Returns whether an item should be matched.</param>
/// <param name="count">The number of items to find.</param>
/// <returns>Returns whether the item was consumed.</returns>
bool TryConsume(Func<ITrackedStack, bool> predicate, int count);
/// <summary>Consume an ingredient needed for a recipe.</summary>
/// <param name="itemID">The item ID.</param>
/// <param name="count">The number of items to find.</param>
/// <param name="type">The item type to find, or <c>null</c> to match any.</param>
/// <returns>Returns whether the item was consumed.</returns>
bool TryConsume(int itemID, int count, ItemType? type = ItemType.Object);
/****
** TryPush
****/
/// <summary>Add the given item stack to the pipes if there's space.</summary>
/// <param name="item">The item stack to push.</param>
bool TryPush(ITrackedStack? item);
}
}