123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using System;
- using System.Collections.Generic;
- using wf;
- namespace Kasizuki
- {
- public static class ItemData
- {
- public static int Count
- {
- get
- {
- ItemData.CreateData();
- return ItemData.commonIdManager.idMap.Count;
- }
- }
- public static bool Contains(string name)
- {
- return ItemData.commonIdManager.nameMap.ContainsKey(name);
- }
- public static bool Contains(int id)
- {
- return ItemData.commonIdManager.idMap.ContainsKey(id);
- }
- public static int uniqueNameToId(string uniqueName)
- {
- ItemData.CreateData();
- NDebug.Assert(ItemData.commonIdManager.nameMap.ContainsKey(uniqueName), "傅き.持ち込みアイテムデータ\nユニーク名[" + uniqueName + "]をIDに変換できませんでした");
- return ItemData.commonIdManager.nameMap[uniqueName];
- }
- public static string IdToUniqueName(int id)
- {
- ItemData.CreateData();
- NDebug.Assert(ItemData.commonIdManager.idMap.ContainsKey(id), "傅き.持ち込みアイテムデータ\nID[" + id + "]をユニーク名に変換できませんでした");
- return ItemData.commonIdManager.idMap[id].Key;
- }
- public static ItemData.Data GetData(int id)
- {
- ItemData.CreateData();
- NDebug.Assert(ItemData.basicDatas.ContainsKey(id), "傅き.持ち込みアイテムデータ\nID[" + id + "]のデータは存在しません");
- return ItemData.basicDatas[id];
- }
- public static ItemData.Data GetData(string uniqueName)
- {
- return ItemData.GetData(ItemData.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(string uniqueName)
- {
- ItemData.CreateData();
- return ItemData.commonIdManager.enabledIdList.Contains(ItemData.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(int id)
- {
- ItemData.CreateData();
- return ItemData.commonIdManager.enabledIdList.Contains(id);
- }
- public static List<ItemData.Data> GetAllDatas(bool onlyEnabled)
- {
- ItemData.CreateData();
- List<ItemData.Data> list = new List<ItemData.Data>();
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in ItemData.commonIdManager.idMap)
- {
- if (!onlyEnabled || ItemData.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
- {
- list.Add(ItemData.basicDatas[keyValuePair.Key]);
- }
- }
- return list;
- }
- public static void CreateData()
- {
- if (ItemData.commonIdManager != null)
- {
- return;
- }
- ItemData.commonIdManager = new CsvCommonIdManager("kasizuki_item", "傅き.持ち込みアイテムデータ", CsvCommonIdManager.Type.IdAndUniqueName, null);
- ItemData.basicDatas = new Dictionary<int, ItemData.Data>();
- string[] array = new string[]
- {
- "list"
- };
- KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
- for (int i = 0; i < array2.Length; i++)
- {
- string text = "kasizuki_item_" + array[i] + ".nei";
- AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
- CsvParser csvParser = new CsvParser();
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, text + "\nopen failed.");
- array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
- }
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in ItemData.commonIdManager.idMap)
- {
- int key = keyValuePair.Key;
- ItemData.Data value = new ItemData.Data(key, array2[0].Value);
- ItemData.basicDatas.Add(key, value);
- }
- foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
- {
- keyValuePair2.Value.Dispose();
- keyValuePair2.Key.Dispose();
- }
- }
- private const string csvTopCommonName = "kasizuki_item";
- private const string typeNameForErrorLog = "傅き.持ち込みアイテムデータ";
- private static CsvCommonIdManager commonIdManager;
- private static Dictionary<int, ItemData.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.uniqueName = csv.GetCellAsString(num++, i);
- this.drawName = csv.GetCellAsString(num++, i);
- this.iconName = csv.GetCellAsString(num++, i);
- this.modelResourceName = csv.GetCellAsString(num++, i);
- this.categoryName = csv.GetCellAsString(num++, i);
- }
- }
- }
- public readonly int ID;
- public readonly string uniqueName;
- public readonly string drawName;
- public readonly string iconName;
- public readonly string modelResourceName;
- public readonly string categoryName;
- }
- }
- }
|