public bool MergeItem(GameObject item) { if (item == null) { return(false); } if (GetItem() != null) { GameObject recipesObj = GameObject.FindGameObjectWithTag("Recipes"); Recipes recipes = recipesObj.GetComponent <Recipes>(); ItemType itemTypeA = GetItem().GetComponent <Item>().itemType; ItemType itemTypeB = item.GetComponent <Item>().itemType; Recipes.Recipe recipe = recipes.GetRecipe(itemTypeA, itemTypeB); if (recipe.output != null) { GetItem().GetComponent <Item>().SetItemType(recipe.output); return(true); } else { return(false); } } return(false); }
void HighlightInteractableTiles(Pim pim, Item item) { List <GameObject> gos = GameObject.FindGameObjectsWithTag("PickupPoint").ToList <GameObject>(); List <PickupPoint> pickupPoints = new List <PickupPoint>(); foreach (var go in gos) { PickupPoint pickupPoint = go.GetComponent <PickupPoint>(); if (pickupPoint) { pickupPoints.Add(pickupPoint); } } foreach (PickupPoint pickupPoint in pickupPoints) { //if (pickupPoint.CanDropHere()) { if (pickupPoint.IsOccupied()) { GameObject recipesObj = GameObject.FindGameObjectWithTag("Recipes"); Recipes recipes = recipesObj.GetComponent <Recipes>(); GameObject itemObject = pickupPoint.GetItem(); if (itemObject != null) { Item anItem = itemObject.GetComponent <Item>(); if (anItem != null) { ItemType itemType = anItem.itemType; Item currentItemObj = currentItem.GetComponent <Item>(); if (currentItem != null) { Recipes.Recipe foundRecipe = recipes.GetRecipe(itemType, currentItemObj.itemType); if (foundRecipe.output != null) { GameObject go = Instantiate(mergableEffect, pickupPoint.gameObject.transform.position, Quaternion.identity); highlightEffectCache.Add(go); go.transform.SetParent(itemObject.transform); } } } } } else { if (pickupPoint.CanDropHere()) { GameObject go = Instantiate(highlightEffect, pickupPoint.gameObject.transform.position, Quaternion.identity); highlightEffectCache.Add(go); } } //} } }
// return shopping list/count given receipe list, list of current materials. static public List <Tuple <MaterialCommodities, int> > GetShoppingList(List <Tuple <Recipes.Recipe, int> > wantedrecipes, List <MaterialCommodities> list) { var shoppingList = new List <Tuple <MaterialCommodities, int> >(); var totals = TotalList(list); foreach (Tuple <Recipes.Recipe, int> want in wantedrecipes) { Recipes.Recipe r = want.Item1; int wanted = want.Item2; for (int i = 0; i < r.Ingredients.Length; i++) { string ingredient = r.Ingredients[i].Shortname; int mi = list.FindIndex(x => x.Details.Shortname.Equals(ingredient)); // see if we have any in list MaterialCommodities matc = mi != -1 ? list[mi] : new MaterialCommodities(MaterialCommodityData.GetByShortName(ingredient)); // if not there, make one if (mi == -1) // if not there, make an empty total entry { totals[matc.Details.FDName] = 0; } int got = totals[matc.Details.FDName]; // what we have left from totals int need = r.Amount[i] * wanted; int left = got - need; if (left < 0) // if not enough { int shopentry = shoppingList.FindIndex(x => x.Item1.Details.Shortname.Equals(ingredient)); // have we already got it in the shopping list if (shopentry >= 0) // found, update list with new wanted total { shoppingList[shopentry] = new Tuple <MaterialCommodities, int>(shoppingList[shopentry].Item1, shoppingList[shopentry].Item2 - left); // need this more } else { shoppingList.Add(new Tuple <MaterialCommodities, int>(matc, -left)); // a new shop entry with this many needed } totals[matc.Details.FDName] = 0; // clear count } else { totals[matc.Details.FDName] -= need; // decrement total } } } shoppingList.Sort(delegate(Tuple <MaterialCommodities, int> left, Tuple <MaterialCommodities, int> right) { return(left.Item1.Details.Name.CompareTo(right.Item1.Details.Name)); }); return(shoppingList); }
void OnPickupPointRecievedItemEvent(PickupPoint pickupPoint, Item item) { List <GameObject> destroyTheseObjects = new List <GameObject>(); bool isAlreadyCached = false; foreach (GameObject highlightedObject in highlightEffectCache) { if (highlightedObject == null) { destroyTheseObjects.Add(highlightedObject); } else { if (highlightedObject.transform.parent) { if (highlightedObject.transform.parent.gameObject == item.gameObject) { isAlreadyCached = true; break; } } } } if (!isAlreadyCached) { if (currentItem != null) { GameObject recipesObj = GameObject.FindGameObjectWithTag("Recipes"); Recipes recipes = recipesObj.GetComponent <Recipes>(); Item currentItemObj = currentItem.GetComponent <Item>(); Recipes.Recipe foundRecipe = recipes.GetRecipe(item.itemType, currentItemObj.itemType); if (foundRecipe.output != null) { GameObject go = Instantiate(mergableEffect, item.transform.position, Quaternion.identity); highlightEffectCache.Add(go); go.transform.SetParent(item.gameObject.transform); } } } foreach (GameObject go in destroyTheseObjects) { highlightEffectCache.Remove(go); Destroy(go); } }
private bool FitsRecipe(Recipes.Recipe recipe) { Recipes.eIngredients[] recipeIngr = new Recipes.eIngredients[3]; recipeIngr[0] = recipe.ingredient1; recipeIngr[1] = recipe.ingredient2; recipeIngr[2] = recipe.ingredient3; foreach (Recipes.eIngredients ingr in inPot) { if (CountIngredient(ingr, recipeIngr) != CountIngredient(ingr, inPot)) { return false; } } return true; }
public static void ProduceConsume(int colonyid, Recipes.Recipe recipe, List <Recipes.RecipeResult> results) { if (oldstockpileinfo.ContainsKey(colonyid) == false) { oldstockpileinfo.Add(colonyid, new OldStockpiles()); } foreach (var item in recipe.Requirements) { AddRemove(colonyid, item.Type, -item.Amount); } foreach (var item in results) { AddRemove(colonyid, item.Type, item.Amount); } }
static public List <MaterialCommodities> GetShoppingList(List <Tuple <Recipes.Recipe, int> > target, List <MaterialCommodities> list) { List <MaterialCommodities> shoppingList = new List <MaterialCommodities>(); foreach (Tuple <Recipes.Recipe, int> want in target) { Recipes.Recipe r = want.Item1; int wanted = want.Item2; for (int i = 0; i < r.ingredients.Length; i++) { string ingredient = r.ingredients[i]; int mi = list.FindIndex(x => x.Details.Shortname.Equals(ingredient)); int got = (mi >= 0) ? list[mi].scratchpad : 0; int need = r.count[i] * wanted; if (got < need) { int shopentry = shoppingList.FindIndex(x => x.Details.Shortname.Equals(ingredient)); if (shopentry >= 0) { shoppingList[shopentry].scratchpad += (need - got); } else { MaterialCommodityData db = MaterialCommodityData.GetByShortName(ingredient); if (db != null) // MUST be there, its well know, but will check.. { MaterialCommodities mc = new MaterialCommodities(db); // make a new entry mc.scratchpad = (need - got); shoppingList.Add(mc); } } if (mi >= 0) { list[mi].scratchpad = 0; } } else { if (mi >= 0) { list[mi].scratchpad -= need; } } } } return(shoppingList); }
private bool CheckRecipes() { for (int recipeIdx = 0; recipeIdx < Game.GAME.GetFoodOrders().Length; recipeIdx++) { Recipes.Recipe recipe = Game.GAME.GetFoodOrders()[recipeIdx]; if (FitsRecipe(recipe)) { PointLabel.SpawnAt(pointLabelPrefab, transform.parent, transform.position, recipe.points); Game.GAME.AddScore(recipe.points); Game.GAME.NextRecipe(recipeIdx); EmptyCookingPlace(false); return true; } } return false; }
private void RemoveRecipeFromList(Recipes.Recipe selected, int s_index) { _state.Player.Loot.Recipes.Remove(selected); recipeList.DataSource = null; if (_state.Player.Loot.Wishlist.Contains(selected)) { _state.Player.Loot.Wishlist.Remove(selected); } var display = _state.Player.Loot.Recipes.FindAll(r => r.Result != null); if (display != null && display.Count > 0) { for (int i = 0; i < rbuttons.Count; i++) { if (rbuttons[i].Checked) { FindPiece(i); } } if (allButton.Checked) { recipeList.DataSource = display; } if (wlistButton.Checked) { recipeList.DataSource = _state.Player.Loot.Wishlist; } if (recipeList.Items.Count > 0) { _state.HandleSelectedIndex(recipeList, s_index); } else { ClearDisplayBox(); } } else { ClearDisplayBox(); } }
public static string recipe() { Func <string, Recipes.eIngredients> toIngr = str => { switch (str[0]) { case 'a': return(Recipes.eIngredients.asparagus); case 'c': return(Recipes.eIngredients.carrot); case 'h': return(Recipes.eIngredients.chicken); case 'o': return(Recipes.eIngredients.onion); case 't': return(Recipes.eIngredients.tomato); default: return(Recipes.eIngredients.empty); } }; string output = BuildOutput(); if (argc < 3) { return(output + "\nPlease specify a recipe with ingredient ids (see Recipes)!\n" + "recipe <ingr1> <ingr2> (<ingr3>)"); } Recipes.Recipe recipe = new Recipes.Recipe(); recipe.ingredient1 = toIngr(args[1]); recipe.ingredient2 = toIngr(args[2]); recipe.ingredient3 = Recipes.eIngredients.empty; if (argc >= 4) { recipe.ingredient3 = toIngr(args[3]); } Game.GAME.SetRecipe(0, recipe); return(output); }
public void ShowRecipe(Recipes.Recipe recipe, int idx) { ResetRecipeUI(idx); // Hide plus-icons when necessary if (recipe.ingredient1 != Recipes.eIngredients.empty) { iconSlots[Game.RECIPE_MAX_SIZE * idx].sprite = iconTextures[(int)recipe.ingredient1 - 1]; iconSlots[Game.RECIPE_MAX_SIZE * idx].enabled = true; } if (recipe.ingredient2 != Recipes.eIngredients.empty) { iconSlots[Game.RECIPE_MAX_SIZE * idx + 1].sprite = iconTextures[(int)recipe.ingredient2 - 1]; iconSlots[Game.RECIPE_MAX_SIZE * idx + 1].enabled = true; plusSigns[(Game.RECIPE_MAX_SIZE - 1) * idx].enabled = true; } if (recipe.ingredient3 != Recipes.eIngredients.empty) { iconSlots[Game.RECIPE_MAX_SIZE * idx + 2].sprite = iconTextures[(int)recipe.ingredient3 - 1]; iconSlots[Game.RECIPE_MAX_SIZE * idx + 2].enabled = true; plusSigns[(Game.RECIPE_MAX_SIZE - 1) * idx + 1].enabled = true; } }
private void UpdateHighlighting() { if(mainMesh == null) { return; } for (int recipeIdx = 0; recipeIdx < Game.GAME.GetFoodOrders().Length; recipeIdx++) { Recipes.Recipe recipe = Game.GAME.GetFoodOrders()[recipeIdx]; if (FitsRecipe(recipe)) { blinkTimer += Time.deltaTime; if (blinkTimer > 0.5f) { blinkTimer = 0.0f; int marked = mainMesh.GetComponent<MeshRenderer>().material.GetInt("_Marked"); mainMesh.GetComponent<MeshRenderer>().material.SetInt("_Marked", (marked + 1) % 2); } return; } } mainMesh.GetComponent<MeshRenderer>().material.SetInt("_Marked", 0); }
private void Display() { //DONT turn on sorting in the future, thats not how it works. You click and drag to sort manually since it gives you // the order of recipies. List <Tuple <Recipes.Recipe, int> > wantedList = null; if (last_he != null) { List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false); int fdrow = dataGridViewSynthesis.FirstDisplayedScrollingRowIndex; // remember where we were displaying var totals = MaterialCommoditiesRecipe.TotalList(mcl); // start with totals present wantedList = new List <Tuple <Recipes.Recipe, int> >(); string recep = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbRecipeFilterSave, "All"); string[] recipeArray = recep.Split(';'); string levels = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbLevelFilterSave, "All"); string[] lvlArray = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';'); string materials = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbMaterialFilterSave, "All"); var matList = materials.Split(';'); // list of materials to show for (int i = 0; i < Recipes.SynthesisRecipes.Count; i++) { int rno = (int)dataGridViewSynthesis.Rows[i].Tag; dataGridViewSynthesis.Rows[i].Cells[2].Value = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals, Recipes.SynthesisRecipes[rno]).Item1.ToString(); bool visible = true; if (recep != "All" || levels != "All" || materials != "All") { if (recep != "All") { visible &= recipeArray.Contains(Recipes.SynthesisRecipes[rno].Name); } if (levels != "All") { visible &= lvlArray.Contains(Recipes.SynthesisRecipes[rno].level); } if (materials != "All") { var inglongname = Recipes.SynthesisRecipes[rno].Ingredients.Select(x => x.Name); var included = matList.Intersect <string>(inglongname); visible &= included.Count() > 0; } } dataGridViewSynthesis.Rows[i].Visible = visible; } for (int i = 0; i < Recipes.SynthesisRecipes.Count; i++) { int rno = (int)dataGridViewSynthesis.Rows[i].Tag; if (dataGridViewSynthesis.Rows[i].Visible) { Recipes.Recipe r = Recipes.SynthesisRecipes[rno]; Tuple <int, int, string, string> res = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals, r, Wanted[rno]); //System.Diagnostics.Debug.WriteLine("{0} Recipe {1} executed {2} {3} ", i, rno, Wanted[rno], res.Item2); using (DataGridViewRow row = dataGridViewSynthesis.Rows[i]) { row.Cells[3].Value = Wanted[rno].ToString(); row.Cells[4].Value = res.Item2.ToString(); row.Cells[5].Value = res.Item3; row.Cells[5].ToolTipText = res.Item4; row.Cells[6].Value = r.IngredientsStringvsCurrent(last_he.MaterialCommodity); row.Cells[6].ToolTipText = r.IngredientsStringLong; } } if (Wanted[rno] > 0 && (dataGridViewSynthesis.Rows[i].Visible || isEmbedded)) { wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.SynthesisRecipes[rno], Wanted[rno])); } } dataGridViewSynthesis.RowCount = Recipes.SynthesisRecipes.Count; // truncate previous shopping list.. if (!isEmbedded) { var shoppinglist = MaterialCommoditiesRecipe.GetShoppingList(wantedList, mcl); foreach (var c in shoppinglist) // and add new.. { var cur = last_he.MaterialCommodity.Find(c.Item1.Details); // may be null Object[] values = { c.Item1.Details.Name, c.Item1.Details.TranslatedCategory, (cur?.Count ?? 0).ToString(), c.Item2.ToString(), "", "", c.Item1.Details.Shortname }; int rn = dataGridViewSynthesis.Rows.Add(values); dataGridViewSynthesis.Rows[rn].ReadOnly = true; // disable editing wanted.. } } if (fdrow >= 0 && dataGridViewSynthesis.Rows[fdrow].Visible) // better check visible, may have changed.. { dataGridViewSynthesis.SafeFirstDisplayedScrollingRowIndex(fdrow); } } if (OnDisplayComplete != null) { OnDisplayComplete(wantedList); } }
private void Display() { //DONT turn on sorting in the future, thats not how it works. You click and drag to sort manually since it gives you // the order of recipies. List <Tuple <Recipes.Recipe, int> > wantedList = null; System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this, true) + " EN " + displaynumber + " Begin Display"); if (last_he != null) { List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false); int fdrow = dataGridViewEngineering.FirstDisplayedScrollingRowIndex; // remember where we were displaying MaterialCommoditiesRecipe.ResetUsed(mcl); wantedList = new List <Tuple <Recipes.Recipe, int> >(); string engineers = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbEngFilterSave, "All"); List <string> engList = engineers.Split(';').ToList <string>(); string modules = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbModFilterSave, "All"); List <string> modList = modules.Split(';').ToList <string>(); string levels = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbLevelFilterSave, "All"); string[] lvlArray = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';'); string upgrades = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbUpgradeFilterSave, "All"); string[] upgArray = upgrades.Split(';'); string materials = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbMaterialFilterSave, "All"); var matList = materials.Split(';'); // list of materials to show for (int i = 0; i < Recipes.EngineeringRecipes.Count; i++) { int rno = (int)dataGridViewEngineering.Rows[i].Tag; dataGridViewEngineering[MaxCol.Index, i].Value = MaterialCommoditiesRecipe.HowManyLeft(mcl, Recipes.EngineeringRecipes[rno]).Item1.ToString(); bool visible = true; if (!(engineers == "All" && modules == "All" && levels == "All" && upgrades == "All" && materials == "All")) { if (engineers != "All") { var included = engList.Intersect <string>(Recipes.EngineeringRecipes[rno].engineers.ToList <string>()); visible &= included.Count() > 0; } if (modules != "All") { var included = modList.Intersect <string>(Recipes.EngineeringRecipes[rno].modules.ToList <string>()); visible &= included.Count() > 0; } if (levels != "All") { visible &= lvlArray.Contains(Recipes.EngineeringRecipes[rno].level); } if (upgrades != "All") { visible &= upgArray.Contains(Recipes.EngineeringRecipes[rno].Name); } if (materials != "All") { var inglongname = Recipes.EngineeringRecipes[rno].Ingredients.Select(x => x.Name); var included = matList.Intersect <string>(inglongname); visible &= included.Count() > 0; } } dataGridViewEngineering.Rows[i].Visible = visible; if (visible) { Recipes.Recipe r = Recipes.EngineeringRecipes[i]; Tuple <int, int, string, string> res = MaterialCommoditiesRecipe.HowManyLeft(mcl, Recipes.EngineeringRecipes[rno], Wanted[rno]); //System.Diagnostics.Debug.WriteLine("{0} Recipe {1} executed {2} {3} ", i, rno, Wanted[rno], res.Item2); dataGridViewEngineering[WantedCol.Index, i].Value = Wanted[rno].ToString(); dataGridViewEngineering[AvailableCol.Index, i].Value = res.Item2.ToString(); dataGridViewEngineering[NotesCol.Index, i].Value = res.Item3; dataGridViewEngineering[NotesCol.Index, i].ToolTipText = res.Item4; dataGridViewEngineering[RecipeCol.Index, i].Value = r.IngredientsStringvsCurrent(last_he.MaterialCommodity); dataGridViewEngineering[RecipeCol.Index, i].ToolTipText = r.IngredientsStringLong; } if (Wanted[rno] > 0 && (visible || isEmbedded)) // embedded, need to { wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.EngineeringRecipes[rno], Wanted[rno])); } } if (!isEmbedded) { MaterialCommoditiesRecipe.ResetUsed(mcl); List <MaterialCommodities> shoppinglist = MaterialCommoditiesRecipe.GetShoppingList(wantedList, mcl); dataGridViewEngineering.RowCount = Recipes.EngineeringRecipes.Count; // truncate previous shopping list.. foreach (MaterialCommodities c in shoppinglist.OrderBy(mat => mat.Details.Name)) // and add new.. { var cur = last_he.MaterialCommodity.Find(c.Details); // may be null int rn = dataGridViewEngineering.Rows.Add(); foreach (var cell in dataGridViewEngineering.Rows[rn].Cells.OfType <DataGridViewCell>()) { if (cell.OwningColumn == UpgradeCol) { cell.Value = c.Details.Name; } else if (cell.OwningColumn == MaxCol) { cell.Value = (cur?.Count ?? 0).ToString(); } else if (cell.OwningColumn == WantedCol) { cell.Value = c.scratchpad.ToString(); } else if (cell.OwningColumn == RecipeCol) { cell.Value = c.Details.Shortname; } else if (cell.ValueType == null || cell.ValueType.IsAssignableFrom(typeof(string))) { cell.Value = string.Empty; } } dataGridViewEngineering.Rows[rn].ReadOnly = true; // disable editing wanted.. } } if (fdrow >= 0 && dataGridViewEngineering.Rows[fdrow].Visible) // better check visible, may have changed.. { dataGridViewEngineering.FirstDisplayedScrollingRowIndex = fdrow; } } if (OnDisplayComplete != null) { OnDisplayComplete(wantedList); } System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this) + " EN " + displaynumber + " Load Finished"); }
//return maximum can make, how many made, needed string. static public Tuple <int, int, string, string> HowManyLeft(List <MaterialCommodities> list, Recipes.Recipe r, int tomake = 0) { int max = int.MaxValue; System.Text.StringBuilder needed = new System.Text.StringBuilder(64); System.Text.StringBuilder neededlong = new System.Text.StringBuilder(64); for (int i = 0; i < r.ingredients.Length; i++) { string ingredient = r.ingredients[i]; int mi = list.FindIndex(x => x.Details.Shortname.Equals(ingredient)); int got = (mi >= 0) ? list[mi].scratchpad : 0; int sets = got / r.count[i]; max = Math.Min(max, sets); int need = r.count[i] * tomake; if (got < need) { string dispshort; string displong; if (mi > 0) // if got one.. { dispshort = (list[mi].Details.IsEncodedOrManufactured) ? " " + list[mi].Details.Name : list[mi].Details.Shortname; displong = " " + list[mi].Details.Name; } else { MaterialCommodityData db = MaterialCommodityData.GetByShortName(ingredient); dispshort = (db.Category == MaterialCommodityData.MaterialEncodedCategory || db.Category == MaterialCommodityData.MaterialManufacturedCategory) ? " " + db.Name : db.Shortname; displong = " " + db.Name; } string sshort = (need - got).ToStringInvariant() + dispshort; string slong = (need - got).ToStringInvariant() + " x " + displong + Environment.NewLine; if (needed.Length == 0) { needed.Append("Need:" + sshort); neededlong.Append("Need:" + Environment.NewLine + slong); } else { needed.Append("," + sshort); neededlong.Append(slong); } } } int made = 0; if (max > 0 && tomake > 0) // if we have a set, and use it up { made = Math.Min(max, tomake); // can only make this much System.Text.StringBuilder usedstrshort = new System.Text.StringBuilder(64); System.Text.StringBuilder usedstrlong = new System.Text.StringBuilder(64); for (int i = 0; i < r.ingredients.Length; i++) { int mi = list.FindIndex(x => x.Details.Shortname.Equals(r.ingredients[i])); System.Diagnostics.Debug.Assert(mi != -1); int used = r.count[i] * made; list[mi].scratchpad -= used; string dispshort = (list[mi].Details.IsEncodedOrManufactured) ? " " + list[mi].Details.Name : list[mi].Details.Shortname; string displong = " " + list[mi].Details.Name; usedstrshort.AppendPrePad(used.ToStringInvariant() + dispshort, ","); usedstrlong.AppendPrePad(used.ToStringInvariant() + " x " + displong, Environment.NewLine); } needed.AppendPrePad("Used: " + usedstrshort.ToString(), ", "); neededlong.Append("Used: " + Environment.NewLine + usedstrlong.ToString()); } return(new Tuple <int, int, string, string>(max, made, needed.ToNullSafeString(), neededlong.ToNullSafeString())); }
private void Display() { //DONT turn on sorting in the future, thats not how it works. You click and drag to sort manually since it gives you // the order of recipies. List <Tuple <Recipes.Recipe, int> > wantedList = null; if (last_he != null) { List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false); int fdrow = dataGridViewEngineering.FirstDisplayedScrollingRowIndex; // remember where we were displaying var totals = MaterialCommoditiesRecipe.TotalList(mcl); // start with totals present wantedList = new List <Tuple <Recipes.Recipe, int> >(); string engineers = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbEngFilterSave, "All"); List <string> engList = engineers.Split(';').ToList <string>(); string modules = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbModFilterSave, "All"); List <string> modList = modules.Split(';').ToList <string>(); string levels = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbLevelFilterSave, "All"); string[] lvlArray = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';'); string upgrades = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbUpgradeFilterSave, "All"); string[] upgArray = upgrades.Split(';'); string materials = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbMaterialFilterSave, "All"); var matList = materials.Split(';'); // list of materials to show for (int i = 0; i < Recipes.EngineeringRecipes.Count; i++) { int rno = (int)dataGridViewEngineering.Rows[i].Tag; dataGridViewEngineering[MaxCol.Index, i].Value = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals, Recipes.EngineeringRecipes[rno]).Item1.ToString(); bool visible = true; if (!(engineers == "All" && modules == "All" && levels == "All" && upgrades == "All" && materials == "All")) { if (engineers != "All") { var included = engList.Intersect <string>(Recipes.EngineeringRecipes[rno].engineers.ToList <string>()); visible &= included.Count() > 0; } if (modules != "All") { var included = modList.Intersect <string>(Recipes.EngineeringRecipes[rno].modules.ToList <string>()); visible &= included.Count() > 0; } if (levels != "All") { visible &= lvlArray.Contains(Recipes.EngineeringRecipes[rno].level); } if (upgrades != "All") { visible &= upgArray.Contains(Recipes.EngineeringRecipes[rno].Name); } if (materials != "All") { var inglongname = Recipes.EngineeringRecipes[rno].Ingredients.Select(x => x.Name); var included = matList.Intersect <string>(inglongname); visible &= included.Count() > 0; } } dataGridViewEngineering.Rows[i].Visible = visible; if (visible) { Recipes.Recipe r = Recipes.EngineeringRecipes[i]; Tuple <int, int, string, string> res = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals, Recipes.EngineeringRecipes[rno], Wanted[rno]); //System.Diagnostics.Debug.WriteLine("{0} Recipe {1} executed {2} {3} ", i, rno, Wanted[rno], res.Item2); dataGridViewEngineering[WantedCol.Index, i].Value = Wanted[rno].ToString(); dataGridViewEngineering[AvailableCol.Index, i].Value = res.Item2.ToString(); dataGridViewEngineering[NotesCol.Index, i].Value = res.Item3; dataGridViewEngineering[NotesCol.Index, i].ToolTipText = res.Item4; dataGridViewEngineering[RecipeCol.Index, i].Value = r.IngredientsStringvsCurrent(last_he.MaterialCommodity); dataGridViewEngineering[RecipeCol.Index, i].ToolTipText = r.IngredientsStringLong; } if (Wanted[rno] > 0 && (visible || isEmbedded)) // embedded, need to { wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.EngineeringRecipes[rno], Wanted[rno])); } } if (!isEmbedded) { var shoppinglist = MaterialCommoditiesRecipe.GetShoppingList(wantedList, mcl); dataGridViewEngineering.RowCount = Recipes.EngineeringRecipes.Count; // truncate previous shopping list.. foreach (var c in shoppinglist) // and add new.. { var cur = last_he.MaterialCommodity.Find(c.Item1.Details); // may be null DataGridViewRow r = dataGridViewEngineering.RowTemplate.Clone() as DataGridViewRow; r.CreateCells(dataGridViewEngineering, c.Item1.Details.Name, "", "", "", c.Item2.ToString(), (cur?.Count ?? 0).ToString(), "", c.Item1.Details.Shortname, ""); r.ReadOnly = true; dataGridViewEngineering.Rows.Add(r); } } if (fdrow >= 0 && dataGridViewEngineering.Rows[fdrow].Visible) // better check visible, may have changed.. { dataGridViewEngineering.FirstDisplayedScrollingRowIndex = fdrow; } } if (OnDisplayComplete != null) { OnDisplayComplete(wantedList); } }
public void SetRecipe(int recipeIdx, Recipes.Recipe recipe) { recipeOrderUI.ShowRecipe(recipe, recipeIdx); foodOrders[recipeIdx] = recipe; }
private void Display() { //DONT turn on sorting in the future, thats not how it works. You click and drag to sort manually since it gives you // the order of recipies. List <Tuple <Recipes.Recipe, int> > wantedList = null; if (last_he != null) { var mcllist = discoveryform.history.MaterialCommoditiesMicroResources.Get(last_he.MaterialCommodity); // mcl at this point var lastengprog = discoveryform.history.GetLastHistoryEntry(x => x.EntryType == JournalTypeEnum.EngineerProgress, last_he); int fdrow = dataGridViewEngineering.SafeFirstDisplayedScrollingRowIndex(); // remember where we were displaying var totals = MaterialCommoditiesRecipe.TotalList(mcllist); // start with totals present wantedList = new List <Tuple <Recipes.Recipe, int> >(); string engineers = GetSetting(dbEngFilterSave, "All"); List <string> engList = engineers.Split(';').ToList <string>(); string modules = GetSetting(dbModFilterSave, "All"); List <string> modList = modules.Split(';').ToList <string>(); string levels = GetSetting(dbLevelFilterSave, "All"); string[] lvlArray = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';'); string upgrades = GetSetting(dbUpgradeFilterSave, "All"); string[] upgArray = upgrades.Split(';'); string materials = GetSetting(dbMaterialFilterSave, "All"); var matList = materials.Split(';'); // list of materials to show for (int i = 0; i < Recipes.EngineeringRecipes.Count; i++) { int rno = (int)dataGridViewEngineering.Rows[i].Tag; // maximum we can make, not taking any, so not changing totals dataGridViewEngineering[MaxCol.Index, i].Value = MaterialCommoditiesRecipe.HowManyLeft(mcllist, totals, Recipes.EngineeringRecipes[rno]).Item1.ToString(); bool visible = true; if (!(engineers == "All" && modules == "All" && levels == "All" && upgrades == "All" && materials == "All")) { if (engineers != "All") { var included = engList.Intersect <string>(Recipes.EngineeringRecipes[rno].engineers.ToList <string>()); visible &= included.Count() > 0; } if (modules != "All") { var included = modList.Intersect <string>(Recipes.EngineeringRecipes[rno].modules.ToList <string>()); visible &= included.Count() > 0; } if (levels != "All") { visible &= lvlArray.Contains(Recipes.EngineeringRecipes[rno].level); } if (upgrades != "All") { visible &= upgArray.Contains(Recipes.EngineeringRecipes[rno].Name); } if (materials != "All") { var inglongname = Recipes.EngineeringRecipes[rno].Ingredients.Select(x => x.Name); var included = matList.Intersect <string>(inglongname); visible &= included.Count() > 0; } } dataGridViewEngineering.Rows[i].Visible = visible; if (visible) { Recipes.Recipe r = Recipes.EngineeringRecipes[i]; var res = MaterialCommoditiesRecipe.HowManyLeft(mcllist, totals, Recipes.EngineeringRecipes[rno], WantedPerRecipe[rno]); // System.Diagnostics.Debug.WriteLine($"{i} Recipe {rno} executed {WantedPerRecipe[rno]}; {res.Item2}, {res.Item3} "); dataGridViewEngineering[WantedCol.Index, i].Value = WantedPerRecipe[rno].ToString(); dataGridViewEngineering[AvailableCol.Index, i].Value = res.Item2.ToString(); dataGridViewEngineering[PercentageCol.Index, i].Value = res.Item5.ToString("N0"); dataGridViewEngineering[NotesCol.Index, i].Value = res.Item3; dataGridViewEngineering[NotesCol.Index, i].ToolTipText = res.Item4; dataGridViewEngineering[RecipeCol.Index, i].Value = r.IngredientsStringvsCurrent(mcllist); dataGridViewEngineering[RecipeCol.Index, i].ToolTipText = r.IngredientsStringLong; dataGridViewEngineering.Rows[i].DefaultCellStyle.BackColor = (res.Item5 >= 100.0) ? ExtendedControls.Theme.Current.GridHighlightBack : ExtendedControls.Theme.Current.GridCellBack; } if (WantedPerRecipe[rno] > 0 && (visible || isEmbedded)) // embedded, need to { wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.EngineeringRecipes[rno], WantedPerRecipe[rno])); } if (lastengprog != null) { string[] list = dataGridViewEngineering[EngineersCol.Index, i].Tag as string[]; string[] state = ((EliteDangerousCore.JournalEvents.JournalEngineerProgress)lastengprog.journalEntry).ApplyProgress(list); dataGridViewEngineering[EngineersCol.Index, i].Value = string.Join(Environment.NewLine, state); } } if (!isEmbedded) { var shoppinglist = MaterialCommoditiesRecipe.GetShoppingList(wantedList, mcllist); dataGridViewEngineering.RowCount = Recipes.EngineeringRecipes.Count; // truncate previous shopping list.. foreach (var c in shoppinglist) // and add new.. { var cur = mcllist.Find((x) => x.Details == c.Item1.Details); // may be null DataGridViewRow r = dataGridViewEngineering.RowTemplate.Clone() as DataGridViewRow; r.CreateCells(dataGridViewEngineering, c.Item1.Details.Name, "", "", "", c.Item2.ToString(), (cur?.Count ?? 0).ToString(), "", c.Item1.Details.Shortname, ""); r.ReadOnly = true; dataGridViewEngineering.Rows.Add(r); } } if (fdrow >= 0 && dataGridViewEngineering.Rows[fdrow].Visible) // better check visible, may have changed.. { dataGridViewEngineering.SafeFirstDisplayedScrollingRowIndex(fdrow); } } if (OnDisplayComplete != null) { OnDisplayComplete(wantedList); } }
private static List <IItem> RecipeLines(NetworkMenu menu, Players.Player player, Recipes.Recipe recipe, JSONNode item) { List <IItem> menuItems = new List <IItem>(); menuItems.Add(new Label(new LabelData(recipe.Name, UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter, 30, LabelData.ELocalizationType.Type)).ApplyPosition(item)); menuItems.Add(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Requirements"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 24)).ApplyPosition(item)); List <ValueTuple <IItem, int> > headerItems = new List <ValueTuple <IItem, int> >(); headerItems.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData("", UnityEngine.Color.black)), 70)); headerItems.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Item"), UnityEngine.Color.black)), 150)); headerItems.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Amount"), UnityEngine.Color.black)), 100)); menuItems.Add(new HorizontalRow(headerItems).ApplyPosition(item)); foreach (var req in recipe.Requirements) { if (req == null) { continue; } string reqName = ItemTypes.IndexLookup.GetName(req.Type); ItemIcon icon = new ItemIcon(reqName); if (Localization.TryGetType(player.LastKnownLocale, req.Type, out string localeReqName)) { reqName = localeReqName; } Label labelName = new Label(new LabelData(reqName, UnityEngine.Color.black)); Label labelAmount = new Label(new LabelData(req.Amount.ToString(), UnityEngine.Color.black)); List <ValueTuple <IItem, int> > items = new List <ValueTuple <IItem, int> >(); items.Add(ValueTuple.Create <IItem, int>(icon, 70)); items.Add(ValueTuple.Create <IItem, int>(labelName, 150)); items.Add(ValueTuple.Create <IItem, int>(labelAmount, 100)); menuItems.Add(new HorizontalRow(items).ApplyPosition(item)); } menuItems.Add(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Results"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 24)).ApplyPosition(item)); headerItems = new List <ValueTuple <IItem, int> >(); headerItems.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData("", UnityEngine.Color.black)), 70)); headerItems.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Item"), UnityEngine.Color.black)), 150)); headerItems.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Amount"), UnityEngine.Color.black)), 100)); headerItems.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Chance"), UnityEngine.Color.black)), 100)); menuItems.Add(new HorizontalRow(headerItems).ApplyPosition(item)); foreach (var req in recipe.Results) { string reqName = ItemTypes.IndexLookup.GetName(req.Type); ItemIcon icon = new ItemIcon(reqName); if (Localization.TryGetType(player.LastKnownLocale, req.Type, out string localeReqName)) { reqName = localeReqName; } Label labelName = new Label(new LabelData(reqName, UnityEngine.Color.black)); Label labelAmount = new Label(new LabelData(req.Amount.ToString(), UnityEngine.Color.black)); Label chance = new Label(new LabelData(req.Chance * 100 + "%", UnityEngine.Color.black)); List <ValueTuple <IItem, int> > items = new List <ValueTuple <IItem, int> >(); items.Add(ValueTuple.Create <IItem, int>(icon, 70)); items.Add(ValueTuple.Create <IItem, int>(labelName, 150)); items.Add(ValueTuple.Create <IItem, int>(labelAmount, 100)); items.Add(ValueTuple.Create <IItem, int>(chance, 100)); menuItems.Add(new HorizontalRow(items).ApplyPosition(item)); if (Localization.TryGetTypeUse(player.LastKnownLocale, req.Type, out var description)) { menuItems.Add(new Label(new LabelData(description, UnityEngine.Color.black)).ApplyPosition(item)); } if (Localization.TryGetSentence(player.LastKnownLocale, _localizationHelper.GetLocalizationKey("ItemDetails." + ItemId.GetItemId(req.Type).Name), out var extendedDetail)) { menuItems.Add(new Label(new LabelData(extendedDetail, UnityEngine.Color.black)).ApplyPosition(item)); } } menuItems.Add(new Line(UnityEngine.Color.black, 1)); return(menuItems); }
private void RemoveRecipeFromList(Recipes.Recipe selected) { _state.Player.Loot.Wishlist.Remove(selected); RefreshList(); }