| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- using System.Collections.Generic;
- using UnityEngine;
- namespace RecipeMenuCore.API
- {
- /// <summary>
- /// Defines a custom RecipePage. Make sure to call Register on it to enable your RecipePage and to add at least one RecipePageEntry using AddRecipePageEntry.
- /// </summary>
- public class RecipePage
- {
- /// <summary>
- /// The RecipePageType of this RecipePage
- /// </summary>
- public readonly RecipePageType Type;
- /// <summary>
- /// The Title displayed on top of this RecipePage.
- /// </summary>
- public readonly string Title;
- /// <summary>
- /// The Texture associated with this RecipePage. May be null.
- /// </summary>
- public Texture Tex { get; protected set; }
- /// <summary>
- /// The Material associated with this RecipePage. May be null.
- /// </summary>
- public Material Mat { get; protected set; }
- internal List<RecipePageEntry> Rows = new List<RecipePageEntry>();
- /// <summary>
- /// Use to create a new RecipePage. Make sure to call Register on it to enable your RecipePage.
- /// </summary>
- public RecipePage(RecipePageType Type, string Title, Texture Tex)
- {
- this.Type = Type;
- this.Title = Title;
- this.Tex = Tex;
- }
- /// <summary>
- /// Use to create a new RecipePage. Make sure to call Register on it to enable your RecipePage.
- /// </summary>
- public RecipePage(RecipePageType Type, string Title, Material Mat)
- {
- this.Type = Type;
- this.Title = Title;
- this.Mat = Mat;
- }
- /// <summary>
- /// Used to register the page and make it show.
- /// </summary>
- 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;
- }
- /// <summary>
- /// Used to register the page to repalce a vanilla one and make it show.
- /// </summary>
- 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;
- }
- }
- /// <summary>
- /// Used to register the RecipePage to make it show up.
- /// </summary>
- public RecipePageType GetEntryType()
- {
- return Type;
- }
- /// <summary>
- /// Adds a new RecipePageEntry to the RecipePage.
- /// </summary>
- public void AddRecipePageEntry(RecipePageEntry row)
- {
- Rows.Add(row);
- }
- /// <summary>
- /// Returns the list of avalible RecipePageEntry on this RecipePage.
- /// </summary>
- public RecipePageEntry[] GetRecipePageEntries()
- {
- return Rows.ToArray();
- }
- }
- /// <summary>
- /// This indicates what types of recipes are avalible.
- /// </summary>
- public enum RecipePageType
- {
- /// <summary>
- /// This recipe is for the Gear Forge.
- /// </summary>
- GearForge,
- /// <summary>
- /// This recipe is for the Alchemy Station.
- /// </summary>
- AlchemyStation,
- /// <summary>
- /// This recipe is for the Ultimate Forge.
- /// </summary>
- UltimateForge,
- /// <summary>
- /// This recipe is for the Gadget Core Universal Crafter.
- /// </summary>
- UniversalCrafter
- }
- }
|