using System; using System.Collections.Generic; using System.IO; using MaidStatus; using UnityEngine; using wf; public static class YotogiStage { public static int Count { get { YotogiStage.CreateData(); return YotogiStage.commonIdManager.idMap.Count; } } public static bool Contains(string name) { YotogiStage.CreateData(); return YotogiStage.commonIdManager.nameMap.ContainsKey(name); } public static bool Contains(int id) { YotogiStage.CreateData(); return YotogiStage.commonIdManager.idMap.ContainsKey(id); } public static int uniqueNameToId(string name) { YotogiStage.CreateData(); NDebug.Assert(YotogiStage.commonIdManager.nameMap.ContainsKey(name), "夜伽ステージ\nユニーク名[" + name + "]をIDに変換できませんでした"); return YotogiStage.commonIdManager.nameMap[name]; } public static string IdToUniqueName(int id) { YotogiStage.CreateData(); NDebug.Assert(YotogiStage.commonIdManager.idMap.ContainsKey(id), "夜伽ステージ\nID[" + id + "]をユニーク名に変換できませんでした"); return YotogiStage.commonIdManager.idMap[id].Key; } public static YotogiStage.Data GetData(int id) { YotogiStage.CreateData(); NDebug.Assert(YotogiStage.basicDatas.ContainsKey(id), "夜伽ステージ\nID[" + id + "]のデータは存在しません"); return YotogiStage.basicDatas[id]; } public static YotogiStage.Data GetData(string uniqueName) { return YotogiStage.GetData(YotogiStage.uniqueNameToId(uniqueName)); } public static bool IsEnabled(string uniqueName) { YotogiStage.CreateData(); return YotogiStage.commonIdManager.enabledIdList.Contains(YotogiStage.uniqueNameToId(uniqueName)); } public static bool IsEnabled(int id) { YotogiStage.CreateData(); return YotogiStage.commonIdManager.enabledIdList.Contains(id); } public static List GetAllDatas(bool onlyEnabled) { YotogiStage.CreateData(); List list = new List(); foreach (KeyValuePair> keyValuePair in YotogiStage.commonIdManager.idMap) { if (!onlyEnabled || YotogiStage.commonIdManager.enabledIdList.Contains(keyValuePair.Key)) { list.Add(YotogiStage.basicDatas[keyValuePair.Key]); } } return list; } public static void CreateData() { if (YotogiStage.commonIdManager != null) { return; } YotogiStage.commonIdManager = new CsvCommonIdManager("yotogi_stage", "夜伽ステージ", CsvCommonIdManager.Type.IdAndUniqueName, null); YotogiStage.basicDatas = new Dictionary(); string[] array = new string[] { "list" }; KeyValuePair[] array2 = new KeyValuePair[array.Length]; for (int i = 0; i < array2.Length; i++) { string text = "yotogi_stage_" + 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); } HashSet hashSet = new HashSet(YotogiStage.commonIdManager.enabledIdList); using (AFileBase afileBase2 = GameUty.FileSystem.FileOpen("yotogi_stage_compatibility_list.nei")) { if (afileBase2 != null && afileBase2.IsValid()) { using (CsvParser csvParser2 = new CsvParser()) { if (csvParser2.Open(afileBase2)) { for (int j = 1; j < csvParser2.max_cell_y; j++) { if (csvParser2.IsCellToExistData(0, j)) { int cellAsInteger = csvParser2.GetCellAsInteger(0, j); string cellAsString = csvParser2.GetCellAsString(2, j); bool flag = !string.IsNullOrEmpty(cellAsString) && PluginData.IsEnabled(cellAsString); if (flag && !hashSet.Contains(cellAsInteger)) { hashSet.Add(cellAsInteger); } } } } } } } Dictionary> idMap = new Dictionary>(YotogiStage.commonIdManager.idMap); Dictionary nameMap = new Dictionary(YotogiStage.commonIdManager.nameMap); YotogiStage.commonIdManager = new CsvCommonIdManager(idMap, nameMap, hashSet, CsvCommonIdManager.Type.IdAndUniqueName); foreach (KeyValuePair> keyValuePair in YotogiStage.commonIdManager.idMap) { YotogiStage.basicDatas.Add(keyValuePair.Key, new YotogiStage.Data(keyValuePair.Key, array2[0].Value)); } foreach (KeyValuePair keyValuePair2 in array2) { keyValuePair2.Value.Dispose(); keyValuePair2.Key.Dispose(); } } private const string csvTopCommonName = "yotogi_stage"; private const string typeNameForErrorLog = "夜伽ステージ"; public const string termRootText = "SceneYotogi/背景タイプ/"; private static CsvCommonIdManager commonIdManager; private static Dictionary basicDatas; public class Data : IComparable, IComparable { public Data(int id, CsvParser basicCsv) { List list = new List(); for (int i = 1; i < basicCsv.max_cell_y; i++) { if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id) { this.id = id; int num = 1; string text = string.Empty; this.uniqueName = basicCsv.GetCellAsString(num++, i); this.drawName = basicCsv.GetCellAsString(num++, i); this.sortId = basicCsv.GetCellAsInteger(num++, i); this.drawClubGrade = basicCsv.GetCellAsInteger(num++, i); this.requestClubGrade = basicCsv.GetCellAsInteger(num++, i); this.requestFacilityIds = new int[0]; text = basicCsv.GetCellAsString(num++, i); if (!string.IsNullOrEmpty(text)) { string[] array = text.Split(new char[] { ',' }); this.requestFacilityIds = new int[array.Length]; for (int j = 0; j < array.Length; j++) { this.requestFacilityIds[j] = int.Parse(array[j].Trim()); } } this.prefabName = new string[2]; this.thumbnailName = new string[2]; for (int k = 0; k < this.prefabName.Length; k++) { this.prefabName[k] = basicCsv.GetCellAsString(num++, i); this.thumbnailName[k] = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".tex"); } this.bgmFileName = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ogg"); string cellAsString = basicCsv.GetCellAsString(num++, i); string[] array2 = cellAsString.Split(new char[] { ',' }); NDebug.Assert(array2.Length == 6, "ステージカメラ設定が不正です\nLine : " + i.ToString()); Vector3 center = new Vector3(float.Parse(array2[0]), float.Parse(array2[1]), float.Parse(array2[2])); float radius = float.Parse(array2[3]); Vector2 v = new Vector2(float.Parse(array2[4]), float.Parse(array2[5])); this.stageSelectCameraData = new YotogiStage.Data.Camera(center, v, radius); cellAsString = basicCsv.GetCellAsString(num++, i); array2 = cellAsString.Split(new char[] { ',' }); NDebug.Assert(array2.Length == 6, "カス子位置情報が不正です\nLine : " + i.ToString()); Vector3 position = new Vector3(float.Parse(array2[0]), float.Parse(array2[1]), float.Parse(array2[2])); Vector3 rotation = new Vector3(float.Parse(array2[3]), float.Parse(array2[4]), float.Parse(array2[5])); cellAsString = basicCsv.GetCellAsString(num++, i); array2 = cellAsString.Split(new char[] { ',' }); NDebug.Assert(array2.Length == 2, "スキル選択時カメラデータが不正です\nLine : " + i.ToString()); Vector2 cameraAngle = new Vector2(float.Parse(array2[0]), float.Parse(array2[1])); this.skillSelectcharacterData = new YotogiStage.Data.Character(position, rotation, cameraAngle); string cellAsString2 = basicCsv.GetCellAsString(num++, i); string[] array3 = cellAsString2.Split(new char[] { ',' }); NDebug.Assert(array3.Length == 4, "スキル選択時ライトデータが不正です\nLine : " + i.ToString()); Vector3 position2 = new Vector3(float.Parse(array3[0]), float.Parse(array3[1]), float.Parse(array3[2])); float intensity = float.Parse(array3[3]); this.skillSelectLightData = new YotogiStage.Data.Light(position2, intensity); break; } } } public int CompareTo(YotogiStage.Data other) { return this.sortId.CompareTo(other.sortId); } public int CompareTo(object other) { return this.sortId.CompareTo(((YotogiStage.Data)other).sortId); } public bool isYotogiPlayable(int clubGrade, bool checkFacility) { if (clubGrade < this.requestClubGrade) { return false; } bool flag = this.requestFacilityIds.Length == 0; FacilityManager facilityMgr = GameMain.Instance.FacilityMgr; foreach (int facilityTypeID in this.requestFacilityIds) { if (checkFacility) { flag |= facilityMgr.IsExistTypeFacility(facilityTypeID); } else { flag |= facilityMgr.IsFacilityBuildFlag(facilityTypeID); } } return flag; } public bool isYotogiPlayable(Maid maid, int clubGrade, bool checkFacility) { if (clubGrade < this.requestClubGrade) { return false; } bool flag = this.requestFacilityIds.Length == 0; FacilityManager facilityMgr = GameMain.Instance.FacilityMgr; foreach (int facilityTypeID in this.requestFacilityIds) { if (checkFacility) { flag |= facilityMgr.IsExistTypeFacility(facilityTypeID); } else { flag |= facilityMgr.IsFacilityBuildFlag(facilityTypeID); } } if (flag && this.uniqueName == "プライベートルーム") { if (!PluginData.IsEnabled("GP002") || maid == null || maid.status.specialRelation != SpecialRelation.Married) { flag = false; } if (flag) { bool flag2 = false; if (maid.status.yotogiSkill != null && maid.status.yotogiSkill.datas != null) { foreach (YotogiSkillData yotogiSkillData in maid.status.yotogiSkill.datas.GetValueArray()) { if (yotogiSkillData != null) { if (yotogiSkillData.data.getcondition_data.requestMarried) { flag2 = true; break; } } } } if (!flag2) { flag = false; } } } return flag; } public string termName { get { return "SceneYotogi/背景タイプ/" + this.uniqueName; } } public readonly int id; public readonly string uniqueName; public readonly string drawName; public readonly int drawClubGrade; public readonly int sortId; public readonly int requestClubGrade; public readonly int[] requestFacilityIds; public readonly string[] prefabName; public readonly string[] thumbnailName; public readonly string bgmFileName; public readonly YotogiStage.Data.Camera stageSelectCameraData; public readonly YotogiStage.Data.Light skillSelectLightData; public readonly YotogiStage.Data.Character skillSelectcharacterData; public class Camera { public Camera(Vector3 center, Vector3 angle, float radius) { this.center = center; this.angle = angle; this.radius = radius; } public void Apply(CameraMain camera) { camera.SetFromScriptOnTarget(this.center, this.radius, this.angle); } public void Apply() { this.Apply(GameMain.Instance.MainCamera); } public readonly Vector3 center; public readonly Vector2 angle; public readonly float radius; } public class Light { public Light(Vector3 position, float intensity) { this.position = position; this.intensity = intensity; } public void Apply(LightMain light) { light.SetRotation(this.position); light.SetIntensity(this.intensity); } public void Apply() { this.Apply(GameMain.Instance.MainLight); } public readonly Vector3 position; public readonly float intensity; } public class Character { public Character(Vector3 position, Vector3 rotation, Vector2 cameraAngle) { this.position = position; this.rotation = rotation; this.cameraAngle = cameraAngle; } public void Apply(CharacterMgr charaMgr) { charaMgr.SetCharaAllPos(this.position); charaMgr.SetCharaAllRot(this.rotation); } public void Apply() { this.Apply(GameMain.Instance.CharacterMgr); } public readonly Vector3 position; public readonly Vector3 rotation; public readonly Vector2 cameraAngle; } } }