public override void UpdateMisc() { ScienceWorkbenchEntity entity = UIEntity as ScienceWorkbenchEntity; if (nextRecipe.LeftClick && GetSlot(SlotsLength - 1).StoredItem.IsAir) { CurrentRecipe++; PromptForRecipes = true; if (CurrentRecipe > entity.curRecipes.Count) { CurrentRecipe = entity.curRecipes.Count - 1; } Main.PlaySound(SoundID.MenuTick); } else if (prevRecipe.LeftClick && GetSlot(SlotsLength - 1).StoredItem.IsAir) { CurrentRecipe--; PromptForRecipes = true; if (CurrentRecipe < 0) { CurrentRecipe = 0; } Main.PlaySound(SoundID.MenuTick); } }
internal override void UpdateText(List <UIText> text) { ScienceWorkbenchEntity entity = UIEntity as ScienceWorkbenchEntity; if (entity.curRecipeType > 0) { text[0].SetText($"Crafting: {Lang.GetItemNameValue(entity.curRecipeType)}"); } else { text[0].SetText("No valid recipe!"); craft.BackgroundColor = new Color(30, 40, 100) * 0.7f; } }
internal override void UpdateEntity() { UpdateSuccess = false; ScienceWorkbenchEntity entity = UIEntity as ScienceWorkbenchEntity; Item resultSlot = GetSlot(SlotsLength - 1).StoredItem; //Check if any of the ingredients have been added/removed for (int i = 0; i < SlotsLength - 1; i++) { if (GetSlot(i).ItemChanged) { PromptForRecipes = true; break; } } if (PromptForRecipes) { entity.HasRecipe = RecipeUtils.HasRecipe(this, out entity.curRecipeType, out entity.curRecipeStack, entity.curRecipes); PromptForRecipes = false; } if (entity.HasRecipe && craft.LeftClick) { //The recipe found an item. Copy the defaults if it's air. if (entity.curRecipeType > 0 && resultSlot.type <= ItemID.None) { resultSlot.SetDefaults(entity.curRecipeType); resultSlot.stack = 0; } //We have room to add another item if (resultSlot.stack + entity.curRecipeStack < resultSlot.maxStack) { entity.ReactionProgress = 100; UpdateSuccess = true; } else { UpdateSuccess = false; } } else { UpdateSuccess = false; } }