DefaultEncyclopediaCategory.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. namespace KairoEngine.UI.Encyclopedia
  6. {
  7. public class DefaultEncyclopediaCategory : EncyclopediaCategory
  8. {
  9. public List<DefaultEncyclopediaCategoryArticle> articles = new List<DefaultEncyclopediaCategoryArticle>();
  10. private List<EncyclopediaArticle> data = new List<EncyclopediaArticle>();
  11. [System.Serializable]
  12. public class DefaultEncyclopediaCategoryArticle
  13. {
  14. [HorizontalGroup("Line", 0.015f), HideLabel] public bool unlocked = true;
  15. [HorizontalGroup("Line", 0.985f), HideLabel] public DefaultEncyclopediaArticle article;
  16. }
  17. public override List<EncyclopediaArticle> GetArticles()
  18. {
  19. if(data.Count == 0) UpdateArticles();
  20. return data;
  21. }
  22. public override void UpdateArticles()
  23. {
  24. data = new List<EncyclopediaArticle>();
  25. foreach (DefaultEncyclopediaCategoryArticle item in articles)
  26. {
  27. var article = item.article.GetArticle();
  28. article.id = id + "_" + article.id;
  29. article.unlocked = item.unlocked;
  30. data.Add(article);
  31. }
  32. }
  33. }
  34. }