1using System.Collections.Generic;
12 private List<Item>
items =
new List<Item>();
13 private List<int>
groups =
new List<int>();
15 private List<int>
tiles =
new List<int>();
42 item.SetDefaults(itemID,
false);
53 if (!RecipeGroup.recipeGroupIDs.ContainsKey(name)) {
56 int id = RecipeGroup.recipeGroupIDs[name];
57 RecipeGroup rec = RecipeGroup.recipeGroups[id];
69 if (!RecipeGroup.recipeGroupIDs.ContainsValue(recipeGroupID)) {
70 throw new RecipeException(
"No recipe group has the RecipeGroupID " + recipeGroupID);
72 RecipeGroup rec = RecipeGroup.recipeGroups[recipeGroupID];
86 result.SetDefaults(itemID,
false);
106 for (
int k = 0; k < Recipe.numRecipes; k++) {
107 Recipe recipe = Main.recipe[k];
109 List<Item> checkItems =
new List<Item>(
items);
110 for (
int i = 0; i < Recipe.maxRequirements; i++) {
111 Item item = recipe.requiredItem[i];
112 if (item.type == 0) {
115 bool itemMatched =
false;
116 for (
int j = 0; j < checkItems.Count; j++) {
117 if (item.type == checkItems[j].type && item.stack == checkItems[j].stack) {
119 checkItems.RemoveAt(j);
128 if (checkItems.Count > 0) {
131 List<int> checkGroups =
new List<int>(
groups);
133 for (
int i = 0; i < acceptedGroups.Count; i++) {
134 int group = acceptedGroups[i];
135 bool groupMatched =
false;
136 for (
int j = 0; j < checkGroups.Count; j++) {
137 if (group == checkGroups[j]) {
139 checkGroups.RemoveAt(j);
148 if (checkGroups.Count > 0) {
151 if (
result.type != recipe.createItem.type ||
result.stack != recipe.createItem.stack) {
154 List<int> checkTiles =
new List<int>(
tiles);
155 for (
int i = 0; i < Recipe.maxRequirements; i++) {
156 int tile = recipe.requiredTile[i];
160 bool tileMatched =
false;
161 for (
int j = 0; j < checkTiles.Count; j++) {
162 if (tile == checkTiles[j]) {
164 checkTiles.RemoveAt(j);
173 if (checkTiles.Count > 0) {
179 else if (
needLava != recipe.needLava) {
182 else if (
needHoney != recipe.needHoney) {
197 List<Recipe> recipes =
new List<Recipe>();
198 for (
int k = 0; k < Recipe.numRecipes; k++) {
199 Recipe recipe = Main.recipe[k];
201 List<Item> checkItems =
new List<Item>(
items);
202 for (
int i = 0; i < Recipe.maxRequirements; i++) {
203 Item item = recipe.requiredItem[i];
204 if (item.type == 0) {
207 for (
int j = 0; j < checkItems.Count; j++) {
208 if (item.type == checkItems[j].type && item.stack >= checkItems[j].stack) {
209 checkItems.RemoveAt(j);
214 if (checkItems.Count > 0) {
217 List<int> checkGroups =
new List<int>(
groups);
219 for (
int i = 0; i < acceptedGroups.Count; i++) {
220 int group = acceptedGroups[i];
221 for (
int j = 0; j < checkGroups.Count; j++) {
222 if (group == checkGroups[j]) {
223 checkGroups.RemoveAt(j);
228 if (checkGroups.Count > 0) {
232 if (
result.type != recipe.createItem.type) {
235 else if (
result.stack > recipe.createItem.stack) {
239 List<int> checkTiles =
new List<int>(
tiles);
240 for (
int i = 0; i < Recipe.maxRequirements; i++) {
241 int tile = recipe.requiredTile[i];
245 for (
int j = 0; j < checkTiles.Count; j++) {
246 if (tile == checkTiles[j]) {
247 checkTiles.RemoveAt(j);
252 if (checkTiles.Count > 0) {
258 else if (
needLava && !recipe.needLava) {
261 else if (
needHoney && !recipe.needHoney) {
272 List<int> acceptedGroups =
new List<int>(recipe.acceptedGroups);
273 if (recipe.anyWood) {
274 acceptedGroups.Add(RecipeGroupID.Wood);
276 if (recipe.anyIronBar) {
277 acceptedGroups.Add(RecipeGroupID.IronBar);
279 if (recipe.anySand) {
280 acceptedGroups.Add(RecipeGroupID.Sand);
282 if (recipe.anyPressurePlate) {
283 acceptedGroups.Add(RecipeGroupID.PressurePlate);
285 if (recipe.anyFragment) {
286 acceptedGroups.Add(RecipeGroupID.Fragment);
288 return acceptedGroups;
This serves as the central class from which item-related functions are carried out....
This class will search through all existing recipes for you based on criteria that you give it....
bool needLava
Adds the requirement of being nearby lava to the search criteria. Defaults to false.
bool needWater
Adds the requirement of being nearby water to the search criteria. Defaults to false.
Recipe FindExactRecipe()
Searches for a recipe that matches the search criteria exactly, then returns it. That means the recip...
void AddRecipeGroup(int recipeGroupID, int stack=1)
Adds a recipe group ingredient with the given RecipeGroupID and stack size to the search criteria.
void AddRecipeGroup(string name, int stack=1)
Adds a recipe group ingredient with the given RecipeGroup name and stack size to the search criteria.
List< Recipe > SearchRecipes()
Searches for all recipes that include the search criteria, then returns them in a list....
static List< int > GetAcceptedGroups(Recipe recipe)
bool needHoney
Adds the requirement of being nearby honey to the search criteria. Defaults to false.
void AddIngredient(int itemID, int stack=1)
Adds an ingredient with the given item type and stack size to the search criteria.
void SetResult(int itemID, int stack=1)
Sets the search criteria's result to the given item type and stack size.
void AddTile(int tileID)
Adds a required crafting station with the given tile type to the search criteria.
This serves as the central class from which tile-related functions are supported and carried out.