123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using wf;
- namespace MaidStatus
- {
- public static class Personal
- {
- public static int Count
- {
- get
- {
- Personal.CreateData();
- return Personal.commonIdManager.idMap.Count;
- }
- }
- public static bool Contains(string name)
- {
- return Personal.commonIdManager.nameMap.ContainsKey(name);
- }
- public static bool Contains(int id)
- {
- return Personal.commonIdManager.idMap.ContainsKey(id);
- }
- public static int uniqueNameToId(string name)
- {
- Personal.CreateData();
- NDebug.Assert(Personal.commonIdManager.nameMap.ContainsKey(name), "性格\nユニーク名[" + name + "]をIDに変換できませんでした");
- return Personal.commonIdManager.nameMap[name];
- }
- public static string IdToUniqueName(int id)
- {
- Personal.CreateData();
- NDebug.Assert(Personal.commonIdManager.idMap.ContainsKey(id), "性格\nID[" + id + "]をユニーク名に変換できませんでした");
- return Personal.commonIdManager.idMap[id].Key;
- }
- public static Personal.Data GetData(int id)
- {
- Personal.CreateData();
- NDebug.Assert(Personal.basicDatas.ContainsKey(id), "性格\nID[" + id + "]のデータは存在しません");
- return Personal.basicDatas[id];
- }
- public static Personal.Data GetData(string uniqueName)
- {
- return Personal.GetData(Personal.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(string uniqueName)
- {
- Personal.CreateData();
- return Personal.commonIdManager.enabledIdList.Contains(Personal.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(int id)
- {
- Personal.CreateData();
- return Personal.commonIdManager.enabledIdList.Contains(id);
- }
- public static List<Personal.Data> GetAllDatas(bool onlyEnabled)
- {
- Personal.CreateData();
- List<Personal.Data> list = new List<Personal.Data>();
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Personal.commonIdManager.idMap)
- {
- if (!onlyEnabled || Personal.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
- {
- list.Add(Personal.basicDatas[keyValuePair.Key]);
- }
- }
- return list;
- }
- public static void CreateData()
- {
- if (Personal.commonIdManager != null)
- {
- return;
- }
- Personal.commonIdManager = new CsvCommonIdManager("maid_status_personal", "性格", CsvCommonIdManager.Type.IdAndUniqueName, null);
- Personal.basicDatas = new Dictionary<int, Personal.Data>();
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen("maid_status_personal_request_plugin.nei"))
- {
- using (CsvParser csvParser = new CsvParser())
- {
- csvParser.Open(afileBase);
- NDebug.Assert(csvParser.IsValid(), "maid_status_personal_request_plugin\nopen failed.");
- for (int i = 1; i < csvParser.max_cell_y; i++)
- {
- int cellAsInteger = csvParser.GetCellAsInteger(0, i);
- string cellAsString = csvParser.GetCellAsString(3, i);
- if (!string.IsNullOrEmpty(cellAsString))
- {
- if (Personal.commonIdManager.enabledIdList.Contains(cellAsInteger) && !PluginData.IsEnabled(cellAsString))
- {
- Personal.commonIdManager.enabledIdList.Remove(cellAsInteger);
- }
- }
- }
- }
- }
- string[] array = new string[]
- {
- "list",
- "feature_condition"
- };
- KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
- for (int j = 0; j < array2.Length; j++)
- {
- string text = "maid_status_personal_" + array[j] + ".nei";
- AFileBase afileBase2 = GameUty.FileSystem.FileOpen(text);
- CsvParser csvParser2 = new CsvParser();
- bool condition = csvParser2.Open(afileBase2);
- NDebug.Assert(condition, text + "\nopen failed.");
- array2[j] = new KeyValuePair<AFileBase, CsvParser>(afileBase2, csvParser2);
- }
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Personal.commonIdManager.idMap)
- {
- Personal.basicDatas.Add(keyValuePair.Key, new Personal.Data(keyValuePair.Key, array2[0].Value, array2[1].Value));
- }
- foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
- {
- keyValuePair2.Value.Dispose();
- keyValuePair2.Key.Dispose();
- }
- }
- private const string csvTopCommonName = "maid_status_personal";
- private const string typeNameForErrorLog = "性格";
- private static CsvCommonIdManager commonIdManager;
- private static Dictionary<int, Personal.Data> basicDatas;
- public class Data
- {
- public Data(int id, CsvParser basicCsv, CsvParser featureConditionsCsv)
- {
- List<int> list = new List<int>();
- for (int i = 0; i < basicCsv.max_cell_y; i++)
- {
- if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
- {
- this.id = id;
- int num = 1;
- this.uniqueName = basicCsv.GetCellAsString(num++, i);
- this.drawName = basicCsv.GetCellAsString(num++, i);
- this.replaceText = basicCsv.GetCellAsString(num++, i);
- this.bgmFileName = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ogg");
- string cellAsString = basicCsv.GetCellAsString(num++, i);
- this.oldPersonal = (cellAsString == "〇");
- string[] array = basicCsv.GetCellAsString(num++, i).Split(new char[]
- {
- '/'
- });
- this.competitiveMotionFileVictory = new KeyValuePair<string, string>(Path.ChangeExtension(array[0], ".ks"), array[1]);
- array = basicCsv.GetCellAsString(num++, i).Split(new char[]
- {
- '/'
- });
- this.competitiveMotionFileDefeat = new KeyValuePair<string, string>(Path.ChangeExtension(array[0], ".ks"), array[1]);
- break;
- }
- }
- this.acquisitionFeatureList = new List<Personal.Data.LearnFeature>();
- for (int j = 0; j < featureConditionsCsv.max_cell_y; j++)
- {
- if (featureConditionsCsv.IsCellToExistData(0, j) && featureConditionsCsv.GetCellAsString(0, j) == this.uniqueName)
- {
- int num2 = 0;
- while (featureConditionsCsv.IsCellToExistData(1, j + num2))
- {
- this.acquisitionFeatureList.Add(new Personal.Data.LearnFeature(featureConditionsCsv, j + num2));
- num2++;
- }
- break;
- }
- }
- }
- public readonly int id;
- public readonly string uniqueName;
- public readonly string drawName;
- public readonly string replaceText;
- public readonly string bgmFileName;
- public readonly bool oldPersonal;
- public readonly KeyValuePair<string, string> competitiveMotionFileVictory;
- public readonly KeyValuePair<string, string> competitiveMotionFileDefeat;
- public readonly List<Personal.Data.LearnFeature> acquisitionFeatureList;
- public class LearnFeature
- {
- public LearnFeature(CsvParser featureConditionsCsv, int lineY)
- {
- this.requestParameters = new ParametersPack();
- int cell_x = 1;
- string cellAsString = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
- this.feature = Feature.GetData(cellAsString);
- this.requestSeikeikens = true;
- string cellAsString2 = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
- if (cellAsString2 == "両穴")
- {
- this.needSeikeiken = Seikeiken.Yes_Yes;
- }
- else if (cellAsString2 == "前穴")
- {
- this.needSeikeiken = Seikeiken.Yes_No;
- }
- else if (cellAsString2 == "後穴")
- {
- this.needSeikeiken = Seikeiken.No_Yes;
- }
- else
- {
- this.requestSeikeikens = false;
- }
- while (featureConditionsCsv.IsCellToExistData(cell_x, lineY))
- {
- string cellAsString3 = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
- int cellAsInteger = featureConditionsCsv.GetCellAsInteger(cell_x++, lineY);
- this.requestParameters.Add(ParametersPack.NameToStatusType(cellAsString3), cellAsInteger);
- }
- }
- public bool isLearnPossible(Status status)
- {
- return (!this.requestSeikeikens || this.needSeikeiken == status.seikeiken) && this.requestParameters.GreaterThanOrEqualToStatus(status);
- }
- public readonly Feature.Data feature;
- public readonly bool requestSeikeikens;
- public readonly Seikeiken needSeikeiken;
- public readonly ParametersPack requestParameters;
- }
- }
- }
- }
|