123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- using wf;
- namespace SceneEditWindow
- {
- public class BgIconData
- {
- public static List<BgIconData.ItemData> itemList { get; private set; }
- public static BgIconData.ItemData GetItemData(int id)
- {
- BgIconData.ItemData result = default(BgIconData.ItemData);
- foreach (BgIconData.ItemData itemData in BgIconData.itemList)
- {
- if (itemData.id == id)
- {
- result = itemData;
- break;
- }
- }
- return result;
- }
- public static void Create()
- {
- if (BgIconData.itemList != null)
- {
- return;
- }
- HashSet<int> hashSet = new HashSet<int>();
- CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "edit_bg_enabled_list", ref hashSet);
- HashSet<int> hashSet2 = new HashSet<int>();
- BgIconData.itemList = new List<BgIconData.ItemData>();
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen("edit_bg.nei"))
- {
- using (CsvParser csvParser = new CsvParser())
- {
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, "edit_bg.nei\nopen failed.");
- for (int i = 1; i < csvParser.max_cell_y; i++)
- {
- if (csvParser.IsCellToExistData(0, i))
- {
- int num = 0;
- BgIconData.ItemData item = default(BgIconData.ItemData);
- item.id = csvParser.GetCellAsInteger(num++, i);
- if (hashSet.Contains(item.id))
- {
- if (!hashSet2.Contains(item.id))
- {
- hashSet2.Add(item.id);
- item.iconTexName = Path.ChangeExtension(csvParser.GetCellAsString(num++, i).ToString(), "tex");
- item.bgName = csvParser.GetCellAsString(num++, i);
- item.yotogiStageData = null;
- string cellAsString = csvParser.GetCellAsString(num++, i);
- if (!string.IsNullOrEmpty(cellAsString))
- {
- try
- {
- item.yotogiStageData = YotogiStage.GetData(cellAsString);
- }
- catch (Exception)
- {
- item.yotogiStageData = null;
- goto IL_1D0;
- }
- }
- item.isRefNoon = (csvParser.GetCellAsString(num++, i) == "昼");
- item.isLegacyBG = (csvParser.GetCellAsString(num++, i) == "〇");
- item.position = Parse.Vector3(csvParser.GetCellAsString(num++, i));
- item.rotation_y = float.Parse(csvParser.GetCellAsString(num++, i));
- BgIconData.itemList.Add(item);
- }
- }
- }
- IL_1D0:;
- }
- }
- }
- BgIconData.itemList.Sort((BgIconData.ItemData a, BgIconData.ItemData b) => a.id - b.id);
- }
- public struct ItemData
- {
- public bool enabled
- {
- get
- {
- return this.yotogiStageData == null || (YotogiStage.IsEnabled(this.yotogiStageData.id) && this.yotogiStageData.isYotogiPlayable(GameMain.Instance.CharacterMgr.status.clubGrade, false));
- }
- }
- public bool Exec()
- {
- if (GameMain.Instance == null || GameMain.Instance.BgMgr == null)
- {
- return false;
- }
- BgMgr bgMgr = GameMain.Instance.BgMgr;
- if (string.IsNullOrEmpty(this.bgName) && this.yotogiStageData != null)
- {
- int num = (!this.isRefNoon) ? 1 : 0;
- GameMain.Instance.BgMgr.ChangeBg(this.yotogiStageData.prefabName[num]);
- }
- else
- {
- bgMgr.ChangeBg(this.bgName);
- }
- bgMgr.SetPos(this.position);
- bgMgr.SetRot(new Vector3(0f, this.rotation_y, 0f));
- return true;
- }
- public int id;
- public bool isLegacyBG;
- public YotogiStage.Data yotogiStageData;
- public bool isRefNoon;
- public string iconTexName;
- public string bgName;
- public Vector3 position;
- public float rotation_y;
- }
- }
- }
|