TBodySkin.cs 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Text.RegularExpressions;
  6. using UnityEngine;
  7. public class TBodySkin
  8. {
  9. public TBodySkin(TBody body_, string cate_, TBody.SlotID slot_id_, bool man, int subNo = 0)
  10. {
  11. this.boVisible = true;
  12. this.crcPartHideVisible = true;
  13. this.body = body_;
  14. this.Category = cate_;
  15. this.SlotId = slot_id_;
  16. this.m_bMan = man;
  17. this.m_subNo = subNo;
  18. this.m_trMaid = this.body.maid.transform;
  19. this.m_trMaidOffs = this.body.maid.m_goOffset.transform;
  20. this.MaterialMgr = new MaterialMgr(this);
  21. this.dbManager = new DynamicBoneMgr(body_, this);
  22. this.bonehair = new TBoneHair_(this);
  23. this.TextureCache = new InfinityColorTextureCache(body_.maid);
  24. this.bonehair2 = new BoneHair2(this);
  25. this.bonehair3 = new BoneHair3(this);
  26. this.m_HairLengthCtrl = new TBodySkin.HairLengthCtrl(this);
  27. }
  28. public void AddRtMaterial(Material f_mat)
  29. {
  30. this.m_listRtMaterial.Add(f_mat);
  31. }
  32. public DynamicBoneMgr dbManager { get; private set; }
  33. public int PartsVersion
  34. {
  35. get
  36. {
  37. return this.m_partsVersion;
  38. }
  39. }
  40. public KupaCtrl kupaCtrl { get; private set; }
  41. public MaterialMgr MaterialMgr { get; private set; }
  42. public bool IsCRC
  43. {
  44. get
  45. {
  46. return this.m_IsCrcImported || 200 <= this.m_partsVersion;
  47. }
  48. }
  49. public TongueCtrl tongueCtrl { get; private set; }
  50. public void DelItem()
  51. {
  52. if (this.m_pairSlotIds != null)
  53. {
  54. foreach (TBody.SlotID f_nSlotNo in this.m_pairSlotIds)
  55. {
  56. this.body.GetSlot((int)f_nSlotNo, this.m_subNo).DelItem();
  57. }
  58. }
  59. this.DeleteObj(true);
  60. }
  61. public void DeleteObj(bool fromDelItem = false)
  62. {
  63. this.m_ParentMPN = MPN.null_mpn;
  64. this.m_mp = null;
  65. this.RID = 0;
  66. this.SyojiType = 0;
  67. this.m_animItem = null;
  68. this.MaterialMgr.Remove();
  69. this.m_isHiheel = false;
  70. this.m_chikubiState = TBodySkin.CHIKUBI_STATE.None;
  71. if (this.dbManager != null)
  72. {
  73. this.dbManager.UnInit();
  74. }
  75. this.body.MulTexRemove(this.Category);
  76. this.TextureCache.RemoveTexture();
  77. this.m_listManAlphaMat.Clear();
  78. this.m_HairLengthCtrl.NotExistThenClearHairLength();
  79. this.listTrs = null;
  80. this.listTrsScr = null;
  81. foreach (UnityEngine.Object @object in this.listDEL)
  82. {
  83. UnityEngine.Object.DestroyImmediate(@object);
  84. }
  85. this.listDEL = new List<UnityEngine.Object>();
  86. this.boMizugi = false;
  87. if (this.morph != null)
  88. {
  89. this.morph.DeleteObj();
  90. this.morph = null;
  91. }
  92. if (this.IsCRC && this.SlotId != TBody.SlotID.body)
  93. {
  94. this.body.RemoveBaseBlendValue(this.SlotId);
  95. }
  96. this.boVisible = false;
  97. this.crcPartHideVisible = false;
  98. this.listMaskSlot = new List<int>();
  99. this.m_dicBackupShader.Clear();
  100. if (this.bonehair != null)
  101. {
  102. this.bonehair.Init();
  103. }
  104. if (this.bonehair2 != null)
  105. {
  106. this.bonehair2.Uninit();
  107. }
  108. if (this.bonehair3 != null)
  109. {
  110. this.bonehair3.Uninit();
  111. }
  112. if (this.obj != null)
  113. {
  114. this.obj_tr.parent = null;
  115. UnityEngine.Object.DestroyImmediate(this.obj);
  116. this.obj = null;
  117. this.obj_tr = null;
  118. }
  119. if (this.m_myBoneMorphs != null)
  120. {
  121. this.m_myBoneMorphs = null;
  122. }
  123. this.m_dicDelNodeParts.Clear();
  124. if (this.m_goCenter != null)
  125. {
  126. UnityEngine.Object.Destroy(this.m_goCenter);
  127. this.m_goCenter = null;
  128. }
  129. if (this.m_copyRoot != null)
  130. {
  131. UnityEngine.Object.Destroy(this.m_copyRoot[0].Item2.gameObject);
  132. this.m_copyRoot = null;
  133. }
  134. if (this.m_copyObjTr != null)
  135. {
  136. UnityEngine.Object.Destroy(this.m_copyObjTr);
  137. this.m_copyObjTr = null;
  138. }
  139. this.m_NewAttachRealSlot = TBody.SlotID.end;
  140. this.m_dicParam.Clear();
  141. this.m_dicParam2.Clear();
  142. this.m_OriVert.Clear();
  143. this.m_ParentMPN = MPN.null_mpn;
  144. this.m_mp = null;
  145. this.m_bHitFloorY = true;
  146. this.kupaCtrl = null;
  147. if (!string.IsNullOrEmpty(this.m_AttachName))
  148. {
  149. TMorphSkin tmorphSkin = this.body.GetSlot(this.m_AttachSlotIdx, this.m_AttachSlotSubIdx).morph as TMorphSkin;
  150. if (tmorphSkin != null)
  151. {
  152. tmorphSkin.RemoveNewAttachPoint(this.m_AttachName);
  153. }
  154. }
  155. this.m_attachType = TBodySkin.ATTACH_TYPE.NONE;
  156. this.m_trsBoneAttach = null;
  157. this.m_BackAttachName = (this.m_AttachName = null);
  158. this.m_BackAttachSlotIdx = (this.m_AttachSlotIdx = 0);
  159. this.m_BackAttachSlotSubIdx = (this.m_AttachSlotSubIdx = 0);
  160. this.m_boneAttachEdited = false;
  161. this.m_savedAttachPos = null;
  162. this.m_BackBones = null;
  163. if (this.attachPosObj != null)
  164. {
  165. UnityEngine.Object.Destroy(this.attachPosObj);
  166. }
  167. if (this.IsCRC)
  168. {
  169. if (this.m_pairSlotIds != null)
  170. {
  171. if (!fromDelItem)
  172. {
  173. foreach (TBody.SlotID f_nSlotNo in this.m_pairSlotIds)
  174. {
  175. this.body.GetSlot((int)f_nSlotNo, this.m_subNo).DeleteObj(false);
  176. }
  177. }
  178. this.m_pairSlotIds = null;
  179. }
  180. this.m_dicDelNodeBody.Clear();
  181. }
  182. this.m_partsVersion = 0;
  183. this.m_IsCrcImported = false;
  184. }
  185. public void NewParamSet(string A)
  186. {
  187. string[] stringList = UTY.GetStringList(A);
  188. string key = stringList[1];
  189. int num = (stringList.Length - 2) / 2;
  190. KeyValuePair<float, string>[] array = new KeyValuePair<float, string>[num];
  191. for (int i = 0; i < num; i++)
  192. {
  193. string value = stringList[3 + i * 2];
  194. float key2 = float.Parse(stringList[2 + i * 2]);
  195. array[i] = new KeyValuePair<float, string>(key2, value);
  196. }
  197. this.dicParamSet[key] = array;
  198. }
  199. public void SetParam(string f_strTag, string f_strValue)
  200. {
  201. if (this.m_dicParam.ContainsKey(f_strTag))
  202. {
  203. this.m_dicParam[f_strTag] = f_strValue;
  204. }
  205. else
  206. {
  207. this.m_dicParam.Add(f_strTag, f_strValue);
  208. }
  209. }
  210. public string GetParam(string f_strTag)
  211. {
  212. string empty;
  213. this.m_dicParam.TryGetValue(f_strTag, out empty);
  214. if (empty == null)
  215. {
  216. empty = string.Empty;
  217. }
  218. return empty;
  219. }
  220. public void SetParam2(string f_strTag, string f_strValue)
  221. {
  222. if (this.m_dicParam2.ContainsKey(f_strTag))
  223. {
  224. this.m_dicParam2[f_strTag] = f_strValue;
  225. }
  226. else
  227. {
  228. this.m_dicParam2.Add(f_strTag, f_strValue);
  229. }
  230. }
  231. public string GetParam2(string f_strTag)
  232. {
  233. string empty;
  234. this.m_dicParam2.TryGetValue(f_strTag, out empty);
  235. if (empty == null)
  236. {
  237. empty = string.Empty;
  238. }
  239. return empty;
  240. }
  241. public void SetMaterialProperty(MPN f_SrcMpn, int f_nMatNo, string f_strPropName, string f_strTypeName, string f_strValue, bool f_bEditSave)
  242. {
  243. if (this.obj == null)
  244. {
  245. return;
  246. }
  247. foreach (Transform transform in this.obj.transform.GetComponentsInChildren<Transform>(true))
  248. {
  249. Renderer component = transform.GetComponent<Renderer>();
  250. if (component != null && component.material != null && f_nMatNo < component.materials.Length)
  251. {
  252. Material material = component.materials[f_nMatNo];
  253. if (f_strTypeName == "DEFINE")
  254. {
  255. if (f_strValue == "0")
  256. {
  257. material.DisableKeyword(f_strPropName);
  258. }
  259. else if (f_strValue == "1")
  260. {
  261. material.EnableKeyword(f_strPropName);
  262. }
  263. }
  264. else if (material.HasProperty(f_strPropName))
  265. {
  266. if (f_strTypeName == "Color")
  267. {
  268. string[] array = f_strValue.Split(new char[]
  269. {
  270. ':'
  271. });
  272. material.SetColor(f_strPropName, new Color(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]), float.Parse(array[3])));
  273. }
  274. else
  275. {
  276. material.SetFloat(f_strPropName, float.Parse(f_strValue));
  277. }
  278. if (f_bEditSave)
  279. {
  280. this.body.maid.SetMaterialProperty(f_SrcMpn, this.SlotId, f_nMatNo, f_strPropName, f_strTypeName, f_strValue);
  281. }
  282. else
  283. {
  284. MatPropSave materialProperty = this.body.maid.GetMaterialProperty(f_SrcMpn, this.SlotId);
  285. if (materialProperty != null)
  286. {
  287. this.SetMaterialProperty(f_SrcMpn, materialProperty.nMatNo, materialProperty.strPropName, materialProperty.strTypeName, materialProperty.strValue, true);
  288. }
  289. }
  290. }
  291. else
  292. {
  293. Debug.LogError(f_strPropName + "はありませんでした。");
  294. }
  295. }
  296. }
  297. }
  298. public string GetMaterialProperty(int f_nMatNo, string f_strPropName, string f_strType = "AUTO")
  299. {
  300. if (this.obj == null)
  301. {
  302. return string.Empty;
  303. }
  304. Transform[] componentsInChildren = this.obj.transform.GetComponentsInChildren<Transform>(true);
  305. int i = 0;
  306. while (i < componentsInChildren.Length)
  307. {
  308. Transform transform = componentsInChildren[i];
  309. Renderer component = transform.GetComponent<Renderer>();
  310. if (component != null && component.material != null && f_nMatNo < component.materials.Length)
  311. {
  312. Material material = component.materials[f_nMatNo];
  313. if (f_strType == "DEFINE")
  314. {
  315. return (!material.IsKeywordEnabled(f_strPropName)) ? "0" : "1";
  316. }
  317. if (f_strType == "Color")
  318. {
  319. Color color = material.GetColor(f_strPropName);
  320. return string.Concat(new string[]
  321. {
  322. color.r.ToString(),
  323. ":",
  324. color.g.ToString(),
  325. ":",
  326. color.b.ToString(),
  327. ":",
  328. color.a.ToString()
  329. });
  330. }
  331. return material.GetFloat(f_strPropName).ToString();
  332. }
  333. else
  334. {
  335. i++;
  336. }
  337. }
  338. return string.Empty;
  339. }
  340. public void ChangeShader(int f_nMatNo, string f_strShaderFileName)
  341. {
  342. this.ChangeShader(f_nMatNo, Resources.Load<Shader>("Shaders/" + f_strShaderFileName));
  343. }
  344. private void ChangeShader(int f_nMatNo, Shader f_shader)
  345. {
  346. GameObject gameObject = this.obj;
  347. if (gameObject == null)
  348. {
  349. return;
  350. }
  351. foreach (Transform transform in gameObject.transform.GetComponentsInChildren<Transform>(true))
  352. {
  353. Renderer component = transform.GetComponent<Renderer>();
  354. if (component != null && component.material != null && f_nMatNo < component.materials.Length)
  355. {
  356. if (!this.m_dicBackupShader.ContainsKey(f_nMatNo))
  357. {
  358. this.m_dicBackupShader[f_nMatNo] = component.materials[f_nMatNo].shader;
  359. }
  360. Material material = component.materials[f_nMatNo];
  361. int renderQueue = material.renderQueue;
  362. material.shader = f_shader;
  363. material.renderQueue = renderQueue;
  364. }
  365. }
  366. }
  367. public void RestoreShader()
  368. {
  369. foreach (KeyValuePair<int, Shader> keyValuePair in this.m_dicBackupShader)
  370. {
  371. this.ChangeShader(keyValuePair.Key, keyValuePair.Value);
  372. }
  373. this.m_dicBackupShader.Clear();
  374. }
  375. public float MayuThick
  376. {
  377. set
  378. {
  379. if (!this.m_bMan && this.SlotId == TBody.SlotID.head && 120 <= this.PartsVersion)
  380. {
  381. SkinnedMeshRenderer componentInChildren = this.obj.GetComponentInChildren<SkinnedMeshRenderer>();
  382. Material material = componentInChildren.materials[3];
  383. float num = 0.5f * (value - 0.5f) / -0.5f;
  384. material.SetTextureScale("_MainTex", new Vector2(1f, 1f + num));
  385. material.SetTextureOffset("_MainTex", new Vector2(0f, -(num / 2f)));
  386. }
  387. }
  388. }
  389. public bool EnablePartsPosEdit
  390. {
  391. get
  392. {
  393. return this.m_bEnablePartPosEdit;
  394. }
  395. set
  396. {
  397. if (this.m_bEnablePartPosEdit == value)
  398. {
  399. return;
  400. }
  401. if (value)
  402. {
  403. BoneAttachPos tbodySkinPos = this.body.maid.GetTBodySkinPos(this.m_ParentMPN, this.SlotId);
  404. if (tbodySkinPos != null && this.obj_tr != null)
  405. {
  406. Vector3 vector = tbodySkinPos.pss.position;
  407. this.obj_tr.localPosition = vector;
  408. this.m_vPosLocal = vector;
  409. Quaternion rotation = tbodySkinPos.pss.rotation;
  410. this.obj_tr.localRotation = rotation;
  411. this.m_qRotLocal = rotation;
  412. vector = tbodySkinPos.pss.scale;
  413. this.obj_tr.localScale = vector;
  414. this.m_vScaleRate = vector;
  415. }
  416. }
  417. else if (this.obj_tr != null)
  418. {
  419. this.obj_tr.localPosition = this.m_vDefPosLocal;
  420. this.obj_tr.localRotation = this.m_qDefRotLocal;
  421. this.obj_tr.localScale = this.m_vDefScaleLocal;
  422. }
  423. if (this.center_tr != null)
  424. {
  425. this.center_tr.localPosition = this.m_vCenterPosLocal;
  426. this.center_tr.localRotation = Quaternion.identity;
  427. this.center_tr.localScale = Vector3.one;
  428. }
  429. this.m_bEnablePartPosEdit = value;
  430. this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit);
  431. }
  432. }
  433. public bool GetAttachObjPointLocal(out Vector3 f_vPosLocal, out Quaternion f_vRotLocal, out Vector3 f_vScaleLocal)
  434. {
  435. f_vPosLocal = Vector3.zero;
  436. f_vRotLocal = Quaternion.identity;
  437. f_vScaleLocal = Vector3.zero;
  438. return false;
  439. }
  440. public bool SetAttachObjPointLocal(Vector3 f_vPosLocal, Quaternion f_vRotLocal, Vector3 f_vScaleLocal)
  441. {
  442. return false;
  443. }
  444. public bool CopyAttachObjPoint()
  445. {
  446. if (this.center_tr == null || this.obj_tr == null)
  447. {
  448. return false;
  449. }
  450. this.m_vTempAttachPointPos = this.obj_tr.localPosition;
  451. this.m_qTempAttachPointRot = this.obj_tr.localRotation;
  452. this.m_vTempAttachPointScale = this.obj_tr.localScale;
  453. return true;
  454. }
  455. public bool PastAttachObjPoint()
  456. {
  457. if (this.center_tr == null || this.obj_tr == null || !this.m_bEnablePartPosEdit)
  458. {
  459. return false;
  460. }
  461. Vector3 vector = this.m_vTempAttachPointPos;
  462. this.obj_tr.localPosition = vector;
  463. this.m_vPosLocal = vector;
  464. Quaternion qTempAttachPointRot = this.m_qTempAttachPointRot;
  465. this.obj_tr.localRotation = qTempAttachPointRot;
  466. this.m_qRotLocal = qTempAttachPointRot;
  467. vector = this.m_vTempAttachPointScale;
  468. this.obj_tr.localScale = vector;
  469. this.m_vScaleRate = vector;
  470. this.center_tr.localPosition = this.m_vCenterPosLocal;
  471. this.center_tr.localRotation = Quaternion.identity;
  472. this.center_tr.localScale = Vector3.one;
  473. this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit);
  474. return true;
  475. }
  476. public bool GetAttachCenterPointWorld(out Vector3 f_vPosWorld, out Quaternion f_vRotWorld, out Vector3 f_vScaleLocal)
  477. {
  478. if (this.center_tr == null)
  479. {
  480. f_vPosWorld = Vector3.zero;
  481. f_vRotWorld = Quaternion.identity;
  482. f_vScaleLocal = Vector3.zero;
  483. return false;
  484. }
  485. f_vPosWorld = this.center_tr.position;
  486. f_vRotWorld = this.center_tr.rotation;
  487. f_vScaleLocal = this.m_vScaleRate;
  488. return true;
  489. }
  490. public bool SetAttachCenterPointWorld(Vector3 f_vPosWorld, Quaternion f_vRotWorld, Vector3 f_vScaleLocal)
  491. {
  492. if (this.center_tr == null || !this.m_bEnablePartPosEdit)
  493. {
  494. return false;
  495. }
  496. Transform parent = this.center_tr.parent;
  497. Transform parent2 = this.obj_tr.parent;
  498. this.obj_tr.localPosition = (this.m_vPosLocal = this.m_vDefPosLocal);
  499. this.obj_tr.localRotation = (this.m_qRotLocal = this.m_qDefRotLocal);
  500. this.obj_tr.localScale = (this.m_vScaleRate = this.m_vDefScaleLocal);
  501. this.center_tr.localPosition = this.m_vCenterPosLocal;
  502. this.center_tr.localRotation = Quaternion.identity;
  503. this.center_tr.localScale = Vector3.one;
  504. this.center_tr.SetParent(this.obj_tr.parent, true);
  505. this.obj_tr.SetParent(this.center_tr, true);
  506. this.center_tr.position = f_vPosWorld;
  507. this.center_tr.rotation = f_vRotWorld;
  508. this.center_tr.localScale = f_vScaleLocal;
  509. this.obj_tr.SetParent(parent2, true);
  510. this.center_tr.SetParent(parent, true);
  511. this.center_tr.localPosition = this.m_vCenterPosLocal;
  512. this.center_tr.localRotation = Quaternion.identity;
  513. this.center_tr.localScale = Vector3.one;
  514. this.m_vPosLocal = this.obj_tr.localPosition;
  515. this.m_qRotLocal = this.obj_tr.localRotation;
  516. this.m_vScaleRate = this.obj_tr.localScale;
  517. this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit);
  518. return true;
  519. }
  520. public bool ResetAttachCenterPoint()
  521. {
  522. if (this.center_tr == null)
  523. {
  524. return false;
  525. }
  526. this.obj_tr.localPosition = (this.m_vPosLocal = this.m_vDefPosLocal);
  527. this.obj_tr.localRotation = (this.m_qRotLocal = this.m_qDefRotLocal);
  528. this.obj_tr.localScale = (this.m_vScaleRate = this.m_vDefScaleLocal);
  529. this.center_tr.localPosition = this.m_vCenterPosLocal;
  530. this.center_tr.localRotation = Quaternion.identity;
  531. this.center_tr.localScale = Vector3.one;
  532. this.body.maid.ClearTBodySkinPos(this.m_ParentMPN, this.SlotId);
  533. return true;
  534. }
  535. public void LoadHitcheckData(Transform body_bone, string fn, int rot, string tag)
  536. {
  537. this.LoadHitcheckData(body_bone, fn, rot, tag, false);
  538. }
  539. public void LoadHitcheckData(Transform body_bone, string fn, int rot, string tag, bool isNewBody)
  540. {
  541. if (isNewBody)
  542. {
  543. this.LoadHitcheckData(body_bone, fn + ".hitcheck", rot, tag);
  544. }
  545. if (!isNewBody)
  546. {
  547. this.bonehair.Init();
  548. this.bonehair.LoadHitCheck(body_bone, fn + ".hitcheck", rot, tag);
  549. }
  550. this.bonehair2.Init();
  551. this.bonehair3.Init();
  552. }
  553. public void Load(MPN mpn, Transform srcbody, Transform body1, Dictionary<string, Transform> trans, string bonename, string filename, string slotname, string AttachSlot, int layer, bool f_bTemp)
  554. {
  555. this.Load(mpn, srcbody, body1, trans, bonename, filename, slotname, AttachSlot, 0, string.Empty, layer, f_bTemp, 100, false, null);
  556. }
  557. public void Load(MPN mpn, Transform srcbody, Transform body1, Dictionary<string, Transform> trans, string bonename, string filename, string slotname, string AttachSlot, int layer, bool f_bTemp, int version)
  558. {
  559. this.Load(mpn, srcbody, body1, trans, bonename, filename, slotname, AttachSlot, 0, string.Empty, layer, f_bTemp, 100, false, null);
  560. }
  561. public void Load(MPN mpn, Transform srcbody, Transform body1, Dictionary<string, Transform> trans, string bonename, string filename, string slotname, string AttachSlot, int AttachSubNo, string AttachName, int layer, bool f_bTemp, int version, bool crcImport, TBodySkin.SplitParam splitParam)
  562. {
  563. this.DeleteObj(false);
  564. this.m_partsVersion = version;
  565. this.m_IsCrcImported = crcImport;
  566. if (mpn == MPN.accashi || mpn == MPN.shoes)
  567. {
  568. this.m_bHitFloorY = false;
  569. }
  570. if (mpn == MPN.shoes && filename.ToLower().Contains("_heel"))
  571. {
  572. this.m_isHiheel = true;
  573. }
  574. this.m_ParentMPN = mpn;
  575. if (this.m_ParentMPN != MPN.null_mpn)
  576. {
  577. this.m_mp = this.body.maid.GetProp(this.m_ParentMPN);
  578. }
  579. this.m_bTemp = f_bTemp;
  580. this.boVisible = true;
  581. this.crcPartHideVisible = true;
  582. Vector3 position = srcbody.position;
  583. Quaternion rotation = srcbody.rotation;
  584. Vector3 localScale = srcbody.localScale;
  585. Vector3 position2 = body1.position;
  586. Quaternion rotation2 = body1.rotation;
  587. Vector3 localScale2 = body1.localScale;
  588. srcbody.position = Vector3.zero;
  589. srcbody.rotation = Quaternion.identity;
  590. srcbody.localScale = new Vector3(1f / srcbody.lossyScale.x, 1f / srcbody.lossyScale.y, 1f / srcbody.lossyScale.z);
  591. body1.position = Vector3.zero;
  592. body1.rotation = Quaternion.identity;
  593. body1.localScale = new Vector3(1f / body1.lossyScale.x, 1f / body1.lossyScale.y, 1f / body1.lossyScale.z);
  594. if (this.IsCRC)
  595. {
  596. this.morph = new TMorphSkin(this, this.m_bMan);
  597. }
  598. else
  599. {
  600. this.morph = new TMorph(this);
  601. }
  602. GameObject gameObject = ImportCM.LoadSkinMesh_R(filename, this.morph, slotname, this, layer);
  603. if (this.IsCRC && mpn == MPN.head)
  604. {
  605. gameObject.name = "_SM_Face";
  606. }
  607. if (this.m_bMan)
  608. {
  609. foreach (Transform transform in gameObject.GetComponentsInChildren<Transform>(true))
  610. {
  611. Renderer component = transform.GetComponent<Renderer>();
  612. if (!(component == null) && component.materials != null)
  613. {
  614. foreach (Material material in component.materials)
  615. {
  616. if (material.shader.name == "CM3D2/Man")
  617. {
  618. this.m_listManAlphaMat.Add(material);
  619. }
  620. if (material.shader.name == "CM3D2/Mosaic")
  621. {
  622. material.SetFloat("_FloatValue1", 15f);
  623. }
  624. }
  625. }
  626. }
  627. }
  628. if (this.m_bMan && Product.isEnglish && !Product.isPublic)
  629. {
  630. foreach (Transform transform2 in gameObject.GetComponentsInChildren<Transform>(true))
  631. {
  632. Renderer component2 = transform2.GetComponent<Renderer>();
  633. if (!(component2 == null) && component2.materials != null)
  634. {
  635. foreach (Material material2 in component2.materials)
  636. {
  637. if (material2.shader.name == "CM3D2/Mosaic")
  638. {
  639. material2.shader = Shader.Find("CM3D2/Mosaic_en");
  640. }
  641. }
  642. }
  643. }
  644. }
  645. foreach (Transform transform3 in gameObject.GetComponentsInChildren<Transform>(true))
  646. {
  647. Renderer component3 = transform3.GetComponent<Renderer>();
  648. if (!(component3 == null) && component3.materials != null)
  649. {
  650. Material[] materials3 = component3.materials;
  651. this.MaterialMgr.Init(gameObject, materials3);
  652. break;
  653. }
  654. }
  655. this.morph.InitGameObject(gameObject);
  656. if (Product.isEnglish && !Product.isPublic)
  657. {
  658. if (mpn == MPN.body)
  659. {
  660. this.kupaCtrl = new KupaCtrl(this.body, this.morph);
  661. }
  662. else if (mpn == MPN.moza)
  663. {
  664. this.body.GetSlot(0).kupaCtrl.AddMozaMorph(this.morph);
  665. }
  666. }
  667. if (this.IsCRC && this.m_bMan && (mpn == MPN.head || mpn == MPN.hairf || mpn == MPN.hairr || mpn == MPN.hairs || mpn == MPN.headset || mpn == MPN.acchat))
  668. {
  669. gameObject.transform.localPosition = new Vector3(0f, 0.10818f, 0.00143f);
  670. }
  671. gameObject.transform.parent = CMT.SearchObjName(srcbody, bonename, true);
  672. Vector3 localPosition = gameObject.transform.localPosition;
  673. Vector3 localScale3 = gameObject.transform.localScale;
  674. Quaternion localRotation = gameObject.transform.localRotation;
  675. gameObject.transform.parent = CMT.SearchObjName(body1, bonename, true);
  676. if (!string.IsNullOrEmpty(AttachSlot))
  677. {
  678. this.m_AttachVisible = true;
  679. }
  680. if (AttachSlot == "ボーンにアタッチ" && (bonename == "_IK_handR" || bonename == "_IK_handL"))
  681. {
  682. localPosition = Vector3.zero;
  683. localRotation = Quaternion.identity;
  684. localScale3 = Vector3.one;
  685. }
  686. this.m_trsBoneAttach = null;
  687. this.m_BackAttachName = (this.m_AttachName = null);
  688. this.m_BackAttachSlotIdx = (this.m_AttachSlotIdx = 0);
  689. this.m_BackAttachSlotSubIdx = (this.m_AttachSlotSubIdx = 0);
  690. if (this.IsCRC)
  691. {
  692. if (bonename == "_ROOT_")
  693. {
  694. this.m_attachType = TBodySkin.ATTACH_TYPE.BONE_ROOT;
  695. }
  696. else
  697. {
  698. this.m_attachType = TBodySkin.ATTACH_TYPE.BONE_CHILD_DEF;
  699. }
  700. if (AttachSlot == "ボーンにアタッチ")
  701. {
  702. this.m_attachType = TBodySkin.ATTACH_TYPE.BONE_CHILD_MENU;
  703. this.m_trsBoneAttach = this.body.m_dicBones[AttachName];
  704. }
  705. else if (AttachSlot != string.Empty)
  706. {
  707. this.m_attachType = TBodySkin.ATTACH_TYPE.VERTEX;
  708. this.m_AttachName = AttachName;
  709. this.m_BackAttachName = AttachName;
  710. this.m_BackAttachSlotIdx = (this.m_AttachSlotIdx = (int)TBody.hashSlotName[AttachSlot]);
  711. this.m_AttachSlotSubIdx = AttachSubNo;
  712. this.m_BackAttachSlotSubIdx = AttachSubNo;
  713. }
  714. }
  715. gameObject.transform.localPosition = localPosition;
  716. gameObject.transform.localRotation = localRotation;
  717. gameObject.transform.localScale = localScale3;
  718. this.obj = gameObject;
  719. this.obj_tr = this.obj.transform;
  720. this.listTrs = new List<Transform>(200);
  721. this.listTrsScr = new List<Transform>(4);
  722. CMT.BindTrans(this.listTrs, this.listTrsScr, trans, gameObject.transform, this.body.IsCrcBody);
  723. srcbody.position = position;
  724. srcbody.rotation = rotation;
  725. srcbody.localScale = localScale;
  726. body1.position = position2;
  727. body1.rotation = rotation2;
  728. body1.localScale = localScale2;
  729. if (this.body.m_bNewPhyscs)
  730. {
  731. if (!this.dbManager.SetUpGameObject(gameObject, mpn) && !this.bonehair2.InitGameObject(gameObject, mpn))
  732. {
  733. bool bNoSkirt = this.bonehair3.InitGameObject(gameObject, mpn);
  734. if (!this.body.IsCrcBody)
  735. {
  736. this.bonehair.SearchGameObj(gameObject, bNoSkirt);
  737. }
  738. }
  739. }
  740. else if (!this.body.IsCrcBody)
  741. {
  742. this.bonehair.SearchGameObj(gameObject, false);
  743. }
  744. this.ItemScaleReset();
  745. this.OnChangeScreenSizeOrAA();
  746. if (this.m_bMan)
  747. {
  748. this.ManColorUpdate();
  749. }
  750. if (!this.body.IsCrcBody)
  751. {
  752. foreach (KeyValuePair<string, float> keyValuePair in this.m_BonehairBodyhitScaleBackup)
  753. {
  754. this.bonehair.bodyhit.ScaleMune(keyValuePair.Key, keyValuePair.Value);
  755. }
  756. }
  757. IEnumerator enumerator2 = this.morph.hash.Keys.GetEnumerator();
  758. try
  759. {
  760. while (enumerator2.MoveNext())
  761. {
  762. object obj = enumerator2.Current;
  763. string key = (string)obj;
  764. int f_nIdx = (int)this.morph.hash[key];
  765. float f_fValue;
  766. if (this.body.m_MorphBlendValues.TryGetValue(key, out f_fValue))
  767. {
  768. this.morph.SetBlendValues(f_nIdx, f_fValue);
  769. }
  770. }
  771. }
  772. finally
  773. {
  774. IDisposable disposable;
  775. if ((disposable = (enumerator2 as IDisposable)) != null)
  776. {
  777. disposable.Dispose();
  778. }
  779. }
  780. this.morph.FixBlendValues();
  781. this.m_vDefPosLocal = (this.m_vPosLocal = this.obj_tr.localPosition);
  782. this.m_qDefRotLocal = (this.m_qRotLocal = this.obj_tr.localRotation);
  783. this.m_vDefScaleLocal = (this.m_vScaleRate = this.obj_tr.localScale);
  784. if (!this.IsCRC)
  785. {
  786. if (!f_bTemp && (this.SlotId == TBody.SlotID.accHat || this.SlotId == TBody.SlotID.headset || this.SlotId == TBody.SlotID.hairT || this.SlotId == TBody.SlotID.accSenaka || this.SlotId == TBody.SlotID.accKubi || this.SlotId == TBody.SlotID.accKubiwa || this.SlotId == TBody.SlotID.accShippo || this.SlotId == TBody.SlotID.accKubiwa))
  787. {
  788. SkinnedMeshRenderer componentInChildren = this.obj_tr.GetComponentInChildren<SkinnedMeshRenderer>(true);
  789. if (componentInChildren != null)
  790. {
  791. Bounds bounds = componentInChildren.bounds;
  792. GameObject gameObject2 = new GameObject("center");
  793. gameObject2.transform.SetParent(this.obj_tr, false);
  794. gameObject2.transform.position = bounds.center;
  795. GameObject gameObject3 = new GameObject("center2");
  796. gameObject3.transform.SetParent(gameObject2.transform, false);
  797. gameObject3.transform.position = bounds.center;
  798. this.m_vCenterPosLocal = gameObject2.transform.localPosition;
  799. this.center_tr = gameObject2.transform;
  800. this.center_tr2 = gameObject3.transform;
  801. BoneAttachPos tbodySkinPos = this.body.maid.GetTBodySkinPos(this.m_ParentMPN, this.SlotId);
  802. if (tbodySkinPos != null)
  803. {
  804. this.m_vPosLocal = tbodySkinPos.pss.position;
  805. this.m_qRotLocal = tbodySkinPos.pss.rotation;
  806. this.m_vScaleRate = tbodySkinPos.pss.scale;
  807. this.m_bEnablePartPosEdit = tbodySkinPos.bEnable;
  808. if (this.m_bEnablePartPosEdit)
  809. {
  810. this.obj_tr.localPosition = tbodySkinPos.pss.position;
  811. this.obj_tr.localRotation = tbodySkinPos.pss.rotation;
  812. this.obj_tr.localScale = tbodySkinPos.pss.scale;
  813. }
  814. }
  815. else
  816. {
  817. this.body.maid.ClearTBodySkinPos(this.m_ParentMPN, this.SlotId);
  818. }
  819. }
  820. }
  821. }
  822. else if (this.SlotId == TBody.SlotID.accHat || this.SlotId == TBody.SlotID.headset || this.SlotId == TBody.SlotID.hairS || this.SlotId == TBody.SlotID.hairS_2 || this.SlotId == TBody.SlotID.hairT || this.SlotId == TBody.SlotID.hairT_2 || this.SlotId == TBody.SlotID.hairAho || this.SlotId == TBody.SlotID.accKubiwa || this.SlotId == TBody.SlotID.accKami_1_ || this.SlotId == TBody.SlotID.accKami_2_ || this.SlotId == TBody.SlotID.accKami_3_ || this.SlotId == TBody.SlotID.accHead || this.SlotId == TBody.SlotID.accHead_2 || this.SlotId == TBody.SlotID.megane || this.SlotId == TBody.SlotID.accMiMiL || this.SlotId == TBody.SlotID.accMiMiR || this.SlotId == TBody.SlotID.accHana || this.SlotId == TBody.SlotID.accFace || this.SlotId == TBody.SlotID.accKubi || this.SlotId == TBody.SlotID.accNipL || this.SlotId == TBody.SlotID.accNipR || this.SlotId == TBody.SlotID.accKoshi || this.SlotId == TBody.SlotID.accUde || this.SlotId == TBody.SlotID.accUde_2 || this.SlotId == TBody.SlotID.glove || this.SlotId == TBody.SlotID.accHeso || this.SlotId == TBody.SlotID.accAshi || this.SlotId == TBody.SlotID.accAshi_2 || this.SlotId == TBody.SlotID.accSenaka || this.SlotId == TBody.SlotID.accShippo || this.SlotId == TBody.SlotID.accVag || this.SlotId == TBody.SlotID.accKamiSubL || this.SlotId == TBody.SlotID.accKamiSubR || this.SlotId == TBody.SlotID.accVag || this.SlotId == TBody.SlotID.accAnl || this.SlotId == TBody.SlotID.accXXX)
  823. {
  824. this.m_mf = this.obj_tr.GetComponentInChildren<SkinnedMeshRenderer>(true);
  825. if (this.m_mf != null)
  826. {
  827. if (splitParam != null)
  828. {
  829. if (splitParam.splitPartBone != null)
  830. {
  831. Transform[] bones = this.m_mf.bones;
  832. List<int> list = new List<int>();
  833. for (int n = 0; n < splitParam.splitPartBone.Length; n++)
  834. {
  835. string text = splitParam.splitPartBone[n];
  836. List<string> search = new List<string>();
  837. if (text.LastIndexOf('~') == text.Length - 1)
  838. {
  839. text = text.Remove(text.Length - 1, 1);
  840. Transform x = CMT.SearchObjName(this.listTrs[0], text, true);
  841. NDebug.Assert(x != null, "not found bone -> " + text);
  842. Action<Transform> AddChild = null;
  843. AddChild = delegate(Transform parent)
  844. {
  845. search.Add(parent.name);
  846. for (int num3 = 0; num3 < parent.childCount; num3++)
  847. {
  848. AddChild(parent.GetChild(num3));
  849. }
  850. };
  851. AddChild(x);
  852. }
  853. else
  854. {
  855. search.Add(text);
  856. }
  857. using (List<string>.Enumerator enumerator3 = search.GetEnumerator())
  858. {
  859. while (enumerator3.MoveNext())
  860. {
  861. string sea = enumerator3.Current;
  862. int num = Array.FindIndex<Transform>(bones, (Transform t) => sea == t.name);
  863. if (num != -1)
  864. {
  865. list.Add(num);
  866. }
  867. }
  868. }
  869. }
  870. ((TMorphSkin)this.morph).VisibleVtxByBonwWeight(list);
  871. }
  872. else if (splitParam.plane != Vector3Int.zero)
  873. {
  874. ((TMorphSkin)this.morph).VisibleVtxByPlane(splitParam.plane, splitParam.pos);
  875. }
  876. this.m_pairSlotIds = splitParam.pairSlotIds;
  877. }
  878. if (this.m_attachType == TBodySkin.ATTACH_TYPE.BONE_ROOT)
  879. {
  880. Transform transform4 = null;
  881. Dictionary<int, Transform> loadToRoot = new Dictionary<int, Transform>();
  882. Func<Transform, Transform, bool> CheckParent = null;
  883. CheckParent = delegate(Transform search, Transform tr)
  884. {
  885. if (tr == null)
  886. {
  887. return false;
  888. }
  889. loadToRoot[tr.GetInstanceID()] = tr;
  890. return tr == search || CheckParent(search, tr.parent);
  891. };
  892. Transform transform5 = this.m_mf.bones[0];
  893. while (transform5 != null)
  894. {
  895. bool flag = false;
  896. for (int num2 = 0; num2 < this.m_mf.bones.Length; num2++)
  897. {
  898. flag |= !CheckParent(transform5, this.m_mf.bones[num2]);
  899. }
  900. if (!flag)
  901. {
  902. transform4 = transform5;
  903. break;
  904. }
  905. transform5 = transform5.parent;
  906. }
  907. Transform transform6 = new GameObject(transform4.name).transform;
  908. Action<Transform, Transform> CopyHie = null;
  909. CopyHie = delegate(Transform src, Transform cpy)
  910. {
  911. if (this.m_copyRoot == null)
  912. {
  913. this.m_copyRoot = new List<Tuple<Transform, Transform>>();
  914. }
  915. cpy.position = src.position;
  916. cpy.rotation = src.rotation;
  917. cpy.localScale = src.localScale;
  918. this.m_copyRoot.Add(new Tuple<Transform, Transform>(src, cpy));
  919. for (int num3 = 0; num3 < src.childCount; num3++)
  920. {
  921. Transform child = src.GetChild(num3);
  922. if (loadToRoot.ContainsKey(child.GetInstanceID()))
  923. {
  924. Transform transform7 = new GameObject(child.name).transform;
  925. transform7.SetParent(cpy);
  926. CopyHie(child, transform7);
  927. }
  928. }
  929. };
  930. CopyHie(transform4, transform6);
  931. this.m_copyObjTr = transform6;
  932. transform6.parent = this.body.m_trAttachCache;
  933. this.m_BackBones = this.m_mf.bones;
  934. }
  935. Bounds bounds2 = this.m_mf.bounds;
  936. this.attachPosObj = new GameObject("_AM_" + this.obj_tr.name + " _AttachMoveCtrlPoints");
  937. this.attachPosObj.transform.SetParent(this.obj_tr.parent, false);
  938. this.attachPosObj.transform.position = this.obj_tr.position;
  939. GameObject gameObject4 = new GameObject("center_" + this.SlotId.ToString());
  940. gameObject4.transform.SetParent(this.attachPosObj.transform, false);
  941. gameObject4.transform.position = bounds2.center;
  942. gameObject4.transform.rotation = Quaternion.identity;
  943. this.m_goCenter = gameObject4;
  944. GameObject gameObject5 = new GameObject("center2");
  945. gameObject5.transform.SetParent(gameObject4.transform, false);
  946. gameObject5.transform.position = bounds2.center;
  947. gameObject5.transform.rotation = Quaternion.identity;
  948. if (this.m_attachType == TBodySkin.ATTACH_TYPE.BONE_CHILD_DEF && (this.SlotId == TBody.SlotID.hairS || this.SlotId == TBody.SlotID.hairS_2 || this.SlotId == TBody.SlotID.hairT || this.SlotId == TBody.SlotID.hairT_2 || this.SlotId == TBody.SlotID.hairAho) && this.m_mf.bones != null && this.m_mf.bones.Length != 0)
  949. {
  950. gameObject5.transform.position = this.m_mf.bones[0].position;
  951. }
  952. GameObject gameObject6 = new GameObject("center3");
  953. gameObject6.transform.SetParent(gameObject5.transform, false);
  954. gameObject6.transform.position = this.obj_tr.position;
  955. this.m_vCenterPosLocal = gameObject4.transform.localPosition;
  956. this.center_tr = gameObject4.transform;
  957. this.center_tr2 = gameObject5.transform;
  958. this.center_tr3 = gameObject6.transform;
  959. this.centerTrDef.SetFromTransformLocal(this.center_tr);
  960. this.centerTr2Def.SetFromTransformLocal(this.center_tr2);
  961. this.centerTr3Def.SetFromTransformLocal(this.center_tr3);
  962. }
  963. }
  964. this.m_HairLengthCtrl.NotExistThenClearHairLength();
  965. if (mpn == MPN.head)
  966. {
  967. Transform exists = gameObject.transform.Find("Bone_Face/Bero1");
  968. if (exists)
  969. {
  970. this.tongueCtrl = new TongueCtrl(this, gameObject);
  971. }
  972. else
  973. {
  974. this.tongueCtrl = null;
  975. }
  976. }
  977. if (OvrIK.IsModeVRIK && OvrIK.Instance != null && OvrIK.Instance.NowMaid == this.body.maid && (this.SlotId == TBody.SlotID.head || this.SlotId == TBody.SlotID.megane || this.SlotId == TBody.SlotID.accHead))
  978. {
  979. this.LayerCheck(this.obj);
  980. }
  981. }
  982. public bool LoadOrNewAttachPoint(string partName)
  983. {
  984. if (this.m_savedAttachPos == null)
  985. {
  986. return false;
  987. }
  988. SavedAttachData nap;
  989. if ((nap = this.m_savedAttachPos.Find((SavedAttachData a) => a.partName == partName)) == null)
  990. {
  991. return false;
  992. }
  993. if (!nap.bEnable)
  994. {
  995. return false;
  996. }
  997. if (Array.FindIndex<TBody.SlotID>(TBodySkin.m_findSlots, (TBody.SlotID s) => s == nap.eTargetSlotID) == -1)
  998. {
  999. Debug.Log("crc body attach target is not available. -> " + nap.eMySlotID.ToString());
  1000. nap.bEnable = false;
  1001. return false;
  1002. }
  1003. TBodySkin slot = this.body.GetSlot((int)nap.eTargetSlotID, nap.nTargetSlotNo);
  1004. ((TMorphSkin)slot.morph).AddNewAttachPoint(this, nap.strTargetAttachPointName, nap.newAttachVidx);
  1005. this.m_AttachVisible = true;
  1006. this.m_AttachName = nap.strTargetAttachPointName;
  1007. this.m_AttachSlotIdx = (int)slot.SlotId;
  1008. this.center_tr2.localPosition = nap.prs2.position;
  1009. this.center_tr2.localRotation = nap.prs2.rotation;
  1010. this.center_tr3.localPosition = nap.prs3.position;
  1011. this.center_tr3.localRotation = nap.prs3.rotation;
  1012. this.center_tr3.localScale = nap.prs3.scale;
  1013. this.m_boneAttachEdited = nap.boneAttachEdited;
  1014. if (this.m_attachType == TBodySkin.ATTACH_TYPE.BONE_ROOT && this.m_boneAttachEdited)
  1015. {
  1016. foreach (Tuple<Transform, Transform> tuple in this.m_copyRoot)
  1017. {
  1018. tuple.Item2.position = tuple.Item1.position;
  1019. tuple.Item2.rotation = tuple.Item1.rotation;
  1020. tuple.Item2.localScale = tuple.Item1.localScale;
  1021. nap.boneAttachedHie[tuple.Item1.name].SetToTransformLocal(tuple.Item2);
  1022. }
  1023. Transform[] array = new Transform[this.m_mf.bones.Length];
  1024. for (int i = 0; i < this.m_mf.bones.Length; i++)
  1025. {
  1026. Transform sb = this.m_mf.bones[i];
  1027. array[i] = this.m_copyRoot.Find((Tuple<Transform, Transform> t) => t.Item2.name == sb.name).Item2;
  1028. }
  1029. this.m_mf.bones = array;
  1030. }
  1031. return true;
  1032. }
  1033. public void ResetAttachPoint()
  1034. {
  1035. if (this.m_boneAttachEdited)
  1036. {
  1037. this.m_mf.bones = this.m_BackBones;
  1038. }
  1039. this.m_AttachName = this.m_BackAttachName;
  1040. this.m_AttachSlotIdx = this.m_BackAttachSlotIdx;
  1041. this.m_AttachSlotSubIdx = this.m_BackAttachSlotSubIdx;
  1042. if (this.center_tr != null)
  1043. {
  1044. this.center_tr.rotation = Quaternion.identity;
  1045. }
  1046. if (this.center_tr2 != null)
  1047. {
  1048. this.center_tr2.rotation = Quaternion.identity;
  1049. }
  1050. if (this.center_tr3 != null)
  1051. {
  1052. this.center_tr3.localScale = Vector3.one;
  1053. }
  1054. this.obj_tr.localPosition = this.m_vDefPosLocal;
  1055. this.obj_tr.localRotation = this.m_qDefRotLocal;
  1056. this.obj_tr.localScale = this.m_vDefScaleLocal;
  1057. this.centerTrDef.SetToTransformLocal(this.center_tr);
  1058. this.centerTr2Def.SetToTransformLocal(this.center_tr2);
  1059. this.centerTr3Def.SetToTransformLocal(this.center_tr3);
  1060. this.m_boneAttachEdited = false;
  1061. }
  1062. public void ItemScaleReset()
  1063. {
  1064. if (this.m_mp != null && this.m_mp.bNoScale)
  1065. {
  1066. Transform parent = this.obj_tr.parent;
  1067. this.obj_tr.SetParent(null, true);
  1068. this.obj_tr.localScale = Vector3.one;
  1069. this.obj_tr.SetParent(parent, true);
  1070. }
  1071. }
  1072. private void LayerCheck(GameObject goParent)
  1073. {
  1074. for (int i = 0; i < goParent.transform.childCount; i++)
  1075. {
  1076. this.LayerCheck(goParent.transform.GetChild(i).gameObject);
  1077. }
  1078. goParent.layer = LayerMask.NameToLayer("Face");
  1079. }
  1080. public void AddMyBoneMorph(string name, List<TBodySkin.MyBoneMorph> myBoneMorphs)
  1081. {
  1082. if (this.m_myBoneMorphs == null)
  1083. {
  1084. this.m_myBoneMorphs = new Dictionary<string, List<TBodySkin.MyBoneMorph>>();
  1085. }
  1086. foreach (TBodySkin.MyBoneMorph myBoneMorph in myBoneMorphs)
  1087. {
  1088. myBoneMorph.targetTrs = CMT.SearchObjName(this.listTrs[0], myBoneMorph.targetBoneName, true);
  1089. NDebug.Assert(myBoneMorph.targetTrs != null, "suso bone not found. -> " + myBoneMorph.targetBoneName);
  1090. }
  1091. this.m_myBoneMorphs[name] = myBoneMorphs;
  1092. }
  1093. public void UpdateMyBoneMorph(string name, float val)
  1094. {
  1095. List<TBodySkin.MyBoneMorph> list;
  1096. if (this.m_myBoneMorphs == null || !this.m_myBoneMorphs.TryGetValue(name, out list))
  1097. {
  1098. return;
  1099. }
  1100. foreach (TBodySkin.MyBoneMorph myBoneMorph in list)
  1101. {
  1102. if (myBoneMorph.usePos)
  1103. {
  1104. myBoneMorph.targetTrs.localPosition = Vector3.Lerp(myBoneMorph.pos, myBoneMorph.pos2, val);
  1105. }
  1106. if (myBoneMorph.useRot)
  1107. {
  1108. myBoneMorph.targetTrs.localRotation = Quaternion.Lerp(Quaternion.Euler(myBoneMorph.rot), Quaternion.Euler(myBoneMorph.rot2), val);
  1109. }
  1110. if (myBoneMorph.useScl)
  1111. {
  1112. myBoneMorph.targetTrs.localScale = Vector3.Lerp(myBoneMorph.scl, myBoneMorph.scl2, val);
  1113. }
  1114. }
  1115. }
  1116. public void SetVisibleFlag(bool boSetFlag, string name, Transform t = null, bool boTgt = false)
  1117. {
  1118. if (t.name.IndexOf(name) >= 0)
  1119. {
  1120. boTgt = true;
  1121. }
  1122. if (name == "_ALL_")
  1123. {
  1124. boTgt = true;
  1125. }
  1126. if (boTgt)
  1127. {
  1128. this.m_dicDelNodeBody[t.name] = boSetFlag;
  1129. }
  1130. IEnumerator enumerator = t.GetEnumerator();
  1131. try
  1132. {
  1133. while (enumerator.MoveNext())
  1134. {
  1135. object obj = enumerator.Current;
  1136. Transform t2 = (Transform)obj;
  1137. this.SetVisibleFlag(boSetFlag, name, t2, boTgt);
  1138. }
  1139. }
  1140. finally
  1141. {
  1142. IDisposable disposable;
  1143. if ((disposable = (enumerator as IDisposable)) != null)
  1144. {
  1145. disposable.Dispose();
  1146. }
  1147. }
  1148. }
  1149. public void SetVisibleFlagParts(bool f_bSetFlag, string f_strTargetSlot, string f_strBoneName, Transform t = null, bool boTgt = false)
  1150. {
  1151. if (t.name.IndexOf(f_strBoneName) >= 0)
  1152. {
  1153. boTgt = true;
  1154. }
  1155. if (f_strBoneName == "_ALL_")
  1156. {
  1157. boTgt = true;
  1158. }
  1159. if (boTgt)
  1160. {
  1161. Dictionary<string, bool> dictionary;
  1162. if (!this.m_dicDelNodeParts.TryGetValue(f_strTargetSlot, out dictionary))
  1163. {
  1164. dictionary = new Dictionary<string, bool>();
  1165. this.m_dicDelNodeParts.Add(f_strTargetSlot, dictionary);
  1166. }
  1167. dictionary[t.name] = f_bSetFlag;
  1168. }
  1169. IEnumerator enumerator = t.GetEnumerator();
  1170. try
  1171. {
  1172. while (enumerator.MoveNext())
  1173. {
  1174. object obj = enumerator.Current;
  1175. Transform t2 = (Transform)obj;
  1176. this.SetVisibleFlagParts(f_bSetFlag, f_strTargetSlot, f_strBoneName, t2, boTgt);
  1177. }
  1178. }
  1179. finally
  1180. {
  1181. IDisposable disposable;
  1182. if ((disposable = (enumerator as IDisposable)) != null)
  1183. {
  1184. disposable.Dispose();
  1185. }
  1186. }
  1187. }
  1188. public bool IsPartHideOnSlotVisible()
  1189. {
  1190. return this.crcPartHideVisible;
  1191. }
  1192. public void CopyTrans()
  1193. {
  1194. for (int i = 0; i < this.listTrs.Count; i += 2)
  1195. {
  1196. this.listTrs[i].localRotation = this.listTrs[i + 1].localRotation;
  1197. this.listTrs[i].localPosition = this.listTrs[i + 1].localPosition;
  1198. }
  1199. for (int j = 0; j < this.listTrsScr.Count; j += 2)
  1200. {
  1201. this.listTrsScr[j].localScale = this.listTrsScr[j + 1].localScale;
  1202. }
  1203. this.TightSkirt();
  1204. }
  1205. public void TightSkirt()
  1206. {
  1207. }
  1208. private void LookAtAxis(Transform f_trSrc, Vector3 f_vTargetPosWorld, TBodySkin.Axis f_axis, Vector3 f_vForwardWorld)
  1209. {
  1210. Vector3 position = f_trSrc.InverseTransformPoint(f_vTargetPosWorld);
  1211. if (f_axis == TBodySkin.Axis.X)
  1212. {
  1213. position.x = 0f;
  1214. }
  1215. else if (f_axis == TBodySkin.Axis.Y)
  1216. {
  1217. position.y = 0f;
  1218. }
  1219. else
  1220. {
  1221. position.z = 0f;
  1222. }
  1223. Vector3 vector = f_trSrc.TransformPoint(position);
  1224. Debug.DrawLine(vector, f_trSrc.position, Color.cyan);
  1225. Quaternion lhs = Quaternion.FromToRotation(f_vForwardWorld, (vector - f_trSrc.position).normalized);
  1226. f_trSrc.rotation = lhs * f_trSrc.rotation;
  1227. }
  1228. public void OnChangeScreenSizeOrAA()
  1229. {
  1230. bool flag = QualitySettings.antiAliasing != 0;
  1231. if (this.obj == null)
  1232. {
  1233. return;
  1234. }
  1235. bool flag2 = !flag && !GameMain.Instance.MainCamera.IsBloomEnabled;
  1236. if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode)
  1237. {
  1238. flag2 = false;
  1239. }
  1240. this.obj.GetComponentsInChildren<Renderer>(true, this.m_listRnederTemp);
  1241. for (int i = 0; i < this.m_listRnederTemp.Count; i++)
  1242. {
  1243. Renderer renderer = this.m_listRnederTemp[i];
  1244. if (!(renderer.material == null))
  1245. {
  1246. foreach (Material material in renderer.materials)
  1247. {
  1248. if (flag2)
  1249. {
  1250. material.EnableKeyword("UV_POS_REVERSE");
  1251. material.DisableKeyword("UV_POS_NORMAL");
  1252. }
  1253. else
  1254. {
  1255. material.DisableKeyword("UV_POS_NORMAL");
  1256. material.DisableKeyword("UV_POS_REVERSE");
  1257. }
  1258. }
  1259. }
  1260. }
  1261. }
  1262. private IEnumerator CoReFixBlendValues()
  1263. {
  1264. yield return null;
  1265. if (this.morph != null)
  1266. {
  1267. this.morph.ResetBlendValues();
  1268. }
  1269. yield break;
  1270. }
  1271. public void ManColorUpdate()
  1272. {
  1273. this.ManColorUpdateIn();
  1274. if (this.body.maid.pairMan != null && this.body.maid.pairMan.body0 != null)
  1275. {
  1276. this.body.maid.pairMan.body0.GetSlot((int)this.SlotId).ManColorUpdateIn();
  1277. }
  1278. }
  1279. private void ManColorUpdateIn()
  1280. {
  1281. for (int i = 0; i < this.m_listManAlphaMat.Count; i++)
  1282. {
  1283. Material material = this.m_listManAlphaMat[i];
  1284. material.SetFloat("_FloatValue2", (float)GameMain.Instance.CMSystem.ManAlpha / 100f);
  1285. material.SetColor("_Color", this.body.maid.ManColor);
  1286. }
  1287. }
  1288. public bool AnimationLoad(string f_strAnimName)
  1289. {
  1290. if (this.m_animItem == null)
  1291. {
  1292. this.m_animItem = this.obj.AddComponent<Animation>();
  1293. }
  1294. if (this.m_animItem.GetClip(f_strAnimName) == null)
  1295. {
  1296. string text = f_strAnimName;
  1297. if (string.IsNullOrEmpty(Path.GetExtension(text)))
  1298. {
  1299. text += ".anm";
  1300. }
  1301. AnimationClip animationClip = ImportCM.LoadAniClipNative(GameUty.FileSystem, text, true, true, true);
  1302. if (animationClip == null)
  1303. {
  1304. NDebug.Assert("アニメーション " + text + " が見つかりません。", false);
  1305. return false;
  1306. }
  1307. this.m_animItem.Stop();
  1308. this.m_animItem.AddClip(animationClip, f_strAnimName);
  1309. this.m_animItem.clip = animationClip;
  1310. this.m_animItem.playAutomatically = true;
  1311. }
  1312. this.m_animItem.Stop();
  1313. return true;
  1314. }
  1315. public bool AnimationPlay(string f_strAnimName, bool f_bLoop)
  1316. {
  1317. if (this.m_animItem == null)
  1318. {
  1319. Debug.LogError("まだアイテムアニメが読まれていません。");
  1320. return false;
  1321. }
  1322. this.m_animItem.Stop();
  1323. this.m_animItem.wrapMode = ((!f_bLoop) ? WrapMode.Once : WrapMode.Loop);
  1324. if (this.m_animItem.GetClip(f_strAnimName) == null)
  1325. {
  1326. NDebug.Assert("アニメーション " + f_strAnimName + " は設定されていません。", false);
  1327. return false;
  1328. }
  1329. this.m_animItem[f_strAnimName].time = 0f;
  1330. this.m_animItem.Play(f_strAnimName);
  1331. return true;
  1332. }
  1333. public bool AnimationStop()
  1334. {
  1335. if (this.m_animItem == null)
  1336. {
  1337. return false;
  1338. }
  1339. this.m_animItem.Stop();
  1340. return true;
  1341. }
  1342. public void LateAttachUpdate()
  1343. {
  1344. if (this.obj == null)
  1345. {
  1346. return;
  1347. }
  1348. if (this.body.IsCrcBody)
  1349. {
  1350. return;
  1351. }
  1352. if (this.m_AttachName != null && this.body.goSlot[this.m_AttachSlotIdx].morph != null)
  1353. {
  1354. Vector3 position;
  1355. Quaternion rotation;
  1356. Vector3 vector;
  1357. if (this.body.goSlot[this.m_AttachSlotIdx].morph.GetAttachPoint(this.m_AttachName, out position, out rotation, out vector, this.m_bTemp))
  1358. {
  1359. if (!this.m_AttachVisible)
  1360. {
  1361. this.obj_tr.localScale = Vector3.one;
  1362. this.m_AttachVisible = true;
  1363. }
  1364. this.obj_tr.position = position;
  1365. this.obj_tr.rotation = rotation;
  1366. this.obj_tr.localScale = new Vector3(this.m_vDefScaleLocal.x * vector.x, this.m_vDefScaleLocal.y * vector.y, this.m_vDefScaleLocal.z * vector.z);
  1367. }
  1368. else if (this.m_AttachVisible)
  1369. {
  1370. this.obj_tr.localScale = Vector3.zero;
  1371. this.m_AttachVisible = false;
  1372. }
  1373. }
  1374. }
  1375. public void SelfLateUpdate()
  1376. {
  1377. if (this.obj == null)
  1378. {
  1379. return;
  1380. }
  1381. if (!this.body.IsCrcBody)
  1382. {
  1383. return;
  1384. }
  1385. if (this.obj.activeSelf != this.boVisible)
  1386. {
  1387. CMT.SetActiveFlag(this.obj_tr, this.boVisible);
  1388. if (this.boVisible)
  1389. {
  1390. this.body.StartCoroutine(this.CoReFixBlendValues());
  1391. }
  1392. }
  1393. if (!this.boVisible)
  1394. {
  1395. return;
  1396. }
  1397. if (this.m_trsBoneAttach != null)
  1398. {
  1399. this.obj_tr.position = this.m_trsBoneAttach.position;
  1400. this.obj_tr.rotation = this.m_trsBoneAttach.rotation;
  1401. }
  1402. if (this.m_AttachName != null)
  1403. {
  1404. TBodySkin slot = this.body.GetSlot(this.m_AttachSlotIdx, this.m_AttachSlotSubIdx);
  1405. TMorphSkin tmorphSkin = slot.morph as TMorphSkin;
  1406. if (tmorphSkin != null)
  1407. {
  1408. Vector3[] newAttachPointWorld = tmorphSkin.GetNewAttachPointWorld(this.m_AttachName);
  1409. if (newAttachPointWorld == null)
  1410. {
  1411. Vector3 position;
  1412. Quaternion rotation;
  1413. Vector3 vector;
  1414. if (tmorphSkin.GetAttachPoint(this.m_AttachName, out position, out rotation, out vector, this.m_bTemp))
  1415. {
  1416. if (!this.m_AttachVisible)
  1417. {
  1418. this.obj_tr.localScale = Vector3.one;
  1419. this.m_AttachVisible = true;
  1420. }
  1421. this.obj_tr.position = position;
  1422. this.obj_tr.rotation = rotation;
  1423. this.obj_tr.localScale = new Vector3(this.m_vDefScaleLocal.x * vector.x, this.m_vDefScaleLocal.y * vector.y, this.m_vDefScaleLocal.z * vector.z);
  1424. }
  1425. else if (this.m_AttachVisible)
  1426. {
  1427. this.obj_tr.localScale = Vector3.zero;
  1428. this.m_AttachVisible = false;
  1429. }
  1430. }
  1431. else
  1432. {
  1433. this.center_tr.position = newAttachPointWorld[0];
  1434. this.center_tr.LookAt(this.center_tr.position + (newAttachPointWorld[1] - newAttachPointWorld[0]).normalized, (newAttachPointWorld[2] - newAttachPointWorld[0]).normalized);
  1435. if (this.m_copyObjTr != null)
  1436. {
  1437. this.m_copyObjTr.position = this.center_tr3.position;
  1438. this.m_copyObjTr.rotation = this.center_tr3.rotation;
  1439. this.m_copyObjTr.localScale = this.center_tr3.localScale;
  1440. }
  1441. else
  1442. {
  1443. this.obj_tr.position = this.center_tr3.position;
  1444. this.obj_tr.rotation = this.center_tr3.rotation;
  1445. this.obj_tr.localScale = this.center_tr3.localScale;
  1446. }
  1447. }
  1448. }
  1449. }
  1450. if (this.SlotId == TBody.SlotID.head && this.morph != null)
  1451. {
  1452. Vector3[] newAttachPointWorld2 = ((TMorphSkin)this.morph).GetNewAttachPointWorld("上唇");
  1453. Vector3[] newAttachPointWorld3 = ((TMorphSkin)this.morph).GetNewAttachPointWorld("下唇");
  1454. if (newAttachPointWorld2 != null && newAttachPointWorld3 != null)
  1455. {
  1456. this.body.ikMouthCenter.position = newAttachPointWorld3[0] + (newAttachPointWorld2[0] - newAttachPointWorld3[0]) * 0.5f;
  1457. }
  1458. }
  1459. if (this.kupaCtrl != null)
  1460. {
  1461. this.kupaCtrl.SelfUpdate();
  1462. }
  1463. Vector3 localScale = this.m_trMaid.localScale;
  1464. Vector3 localScale2 = this.m_trMaidOffs.localScale;
  1465. if (localScale.x < 0.998f || 1.002f < localScale.x || localScale2.x < 0.998f || 1.002f < localScale2.x)
  1466. {
  1467. this.m_trMaid.localScale = Vector3.one;
  1468. this.m_trMaidOffs.localScale = Vector3.one;
  1469. this.bonehair3.UpdateSelf();
  1470. this.dbManager.DynamicUpdate();
  1471. this.m_trMaid.localScale = localScale;
  1472. this.m_trMaidOffs.localScale = localScale2;
  1473. }
  1474. else
  1475. {
  1476. this.bonehair3.UpdateSelf();
  1477. this.dbManager.DynamicUpdate();
  1478. }
  1479. if (this.tongueCtrl != null)
  1480. {
  1481. this.tongueCtrl.TongueUpdate();
  1482. }
  1483. }
  1484. public bool MaterialAnimatorAdd(int f_nMateNo)
  1485. {
  1486. Renderer componentInChildren = this.obj.GetComponentInChildren<Renderer>();
  1487. if (componentInChildren != null)
  1488. {
  1489. MaterialAnimator materialAnimator = componentInChildren.gameObject.AddComponent<MaterialAnimator>();
  1490. materialAnimator.m_nMateNo = f_nMateNo;
  1491. materialAnimator.Init();
  1492. }
  1493. return true;
  1494. }
  1495. public void Update()
  1496. {
  1497. if (this.obj == null)
  1498. {
  1499. return;
  1500. }
  1501. if (this.body.IsCrcBody)
  1502. {
  1503. return;
  1504. }
  1505. if (this.obj.activeSelf != this.boVisible)
  1506. {
  1507. CMT.SetActiveFlag(this.obj_tr, this.boVisible);
  1508. if (this.boVisible)
  1509. {
  1510. this.body.StartCoroutine(this.CoReFixBlendValues());
  1511. }
  1512. }
  1513. if (!this.boVisible)
  1514. {
  1515. return;
  1516. }
  1517. if (this.m_trsBoneAttach != null)
  1518. {
  1519. this.obj_tr.position = this.m_trsBoneAttach.position;
  1520. this.obj_tr.rotation = this.m_trsBoneAttach.rotation;
  1521. }
  1522. if (this.m_AttachName != null && this.body.goSlot[this.m_AttachSlotIdx].morph != null)
  1523. {
  1524. Vector3 position;
  1525. Quaternion rotation;
  1526. Vector3 vector;
  1527. if (this.body.goSlot[this.m_AttachSlotIdx].morph.GetAttachPoint(this.m_AttachName, out position, out rotation, out vector, this.m_bTemp))
  1528. {
  1529. if (!this.m_AttachVisible)
  1530. {
  1531. this.obj_tr.localScale = Vector3.one;
  1532. this.m_AttachVisible = true;
  1533. }
  1534. this.obj_tr.position = position;
  1535. this.obj_tr.rotation = rotation;
  1536. this.obj_tr.localScale = new Vector3(this.m_vDefScaleLocal.x * vector.x, this.m_vDefScaleLocal.y * vector.y, this.m_vDefScaleLocal.z * vector.z);
  1537. }
  1538. else if (this.m_AttachVisible)
  1539. {
  1540. this.obj_tr.localScale = Vector3.zero;
  1541. this.m_AttachVisible = false;
  1542. }
  1543. }
  1544. if (this.kupaCtrl != null)
  1545. {
  1546. this.kupaCtrl.SelfUpdate();
  1547. }
  1548. Vector3 localScale = this.m_trMaid.localScale;
  1549. Vector3 localScale2 = this.m_trMaidOffs.localScale;
  1550. if (localScale.x < 0.998f || 1.002f < localScale.x || localScale2.x < 0.998f || 1.002f < localScale2.x)
  1551. {
  1552. this.m_trMaid.localScale = Vector3.one;
  1553. this.m_trMaidOffs.localScale = Vector3.one;
  1554. this.bonehair.Update();
  1555. this.bonehair3.UpdateSelf();
  1556. this.m_trMaid.localScale = localScale;
  1557. this.m_trMaidOffs.localScale = localScale2;
  1558. }
  1559. else
  1560. {
  1561. this.bonehair.Update();
  1562. this.bonehair3.UpdateSelf();
  1563. }
  1564. }
  1565. public TBody body;
  1566. public string Category;
  1567. public TBody.SlotID SlotId;
  1568. public int m_subNo;
  1569. public bool boVisible = true;
  1570. public List<int> listMaskSlot = new List<int>();
  1571. public bool crcPartHideVisible;
  1572. public GameObject obj;
  1573. public Transform obj_tr;
  1574. public Transform center_tr;
  1575. public Transform center_tr2;
  1576. public Transform center_tr3;
  1577. private PosRotScale centerTrDef = new PosRotScale();
  1578. private PosRotScale centerTr2Def = new PosRotScale();
  1579. private PosRotScale centerTr3Def = new PosRotScale();
  1580. private GameObject attachPosObj;
  1581. private List<Transform> listTrs;
  1582. private List<Transform> listTrsScr;
  1583. public List<UnityEngine.Object> listDEL = new List<UnityEngine.Object>();
  1584. public Dictionary<string, UnityEngine.Object> dicDel = new Dictionary<string, UnityEngine.Object>();
  1585. private List<Material> m_listRtMaterial = new List<Material>();
  1586. public TMorph morph;
  1587. public Dictionary<string, bool> m_dicDelNodeBody = new Dictionary<string, bool>();
  1588. public Dictionary<string, Dictionary<string, bool>> m_dicDelNodeParts = new Dictionary<string, Dictionary<string, bool>>();
  1589. public TBoneHair_ bonehair;
  1590. public BoneHair2 bonehair2;
  1591. public BoneHair3 bonehair3;
  1592. public bool boMizugi;
  1593. public Dictionary<string, KeyValuePair<float, string>[]> dicParamSet = new Dictionary<string, KeyValuePair<float, string>[]>();
  1594. private Dictionary<string, string> m_dicParam = new Dictionary<string, string>();
  1595. private Dictionary<string, string> m_dicParam2 = new Dictionary<string, string>();
  1596. public TBodySkin.ATTACH_TYPE m_attachType;
  1597. public Transform m_trsBoneAttach;
  1598. public string m_AttachName;
  1599. public bool m_AttachVisible;
  1600. public int m_AttachSlotIdx;
  1601. public int m_AttachSlotSubIdx;
  1602. private Quaternion AttachRotation;
  1603. public string m_BackAttachName;
  1604. public int m_BackAttachSlotIdx;
  1605. public int m_BackAttachSlotSubIdx;
  1606. public Transform[] m_BackBones;
  1607. public List<Tuple<Transform, Transform>> m_copyRoot;
  1608. public Transform m_copyObjTr;
  1609. public bool m_boneAttachEdited;
  1610. public List<SavedAttachData> m_savedAttachPos;
  1611. public Vector3 m_vDefScaleLocal;
  1612. public Vector3 m_vScaleRate;
  1613. public Vector3 m_vTempAttachPointScale;
  1614. public Vector3 m_vDefPosLocal;
  1615. public Vector3 m_vPosLocal;
  1616. public Vector3 m_vCenterPosLocal;
  1617. public Vector3 m_vTempAttachPointPos;
  1618. public Quaternion m_qDefRotLocal;
  1619. public Quaternion m_qRotLocal;
  1620. public Quaternion m_qTempAttachPointRot;
  1621. public int RID;
  1622. public int SyojiType;
  1623. public string m_strModelFileName = string.Empty;
  1624. public MPN m_ParentMPN;
  1625. public MaidProp m_mp;
  1626. public bool m_bMan;
  1627. private List<Material> m_listManAlphaMat = new List<Material>();
  1628. public InfinityColorTextureCache TextureCache;
  1629. private bool m_bEnablePartPosEdit;
  1630. public Dictionary<string, float> m_BonehairBodyhitScaleBackup = new Dictionary<string, float>();
  1631. public Dictionary<string, TMorph.TempAttachPos> m_dicTempAttachPoint = new Dictionary<string, TMorph.TempAttachPos>();
  1632. public bool m_bHitFloorY = true;
  1633. private Transform m_trMaid;
  1634. private Transform m_trMaidOffs;
  1635. private Dictionary<int, Shader> m_dicBackupShader = new Dictionary<int, Shader>();
  1636. private bool m_bTemp;
  1637. private Transform m_trThigh_L;
  1638. private Transform m_trThigh_R;
  1639. private Transform m_trCalf_L;
  1640. private Transform m_trCalf_R;
  1641. private Transform m_trFoot_L;
  1642. private Transform m_trFoot_R;
  1643. public SkinnedMeshRenderer m_mf;
  1644. private GameObject m_goCenter;
  1645. public TBody.SlotID m_NewAttachRealSlot = TBody.SlotID.end;
  1646. public TBodySkin.OriVert m_OriVert = new TBodySkin.OriVert();
  1647. public TBodySkin.HairLengthCtrl m_HairLengthCtrl;
  1648. private Animation m_animItem;
  1649. private int m_partsVersion;
  1650. private bool m_IsCrcImported;
  1651. public bool m_isHiheel;
  1652. public Dictionary<string, List<TBodySkin.MyBoneMorph>> m_myBoneMorphs;
  1653. public TBodySkin.CHIKUBI_STATE m_chikubiState;
  1654. private List<TBody.SlotID> m_pairSlotIds;
  1655. private static TBody.SlotID[] m_findSlots = new TBody.SlotID[]
  1656. {
  1657. TBody.SlotID.body,
  1658. TBody.SlotID.head,
  1659. TBody.SlotID.hairF,
  1660. TBody.SlotID.hairR,
  1661. TBody.SlotID.hairS,
  1662. TBody.SlotID.hairT
  1663. };
  1664. private List<Renderer> m_listRnederTemp = new List<Renderer>(4);
  1665. public class HairLengthCtrl
  1666. {
  1667. public HairLengthCtrl(TBodySkin f_trTbodySkin)
  1668. {
  1669. this.m_tbskin = f_trTbodySkin;
  1670. this.m_maid = this.m_tbskin.body.maid;
  1671. }
  1672. public bool IsHairLengthEditable
  1673. {
  1674. get
  1675. {
  1676. return this.m_dicHairLenght != null && this.m_dicHairLenght.Count != 0;
  1677. }
  1678. }
  1679. public Dictionary<string, TBodySkin.HairLengthCtrl.HairLength> HairLengthGroupList
  1680. {
  1681. get
  1682. {
  1683. return this.m_dicHairLenght;
  1684. }
  1685. }
  1686. public void NotExistThenClearHairLength()
  1687. {
  1688. if (this.m_maid.NotExistThenClearHairLengthMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId))
  1689. {
  1690. }
  1691. this.m_dicHairLenght.Clear();
  1692. }
  1693. public void SearchAndAddHairLengthTarget(string f_strGroupName, string f_strBoneSearchType, string f_strBoneName, Vector3 f_vScaleMin, Vector3 f_vScaleMax)
  1694. {
  1695. if (this.m_tbskin == null || this.m_tbskin.obj_tr == null)
  1696. {
  1697. NDebug.Assert("髪ボーン拡縮検索 親が未だありません。", false);
  1698. }
  1699. string pattern = f_strBoneName.Replace("*", ".*");
  1700. TBodySkin.HairLengthCtrl.SerchMode mode = TBodySkin.HairLengthCtrl.SerchMode.ALL;
  1701. if (f_strBoneSearchType == "fbrother")
  1702. {
  1703. mode = TBodySkin.HairLengthCtrl.SerchMode.FIRST_BROTHER;
  1704. }
  1705. else if (f_strBoneSearchType == "fchild")
  1706. {
  1707. mode = TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD;
  1708. }
  1709. else if (f_strBoneSearchType == "all")
  1710. {
  1711. mode = TBodySkin.HairLengthCtrl.SerchMode.ALL;
  1712. }
  1713. else
  1714. {
  1715. NDebug.Assert("髪ボーン検索タイプが不正です。 " + f_strBoneSearchType, false);
  1716. }
  1717. this.SearchObjAndAdd(f_strGroupName, this.m_tbskin.obj_tr, new Regex(pattern), mode, f_vScaleMin, f_vScaleMax);
  1718. TBodySkin.HairLengthCtrl.HairLength hairLength;
  1719. if (!this.m_dicHairLenght.TryGetValue(f_strGroupName, out hairLength))
  1720. {
  1721. Debug.LogError("髪ボーングループがありません。");
  1722. return;
  1723. }
  1724. float lengthRate = 0.5f;
  1725. if (this.m_maid.GetHairLengthFromMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId, f_strGroupName, out lengthRate))
  1726. {
  1727. hairLength.SetLengthRate(lengthRate);
  1728. }
  1729. else
  1730. {
  1731. this.m_maid.ClearHairLengthMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId);
  1732. }
  1733. this.HairLenghtBlend();
  1734. }
  1735. private Transform SearchObjAndAdd(string f_strGroupName, Transform t, Regex regex, TBodySkin.HairLengthCtrl.SerchMode mode, Vector3 f_vScaleMin, Vector3 f_vScaleMax)
  1736. {
  1737. string name = t.name;
  1738. if (regex.IsMatch(name))
  1739. {
  1740. TBodySkin.HairLengthCtrl.HairLength hairLength;
  1741. if (!this.m_dicHairLenght.TryGetValue(f_strGroupName, out hairLength))
  1742. {
  1743. hairLength = new TBodySkin.HairLengthCtrl.HairLength(this.m_tbskin, f_strGroupName);
  1744. this.m_dicHairLenght[f_strGroupName] = hairLength;
  1745. }
  1746. hairLength.listTarget.Add(new TBodySkin.HairLengthCtrl.HairLengthTarget
  1747. {
  1748. trTarget = t,
  1749. vScaleDef = t.localScale,
  1750. vScaleMin = f_vScaleMin,
  1751. vScaleMax = f_vScaleMax
  1752. });
  1753. if (mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_BROTHER || mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD)
  1754. {
  1755. return t;
  1756. }
  1757. }
  1758. for (int i = 0; i < t.childCount; i++)
  1759. {
  1760. Transform child = t.GetChild(i);
  1761. Transform transform = this.SearchObjAndAdd(f_strGroupName, child, regex, mode, f_vScaleMin, f_vScaleMax);
  1762. if (transform != null && mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD)
  1763. {
  1764. return transform;
  1765. }
  1766. }
  1767. return null;
  1768. }
  1769. public void HairLenghtBlend()
  1770. {
  1771. foreach (KeyValuePair<string, TBodySkin.HairLengthCtrl.HairLength> keyValuePair in this.m_dicHairLenght)
  1772. {
  1773. float lengthRate = keyValuePair.Value.GetLengthRate();
  1774. for (int i = 0; i < keyValuePair.Value.listTarget.Count; i++)
  1775. {
  1776. TBodySkin.HairLengthCtrl.HairLengthTarget hairLengthTarget = keyValuePair.Value.listTarget[i];
  1777. Vector3 localScale = hairLengthTarget.vScaleDef;
  1778. if (lengthRate < 0.5f)
  1779. {
  1780. localScale = Vector3.Lerp(hairLengthTarget.vScaleMin, hairLengthTarget.vScaleDef, lengthRate / 0.5f);
  1781. }
  1782. else if (0.5f < lengthRate)
  1783. {
  1784. localScale = Vector3.Lerp(hairLengthTarget.vScaleDef, hairLengthTarget.vScaleMax, (lengthRate - 0.5f) / 0.5f);
  1785. }
  1786. hairLengthTarget.trTarget.localScale = localScale;
  1787. }
  1788. }
  1789. }
  1790. private Dictionary<string, TBodySkin.HairLengthCtrl.HairLength> m_dicHairLenght = new Dictionary<string, TBodySkin.HairLengthCtrl.HairLength>();
  1791. private TBodySkin m_tbskin;
  1792. private Maid m_maid;
  1793. public class HairLengthTarget
  1794. {
  1795. public Transform trTarget;
  1796. public Vector3 vScaleDef;
  1797. public Vector3 vScaleMin;
  1798. public Vector3 vScaleMax;
  1799. }
  1800. public class HairLength
  1801. {
  1802. public HairLength(TBodySkin f_tbskin, string f_strGroupName)
  1803. {
  1804. this.m_tbskin = f_tbskin;
  1805. this.strGroupName = f_strGroupName;
  1806. }
  1807. public float GetLengthRate()
  1808. {
  1809. return this.fLenghtRate;
  1810. }
  1811. public void SetLengthRate(float f_fRate)
  1812. {
  1813. Maid maid = this.m_tbskin.body.maid;
  1814. MPN parentMPN = this.m_tbskin.m_ParentMPN;
  1815. TBody.SlotID slotId = this.m_tbskin.SlotId;
  1816. string f_strName = this.strGroupName;
  1817. this.fLenghtRate = f_fRate;
  1818. maid.SetHairLengthSaveToMP(parentMPN, slotId, f_strName, f_fRate);
  1819. }
  1820. private TBodySkin m_tbskin;
  1821. private string strGroupName;
  1822. private float fLenghtRate = 0.5f;
  1823. public List<TBodySkin.HairLengthCtrl.HairLengthTarget> listTarget = new List<TBodySkin.HairLengthCtrl.HairLengthTarget>();
  1824. }
  1825. private enum SerchMode
  1826. {
  1827. FIRST_CHILD,
  1828. FIRST_BROTHER,
  1829. ALL
  1830. }
  1831. }
  1832. public enum ATTACH_TYPE
  1833. {
  1834. NONE,
  1835. VERTEX,
  1836. BONE_CHILD_DEF,
  1837. BONE_CHILD_MENU,
  1838. BONE_ROOT
  1839. }
  1840. public class OriVert
  1841. {
  1842. public void Clear()
  1843. {
  1844. this.VCount = 0;
  1845. this.vOriVert = null;
  1846. this.vOriNorm = null;
  1847. this.vOriUV = null;
  1848. this.nSubMeshCount = 0;
  1849. this.nSubMeshOriTri = null;
  1850. this.bwWeight = null;
  1851. }
  1852. public int VCount;
  1853. public Vector3[] vOriVert;
  1854. public Vector3[] vOriNorm;
  1855. public Vector2[] vOriUV;
  1856. public int nSubMeshCount;
  1857. public int[][] nSubMeshOriTri;
  1858. public BoneWeight[] bwWeight;
  1859. public SkinThickness skinThick;
  1860. }
  1861. public class MyBoneMorph
  1862. {
  1863. public string name;
  1864. public string targetBoneName;
  1865. public Transform targetTrs;
  1866. public bool usePos;
  1867. public bool useRot;
  1868. public bool useScl;
  1869. public Vector3 pos;
  1870. public Vector3 pos2;
  1871. public Vector3 rot;
  1872. public Vector3 rot2;
  1873. public Vector3 scl;
  1874. public Vector3 scl2;
  1875. }
  1876. public enum CHIKUBI_STATE
  1877. {
  1878. None,
  1879. 固定凸,
  1880. 基本凹
  1881. }
  1882. public class SplitParam
  1883. {
  1884. public string[] splitPartBone;
  1885. public Vector3Int plane;
  1886. public float pos;
  1887. public List<TBody.SlotID> pairSlotIds;
  1888. }
  1889. private enum Axis
  1890. {
  1891. X,
  1892. Y,
  1893. Z
  1894. }
  1895. }