123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using I2.Loc;
- using UnityEngine;
- using wf;
- namespace MaidStatus
- {
- public static class SubMaid
- {
- public static int Count
- {
- get
- {
- SubMaid.CreateData();
- return SubMaid.commonIdManager.idMap.Count;
- }
- }
- public static bool Contains(string name)
- {
- return SubMaid.commonIdManager.nameMap.ContainsKey(name);
- }
- public static bool Contains(int id)
- {
- return SubMaid.commonIdManager.idMap.ContainsKey(id);
- }
- public static int uniqueNameToId(string name)
- {
- SubMaid.CreateData();
- NDebug.Assert(SubMaid.commonIdManager.nameMap.ContainsKey(name), "Subメイド\nユニーク名[" + name + "]をIDに変換できませんでした");
- return SubMaid.commonIdManager.nameMap[name];
- }
- public static string IdToUniqueName(int id)
- {
- SubMaid.CreateData();
- NDebug.Assert(SubMaid.commonIdManager.idMap.ContainsKey(id), "Subメイド\nID[" + id + "]をユニーク名に変換できませんでした");
- return SubMaid.commonIdManager.idMap[id].Key;
- }
- public static SubMaid.Data GetData(int id)
- {
- SubMaid.CreateData();
- NDebug.Assert(SubMaid.basicDatas.ContainsKey(id), "Subメイド\nID[" + id + "]のデータは存在しません");
- return SubMaid.basicDatas[id];
- }
- public static SubMaid.Data GetData(string uniqueName)
- {
- return SubMaid.GetData(SubMaid.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(string uniqueName)
- {
- SubMaid.CreateData();
- return SubMaid.commonIdManager.enabledIdList.Contains(SubMaid.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(int id)
- {
- SubMaid.CreateData();
- return SubMaid.commonIdManager.enabledIdList.Contains(id);
- }
- public static List<SubMaid.Data> GetAllDatas(bool onlyEnabled)
- {
- SubMaid.CreateData();
- List<SubMaid.Data> list = new List<SubMaid.Data>();
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in SubMaid.commonIdManager.idMap)
- {
- if (!onlyEnabled || SubMaid.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
- {
- list.Add(SubMaid.basicDatas[keyValuePair.Key]);
- }
- }
- return list;
- }
- public static void CreateData()
- {
- if (SubMaid.commonIdManager != null)
- {
- return;
- }
- SubMaid.commonIdManager = new CsvCommonIdManager("maid_status_submaid", "Subメイド", CsvCommonIdManager.Type.IdAndUniqueName, null);
- SubMaid.basicDatas = new Dictionary<int, SubMaid.Data>();
- string[] array = new string[]
- {
- "list",
- "kiss_side_list"
- };
- KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
- for (int i = 0; i < array2.Length; i++)
- {
- string text = "maid_status_submaid_" + 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 SubMaid.commonIdManager.idMap)
- {
- SubMaid.basicDatas.Add(keyValuePair.Key, new SubMaid.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_submaid";
- private const string typeNameForErrorLog = "Subメイド";
- private static CsvCommonIdManager commonIdManager;
- private static Dictionary<int, SubMaid.Data> basicDatas;
- public class Data
- {
- public Data(int id, CsvParser basicCsv, CsvParser kissSideCsv)
- {
- for (int i = 1; i < basicCsv.max_cell_y; i++)
- {
- if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
- {
- int num = 1;
- this.id = id;
- this.uniqueName = basicCsv.GetCellAsString(num++, i);
- this.replaceText = basicCsv.GetCellAsString(num++, i);
- this.isEditPossible = (basicCsv.GetCellAsString(num++, i) == "〇");
- this.status = new SubMaid.Data.CharacterStatus(this.id, this.uniqueName, false, basicCsv, i);
- break;
- }
- }
- for (int j = 1; j < kissSideCsv.max_cell_y; j++)
- {
- if (kissSideCsv.IsCellToExistData(0, j) && kissSideCsv.GetCellAsInteger(0, j) == id)
- {
- this.secondStatus = new SubMaid.Data.CharacterStatus(this.id, this.uniqueName, true, kissSideCsv, j);
- break;
- }
- }
- }
- public void ApplyStatus(Status status, bool refSecondStatus)
- {
- if (status == null)
- {
- return;
- }
- SubMaid.Data.CharacterStatus characterStatus = (!refSecondStatus || this.secondStatus == null) ? this.status : this.secondStatus;
- status.heroineType = HeroineType.Sub;
- status.subCharaData = this;
- status.lastName = characterStatus.lastName;
- status.firstName = characterStatus.firstName;
- if (Product.supportMultiLanguage)
- {
- string translation = LocalizationManager.GetTranslation(characterStatus.lastNameTerm, true, 0, true, false, null, Product.EnumConvert.ToI2LocalizeLanguageName(Product.defaultLanguage));
- if (!string.IsNullOrEmpty(translation))
- {
- status.lastName = translation;
- }
- translation = LocalizationManager.GetTranslation(characterStatus.firstNameTerm, true, 0, true, false, null, Product.EnumConvert.ToI2LocalizeLanguageName(Product.defaultLanguage));
- if (!string.IsNullOrEmpty(translation))
- {
- status.firstName = translation;
- }
- }
- status.contract = characterStatus.contract;
- status.initSeikeiken = (status.seikeiken = characterStatus.initSeikeiken);
- status.likability = characterStatus.likability;
- status.baseLovely = characterStatus.lovely;
- status.baseElegance = characterStatus.elegance;
- status.baseCharm = characterStatus.charm;
- status.baseCare = characterStatus.care;
- status.baseReception = characterStatus.reception;
- status.baseCooking = characterStatus.cooking;
- status.baseDance = characterStatus.dance;
- status.baseVocal = characterStatus.vocal;
- status.playCountNightWork = characterStatus.playCountNightWork;
- int num = characterStatus.hp;
- status.currentHp = num;
- status.baseMaxHp = num;
- num = characterStatus.mind;
- status.currentMind = num;
- status.baseMaxMind = num;
- status.baseInyoku = characterStatus.inyoku;
- status.baseMvalue = characterStatus.mvalue;
- status.baseHentai = characterStatus.hentai;
- status.baseHousi = characterStatus.housi;
- status.playCountYotogi = characterStatus.playCountYotogi;
- }
- public void ApplyPreset(Maid maid, bool refSecondStatus)
- {
- if (maid == null)
- {
- return;
- }
- SubMaid.Data.CharacterStatus characterStatus = (!refSecondStatus || this.secondStatus == null) ? this.status : this.secondStatus;
- CharacterMgr.npcDatas[characterStatus.presetName].Apply(maid, true);
- maid.status.UpdateBodyParam();
- if (!string.IsNullOrEmpty(characterStatus.iconFileName))
- {
- Texture2D texture2D = ImportCM.CreateTexture(characterStatus.iconFileName);
- if (texture2D.format == TextureFormat.DXT1 || texture2D.format == TextureFormat.DXT5)
- {
- Texture2D texture2D2 = new Texture2D(texture2D.width, texture2D.height, TextureFormat.ARGB32, false);
- texture2D2.SetPixels(texture2D.GetPixels());
- texture2D2.Apply();
- UnityEngine.Object.Destroy(texture2D);
- maid.SetThumIcon(texture2D2);
- }
- else
- {
- maid.SetThumIcon(texture2D);
- }
- }
- else
- {
- Debug.LogError(string.Concat(new string[]
- {
- "サブメイド[",
- characterStatus.firstName,
- "]のアイコンファイル[",
- characterStatus.iconFileName,
- "]が見つかりません"
- }));
- }
- if (!string.IsNullOrEmpty(characterStatus.thumbnailFileName))
- {
- Texture2D texture2D3 = ImportCM.CreateTexture(characterStatus.thumbnailFileName);
- if (texture2D3.format == TextureFormat.DXT1 || texture2D3.format == TextureFormat.DXT5)
- {
- Texture2D texture2D4 = new Texture2D(texture2D3.width, texture2D3.height, TextureFormat.ARGB32, false);
- texture2D4.SetPixels(texture2D3.GetPixels());
- texture2D4.Apply();
- UnityEngine.Object.Destroy(texture2D3);
- maid.SetThumCard(texture2D4);
- }
- else
- {
- maid.SetThumCard(texture2D3);
- }
- }
- else
- {
- Debug.LogError(string.Concat(new string[]
- {
- "サブメイド[",
- characterStatus.firstName,
- "]のアイコンファイル[",
- characterStatus.thumbnailFileName,
- "]が見つかりません"
- }));
- }
- }
- public readonly int id;
- public readonly string uniqueName;
- public readonly string replaceText;
- public readonly bool isEditPossible;
- public readonly SubMaid.Data.CharacterStatus status;
- public readonly SubMaid.Data.CharacterStatus secondStatus;
- public class CharacterStatus
- {
- public CharacterStatus(int id, string uniqueName, bool kissSideNPC, CsvParser basicCsv, int lineY)
- {
- this.id = id;
- this.uniqueName = uniqueName;
- this.kissSideNPC = kissSideNPC;
- int num = 4;
- this.lastName = basicCsv.GetCellAsString(num++, lineY);
- this.firstName = basicCsv.GetCellAsString(num++, lineY);
- this.presetName = Path.GetFileNameWithoutExtension(basicCsv.GetCellAsString(num++, lineY));
- this.iconFileName = Path.GetFileNameWithoutExtension(basicCsv.GetCellAsString(num++, lineY)) + ".tex";
- this.thumbnailFileName = Path.GetFileNameWithoutExtension(basicCsv.GetCellAsString(num++, lineY)) + ".tex";
- try
- {
- this.contract = (Contract)Enum.Parse(typeof(Contract), basicCsv.GetCellAsString(num++, lineY));
- }
- catch (Exception e)
- {
- NDebug.AssertParseError("Contract", e);
- }
- this.contractText = basicCsv.GetCellAsString(num++, lineY);
- this.personalText = basicCsv.GetCellAsString(num++, lineY);
- this.relationText = basicCsv.GetCellAsString(num++, lineY);
- try
- {
- this.initSeikeiken = (Seikeiken)Enum.Parse(typeof(Seikeiken), basicCsv.GetCellAsString(num++, lineY));
- }
- catch (Exception e2)
- {
- NDebug.AssertParseError("Seikeiken", e2);
- }
- this.jobClassText = JobClass.GetData(basicCsv.GetCellAsString(num++, lineY)).drawName;
- this.jobClassLevel = basicCsv.GetCellAsInteger(num++, lineY);
- this.yotogiClassText = basicCsv.GetCellAsString(num++, lineY);
- this.yotogiClassLevel = basicCsv.GetCellAsInteger(num++, lineY);
- this.likability = basicCsv.GetCellAsInteger(num++, lineY);
- this.lovely = basicCsv.GetCellAsInteger(num++, lineY);
- this.elegance = basicCsv.GetCellAsInteger(num++, lineY);
- this.charm = basicCsv.GetCellAsInteger(num++, lineY);
- this.care = basicCsv.GetCellAsInteger(num++, lineY);
- this.reception = basicCsv.GetCellAsInteger(num++, lineY);
- this.cooking = basicCsv.GetCellAsInteger(num++, lineY);
- this.dance = basicCsv.GetCellAsInteger(num++, lineY);
- this.vocal = basicCsv.GetCellAsInteger(num++, lineY);
- this.playCountNightWork = basicCsv.GetCellAsInteger(num++, lineY);
- this.hp = basicCsv.GetCellAsInteger(num++, lineY);
- this.mind = basicCsv.GetCellAsInteger(num++, lineY);
- this.inyoku = basicCsv.GetCellAsInteger(num++, lineY);
- this.mvalue = basicCsv.GetCellAsInteger(num++, lineY);
- this.hentai = basicCsv.GetCellAsInteger(num++, lineY);
- this.housi = basicCsv.GetCellAsInteger(num++, lineY);
- this.playCountYotogi = basicCsv.GetCellAsInteger(num++, lineY);
- }
- public string lastNameTerm
- {
- get
- {
- return "SubMaid/" + this.uniqueName + "/苗字";
- }
- }
- public string firstNameTerm
- {
- get
- {
- return "SubMaid/" + this.uniqueName + "/名前";
- }
- }
- public string contractTextTerm
- {
- get
- {
- return "MaidStatus/契約タイプ/" + this.contractText;
- }
- }
- public string personalTextTerm
- {
- get
- {
- return "SubMaid/" + this.uniqueName + "/性格";
- }
- }
- public string relationTextTerm
- {
- get
- {
- return "SubMaid/" + this.uniqueName + "/状態";
- }
- }
- public readonly int id;
- public readonly string uniqueName;
- public readonly bool kissSideNPC;
- public readonly string lastName;
- public readonly string firstName;
- public readonly string presetName;
- public readonly string iconFileName;
- public readonly string thumbnailFileName;
- public readonly Contract contract;
- public readonly string contractText;
- public readonly string personalText;
- public readonly string relationText;
- public readonly Seikeiken initSeikeiken;
- public readonly string jobClassText;
- public readonly int jobClassLevel;
- public readonly string yotogiClassText;
- public readonly int yotogiClassLevel;
- public readonly int likability;
- public readonly int lovely;
- public readonly int elegance;
- public readonly int charm;
- public readonly int care;
- public readonly int reception;
- public readonly int cooking;
- public readonly int dance;
- public readonly int vocal;
- public readonly int playCountNightWork;
- public readonly int hp;
- public readonly int mind;
- public readonly int inyoku;
- public readonly int mvalue;
- public readonly int hentai;
- public readonly int housi;
- public readonly int playCountYotogi;
- }
- }
- }
- }
|