using System.Collections.Generic; using UnityEngine; namespace RecipeMenuCore.API { /// /// Defines a custom RecipePage. Make sure to call Register on it to enable your RecipePage and to add at least one RecipePageEntry using AddRecipePageEntry. /// public class RecipePage { /// /// The RecipePageType of this RecipePage /// public readonly RecipePageType Type; /// /// The Title displayed on top of this RecipePage. /// public readonly string Title; /// /// The Texture associated with this RecipePage. May be null. /// public Texture Tex { get; protected set; } /// /// The Material associated with this RecipePage. May be null. /// public Material Mat { get; protected set; } internal List Rows = new List(); /// /// Use to create a new RecipePage. Make sure to call Register on it to enable your RecipePage. /// public RecipePage(RecipePageType Type, string Title, Texture Tex) { this.Type = Type; this.Title = Title; this.Tex = Tex; } /// /// Use to create a new RecipePage. Make sure to call Register on it to enable your RecipePage. /// public RecipePage(RecipePageType Type, string Title, Material Mat) { this.Type = Type; this.Title = Title; this.Mat = Mat; } /// /// Used to register the page and make it show. /// public virtual RecipePage Register() { PostRegister(); switch (Type) { case RecipePageType.GearForge: Core.pageGearForgeInfoList.Add(this); break; case RecipePageType.AlchemyStation: Core.pageAlchemyStationInfoList.Add(this); break; case RecipePageType.UltimateForge: Core.pageUltimateForgeInfoList.Add(this); break; case RecipePageType.UniversalCrafter: Core.pageUniversalCrafterInfoList.Add(this); break; } return this; } /// /// Used to register the page to repalce a vanilla one and make it show. /// public virtual RecipePage RegisterAsVanilla(int i) { PostRegister(); switch (Type) { case RecipePageType.GearForge: Core.pageGearForgeInfoListVanilla[i] = this; break; case RecipePageType.AlchemyStation: Core.pageAlchemyStationInfoListVanilla[i] = this; break; case RecipePageType.UltimateForge: Core.pageUltimateForgeInfoListVanilla[i] = this; break; } return this; } protected void PostRegister() { if (Mat == null) { Mat = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = Tex }; } else { Tex = Mat.mainTexture; } } /// /// Used to register the RecipePage to make it show up. /// public RecipePageType GetEntryType() { return Type; } /// /// Adds a new RecipePageEntry to the RecipePage. /// public void AddRecipePageEntry(RecipePageEntry row) { Rows.Add(row); } /// /// Returns the list of avalible RecipePageEntry on this RecipePage. /// public RecipePageEntry[] GetRecipePageEntries() { return Rows.ToArray(); } } /// /// This indicates what types of recipes are avalible. /// public enum RecipePageType { /// /// This recipe is for the Gear Forge. /// GearForge, /// /// This recipe is for the Alchemy Station. /// AlchemyStation, /// /// This recipe is for the Ultimate Forge. /// UltimateForge, /// /// This recipe is for the Gadget Core Universal Crafter. /// UniversalCrafter } }