PhotoFaceData.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PhotoFaceData
  5. {
  6. private PhotoFaceData()
  7. {
  8. }
  9. public static void Create()
  10. {
  11. if (PhotoFaceData.face_data_ != null)
  12. {
  13. return;
  14. }
  15. PhotoFaceData.face_data_ = new List<PhotoFaceData>();
  16. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("phot_face_list.nei"))
  17. {
  18. using (CsvParser csvParser = new CsvParser())
  19. {
  20. bool condition = csvParser.Open(afileBase);
  21. NDebug.Assert(condition, "phot_face_list.nei\nopen failed.");
  22. for (int i = 1; i < csvParser.max_cell_y; i++)
  23. {
  24. if (csvParser.IsCellToExistData(0, i))
  25. {
  26. int num = 0;
  27. PhotoFaceData photoFaceData = new PhotoFaceData();
  28. photoFaceData.id = csvParser.GetCellAsInteger(num++, i);
  29. photoFaceData.category = csvParser.GetCellAsString(num++, i);
  30. photoFaceData.name = csvParser.GetCellAsString(num++, i);
  31. photoFaceData.setting_name = csvParser.GetCellAsString(num++, i);
  32. PhotoFaceData.face_data_.Add(photoFaceData);
  33. if (photoFaceData.setting_name == "通常")
  34. {
  35. PhotoFaceData.init_data_ = photoFaceData;
  36. }
  37. }
  38. }
  39. }
  40. }
  41. PhotoFaceData.category_list_ = new Dictionary<string, List<PhotoFaceData>>();
  42. PhotoFaceData.popup_menu_list_ = new List<KeyValuePair<string, UnityEngine.Object>>();
  43. HashSet<string> hashSet = new HashSet<string>();
  44. List<PhotoFaceData> data = PhotoFaceData.data;
  45. for (int j = 0; j < data.Count; j++)
  46. {
  47. if (!PhotoFaceData.category_list_.ContainsKey(data[j].category))
  48. {
  49. PhotoFaceData.category_list_.Add(data[j].category, new List<PhotoFaceData>());
  50. }
  51. PhotoFaceData.category_list_[data[j].category].Add(data[j]);
  52. if (!hashSet.Contains(data[j].category))
  53. {
  54. PhotoFaceData.popup_menu_list_.Add(new KeyValuePair<string, UnityEngine.Object>(data[j].category, null));
  55. hashSet.Add(data[j].category);
  56. }
  57. }
  58. }
  59. public void Apply(Maid maid)
  60. {
  61. if (maid == null || maid.body0 == null || maid.body0.m_Bones == null || maid.IsBusy)
  62. {
  63. return;
  64. }
  65. maid.FaceAnime(this.setting_name, 0f, 0);
  66. }
  67. public float[] BlendArray(Maid maid)
  68. {
  69. if (maid == null || maid.body0 == null || maid.body0.m_Bones == null || maid.IsBusy)
  70. {
  71. return null;
  72. }
  73. return maid.body0.Face.morph.dicBlendSet[this.setting_name];
  74. }
  75. public static List<PhotoFaceData> data
  76. {
  77. get
  78. {
  79. return PhotoFaceData.face_data_;
  80. }
  81. }
  82. public static PhotoFaceData init_data
  83. {
  84. get
  85. {
  86. return PhotoFaceData.init_data_;
  87. }
  88. }
  89. public static Dictionary<string, List<PhotoFaceData>> category_list
  90. {
  91. get
  92. {
  93. return PhotoFaceData.category_list_;
  94. }
  95. }
  96. public static List<KeyValuePair<string, UnityEngine.Object>> popup_category_list
  97. {
  98. get
  99. {
  100. return PhotoFaceData.popup_menu_list_;
  101. }
  102. }
  103. public static PhotoFaceData Get(long id)
  104. {
  105. for (int i = 0; i < PhotoFaceData.face_data_.Count; i++)
  106. {
  107. if ((long)PhotoFaceData.face_data_[i].id == id)
  108. {
  109. return PhotoFaceData.face_data_[i];
  110. }
  111. }
  112. return null;
  113. }
  114. public int id;
  115. public string category;
  116. public string name;
  117. public string setting_name;
  118. private static PhotoFaceData init_data_;
  119. private static List<PhotoFaceData> face_data_;
  120. private static Dictionary<string, List<PhotoFaceData>> category_list_;
  121. private static List<KeyValuePair<string, UnityEngine.Object>> popup_menu_list_;
  122. }