123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- 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>();
- string[] array = new string[]
- {
- "list",
- "feature_condition"
- };
- KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
- for (int i = 0; i < array2.Length; i++)
- {
- string text = "maid_status_personal_" + 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 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 == "〇");
- cellAsString = basicCsv.GetCellAsString(num++, i);
- if (this.oldPersonal)
- {
- this.compatible = true;
- foreach (string text in cellAsString.Split(new char[]
- {
- ','
- }))
- {
- if (!string.IsNullOrEmpty(text) && !PluginData.IsEnabled(text))
- {
- this.compatible = false;
- break;
- }
- }
- }
- else
- {
- this.compatible = false;
- }
- cellAsString = basicCsv.GetCellAsString(num++, i);
- if (this.oldPersonal)
- {
- this.single = true;
- foreach (string text2 in cellAsString.Split(new char[]
- {
- ','
- }))
- {
- if (!string.IsNullOrEmpty(text2) && !PluginData.IsEnabled(text2))
- {
- this.single = false;
- break;
- }
- }
- }
- else
- {
- this.single = true;
- }
- string[] array3 = basicCsv.GetCellAsString(num++, i).Split(new char[]
- {
- '/'
- });
- this.competitiveMotionFileVictory = new KeyValuePair<string, string>(Path.ChangeExtension(array3[0], ".ks"), array3[1]);
- array3 = basicCsv.GetCellAsString(num++, i).Split(new char[]
- {
- '/'
- });
- this.competitiveMotionFileDefeat = new KeyValuePair<string, string>(Path.ChangeExtension(array3[0], ".ks"), array3[1]);
- break;
- }
- }
- this.acquisitionFeatureList = new List<Personal.Data.LearnFeature>();
- for (int l = 0; l < featureConditionsCsv.max_cell_y; l++)
- {
- if (featureConditionsCsv.IsCellToExistData(0, l) && featureConditionsCsv.GetCellAsString(0, l) == this.uniqueName)
- {
- int num2 = 0;
- while (featureConditionsCsv.IsCellToExistData(1, l + num2))
- {
- this.acquisitionFeatureList.Add(new Personal.Data.LearnFeature(featureConditionsCsv, l + 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 bool compatible;
- public readonly bool single;
- 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;
- }
- }
- }
- }
|