MotionKagManager.cs 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using kt.ik;
  6. using kt.Physics;
  7. using kt.Utility;
  8. using script;
  9. using UnityEngine;
  10. public class MotionKagManager : BaseKagManager
  11. {
  12. public MotionKagManager(TJSScript tjs, ScriptManager script_mgr) : base(tjs, script_mgr)
  13. {
  14. for (int i = 0; i < this.last_maid_motion_set_log_.Length; i++)
  15. {
  16. this.last_maid_motion_set_log_[i] = string.Empty;
  17. }
  18. for (int j = 0; j < this.last_man_motion_set_log_.Length; j++)
  19. {
  20. this.last_man_motion_set_log_[j] = string.Empty;
  21. }
  22. }
  23. public override void Initialize()
  24. {
  25. base.Initialize();
  26. this.LoadMotionScriptMeta();
  27. this.kag_.RemoveTagCallBack("motionscript");
  28. this.kag_.RemoveTagCallBack("allprocpropseqstart");
  29. this.kag_.AddTagCallBack("allprocpropseqstart", new KagScript.KagTagCallBack(this.TagMotAllProcPropSeqStart));
  30. this.kag_.RemoveTagCallBack("setmaidoffsetmultipos");
  31. this.kag_.AddTagCallBack("setmaidoffsetmultipos", new KagScript.KagTagCallBack(this.TagSetMaidOffsetMultiPos2));
  32. this.kag_.RemoveTagCallBack("face");
  33. this.kag_.AddTagCallBack("face", new KagScript.KagTagCallBack(this.TagMotFace));
  34. this.kag_.RemoveTagCallBack("faceblend");
  35. this.kag_.AddTagCallBack("faceblend", new KagScript.KagTagCallBack(this.TagMotFaceBlend));
  36. base.kag.AddTagCallBack("penisikattach", new KagScript.KagTagCallBack(this.TagPenisIKAttach));
  37. base.kag.AddTagCallBack("ikplanecolider", new KagScript.KagTagCallBack(this.TagIKPlaneColider));
  38. base.kag.AddTagCallBack("ikcoliderborder", new KagScript.KagTagCallBack(this.TagIKColiderBorder));
  39. base.kag.AddTagCallBack("ikcolidercorrect", new KagScript.KagTagCallBack(this.TagIKColiderCorrect));
  40. base.kag.AddTagCallBack("ikcoliderenable", new KagScript.KagTagCallBack(this.TagIKColiderEnable));
  41. base.kag.AddTagCallBack("ikcolidertarget", new KagScript.KagTagCallBack(this.TagIKColiderTarget));
  42. base.kag.AddTagCallBack("ikcrosscolider", new KagScript.KagTagCallBack(this.TagIKCrossColider));
  43. base.kag.AddTagCallBack("setpartner", new KagScript.KagTagCallBack(this.TagSetPartner));
  44. base.kag.AddTagCallBack("iksetpelvispull", new KagScript.KagTagCallBack(base.TagIKSetPelvisPull));
  45. base.kag.AddTagCallBack("kupatimer", new KagScript.KagTagCallBack(this.TagKupaTimer));
  46. base.kag.AddTagCallBack("kupainsert", new KagScript.KagTagCallBack(this.TagKupaInsert));
  47. base.kag.AddTagCallBack("shouldertwistcalc", new KagScript.KagTagCallBack(this.TagShoulderTwistCalc));
  48. base.kag.AddTagCallBack("motionoffset", new KagScript.KagTagCallBack(this.TagMotionOffset));
  49. base.kag.AddTagCallBack("autooffset", new KagScript.KagTagCallBack(this.TagAutoOffset));
  50. base.kag.AddTagCallBack("inverseoffset", new KagScript.KagTagCallBack(this.TagInverseOffset));
  51. base.kag.AddTagCallBack("setikorder", new KagScript.KagTagCallBack(this.TagSetIKOrder));
  52. base.kag.AddTagCallBack("setberomorph", new KagScript.KagTagCallBack(this.TagSetBeroMorph));
  53. }
  54. private void LoadMotionScriptMeta()
  55. {
  56. if (!GameUty.FileSystem.IsExistentFile("motionscript.msmeta"))
  57. {
  58. return;
  59. }
  60. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("motionscript.msmeta"))
  61. {
  62. if (afileBase.IsValid())
  63. {
  64. byte[] buffer = afileBase.ReadAll();
  65. this.MotionScriptMetaDic.Clear();
  66. using (MemoryStream memoryStream = new MemoryStream(buffer))
  67. {
  68. using (StreamReader streamReader = new StreamReader(memoryStream))
  69. {
  70. string json = streamReader.ReadToEnd();
  71. MotionKagManager.MotionScriptMetaPackage motionScriptMetaPackage = JsonUtility.FromJson<MotionKagManager.MotionScriptMetaPackage>(json);
  72. foreach (MotionKagManager.MotionScriptMeta motionScriptMeta in motionScriptMetaPackage.metaList)
  73. {
  74. this.MotionScriptMetaDic[motionScriptMeta.scriptName] = motionScriptMeta;
  75. }
  76. }
  77. }
  78. }
  79. else
  80. {
  81. Debug.LogErrorFormat("{0}はありませんでした", new object[]
  82. {
  83. "motionscript.msmeta"
  84. });
  85. }
  86. }
  87. }
  88. public Maid SetMainMaid(Maid maid)
  89. {
  90. this.main_maid_ = maid;
  91. return this.main_maid_;
  92. }
  93. public Maid SetMainMaid(string maid_guid)
  94. {
  95. if (string.IsNullOrEmpty(maid_guid))
  96. {
  97. this.main_maid_ = null;
  98. return null;
  99. }
  100. for (int i = 0; i < GameMain.Instance.CharacterMgr.GetMaidCount(); i++)
  101. {
  102. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(i);
  103. if (maid != null && maid.status.guid == maid_guid)
  104. {
  105. this.main_maid_ = maid;
  106. break;
  107. }
  108. }
  109. return this.main_maid_;
  110. }
  111. public Maid SetMainMan(Maid man)
  112. {
  113. this.main_man_ = man;
  114. return this.main_man_;
  115. }
  116. public Maid SetMainMan(string man_guid)
  117. {
  118. if (string.IsNullOrEmpty(man_guid))
  119. {
  120. this.main_man_ = null;
  121. return null;
  122. }
  123. for (int i = 0; i < GameMain.Instance.CharacterMgr.GetManCount(); i++)
  124. {
  125. Maid man = GameMain.Instance.CharacterMgr.GetMan(i);
  126. if (man != null && man.status.guid == man_guid)
  127. {
  128. this.main_man_ = man;
  129. break;
  130. }
  131. }
  132. return this.main_man_;
  133. }
  134. public override void LoadScriptFile(string fileName, string labelName = "")
  135. {
  136. string currentFileName = base.kag.GetCurrentFileName();
  137. string currentLabel = base.kag.GetCurrentLabel();
  138. bool flag = fileName != currentFileName;
  139. bool flag2 = labelName != currentLabel;
  140. this.CurrentScriptMeta = this.GetMotionScriptMeta(fileName);
  141. if (flag)
  142. {
  143. this.LoadActiveChara();
  144. }
  145. else if (this.main_maid || this.main_man)
  146. {
  147. if (this.main_man && (!this.ActiveManList.Contains(this.main_man) || this.ActiveManList.Count > 1))
  148. {
  149. this.ActiveManList.Clear();
  150. this.ActiveManList.Add(this.main_man);
  151. }
  152. if (this.main_maid && (!this.ActiveMaidList.Contains(this.main_maid) || this.ActiveMaidList.Count > 1))
  153. {
  154. this.ActiveMaidList.Clear();
  155. this.ActiveMaidList.Add(this.main_maid);
  156. }
  157. }
  158. else
  159. {
  160. if (this.ActiveMaidList.Any((Maid ch) => !ch.Visible))
  161. {
  162. for (int i = 0; i < this.ActiveMaidList.Count; i++)
  163. {
  164. Maid maid6 = this.ActiveMaidList[i];
  165. if (!maid6.Visible)
  166. {
  167. this.ActiveMaidList.Remove(maid6);
  168. }
  169. }
  170. }
  171. if (this.ActiveManList.Any((Maid ch) => !ch.Visible))
  172. {
  173. for (int j = 0; j < this.ActiveManList.Count; j++)
  174. {
  175. Maid maid2 = this.ActiveManList[j];
  176. if (!maid2.Visible)
  177. {
  178. this.ActiveManList.Remove(maid2);
  179. }
  180. }
  181. }
  182. }
  183. MotionKagManager.MotionScriptMeta currentScriptMeta = this.CurrentScriptMeta;
  184. if (currentScriptMeta != null)
  185. {
  186. if (!this.main_maid && currentScriptMeta.maidCount == 1)
  187. {
  188. Debug.LogFormat("{0}にメイドの指定がなかったのでメイド0番を自動的に割り振りました", new object[]
  189. {
  190. fileName
  191. });
  192. this.main_maid_ = GameMain.Instance.CharacterMgr.GetMaid(0);
  193. this.ActiveMaidList.Clear();
  194. this.ActiveMaidList.Add(this.main_maid);
  195. }
  196. if (!this.main_man && currentScriptMeta.manCount == 1)
  197. {
  198. Debug.LogFormat("{0}に男の指定がなかったので男0番を自動的に割り振りました", new object[]
  199. {
  200. fileName
  201. });
  202. this.main_man_ = GameMain.Instance.CharacterMgr.GetMan(0);
  203. this.ActiveManList.Clear();
  204. this.ActiveManList.Add(this.main_man);
  205. }
  206. }
  207. bool flag3;
  208. if (this.main_maid)
  209. {
  210. flag3 = this.main_maid.IsCrcBody;
  211. }
  212. else if (this.ActiveMaidList.Count > 0)
  213. {
  214. flag3 = this.ActiveMaidList.Any((Maid ch) => ch.IsCrcBody);
  215. }
  216. else if (this.main_man)
  217. {
  218. flag3 = this.main_man.IsCrcBody;
  219. }
  220. else
  221. {
  222. flag3 = this.ActiveManList.Any((Maid ch) => ch.IsCrcBody);
  223. }
  224. if (!flag3)
  225. {
  226. for (int k = 0; k < this.ActiveManList.Count; k++)
  227. {
  228. Maid maid3 = this.ActiveManList[k];
  229. if (maid3.IsCrcBody)
  230. {
  231. int activeSlotNo = maid3.ActiveSlotNo;
  232. GameMain.Instance.CharacterMgr.SwapNewManBody(activeSlotNo, false);
  233. Maid man = GameMain.Instance.CharacterMgr.GetMan(activeSlotNo);
  234. this.ActiveManList[k] = man;
  235. maid3 = man;
  236. maid3.AllProcProp();
  237. if (this.main_man)
  238. {
  239. this.main_man_ = maid3;
  240. }
  241. }
  242. }
  243. base.LoadScriptFile(fileName, labelName);
  244. return;
  245. }
  246. if (fileName.IndexOf("crc_") != 0)
  247. {
  248. fileName = "crc_" + fileName;
  249. }
  250. if (!GameUty.IsExistFile(fileName, null))
  251. {
  252. Debug.LogWarningFormat("{0}が見つからなかったので{1}を読み込みました。", new object[]
  253. {
  254. fileName,
  255. fileName.Replace("crc_", string.Empty)
  256. });
  257. base.LoadScriptFile(fileName.Replace("crc_", string.Empty), labelName);
  258. return;
  259. }
  260. if (this.main_maid || this.main_man)
  261. {
  262. if (this.main_maid && this.main_maid.body0.isMotionScriptSet && !this.main_maid.body0.IsMotionScritChange(fileName, labelName))
  263. {
  264. Debug.LogWarningFormat("Maid{0}に同フレーム内で同じモーションスクリプトが読み込まれました", new object[]
  265. {
  266. this.main_maid.ActiveSlotNo
  267. });
  268. return;
  269. }
  270. if (this.main_man && this.main_man.body0.isMotionScriptSet && !this.main_man.body0.IsMotionScritChange(fileName, labelName))
  271. {
  272. Debug.LogWarningFormat("Man{0}に同フレーム内で同じモーションスクリプトが読み込まれました", new object[]
  273. {
  274. this.main_man.ActiveSlotNo
  275. });
  276. return;
  277. }
  278. }
  279. for (int l = 0; l < this.ActiveMaidList.Count; l++)
  280. {
  281. Maid maid4 = this.ActiveMaidList[l];
  282. if (maid4.body0.isMotionScriptSet && !maid4.body0.IsMotionScritChange(fileName, labelName))
  283. {
  284. Debug.LogWarningFormat("Maid{0}に同フレーム内で同じモーションスクリプトが読み込まれました", new object[]
  285. {
  286. maid4.ActiveSlotNo
  287. });
  288. this.ActiveMaidList.Remove(maid4);
  289. }
  290. else if (!this.isBodyMixOK && !maid4.IsCrcBody && fileName != "crc_workFF_001.ks")
  291. {
  292. NDebug.Assert("新ボディと旧ボディのキャラが混在しています。旧ボディキャラ:" + maid4.name, false);
  293. return;
  294. }
  295. }
  296. for (int m = 0; m < this.ActiveManList.Count; m++)
  297. {
  298. Maid maid5 = this.ActiveManList[m];
  299. if (maid5.body0.isMotionScriptSet && !maid5.body0.IsMotionScritChange(fileName, labelName))
  300. {
  301. Debug.LogWarningFormat("Man{0}に同フレーム内で同じモーションスクリプトが読み込まれました", new object[]
  302. {
  303. maid5.ActiveSlotNo
  304. });
  305. this.ActiveManList.Remove(maid5);
  306. }
  307. else if (!maid5.IsCrcBody)
  308. {
  309. int activeSlotNo2 = maid5.ActiveSlotNo;
  310. GameMain.Instance.CharacterMgr.SwapNewManBody(activeSlotNo2, true);
  311. Maid man = GameMain.Instance.CharacterMgr.GetMan(activeSlotNo2);
  312. this.ActiveManList[m] = man;
  313. maid5 = man;
  314. maid5.AllProcProp();
  315. if (this.main_man)
  316. {
  317. this.main_man_ = maid5;
  318. }
  319. }
  320. }
  321. if (this.ActiveMaidList.Count == 0 && this.ActiveManList.Count == 0)
  322. {
  323. Debug.LogWarning("モーションを再生できるキャラが1人もいません");
  324. return;
  325. }
  326. if (this.isBodyMixOK)
  327. {
  328. bool flag4 = this.ActiveMaidList.Any((Maid maid) => !maid.IsCrcBody);
  329. if (flag4)
  330. {
  331. this.isBodyMixOK = false;
  332. Action<List<Maid>> action = delegate(List<Maid> chara_list)
  333. {
  334. List<Maid> list = new List<Maid>(chara_list);
  335. for (int n = 0; n < list.Count; n++)
  336. {
  337. Maid maid7 = list[n];
  338. if (maid7.boMAN)
  339. {
  340. this.SetMainMan(maid7);
  341. }
  342. else
  343. {
  344. this.SetMainMaid(maid7);
  345. }
  346. string path = (!maid7.IsCrcBody) ? fileName.Replace("crc_", string.Empty) : fileName;
  347. this.LoadScriptFile(string.Format("{0}_{1}.ks", Path.GetFileNameWithoutExtension(path), maid7.ActiveSlotNo), labelName);
  348. if (n < list.Count - 1)
  349. {
  350. this.Exec();
  351. }
  352. }
  353. };
  354. action(this.ActiveManList);
  355. action(this.ActiveMaidList);
  356. this.isBodyMixOK = true;
  357. return;
  358. }
  359. }
  360. foreach (Maid chara in this.ActiveManList)
  361. {
  362. this.MotionSettingReset(chara, fileName, labelName);
  363. }
  364. foreach (Maid chara2 in this.ActiveMaidList)
  365. {
  366. this.MotionSettingReset(chara2, fileName, labelName);
  367. }
  368. base.LoadScriptFile(fileName, "*共通");
  369. this.Exec();
  370. base.LoadScriptFile(fileName, labelName);
  371. }
  372. private MotionKagManager.MotionScriptMeta GetMotionScriptMeta(string file_name)
  373. {
  374. if (this.MotionScriptMetaDic.ContainsKey(file_name))
  375. {
  376. return this.MotionScriptMetaDic[file_name];
  377. }
  378. file_name = file_name.Replace("crc_", string.Empty);
  379. if (this.MotionScriptMetaDic.ContainsKey(file_name))
  380. {
  381. return this.MotionScriptMetaDic[file_name];
  382. }
  383. return null;
  384. }
  385. private void LoadActiveChara()
  386. {
  387. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  388. this.ActiveMaidList.Clear();
  389. if (this.main_maid)
  390. {
  391. this.ActiveMaidList.Add(this.main_maid);
  392. }
  393. else
  394. {
  395. for (int i = 0; i < characterMgr.GetMaidCount(); i++)
  396. {
  397. if (this.CurrentScriptMeta != null && this.CurrentScriptMeta.maidCount == this.ActiveMaidList.Count)
  398. {
  399. break;
  400. }
  401. Maid maid = characterMgr.GetMaid(i);
  402. if (maid && maid.Visible)
  403. {
  404. this.ActiveMaidList.Add(maid);
  405. }
  406. }
  407. }
  408. this.ActiveManList.Clear();
  409. if (this.main_man)
  410. {
  411. this.ActiveManList.Add(this.main_man);
  412. }
  413. else
  414. {
  415. for (int j = 0; j < characterMgr.GetManCount(); j++)
  416. {
  417. if (this.CurrentScriptMeta != null && this.CurrentScriptMeta.manCount == this.ActiveManList.Count)
  418. {
  419. break;
  420. }
  421. Maid man = characterMgr.GetMan(j);
  422. if (man && man.Visible)
  423. {
  424. this.ActiveManList.Add(man);
  425. }
  426. }
  427. }
  428. }
  429. private void MotionSettingReset(Maid chara, string fileName, string labelName)
  430. {
  431. MotionKagManager.MotionSettingReset(chara);
  432. chara.body0.SetMotionScriptInfo(fileName, labelName);
  433. }
  434. public static void MotionSettingReset(Maid chara)
  435. {
  436. if (!chara.body0.IsCrcBody)
  437. {
  438. return;
  439. }
  440. if (!chara.boMAN)
  441. {
  442. chara.body0.SetMuneYureL(true);
  443. chara.body0.SetMuneYureR(true);
  444. chara.body0.KupaReset();
  445. }
  446. for (int i = 2; i <= 5; i++)
  447. {
  448. chara.body0.StopAnimeLayer(i);
  449. }
  450. chara.body0.SetShoulderTwistCalcType(true, ShoulderTwist.CalcType.Normal);
  451. chara.body0.SetShoulderTwistCalcType(false, ShoulderTwist.CalcType.Normal);
  452. chara.body0.fullBodyIK.IKReset();
  453. chara.motionOffsetGP03 = Vector3.zero;
  454. if (chara.body0.Face.tongueCtrl != null)
  455. {
  456. chara.body0.Face.tongueCtrl.TongueReset();
  457. }
  458. }
  459. public override bool TagMotion(KagTagSupport tag_data)
  460. {
  461. Maid maid = base.GetMaidAndMan(tag_data, true);
  462. if (maid == null)
  463. {
  464. return false;
  465. }
  466. base.CheckAbsolutelyNecessaryTag(tag_data, "motion", new string[]
  467. {
  468. "mot"
  469. });
  470. string play_motion_name = tag_data.GetTagProperty("mot").AsString() + ".anm";
  471. if (maid.body0.IsCrcBody && play_motion_name.IndexOf("crc_") != 0)
  472. {
  473. string text = "crc_" + play_motion_name;
  474. if (GameUty.IsExistFile(text, null))
  475. {
  476. play_motion_name = text;
  477. }
  478. }
  479. int blend = 500;
  480. if (tag_data.IsValid("blend"))
  481. {
  482. blend = tag_data.GetTagProperty("blend").AsInteger();
  483. }
  484. bool loop = false;
  485. if (tag_data.IsValid("loop"))
  486. {
  487. loop = tag_data.GetTagProperty("loop").AsBool();
  488. }
  489. int num = 0;
  490. if (tag_data.IsValid("wait"))
  491. {
  492. num = tag_data.GetTagProperty("wait").AsInteger();
  493. }
  494. WaitEventList waitEventList = base.GetWaitEventList("motion");
  495. if (num <= 0)
  496. {
  497. if (maid.Visible)
  498. {
  499. this.PlayMaidMotion(maid, play_motion_name, false, loop, false, GameUty.MillisecondToSecond(blend));
  500. }
  501. waitEventList.Clear();
  502. }
  503. else
  504. {
  505. waitEventList.Add(delegate
  506. {
  507. if (maid != null && maid.Visible && maid.body0 != null && maid.body0.isLoadedBody)
  508. {
  509. this.PlayMaidMotion(maid, play_motion_name, false, loop, false, GameUty.MillisecondToSecond(blend));
  510. }
  511. }, num);
  512. }
  513. return false;
  514. }
  515. public override bool TagMotionNext(KagTagSupport tag_data)
  516. {
  517. Maid maid = base.GetMaidAndMan(tag_data, true);
  518. if (maid == null)
  519. {
  520. return false;
  521. }
  522. base.CheckAbsolutelyNecessaryTag(tag_data, "motionnext", new string[]
  523. {
  524. "mot"
  525. });
  526. string play_motion_name = tag_data.GetTagProperty("mot").AsString() + ".anm";
  527. if (maid.body0.IsCrcBody && play_motion_name.IndexOf("crc_") != 0)
  528. {
  529. string text = "crc_" + play_motion_name;
  530. if (GameUty.IsExistFile(text, null))
  531. {
  532. play_motion_name = text;
  533. }
  534. }
  535. int blend = 500;
  536. if (tag_data.IsValid("blend"))
  537. {
  538. blend = tag_data.GetTagProperty("blend").AsInteger();
  539. }
  540. bool loop = false;
  541. if (tag_data.IsValid("loop"))
  542. {
  543. loop = tag_data.GetTagProperty("loop").AsBool();
  544. }
  545. WaitEventList waitEventList = base.GetWaitEventList("motion");
  546. if (waitEventList.list.Count <= 0)
  547. {
  548. if (maid.Visible)
  549. {
  550. this.PlayMaidMotion(maid, play_motion_name, false, loop, true, GameUty.MillisecondToSecond(blend));
  551. }
  552. waitEventList.Clear();
  553. }
  554. else
  555. {
  556. int wait_time = waitEventList.list[waitEventList.list.Count - 1].wait_time;
  557. waitEventList.Add(delegate
  558. {
  559. if (maid != null && maid.Visible)
  560. {
  561. this.PlayMaidMotion(maid, play_motion_name, false, loop, true, GameUty.MillisecondToSecond(blend));
  562. }
  563. }, wait_time);
  564. }
  565. return false;
  566. }
  567. private bool TagPenisIKAttach(KagTagSupport tagData)
  568. {
  569. base.CheckAbsolutelyNecessaryTag(tagData, "penisikattach", new string[]
  570. {
  571. "man",
  572. "target",
  573. "targetbone",
  574. "insert_before",
  575. "insert_after"
  576. });
  577. Maid man = this.GetMan(tagData.GetTagProperty("man").AsInteger());
  578. Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("target").AsString());
  579. if (!man || !maidAndMan)
  580. {
  581. return false;
  582. }
  583. PenisIKParam penisIKParam = new PenisIKParam(man, maidAndMan);
  584. penisIKParam.targetBoneName = tagData.GetTagProperty("targetbone").AsString();
  585. IKScriptHelper.SetPenisIKPatam(penisIKParam, tagData);
  586. man.body0.fullBodyIK.IKAttach(FullBodyIKMgr.IKEffectorType.Penis, penisIKParam);
  587. return false;
  588. }
  589. public bool TagIKPlaneColider(KagTagSupport tagData)
  590. {
  591. bool flag = tagData.IsValid("on");
  592. if (tagData.IsValid("src"))
  593. {
  594. Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString());
  595. if (!maidAndMan)
  596. {
  597. return false;
  598. }
  599. if (tagData.IsValid("colider"))
  600. {
  601. string a = tagData.GetTagProperty("colider").AsString();
  602. if (a == "floor")
  603. {
  604. maidAndMan.body0.fullBodyIK.floorColliderEnable = flag;
  605. }
  606. else
  607. {
  608. maidAndMan.body0.fullBodyIK.wallColliderEnable = flag;
  609. }
  610. }
  611. else
  612. {
  613. maidAndMan.body0.fullBodyIK.floorColliderEnable = flag;
  614. maidAndMan.body0.fullBodyIK.wallColliderEnable = flag;
  615. }
  616. }
  617. else
  618. {
  619. for (int i = 0; i < GameMain.Instance.CharacterMgr.GetMaidCount(); i++)
  620. {
  621. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(i);
  622. if (maid)
  623. {
  624. if (tagData.IsValid("colider"))
  625. {
  626. string a2 = tagData.GetTagProperty("colider").AsString();
  627. if (a2 == "floor")
  628. {
  629. maid.body0.fullBodyIK.floorColliderEnable = flag;
  630. }
  631. else
  632. {
  633. maid.body0.fullBodyIK.wallColliderEnable = flag;
  634. }
  635. }
  636. else
  637. {
  638. maid.body0.fullBodyIK.floorColliderEnable = flag;
  639. maid.body0.fullBodyIK.wallColliderEnable = flag;
  640. }
  641. }
  642. }
  643. for (int j = 0; j < GameMain.Instance.CharacterMgr.GetManCount(); j++)
  644. {
  645. Maid man = GameMain.Instance.CharacterMgr.GetMan(j);
  646. if (man)
  647. {
  648. if (tagData.IsValid("colider"))
  649. {
  650. string a3 = tagData.GetTagProperty("colider").AsString();
  651. if (a3 == "floor")
  652. {
  653. man.body0.fullBodyIK.floorColliderEnable = flag;
  654. }
  655. else
  656. {
  657. man.body0.fullBodyIK.wallColliderEnable = flag;
  658. }
  659. }
  660. else
  661. {
  662. man.body0.fullBodyIK.floorColliderEnable = flag;
  663. man.body0.fullBodyIK.wallColliderEnable = flag;
  664. }
  665. }
  666. }
  667. }
  668. return false;
  669. }
  670. public bool TagIKColiderBorder(KagTagSupport tagData)
  671. {
  672. base.CheckAbsolutelyNecessaryTag(tagData, "ikcoliderborder", new string[]
  673. {
  674. "colider",
  675. "value"
  676. });
  677. string a = tagData.GetTagProperty("colider").AsString();
  678. float num = tagData.GetTagProperty("value").AsReal();
  679. string text = (!tagData.IsValid("srcbone")) ? string.Empty : tagData.GetTagProperty("srcbone").AsString();
  680. if (tagData.IsValid("src"))
  681. {
  682. Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString());
  683. if (!maidAndMan)
  684. {
  685. return false;
  686. }
  687. if (a == "floor")
  688. {
  689. if (string.IsNullOrEmpty(text))
  690. {
  691. maidAndMan.body0.fullBodyIK.floorColliderEnable = true;
  692. maidAndMan.body0.fullBodyIK.floorColliderY = num;
  693. }
  694. else
  695. {
  696. NativePlaneCollider floorCollider = maidAndMan.body0.fullBodyIK.GetFloorCollider(text);
  697. if (floorCollider)
  698. {
  699. floorCollider.enabled = true;
  700. floorCollider.status.center.y = num;
  701. }
  702. }
  703. }
  704. else if (string.IsNullOrEmpty(text))
  705. {
  706. maidAndMan.body0.fullBodyIK.wallColliderEnable = true;
  707. maidAndMan.body0.fullBodyIK.wallColliderZ = num;
  708. maidAndMan.fullBodyIK.wallDirectionInverse = (a == "wallfront");
  709. }
  710. else
  711. {
  712. NativePlaneCollider wallCollider = maidAndMan.body0.fullBodyIK.GetWallCollider(text);
  713. if (wallCollider)
  714. {
  715. wallCollider.enabled = true;
  716. wallCollider.status.center.z = num;
  717. wallCollider.planeStatus.isDirectionInverse = (a == "wallfront");
  718. }
  719. }
  720. }
  721. else
  722. {
  723. for (int i = 0; i < GameMain.Instance.CharacterMgr.GetMaidCount(); i++)
  724. {
  725. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(i);
  726. if (maid)
  727. {
  728. if (a == "floor")
  729. {
  730. if (string.IsNullOrEmpty(text))
  731. {
  732. maid.body0.fullBodyIK.floorColliderEnable = true;
  733. maid.body0.fullBodyIK.floorColliderY = num;
  734. }
  735. else
  736. {
  737. NativePlaneCollider floorCollider2 = maid.body0.fullBodyIK.GetFloorCollider(text);
  738. if (floorCollider2)
  739. {
  740. floorCollider2.enabled = true;
  741. floorCollider2.status.center.y = num;
  742. }
  743. }
  744. }
  745. else if (string.IsNullOrEmpty(text))
  746. {
  747. maid.body0.fullBodyIK.wallColliderEnable = true;
  748. maid.body0.fullBodyIK.wallColliderZ = num;
  749. maid.fullBodyIK.wallDirectionInverse = (a == "wallfront");
  750. }
  751. else
  752. {
  753. NativePlaneCollider wallCollider2 = maid.body0.fullBodyIK.GetWallCollider(text);
  754. if (wallCollider2)
  755. {
  756. wallCollider2.enabled = true;
  757. wallCollider2.status.center.z = num;
  758. wallCollider2.planeStatus.isDirectionInverse = (a == "wallfront");
  759. }
  760. }
  761. }
  762. }
  763. for (int j = 0; j < GameMain.Instance.CharacterMgr.GetManCount(); j++)
  764. {
  765. Maid man = GameMain.Instance.CharacterMgr.GetMan(j);
  766. if (man)
  767. {
  768. if (a == "floor")
  769. {
  770. if (string.IsNullOrEmpty(text))
  771. {
  772. man.body0.fullBodyIK.floorColliderEnable = true;
  773. man.body0.fullBodyIK.floorColliderY = num;
  774. }
  775. else
  776. {
  777. NativePlaneCollider floorCollider3 = man.body0.fullBodyIK.GetFloorCollider(text);
  778. if (floorCollider3)
  779. {
  780. floorCollider3.enabled = true;
  781. floorCollider3.status.center.y = num;
  782. }
  783. }
  784. }
  785. else if (string.IsNullOrEmpty(text))
  786. {
  787. man.body0.fullBodyIK.wallColliderEnable = true;
  788. man.body0.fullBodyIK.wallColliderZ = num;
  789. man.fullBodyIK.wallDirectionInverse = (a == "wallfront");
  790. }
  791. else
  792. {
  793. NativePlaneCollider wallCollider3 = man.body0.fullBodyIK.GetWallCollider(text);
  794. if (wallCollider3)
  795. {
  796. wallCollider3.enabled = true;
  797. wallCollider3.status.center.z = num;
  798. wallCollider3.planeStatus.isDirectionInverse = (a == "wallfront");
  799. }
  800. }
  801. }
  802. }
  803. }
  804. return false;
  805. }
  806. public bool TagIKColiderCorrect(KagTagSupport tagData)
  807. {
  808. base.CheckAbsolutelyNecessaryTag(tagData, "ikcolidercorrect", new string[]
  809. {
  810. "src",
  811. "srcbone",
  812. "correcttype"
  813. });
  814. Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString());
  815. if (!maidAndMan)
  816. {
  817. return false;
  818. }
  819. ALimbIKCtrl ikctrl = maidAndMan.body0.fullBodyIK.GetIKCtrl<ALimbIKCtrl>(tagData.GetTagProperty("srcbone").AsString());
  820. if (!ikctrl)
  821. {
  822. return false;
  823. }
  824. ikctrl.correctType = (ALimbIKCtrl.BorderCorrectType)Enum.Parse(typeof(ALimbIKCtrl.BorderCorrectType), tagData.GetTagProperty("correcttype").AsString());
  825. return false;
  826. }
  827. public bool TagIKColiderEnable(KagTagSupport tagData)
  828. {
  829. base.CheckAbsolutelyNecessaryTag(tagData, "ikcoliderenable", new string[]
  830. {
  831. "src",
  832. "srcbone"
  833. });
  834. Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString());
  835. if (!maidAndMan)
  836. {
  837. return false;
  838. }
  839. ALimbIKCtrl ikctrl = maidAndMan.body0.fullBodyIK.GetIKCtrl<ALimbIKCtrl>(tagData.GetTagProperty("srcbone").AsString());
  840. if (!ikctrl)
  841. {
  842. return false;
  843. }
  844. ikctrl.colliderEnable = tagData.IsValid("on");
  845. return false;
  846. }
  847. public bool TagIKColiderTarget(KagTagSupport tagData)
  848. {
  849. base.CheckAbsolutelyNecessaryTag(tagData, "ikcolidertarget", new string[]
  850. {
  851. "src",
  852. "srcbone",
  853. "target",
  854. "targetbone"
  855. });
  856. Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString());
  857. Maid maidAndMan2 = base.GetMaidAndMan(tagData.GetTagProperty("target").AsString());
  858. if (!maidAndMan || !maidAndMan2)
  859. {
  860. return false;
  861. }
  862. string tag_name = IKScriptHelper.ConvertColliderNameToIKName(tagData.GetTagProperty("srcbone").AsString());
  863. ALimbIKCtrl ikctrl = maidAndMan.fullBodyIK.GetIKCtrl<ALimbIKCtrl>(tag_name);
  864. string tag_name2 = IKScriptHelper.ConvertColliderNameToIKName(tagData.GetTagProperty("targetbone").AsString());
  865. ALimbIKCtrl ikctrl2 = maidAndMan2.fullBodyIK.GetIKCtrl<ALimbIKCtrl>(tag_name2);
  866. if (!ikctrl || !ikctrl2)
  867. {
  868. return false;
  869. }
  870. ikctrl.AddHitCheckLimb(ikctrl2);
  871. return false;
  872. }
  873. public bool TagIKCrossColider(KagTagSupport tagData)
  874. {
  875. base.CheckAbsolutelyNecessaryTag(tagData, "ikcrosscolider", new string[]
  876. {
  877. "src",
  878. "body"
  879. });
  880. Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString());
  881. if (!maidAndMan)
  882. {
  883. return false;
  884. }
  885. string a = tagData.GetTagProperty("body").AsString();
  886. if (a == "上半身")
  887. {
  888. maidAndMan.fullBodyIK.upperBorderEnable = true;
  889. }
  890. else if (a == "下半身")
  891. {
  892. maidAndMan.fullBodyIK.lowerBorderEnable = true;
  893. }
  894. return false;
  895. }
  896. public bool TagSetPartner(KagTagSupport tagData)
  897. {
  898. base.CheckAbsolutelyNecessaryTag(tagData, "setpartner", new string[]
  899. {
  900. "partnerlist"
  901. });
  902. string[] array = tagData.GetTagProperty("partnerlist").AsString().Split(new char[]
  903. {
  904. ','
  905. });
  906. if (array.Length <= 1)
  907. {
  908. Debug.LogError("@setpartnerはキャラクターを2人以上指定してください");
  909. return false;
  910. }
  911. for (int i = 0; i < array.Length; i++)
  912. {
  913. Maid maidAndMan = base.GetMaidAndMan(array[i]);
  914. if (maidAndMan)
  915. {
  916. for (int j = i + 1; j < array.Length; j++)
  917. {
  918. Maid maidAndMan2 = base.GetMaidAndMan(array[j]);
  919. if (maidAndMan2)
  920. {
  921. maidAndMan.body0.fullBodyIK.AddPartner(maidAndMan2, true);
  922. }
  923. }
  924. }
  925. }
  926. return false;
  927. }
  928. private bool TagKupaTimer(KagTagSupport tagData)
  929. {
  930. base.CheckAbsolutelyNecessaryTag(tagData, "kupatimer", new string[]
  931. {
  932. "maid",
  933. "morph",
  934. "move",
  935. "time"
  936. });
  937. Maid maid = this.GetMaid(tagData.GetTagProperty("maid").AsInteger());
  938. if (!maid)
  939. {
  940. return false;
  941. }
  942. AutoKupaCtrl.MorphType morph_type = (AutoKupaCtrl.MorphType)Enum.Parse(typeof(AutoKupaCtrl.MorphType), tagData.GetTagProperty("morph").AsString());
  943. AutoKupaCtrl kupaCtrl = maid.body0.GetKupaCtrl(morph_type);
  944. AutoKupaCtrl.KupaType kupa_type = (AutoKupaCtrl.KupaType)Enum.Parse(typeof(AutoKupaCtrl.KupaType), tagData.GetTagProperty("move").AsString());
  945. float kupa_time = MathUtility.MillisecondToSecond(tagData.GetTagProperty("time").AsInteger());
  946. float wait = 0f;
  947. if (tagData.IsValid("wait"))
  948. {
  949. wait = MathUtility.MillisecondToSecond(tagData.GetTagProperty("wait").AsInteger());
  950. }
  951. float kupaSpeed = (!tagData.IsValid("kupaspeed")) ? 1f : MathUtility.PercentageToRatio(tagData.GetTagProperty("kupaspeed").AsInteger(), false);
  952. float morphValueMax = (!tagData.IsValid("kupamax")) ? 1f : MathUtility.PercentageToRatio(tagData.GetTagProperty("kupamax").AsInteger(), false);
  953. kupaCtrl.kupaSpeed = kupaSpeed;
  954. kupaCtrl.morphValueMax = morphValueMax;
  955. kupaCtrl.SetKupaTimer(kupa_type, kupa_time, wait);
  956. return false;
  957. }
  958. private bool TagKupaInsert(KagTagSupport tagData)
  959. {
  960. base.CheckAbsolutelyNecessaryTag(tagData, "kupainsert", new string[]
  961. {
  962. "maid",
  963. "morph",
  964. "target",
  965. "insert",
  966. "insertaxis"
  967. });
  968. Maid maid = this.GetMaid(tagData.GetTagProperty("maid").AsInteger());
  969. if (!maid)
  970. {
  971. return false;
  972. }
  973. AutoKupaCtrl.MorphType morph_type = (AutoKupaCtrl.MorphType)Enum.Parse(typeof(AutoKupaCtrl.MorphType), tagData.GetTagProperty("morph").AsString());
  974. AutoKupaCtrl kupaCtrl = maid.body0.GetKupaCtrl(morph_type);
  975. Vector3 insert_axis = MathUtility.Vec3Parse(tagData.GetTagProperty("insertaxis").AsString(), ',');
  976. kupaCtrl.morphInsert.kupaSpeedIn = (kupaCtrl.morphInsert.kupaSpeedOut = 1f);
  977. kupaCtrl.SetInsertParamFromScript(tagData);
  978. string text = tagData.GetTagProperty("target").AsString();
  979. if (text == "bgitem")
  980. {
  981. string item_name = tagData.GetTagProperty("insert").AsString();
  982. kupaCtrl.SetKupaInsertFromBgItem(item_name, insert_axis);
  983. }
  984. else
  985. {
  986. Maid maidAndMan = base.GetMaidAndMan(text);
  987. if (!maidAndMan)
  988. {
  989. return false;
  990. }
  991. AutoKupaCtrl.InsertObjType insert = (AutoKupaCtrl.InsertObjType)Enum.Parse(typeof(AutoKupaCtrl.InsertObjType), tagData.GetTagProperty("insert").AsString());
  992. kupaCtrl.SetKupaInsert(insert, maidAndMan.body0, insert_axis);
  993. }
  994. return false;
  995. }
  996. private bool TagShoulderTwistCalc(KagTagSupport tagData)
  997. {
  998. base.CheckAbsolutelyNecessaryTag(tagData, "shouldertwistcalc", new string[]
  999. {
  1000. "src",
  1001. "calctype"
  1002. });
  1003. Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString());
  1004. ShoulderTwist.CalcType calc_mode = (ShoulderTwist.CalcType)Enum.Parse(typeof(ShoulderTwist.CalcType), tagData.GetTagProperty("calctype").AsString());
  1005. if (tagData.IsValid("shoulder"))
  1006. {
  1007. bool is_left = tagData.GetTagProperty("shoulder").AsString() == "left";
  1008. maidAndMan.body0.SetShoulderTwistCalcType(is_left, calc_mode);
  1009. }
  1010. else
  1011. {
  1012. maidAndMan.body0.SetShoulderTwistCalcType(true, calc_mode);
  1013. maidAndMan.body0.SetShoulderTwistCalcType(false, calc_mode);
  1014. }
  1015. return false;
  1016. }
  1017. private bool TagMotionOffset(KagTagSupport tagData)
  1018. {
  1019. base.CheckAbsolutelyNecessaryTag(tagData, "motionoffset", new string[]
  1020. {
  1021. "target"
  1022. });
  1023. if (!tagData.IsValid("set") && !tagData.IsValid("add"))
  1024. {
  1025. Debug.LogError("@motionoffset:数値指定がありません");
  1026. return false;
  1027. }
  1028. Maid src_chara = null;
  1029. if (tagData.IsValid("src"))
  1030. {
  1031. src_chara = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString());
  1032. }
  1033. string[] array = tagData.GetTagProperty("target").AsString().Split(new char[]
  1034. {
  1035. ','
  1036. });
  1037. Func<string, Maid, Vector3> func = delegate(string tag, Maid chara)
  1038. {
  1039. Vector3 result = Vector3.zero;
  1040. string text = tagData.GetTagProperty(tag).AsString();
  1041. if (text.Contains("min") && text.Contains("max"))
  1042. {
  1043. string[] array3 = text.Split(new char[]
  1044. {
  1045. ':'
  1046. });
  1047. MaidProp maidProp = null;
  1048. try
  1049. {
  1050. MPN mpn = (MPN)Enum.Parse(typeof(MPN), array3[0]);
  1051. maidProp = ((!(src_chara != null)) ? chara.GetProp(mpn) : src_chara.GetProp(mpn));
  1052. }
  1053. catch
  1054. {
  1055. Debug.LogError("エディットのパラメータが指定されてません");
  1056. return result;
  1057. }
  1058. Vector3 a = MathUtility.Vec3Parse(array3[1].Split(new char[]
  1059. {
  1060. '='
  1061. })[1], ',');
  1062. Vector3 b2 = MathUtility.Vec3Parse(array3[2].Split(new char[]
  1063. {
  1064. '='
  1065. })[1], ',');
  1066. if (maidProp.value > maidProp.value_Default)
  1067. {
  1068. float t = Mathf.InverseLerp((float)maidProp.value_Default, (float)maidProp.max, (float)maidProp.value);
  1069. result = Vector3.Lerp(Vector3.zero, b2, t);
  1070. }
  1071. else if (maidProp.value < maidProp.value_Default)
  1072. {
  1073. float t2 = Mathf.InverseLerp((float)maidProp.min, (float)maidProp.value_Default, (float)maidProp.value);
  1074. result = Vector3.Lerp(a, Vector3.zero, t2);
  1075. }
  1076. return result;
  1077. }
  1078. result = MathUtility.Vec3Parse(text, ',');
  1079. return result;
  1080. };
  1081. foreach (string tag_str in array)
  1082. {
  1083. Maid maidAndMan = base.GetMaidAndMan(tag_str);
  1084. if (maidAndMan)
  1085. {
  1086. Vector3 motionOffsetGP = Vector3.zero;
  1087. Vector3 b = Vector3.zero;
  1088. bool flag = tagData.IsValid("set");
  1089. if (flag)
  1090. {
  1091. motionOffsetGP = func("set", maidAndMan);
  1092. }
  1093. if (tagData.IsValid("add"))
  1094. {
  1095. b = func("add", maidAndMan);
  1096. }
  1097. if (flag)
  1098. {
  1099. maidAndMan.motionOffsetGP03 = motionOffsetGP;
  1100. }
  1101. maidAndMan.motionOffsetGP03 += b;
  1102. }
  1103. }
  1104. return false;
  1105. }
  1106. private bool TagAutoOffset(KagTagSupport tagData)
  1107. {
  1108. base.CheckAbsolutelyNecessaryTag(tagData, "autooffset", new string[]
  1109. {
  1110. "target"
  1111. });
  1112. if (!tagData.IsValid("set") && !tagData.IsValid("add"))
  1113. {
  1114. Debug.LogError("@motionoffset:数値指定がありません");
  1115. return false;
  1116. }
  1117. string[] array = tagData.GetTagProperty("target").AsString().Split(new char[]
  1118. {
  1119. ','
  1120. });
  1121. bool flag = GameMain.Instance.CMSystem.GetTmpGenericFlag("AddAllOffset_Ignore") == 1;
  1122. Func<string, Maid, Vector3> func = delegate(string tag, Maid chara)
  1123. {
  1124. Vector3 result = Vector3.zero;
  1125. string text = tagData.GetTagProperty(tag).AsString();
  1126. if (text.Contains("min") && text.Contains("max"))
  1127. {
  1128. string[] array3 = text.Split(new char[]
  1129. {
  1130. ':'
  1131. });
  1132. MaidProp maidProp = null;
  1133. try
  1134. {
  1135. MPN mpn = (MPN)Enum.Parse(typeof(MPN), array3[0]);
  1136. maidProp = chara.GetProp(mpn);
  1137. }
  1138. catch
  1139. {
  1140. Debug.LogError("エディットのパラメータが指定されてません");
  1141. return result;
  1142. }
  1143. Vector3 a = MathUtility.Vec3Parse(array3[1].Split(new char[]
  1144. {
  1145. '='
  1146. })[1], ',');
  1147. Vector3 b = MathUtility.Vec3Parse(array3[2].Split(new char[]
  1148. {
  1149. '='
  1150. })[1], ',');
  1151. if (maidProp.value > maidProp.value_Default)
  1152. {
  1153. float t = Mathf.InverseLerp((float)maidProp.value_Default, (float)maidProp.max, (float)maidProp.value);
  1154. result = Vector3.Lerp(Vector3.zero, b, t);
  1155. }
  1156. else if (maidProp.value < maidProp.value_Default)
  1157. {
  1158. float t2 = Mathf.InverseLerp((float)maidProp.min, (float)maidProp.value_Default, (float)maidProp.value);
  1159. result = Vector3.Lerp(a, Vector3.zero, t2);
  1160. }
  1161. return result;
  1162. }
  1163. result = MathUtility.Vec3Parse(text, ',');
  1164. return result;
  1165. };
  1166. foreach (string tag_str in array)
  1167. {
  1168. Maid maidAndMan = base.GetMaidAndMan(tag_str);
  1169. if (maidAndMan)
  1170. {
  1171. Vector3 vector = Vector3.zero;
  1172. Vector3 vector2 = Vector3.zero;
  1173. bool flag2 = tagData.IsValid("set");
  1174. if (flag2)
  1175. {
  1176. vector = func("set", maidAndMan);
  1177. }
  1178. if (tagData.IsValid("add"))
  1179. {
  1180. vector2 = func("add", maidAndMan);
  1181. }
  1182. if (flag)
  1183. {
  1184. vector = -vector;
  1185. vector2 = -vector2;
  1186. if (flag2)
  1187. {
  1188. maidAndMan.fullBodyIK.floorColliderY = vector.y;
  1189. maidAndMan.fullBodyIK.wallColliderZ = vector.z;
  1190. }
  1191. maidAndMan.fullBodyIK.floorColliderY += vector2.y;
  1192. maidAndMan.fullBodyIK.wallColliderZ += vector2.z;
  1193. }
  1194. else
  1195. {
  1196. if (flag2)
  1197. {
  1198. maidAndMan.motionOffsetGP03 = vector;
  1199. }
  1200. maidAndMan.motionOffsetGP03 += vector2;
  1201. }
  1202. }
  1203. }
  1204. return false;
  1205. }
  1206. private bool TagInverseOffset(KagTagSupport tagData)
  1207. {
  1208. base.CheckAbsolutelyNecessaryTag(tagData, "inverseoffset", new string[]
  1209. {
  1210. "target"
  1211. });
  1212. if (GameMain.Instance.CMSystem.GetTmpGenericFlag("AddAllOffset_Ignore") != 1)
  1213. {
  1214. return false;
  1215. }
  1216. string[] array = tagData.GetTagProperty("target").AsString().Split(new char[]
  1217. {
  1218. ','
  1219. });
  1220. Vector3 vector = Vector3.zero;
  1221. if (tagData.IsValid("y"))
  1222. {
  1223. vector.y = tagData.GetTagProperty("y").AsReal();
  1224. }
  1225. vector = -vector;
  1226. foreach (string tag_str in array)
  1227. {
  1228. Maid maidAndMan = base.GetMaidAndMan(tag_str);
  1229. if (maidAndMan)
  1230. {
  1231. maidAndMan.motionOffsetGP03 = vector;
  1232. maidAndMan.fullBodyIK.floorColliderY = vector.y;
  1233. maidAndMan.fullBodyIK.wallColliderZ = vector.z;
  1234. }
  1235. }
  1236. return false;
  1237. }
  1238. private bool TagSetIKOrder(KagTagSupport tagData)
  1239. {
  1240. base.CheckAbsolutelyNecessaryTag(tagData, "setikorder", new string[]
  1241. {
  1242. "order"
  1243. });
  1244. string[] array = tagData.GetTagProperty("order").AsString().Split(new char[]
  1245. {
  1246. ','
  1247. });
  1248. if (array.Length <= 1)
  1249. {
  1250. Debug.LogError("@setikorderはキャラクターを2人以上指定してください");
  1251. return false;
  1252. }
  1253. for (int i = 0; i < array.Length; i++)
  1254. {
  1255. Maid maidAndMan = base.GetMaidAndMan(array[i]);
  1256. if (maidAndMan)
  1257. {
  1258. maidAndMan.body0.fullBodyIK.ikExecOrder = i;
  1259. }
  1260. }
  1261. return false;
  1262. }
  1263. private bool TagSetBeroMorph(KagTagSupport tagData)
  1264. {
  1265. base.CheckAbsolutelyNecessaryTag(tagData, "setberomorph", new string[]
  1266. {
  1267. "target"
  1268. });
  1269. Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("target").AsString());
  1270. TongueCtrl tongueCtrl = maidAndMan.body0.Face.tongueCtrl;
  1271. if (tongueCtrl == null)
  1272. {
  1273. return false;
  1274. }
  1275. tongueCtrl.isEnable = true;
  1276. tongueCtrl.BlendStatusReset();
  1277. if (tagData.IsValid("blend"))
  1278. {
  1279. tongueCtrl.blendTime = MathUtility.MillisecondToSecond(tagData.GetTagProperty("blend").AsInteger());
  1280. }
  1281. foreach (TongueCtrl.FaceMorph morph in TongueCtrl.TongueUseMorph)
  1282. {
  1283. string morphName = tongueCtrl.GetMorphData(morph).morphName;
  1284. if (tagData.IsValid(morphName))
  1285. {
  1286. float value = MathUtility.PercentageToRatio(tagData.GetTagProperty(morphName).AsInteger(), false);
  1287. tongueCtrl.SetTargetValue(morph, value);
  1288. }
  1289. }
  1290. return false;
  1291. }
  1292. private bool TagSetMaidOffsetMultiPos2(KagTagSupport tag_data)
  1293. {
  1294. if (this.valid_pos)
  1295. {
  1296. base.TagSetMaidOffsetMultiPos(tag_data);
  1297. }
  1298. return false;
  1299. }
  1300. private bool TagMotAllProcPropSeqStart(KagTagSupport tag_data)
  1301. {
  1302. Maid maidAndMan = base.GetMaidAndMan(tag_data, true);
  1303. if (maidAndMan == null)
  1304. {
  1305. return false;
  1306. }
  1307. if (tag_data.IsValid("fix"))
  1308. {
  1309. maidAndMan.AllProcProp();
  1310. }
  1311. else
  1312. {
  1313. NDebug.Assert(!this.script_mgr_.is_motion_all_prop_seq, "MotionKagManager AllProcPropSeqStart error.");
  1314. this.script_mgr_.is_motion_all_prop_seq = true;
  1315. this.script_mgr_.motion_all_prop_seq_maid = maidAndMan;
  1316. }
  1317. return false;
  1318. }
  1319. private bool TagMotFace(KagTagSupport tag_data)
  1320. {
  1321. return !this.face_fix_ && base.TagFace(tag_data);
  1322. }
  1323. private bool TagMotFaceBlend(KagTagSupport tag_data)
  1324. {
  1325. return !this.face_fix_ && base.TagFaceBlend(tag_data);
  1326. }
  1327. public void SetNextMotion(bool is_next)
  1328. {
  1329. this.next_flag_ = is_next;
  1330. }
  1331. public void SetFaceFix(bool is_fix)
  1332. {
  1333. this.face_fix_ = is_fix;
  1334. }
  1335. protected override void PlayMaidMotion(Maid maid, string fn, bool additive = false, bool loop = false, bool boAddQue = false, float val = 0.5f)
  1336. {
  1337. if (this.next_flag_)
  1338. {
  1339. boAddQue = true;
  1340. this.next_flag_ = false;
  1341. }
  1342. base.PlayMaidMotion(maid, fn, additive, loop, boAddQue, val);
  1343. if (!maid.boMAN && !boAddQue && 0 <= maid.ActiveSlotNo && maid.ActiveSlotNo < this.last_maid_motion_set_log_.Length)
  1344. {
  1345. this.last_maid_motion_set_log_[maid.ActiveSlotNo] = fn.ToLower();
  1346. }
  1347. else if (maid.boMAN && !boAddQue && 0 <= maid.ActiveSlotNo && maid.ActiveSlotNo < this.last_man_motion_set_log_.Length)
  1348. {
  1349. this.last_man_motion_set_log_[maid.ActiveSlotNo] = fn.ToLower();
  1350. }
  1351. }
  1352. public void ClearMotion()
  1353. {
  1354. this.exec_wait_data_.Clear();
  1355. this.wait_event_list_.Clear();
  1356. }
  1357. public void SetSloatNo(int no)
  1358. {
  1359. this.sloat_no_ = no;
  1360. }
  1361. public override string GetKagClassName()
  1362. {
  1363. return "モーションkag : " + this.sloat_no_.ToString();
  1364. }
  1365. public override Maid GetMaid(int no)
  1366. {
  1367. if (no == 0 && this.main_maid_ != null)
  1368. {
  1369. return this.main_maid_;
  1370. }
  1371. return base.GetMaid(no);
  1372. }
  1373. public override Maid GetMan(int man_no)
  1374. {
  1375. if (man_no == 0 && this.main_man_ != null)
  1376. {
  1377. return this.main_man_;
  1378. }
  1379. return base.GetMan(man_no);
  1380. }
  1381. public bool valid_pos
  1382. {
  1383. get
  1384. {
  1385. return this.valid_pos_;
  1386. }
  1387. set
  1388. {
  1389. this.valid_pos_ = value;
  1390. }
  1391. }
  1392. public Maid main_maid
  1393. {
  1394. get
  1395. {
  1396. return this.main_maid_;
  1397. }
  1398. }
  1399. public Maid main_man
  1400. {
  1401. get
  1402. {
  1403. return this.main_man_;
  1404. }
  1405. }
  1406. public string[] last_maid_motion_set_log
  1407. {
  1408. get
  1409. {
  1410. return this.last_maid_motion_set_log_;
  1411. }
  1412. }
  1413. public string[] last_man_motion_set_log
  1414. {
  1415. get
  1416. {
  1417. return this.last_man_motion_set_log_;
  1418. }
  1419. }
  1420. private const string COMMON_SETTING_LABEL = "*共通";
  1421. private List<Maid> ActiveMaidList = new List<Maid>();
  1422. private List<Maid> ActiveManList = new List<Maid>();
  1423. public const string MOTIONSCRIPT_META_FILE = "motionscript.msmeta";
  1424. private Dictionary<string, MotionKagManager.MotionScriptMeta> MotionScriptMetaDic = new Dictionary<string, MotionKagManager.MotionScriptMeta>();
  1425. private MotionKagManager.MotionScriptMeta CurrentScriptMeta;
  1426. public bool isBodyMixOK;
  1427. private int sloat_no_;
  1428. private bool next_flag_;
  1429. private bool face_fix_;
  1430. private Maid main_maid_;
  1431. private Maid main_man_;
  1432. private bool valid_pos_ = true;
  1433. protected string[] last_maid_motion_set_log_ = new string[6];
  1434. protected string[] last_man_motion_set_log_ = new string[6];
  1435. [Serializable]
  1436. public class MotionScriptMetaPackage
  1437. {
  1438. public List<MotionKagManager.MotionScriptMeta> metaList = new List<MotionKagManager.MotionScriptMeta>();
  1439. }
  1440. [Serializable]
  1441. public class MotionScriptMeta
  1442. {
  1443. public string scriptName;
  1444. public int maidCount;
  1445. public int manCount;
  1446. }
  1447. }