123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- using wf;
- public class PhotoMotionData
- {
- private PhotoMotionData()
- {
- }
- public static void Create()
- {
- PhotoMotionData.motion_data_ = new List<PhotoMotionData>();
- HashSet<int> hashSet = new HashSet<int>();
- CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "phot_motion_enabled_list", ref hashSet);
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen("phot_motion_list.nei"))
- {
- using (CsvParser csvParser = new CsvParser())
- {
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, "phot_motion_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;
- PhotoMotionData photoMotionData = new PhotoMotionData();
- photoMotionData.id = (long)csvParser.GetCellAsInteger(num++, i);
- photoMotionData.category = csvParser.GetCellAsString(num++, i);
- photoMotionData.name = csvParser.GetCellAsString(num++, i);
- photoMotionData.direct_file = csvParser.GetCellAsString(num++, i);
- photoMotionData.is_loop = (csvParser.GetCellAsString(num++, i) == "○");
- photoMotionData.call_script_fil = csvParser.GetCellAsString(num++, i);
- photoMotionData.call_script_label = csvParser.GetCellAsString(num++, i);
- photoMotionData.is_mod = false;
- string cellAsString = csvParser.GetCellAsString(num++, i);
- bool flag = csvParser.GetCellAsString(num++, i) == "○";
- photoMotionData.use_animekey_mune_l = (photoMotionData.use_animekey_mune_r = flag);
- photoMotionData.is_man_pose = (csvParser.GetCellAsString(num++, i) == "○");
- if (string.IsNullOrEmpty(cellAsString) || PluginData.IsEnabled(cellAsString))
- {
- PhotoMotionData.motion_data_.Add(photoMotionData);
- if (photoMotionData.call_script_fil == "h_edit_pose_001.ks" && photoMotionData.call_script_label == "*ポーズ001")
- {
- PhotoMotionData.init_data_ = photoMotionData;
- }
- else if (photoMotionData.is_man_pose && PhotoMotionData.init_data_for_man_ == null)
- {
- PhotoMotionData.init_data_for_man_ = photoMotionData;
- }
- }
- }
- }
- }
- }
- Action<string, List<string>> CheckModFile = null;
- CheckModFile = delegate(string path, List<string> result_list)
- {
- string[] files = Directory.GetFiles(path);
- for (int n = 0; n < files.Length; n++)
- {
- if (Path.GetExtension(files[n]) == ".anm")
- {
- result_list.Add(files[n]);
- }
- }
- string[] directories = Directory.GetDirectories(path);
- for (int num4 = 0; num4 < directories.Length; num4++)
- {
- CheckModFile(directories[num4], result_list);
- }
- };
- List<string> list = new List<string>();
- CheckModFile(PhotoWindowManager.path_photo_mod_motion, list);
- CRC32 crc = new CRC32();
- for (int j = 0; j < list.Count; j++)
- {
- long num2 = 0L;
- try
- {
- using (FileStream fileStream = new FileStream(list[j], FileMode.Open, FileAccess.Read))
- {
- byte[] array = new byte[fileStream.Length];
- fileStream.Read(array, 0, array.Length);
- uint num3 = crc.ComputeChecksum(array);
- num2 = (long)((ulong)-1 + (ulong)num3);
- }
- }
- catch
- {
- }
- if ((ulong)-1 <= (ulong)num2)
- {
- string fileName = Path.GetFileName(list[j]);
- PhotoMotionData photoMotionData2 = new PhotoMotionData();
- photoMotionData2.id = num2;
- photoMotionData2.category = "Mod";
- photoMotionData2.name = Path.GetFileNameWithoutExtension(fileName);
- photoMotionData2.direct_file = list[j];
- photoMotionData2.is_loop = false;
- photoMotionData2.call_script_fil = string.Empty;
- photoMotionData2.call_script_label = string.Empty;
- photoMotionData2.is_mod = true;
- PhotoMotionData.motion_data_.Add(photoMotionData2);
- }
- }
- Action<string, List<string>> action = delegate(string path, List<string> result_list)
- {
- string[] files = Directory.GetFiles(path);
- for (int n = 0; n < files.Length; n++)
- {
- if (Path.GetExtension(files[n]) == ".anm")
- {
- result_list.Add(files[n]);
- }
- }
- };
- list.Clear();
- action(PhotoModePoseSave.folder_path, list);
- foreach (string fullpath in list)
- {
- PhotoMotionData.AddMyPose(fullpath);
- }
- List<string> list2 = new List<string>();
- PhotoMotionData.category_list_ = new Dictionary<string, List<PhotoMotionData>>();
- for (int k = 0; k < PhotoMotionData.data.Count; k++)
- {
- PhotoMotionData photoMotionData3 = PhotoMotionData.data[k];
- if (!PhotoMotionData.category_list_.ContainsKey(photoMotionData3.category))
- {
- PhotoMotionData.category_list_.Add(photoMotionData3.category, new List<PhotoMotionData>());
- list2.Add(photoMotionData3.category);
- }
- PhotoMotionData.category_list_[photoMotionData3.category].Add(photoMotionData3);
- }
- HashSet<string> hashSet2 = new HashSet<string>();
- PhotoMotionData.popup_menu_list_ = new List<KeyValuePair<string, UnityEngine.Object>>();
- PhotoMotionData.popup_category_term_list = new List<string>();
- for (int l = 0; l < list2.Count; l++)
- {
- string text = list2[l];
- if (!hashSet2.Contains(text))
- {
- bool flag2 = false;
- List<PhotoMotionData> list3 = PhotoMotionData.category_list_[text];
- foreach (PhotoMotionData photoMotionData4 in list3)
- {
- if (!photoMotionData4.is_man_pose)
- {
- flag2 = true;
- break;
- }
- }
- if (flag2)
- {
- hashSet2.Add(text);
- PhotoMotionData.popup_menu_list_.Add(new KeyValuePair<string, UnityEngine.Object>(text, null));
- PhotoMotionData.popup_category_term_list.Add("ScenePhotoMode/ポーズ/カテゴリー/" + text);
- }
- }
- }
- if (!PhotoMotionData.category_list_.ContainsKey("マイポーズ"))
- {
- PhotoMotionData.popup_menu_list_.Add(new KeyValuePair<string, UnityEngine.Object>("マイポーズ", null));
- PhotoMotionData.popup_category_term_list.Add("ScenePhotoMode/ポーズ/カテゴリー/マイポーズ");
- PhotoMotionData.category_list_.Add("マイポーズ", new List<PhotoMotionData>());
- }
- hashSet2.Clear();
- PhotoMotionData.popup_menu_list_for_man_ = new List<KeyValuePair<string, UnityEngine.Object>>();
- PhotoMotionData.popup_category_term_list_for_man = new List<string>();
- for (int m = 0; m < list2.Count; m++)
- {
- string text2 = list2[m];
- if (!hashSet2.Contains(text2))
- {
- bool flag3 = false;
- List<PhotoMotionData> list4 = PhotoMotionData.category_list_[text2];
- foreach (PhotoMotionData photoMotionData5 in list4)
- {
- if (photoMotionData5.is_man_pose)
- {
- flag3 = true;
- break;
- }
- }
- if (flag3)
- {
- hashSet2.Add(text2);
- PhotoMotionData.popup_menu_list_for_man_.Add(new KeyValuePair<string, UnityEngine.Object>(text2, null));
- PhotoMotionData.popup_category_term_list_for_man.Add("ScenePhotoMode/ポーズ/カテゴリー/" + text2);
- }
- }
- }
- }
- public static PhotoMotionData AddMyPose(string fullpath)
- {
- string fileName = Path.GetFileName(fullpath);
- PhotoMotionData photoMotionData = new PhotoMotionData();
- photoMotionData.id = (long)fileName.GetHashCode();
- photoMotionData.category = "マイポーズ";
- photoMotionData.name = Path.GetFileNameWithoutExtension(fileName);
- photoMotionData.direct_file = fullpath;
- photoMotionData.is_loop = false;
- photoMotionData.call_script_fil = string.Empty;
- photoMotionData.call_script_label = string.Empty;
- photoMotionData.is_mod = false;
- photoMotionData.is_mypose = true;
- byte[] array = new byte[2];
- try
- {
- using (FileStream fileStream = new FileStream(photoMotionData.direct_file, FileMode.Open, FileAccess.Read))
- {
- using (BinaryReader binaryReader = new BinaryReader(fileStream))
- {
- string b = binaryReader.ReadString();
- if ("CM3D2_ANIM" != b)
- {
- return null;
- }
- int num = binaryReader.ReadInt32();
- if (1001 <= num)
- {
- fileStream.Seek(-2L, SeekOrigin.End);
- fileStream.Read(array, 0, array.Length);
- photoMotionData.use_animekey_mune_l = (array[0] != 0);
- photoMotionData.use_animekey_mune_r = (array[1] != 0);
- }
- else
- {
- photoMotionData.use_animekey_mune_l = (photoMotionData.use_animekey_mune_r = false);
- }
- }
- }
- }
- catch
- {
- }
- PhotoMotionData.motion_data_.Add(photoMotionData);
- return photoMotionData;
- }
- public string nameTerm
- {
- get
- {
- return (!(this.category == "マイルーム")) ? ("ScenePhotoMode/ポーズ/" + this.id.ToString() + "/名前") : string.Empty;
- }
- }
- public void Apply(Maid maid)
- {
- GameMain.Instance.ScriptMgr.StopMotionScript();
- if (maid == null || maid.body0 == null || maid.body0.m_Bones == null || maid.IsBusy)
- {
- return;
- }
- if (!maid.boMAN)
- {
- maid.body0.MuneYureL((float)((!this.use_animekey_mune_l) ? 1 : 0));
- maid.body0.MuneYureR((float)((!this.use_animekey_mune_r) ? 1 : 0));
- maid.body0.jbMuneL.enabled = !this.use_animekey_mune_l;
- maid.body0.jbMuneR.enabled = !this.use_animekey_mune_l;
- }
- if (!string.IsNullOrEmpty(this.direct_file))
- {
- maid.IKTargetToBone("左手", null, "無し", Vector3.zero, IKCtrlData.IKAttachType.Point, false, false, false);
- maid.IKTargetToBone("右手", null, "無し", Vector3.zero, IKCtrlData.IKAttachType.Point, false, false, false);
- if (!this.is_mod && !this.is_mypose)
- {
- maid.CrossFade(this.direct_file, false, this.is_loop, false, 0f, 1f);
- }
- else
- {
- byte[] array = new byte[0];
- try
- {
- using (FileStream fileStream = new FileStream(this.direct_file, FileMode.Open, FileAccess.Read))
- {
- array = new byte[fileStream.Length];
- fileStream.Read(array, 0, array.Length);
- }
- }
- catch
- {
- }
- if (0 < array.Length)
- {
- maid.body0.CrossFade(this.id.ToString(), array, false, this.is_loop, false, 0f, 1f);
- Maid.AutoTwist[] array2 = new Maid.AutoTwist[]
- {
- Maid.AutoTwist.ShoulderL,
- Maid.AutoTwist.ShoulderR,
- Maid.AutoTwist.WristL,
- Maid.AutoTwist.WristR,
- Maid.AutoTwist.ThighL,
- Maid.AutoTwist.ThighR
- };
- for (int i = 0; i < array2.Length; i++)
- {
- maid.SetAutoTwist(array2[i], true);
- }
- }
- }
- }
- else if (!string.IsNullOrEmpty(this.call_script_fil) && !string.IsNullOrEmpty(this.call_script_label))
- {
- CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
- int sloat = 0;
- for (int j = 0; j < characterMgr.GetMaidCount(); j++)
- {
- if (maid == characterMgr.GetMaid(j))
- {
- sloat = j;
- break;
- }
- }
- GameMain.Instance.ScriptMgr.LoadMotionScript(sloat, false, this.call_script_fil, this.call_script_label, maid.status.guid, string.Empty, true, true, false);
- }
- }
- public static List<PhotoMotionData> data
- {
- get
- {
- return PhotoMotionData.motion_data_;
- }
- }
- public static PhotoMotionData init_data
- {
- get
- {
- return PhotoMotionData.init_data_;
- }
- }
- public static PhotoMotionData init_data_for_man
- {
- get
- {
- return PhotoMotionData.init_data_for_man_;
- }
- }
- public static Dictionary<string, List<PhotoMotionData>> category_list
- {
- get
- {
- return PhotoMotionData.category_list_;
- }
- }
- public static List<string> popup_category_term_list { get; private set; }
- public static List<KeyValuePair<string, UnityEngine.Object>> popup_category_list
- {
- get
- {
- return PhotoMotionData.popup_menu_list_;
- }
- }
- public static List<string> popup_category_term_list_for_man { get; private set; }
- public static List<KeyValuePair<string, UnityEngine.Object>> popup_category_list_for_man
- {
- get
- {
- return PhotoMotionData.popup_menu_list_for_man_;
- }
- }
- public static PhotoMotionData Get(long id)
- {
- for (int i = 0; i < PhotoMotionData.motion_data_.Count; i++)
- {
- if (PhotoMotionData.motion_data_[i].id == id)
- {
- return PhotoMotionData.motion_data_[i];
- }
- }
- return null;
- }
- public long id;
- public string category;
- public string name;
- public string direct_file;
- public bool is_loop;
- public string call_script_fil;
- public string call_script_label;
- public bool is_mod;
- public bool is_mypose;
- public bool use_animekey_mune_l;
- public bool use_animekey_mune_r;
- public bool is_man_pose;
- private static PhotoMotionData init_data_;
- private static PhotoMotionData init_data_for_man_;
- private static List<PhotoMotionData> motion_data_;
- private static Dictionary<string, List<PhotoMotionData>> category_list_;
- private static List<KeyValuePair<string, UnityEngine.Object>> popup_menu_list_;
- private static List<KeyValuePair<string, UnityEngine.Object>> popup_menu_list_for_man_;
- }
|