using System; using System.Collections.Generic; using System.IO; using UnityEngine; using wf; public class PhotoBGObjectData { private PhotoBGObjectData() { } public static void Create() { if (PhotoBGObjectData.bg_data_ != null) { return; } PhotoBGObjectData.bg_data_ = new List(); HashSet hashSet = new HashSet(); CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "phot_bg_object_enabled_list", ref hashSet); using (AFileBase afileBase = GameUty.FileSystem.FileOpen("phot_bg_object_list.nei")) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, "phot_bg_object_list.nei\nopen failed."); for (int i = 1; i < csvParser.max_cell_y; i++) { if (csvParser.IsCellToExistData(0, i) && hashSet.Contains(csvParser.GetCellAsInteger(0, i))) { int num = 0; PhotoBGObjectData photoBGObjectData = new PhotoBGObjectData(); photoBGObjectData.id = (long)csvParser.GetCellAsInteger(num++, i); photoBGObjectData.category = csvParser.GetCellAsString(num++, i); photoBGObjectData.name = csvParser.GetCellAsString(num++, i); photoBGObjectData.create_prefab_name = csvParser.GetCellAsString(num++, i); photoBGObjectData.create_asset_bundle_name = csvParser.GetCellAsString(num++, i); string cellAsString = csvParser.GetCellAsString(num++, i); if (string.IsNullOrEmpty(cellAsString) || PluginData.IsEnabled(cellAsString)) { PhotoBGObjectData.bg_data_.Add(photoBGObjectData); } } } } } Action> action = delegate(string path, List result_list) { string[] files = Directory.GetFiles(path); for (int k = 0; k < files.Length; k++) { if (Path.GetExtension(files[k]) == ".poj") { result_list.Add(files[k]); } } }; List list = new List(); action(ObjectCreateWindow.folder_path, list); foreach (string fullPath in list) { PhotoBGObjectData.AddMyObject(fullPath); } PhotoBGObjectData.category_list_ = new Dictionary>(); PhotoBGObjectData.popup_menu_list_ = new List>(); PhotoBGObjectData.popup_category_term_list = new List(); HashSet hashSet2 = new HashSet(); for (int j = 0; j < PhotoBGObjectData.bg_data_.Count; j++) { if (!PhotoBGObjectData.category_list_.ContainsKey(PhotoBGObjectData.bg_data_[j].category)) { PhotoBGObjectData.category_list_.Add(PhotoBGObjectData.bg_data_[j].category, new List()); } PhotoBGObjectData.category_list_[PhotoBGObjectData.bg_data_[j].category].Add(PhotoBGObjectData.bg_data_[j]); if (!hashSet2.Contains(PhotoBGObjectData.bg_data_[j].category)) { PhotoBGObjectData.popup_menu_list_.Add(new KeyValuePair(PhotoBGObjectData.bg_data_[j].category, null)); PhotoBGObjectData.popup_category_term_list.Add("ScenePhotoMode/背景オブジェクト/カテゴリー/" + PhotoBGObjectData.bg_data_[j].category); hashSet2.Add(PhotoBGObjectData.bg_data_[j].category); } } if (!hashSet2.Contains("マイオブジェクト")) { PhotoBGObjectData.popup_menu_list_.Add(new KeyValuePair("マイオブジェクト", null)); PhotoBGObjectData.popup_category_term_list.Add("ScenePhotoMode/背景オブジェクト/カテゴリー/マイオブジェクト"); PhotoBGObjectData.category_list_.Add("マイオブジェクト", new List()); } } public static PhotoBGObjectData AddMyObject(string fullPath) { if (!File.Exists(fullPath)) { return null; } using (FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read)) { using (BinaryReader binaryReader = new BinaryReader(fileStream)) { string a = binaryReader.ReadString(); if (a != "COM3D2_PHOTO_CUSTOM_OBJECT") { return null; } } } string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(Path.GetFileName(fullPath)); PhotoBGObjectData photoBGObjectData = new PhotoBGObjectData(); photoBGObjectData.id = (long)fileNameWithoutExtension.GetHashCode(); photoBGObjectData.category = "マイオブジェクト"; photoBGObjectData.name = fileNameWithoutExtension; photoBGObjectData.direct_file = fullPath; PhotoBGObjectData.bg_data_.Add(photoBGObjectData); return photoBGObjectData; } public string termName { get { return (!(this.category == "マイオブジェクト")) ? ("ScenePhotoMode/背景オブジェクト/" + this.id.ToString() + "/名前") : string.Empty; } } public static List data { get { return PhotoBGObjectData.bg_data_; } } public static Dictionary> category_list { get { return PhotoBGObjectData.category_list_; } } public static List popup_category_term_list { get; private set; } public static List> popup_category_list { get { return PhotoBGObjectData.popup_menu_list_; } } public static PhotoBGObjectData Get(long id) { for (int i = 0; i < PhotoBGObjectData.bg_data_.Count; i++) { if (PhotoBGObjectData.bg_data_[i].id == id) { return PhotoBGObjectData.bg_data_[i]; } } return null; } public GameObject Instantiate(string name) { Transform transform = GameMain.Instance.BgMgr.bg_parent_object.transform.Find("PhotoPrefab"); if (transform == null) { GameObject gameObject = new GameObject("PhotoPrefab"); gameObject.transform.SetParent(GameMain.Instance.BgMgr.bg_parent_object.transform, false); transform = gameObject.transform; } GameObject gameObject2 = null; if (!string.IsNullOrEmpty(this.create_prefab_name)) { UnityEngine.Object @object = Resources.Load("Prefab/" + this.create_prefab_name); if (@object == null) { return null; } gameObject2 = (UnityEngine.Object.Instantiate(@object) as GameObject); } else if (!string.IsNullOrEmpty(this.create_asset_bundle_name)) { GameObject gameObject3 = GameMain.Instance.BgMgr.CreateAssetBundle(this.create_asset_bundle_name); if (gameObject3 == null) { return null; } gameObject2 = UnityEngine.Object.Instantiate(gameObject3); } else if (!string.IsNullOrEmpty(this.direct_file)) { BasePhotoCustomObject basePhotoCustomObject = BasePhotoCustomObject.InstantiateFromFile(transform.gameObject, this.direct_file); gameObject2 = basePhotoCustomObject.gameObject; } if (gameObject2 == null) { return null; } if (gameObject2.GetComponentInChildren() == null) { MeshRenderer componentInChildren = gameObject2.GetComponentInChildren(true); if (componentInChildren != null) { componentInChildren.gameObject.AddComponent(); } } if (!string.IsNullOrEmpty(name)) { gameObject2.name = name; } gameObject2.transform.SetParent(transform); return gameObject2; } public long id; public string category; public string name; public string create_prefab_name; public string create_asset_bundle_name; public string direct_file; private static List bg_data_; private static Dictionary> category_list_; private static List> popup_menu_list_; }