123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using System;
- using System.Collections.Generic;
- using wf;
- namespace MyRoomCustom
- {
- public static class TextureData
- {
- public static int Count
- {
- get
- {
- TextureData.CreateData();
- return TextureData.enabledIDList.Count;
- }
- }
- public static bool Contains(int id)
- {
- TextureData.CreateData();
- return TextureData.enabledIDList.Contains(id);
- }
- public static TextureData.Data GetData(int id)
- {
- TextureData.CreateData();
- NDebug.Assert(TextureData.basicDatas.ContainsKey(id), "自室カスタム.壁紙系テクスチャ\nID[" + id + "]のデータは存在しません");
- return TextureData.basicDatas[id];
- }
- public static bool IsEnabled(int id)
- {
- TextureData.CreateData();
- return TextureData.enabledIDList.Contains(id);
- }
- public static List<TextureData.Data> GetAllDatas(bool onlyEnabled)
- {
- TextureData.CreateData();
- List<TextureData.Data> list = new List<TextureData.Data>();
- foreach (KeyValuePair<int, TextureData.Data> keyValuePair in TextureData.basicDatas)
- {
- if (!onlyEnabled || TextureData.enabledIDList.Contains(keyValuePair.Key))
- {
- list.Add(keyValuePair.Value);
- }
- }
- return list;
- }
- public static List<TextureData.Data> GetDatas(Func<TextureData.Data, bool> customCheckFunction)
- {
- TextureData.CreateData();
- List<TextureData.Data> list = new List<TextureData.Data>();
- foreach (int key in TextureData.enabledIDList)
- {
- TextureData.Data data = TextureData.basicDatas[key];
- if (customCheckFunction(data))
- {
- list.Add(data);
- }
- }
- return list;
- }
- public static void CreateData()
- {
- if (TextureData.enabledIDList != null)
- {
- return;
- }
- TextureData.basicDatas = new Dictionary<int, TextureData.Data>();
- TextureData.enabledIDList = new HashSet<int>();
- CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "my_room_texture_panel_enabled_list", ref TextureData.enabledIDList);
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen("my_room_texture_panel_list.nei"))
- {
- using (CsvParser csvParser = new CsvParser())
- {
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, "my_room_texture_panel_list\nopen failed.");
- foreach (int num in TextureData.enabledIDList)
- {
- TextureData.Data value = new TextureData.Data(num, csvParser);
- TextureData.basicDatas.Add(num, value);
- }
- }
- }
- }
- public static void Clear()
- {
- if (TextureData.enabledIDList != null)
- {
- TextureData.enabledIDList = null;
- }
- }
- private const string csvTopCommonName = "my_room_texture_panel";
- private const string typeNameForErrorLog = "自室カスタム.壁紙系テクスチャ";
- private static HashSet<int> enabledIDList;
- private static Dictionary<int, TextureData.Data> basicDatas;
- public class Data
- {
- public Data(int uniqueID, CsvParser csv)
- {
- for (int i = 1; i < csv.max_cell_y; i++)
- {
- if (csv.IsCellToExistData(0, i) && csv.GetCellAsInteger(0, i) == uniqueID)
- {
- int num = 1;
- this.ID = uniqueID;
- this.drawName = csv.GetCellAsString(num++, i);
- this.resourceName = csv.GetCellAsString(num++, i);
- }
- }
- }
- public readonly int ID;
- public readonly string drawName;
- public readonly string resourceName;
- }
- }
- }
|