FullBodyIKMgr.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using kt;
  5. using kt.ik;
  6. using kt.Physics;
  7. using kt.Utility;
  8. using RootMotion.FinalIK;
  9. using UnityEngine;
  10. public class FullBodyIKMgr : MonoBehaviour
  11. {
  12. public TBody body
  13. {
  14. get
  15. {
  16. return this.Body;
  17. }
  18. }
  19. public Maid chara
  20. {
  21. get
  22. {
  23. return this.body.maid;
  24. }
  25. }
  26. public Transform ikTargetRoot
  27. {
  28. get
  29. {
  30. return this.IKTargetRoot;
  31. }
  32. }
  33. public FullBodyBipedIK ik
  34. {
  35. get
  36. {
  37. return this.IK;
  38. }
  39. }
  40. public IKEffector bodyEffector
  41. {
  42. get
  43. {
  44. return this.ik.solver.bodyEffector;
  45. }
  46. }
  47. public IKBodyOffsetCtrl bodyOffsetCtrl
  48. {
  49. get
  50. {
  51. return this.BodyOffsetCtrl;
  52. }
  53. }
  54. public Dictionary<string, AIKCtrl> strIKCtrlPair
  55. {
  56. get
  57. {
  58. return this.StrIKCtrlPair;
  59. }
  60. }
  61. public float blendTime
  62. {
  63. get
  64. {
  65. return this.BlendTime;
  66. }
  67. set
  68. {
  69. this.BlendTime = value;
  70. foreach (AIKCtrl aikctrl in this.strIKCtrlPair.Values)
  71. {
  72. aikctrl.blendTime = value;
  73. }
  74. }
  75. }
  76. public bool isUpdateEnd { get; private set; }
  77. public bool isIKExec
  78. {
  79. get
  80. {
  81. bool result;
  82. if (this.isIKActive)
  83. {
  84. result = this.strIKCtrlPair.Any((KeyValuePair<string, AIKCtrl> ik) => ik.Value.isIKExec);
  85. }
  86. else
  87. {
  88. result = false;
  89. }
  90. return result;
  91. }
  92. }
  93. public bool isNeedAttachTargetUpdatePreExec
  94. {
  95. get
  96. {
  97. bool result;
  98. if (this.isIKActive)
  99. {
  100. result = this.strIKCtrlPair.Any((KeyValuePair<string, AIKCtrl> ik) => ik.Value.isNeedAttachTargetUpdatePreExec);
  101. }
  102. else
  103. {
  104. result = false;
  105. }
  106. return result;
  107. }
  108. }
  109. public Transform planeColliderTrans { get; private set; }
  110. public float floorColliderY
  111. {
  112. get
  113. {
  114. return this.FloorColliderY;
  115. }
  116. set
  117. {
  118. this.FloorColliderY = value;
  119. Vector3 localPosition = this.planeColliderTrans.localPosition;
  120. localPosition.y = this.FloorColliderY;
  121. this.planeColliderTrans.localPosition = localPosition;
  122. }
  123. }
  124. public bool floorColliderEnable
  125. {
  126. set
  127. {
  128. foreach (NativePlaneCollider nativePlaneCollider in this.FloorColliderList)
  129. {
  130. if (nativePlaneCollider)
  131. {
  132. nativePlaneCollider.enabled = value;
  133. }
  134. }
  135. }
  136. }
  137. public float wallColliderZ
  138. {
  139. get
  140. {
  141. return this.WallColliderZ;
  142. }
  143. set
  144. {
  145. this.WallColliderZ = value;
  146. Vector3 localPosition = this.planeColliderTrans.localPosition;
  147. localPosition.z = this.WallColliderZ;
  148. this.planeColliderTrans.localPosition = localPosition;
  149. }
  150. }
  151. public bool wallColliderEnable
  152. {
  153. set
  154. {
  155. foreach (NativePlaneCollider nativePlaneCollider in this.WallColliderList)
  156. {
  157. if (nativePlaneCollider)
  158. {
  159. nativePlaneCollider.enabled = value;
  160. }
  161. }
  162. }
  163. }
  164. public bool wallDirectionInverse
  165. {
  166. set
  167. {
  168. foreach (NativePlaneCollider nativePlaneCollider in this.WallColliderList)
  169. {
  170. if (nativePlaneCollider)
  171. {
  172. nativePlaneCollider.planeStatus.isDirectionInverse = value;
  173. }
  174. }
  175. }
  176. }
  177. public FullBodyIKMgr.BoneCrossBorder upperCrossBorder { get; private set; }
  178. public bool upperBorderEnable
  179. {
  180. get
  181. {
  182. return this.upperCrossBorder.left.enabled && this.upperCrossBorder.right.enabled;
  183. }
  184. set
  185. {
  186. Behaviour left = this.upperCrossBorder.left;
  187. this.upperCrossBorder.right.enabled = value;
  188. left.enabled = value;
  189. }
  190. }
  191. public FullBodyIKMgr.BoneCrossBorder lowerCrossBorder { get; private set; }
  192. public bool lowerBorderEnable
  193. {
  194. get
  195. {
  196. return this.lowerCrossBorder.left.enabled && this.lowerCrossBorder.right.enabled;
  197. }
  198. set
  199. {
  200. Behaviour left = this.lowerCrossBorder.left;
  201. this.lowerCrossBorder.right.enabled = value;
  202. left.enabled = value;
  203. }
  204. }
  205. public HashSet<Maid> partnerList
  206. {
  207. get
  208. {
  209. return this.PartnerList;
  210. }
  211. }
  212. public IKColliderSaveLoader colliderLoader { get; private set; }
  213. public void Init()
  214. {
  215. this.Body = base.GetComponent<TBody>();
  216. this.DestroyIKObject();
  217. this.IKTargetRoot = new GameObject("IK Target Root").transform;
  218. this.IKTargetRoot.SetParent(this.Body.m_trBones, false);
  219. if (this.body.IsCrcBody)
  220. {
  221. this.STRoot = this.Body.m_trBones.Find("ST_Root");
  222. }
  223. else if (!this.chara.boMAN)
  224. {
  225. this.STRoot = this.Body.m_trBones.Find("ST_Root");
  226. }
  227. this.PlaneColiderSetUp();
  228. if (this.body.IsCrcBody && !this.colliderLoader)
  229. {
  230. this.colliderLoader = this.IKTargetRoot.gameObject.AddComponent<IKColliderSaveLoader>();
  231. }
  232. this.IK = this.IKTargetRoot.gameObject.AddComponent<FullBodyBipedIK>();
  233. this.Mouth = new GameObject("Mouth").transform;
  234. this.Mouth.SetParent(this.body.trsHead, false);
  235. this.Mouth.localEulerAngles = new Vector3(-90f, 90f, 0f);
  236. if (!this.chara.boMAN)
  237. {
  238. this.NippleL = new GameObject("Nipple_L").transform;
  239. this.NippleL.SetParent(CMT.SearchObjName(this.body.m_trBones, "Mune_L_sub", true), false);
  240. this.NippleR = new GameObject("Nipple_R").transform;
  241. this.NippleR.SetParent(CMT.SearchObjName(this.body.m_trBones, "Mune_R_sub", true), false);
  242. }
  243. this.NameFlagObjpair.Clear();
  244. this.partnerList.Clear();
  245. this.IKBoneDic = FullBodyIKMgr.GetAllIKBoneDic(this.chara);
  246. this.IK.references.root = this.Body.m_trBones;
  247. this.IK.references.pelvis = this.GetIKBone(FullBodyIKMgr.IKBoneType.Root);
  248. if (this.body.IsCrcBody)
  249. {
  250. this.IK.references.spine = new Transform[]
  251. {
  252. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine0),
  253. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine3)
  254. };
  255. }
  256. else if (!this.chara.boMAN)
  257. {
  258. this.IK.references.spine = new Transform[]
  259. {
  260. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine0),
  261. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine3)
  262. };
  263. }
  264. else
  265. {
  266. this.IK.references.spine = new Transform[]
  267. {
  268. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine0),
  269. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine2)
  270. };
  271. }
  272. this.IK.references.head = this.GetIKBone(FullBodyIKMgr.IKBoneType.Head);
  273. this.IK.references.leftUpperArm = this.GetIKBone(FullBodyIKMgr.IKBoneType.UpperArm_L);
  274. this.IK.references.leftForearm = this.GetIKBone(FullBodyIKMgr.IKBoneType.Forearm_L);
  275. this.IK.references.leftHand = this.GetIKBone(FullBodyIKMgr.IKBoneType.Hand_L);
  276. this.IK.references.rightUpperArm = this.GetIKBone(FullBodyIKMgr.IKBoneType.UpperArm_R);
  277. this.IK.references.rightForearm = this.GetIKBone(FullBodyIKMgr.IKBoneType.Forearm_R);
  278. this.IK.references.rightHand = this.GetIKBone(FullBodyIKMgr.IKBoneType.Hand_R);
  279. this.IK.references.leftThigh = this.GetIKBone(FullBodyIKMgr.IKBoneType.Thigh_L);
  280. this.IK.references.leftCalf = this.GetIKBone(FullBodyIKMgr.IKBoneType.Calf_L);
  281. this.IK.references.leftFoot = this.GetIKBone(FullBodyIKMgr.IKBoneType.Foot_L);
  282. this.IK.references.rightThigh = this.GetIKBone(FullBodyIKMgr.IKBoneType.Thigh_R);
  283. this.IK.references.rightCalf = this.GetIKBone(FullBodyIKMgr.IKBoneType.Calf_R);
  284. this.IK.references.rightFoot = this.GetIKBone(FullBodyIKMgr.IKBoneType.Foot_R);
  285. this.IK.solver.SetToReferences(this.IK.references, null);
  286. this.IK.fixTransforms = false;
  287. foreach (IKEffector ikeffector in this.IK.solver.effectors)
  288. {
  289. ikeffector.positionWeight = 0f;
  290. ikeffector.rotationWeight = 0f;
  291. }
  292. foreach (FBIKChain fbikchain in this.IK.solver.chain)
  293. {
  294. fbikchain.bendConstraint.weight = 0f;
  295. }
  296. this.BodyOffsetCtrl = this.AddBodyCtrl();
  297. if (this.body.IsCrcBody)
  298. {
  299. this.AddFreeFBIKCtrl(FullBodyIKMgr.IKEffectorType.Head, true, FullBodyIKMgr.IKBoneType.Neck);
  300. this.AddMouthIKCtrl();
  301. if (!this.chara.boMAN)
  302. {
  303. this.AddMuneIKCtrl(FullBodyIKMgr.IKEffectorType.Bust_L);
  304. this.AddMuneIKCtrl(FullBodyIKMgr.IKEffectorType.Bust_R);
  305. }
  306. else
  307. {
  308. this.AddPenisIKCtrl();
  309. }
  310. }
  311. this.IK.solver.GetChain(FullBodyBipedChain.LeftLeg).pull = 0f;
  312. this.IK.solver.GetChain(FullBodyBipedChain.RightLeg).pull = 0f;
  313. this.AddLimbIKCtrl(FullBodyIKMgr.IKEffectorType.Hand_L, FullBodyIKMgr.IKEffectorType.Forearm_L, FullBodyIKMgr.IKEffectorType.UpperArm_L, FullBodyBipedEffector.LeftHand, FullBodyBipedEffector.LeftShoulder);
  314. this.AddLimbIKCtrl(FullBodyIKMgr.IKEffectorType.Hand_R, FullBodyIKMgr.IKEffectorType.Forearm_R, FullBodyIKMgr.IKEffectorType.UpperArm_R, FullBodyBipedEffector.RightHand, FullBodyBipedEffector.RightShoulder);
  315. this.AddLimbIKCtrl(FullBodyIKMgr.IKEffectorType.Foot_L, FullBodyIKMgr.IKEffectorType.Calf_L, FullBodyIKMgr.IKEffectorType.Thigh_L, FullBodyBipedEffector.LeftFoot, FullBodyBipedEffector.LeftThigh);
  316. this.AddLimbIKCtrl(FullBodyIKMgr.IKEffectorType.Foot_R, FullBodyIKMgr.IKEffectorType.Calf_R, FullBodyIKMgr.IKEffectorType.Thigh_R, FullBodyBipedEffector.RightFoot, FullBodyBipedEffector.RightThigh);
  317. if (this.body.IsCrcBody)
  318. {
  319. this.colliderLoader.fullbodyIK = this;
  320. this.colliderLoader.fileName = (this.chara.boMAN ? "manIKCollider.ikcol" : "maidIKCollider.ikcol");
  321. this.colliderLoader.ColliderLoad();
  322. }
  323. if (!this.bodyEffector.target)
  324. {
  325. string name2 = this.bodyEffector.bone.name + "_Target";
  326. Transform transform = this.ikTargetRoot.Find(name2);
  327. if (!transform)
  328. {
  329. transform = new GameObject(name2).transform;
  330. }
  331. transform.SetParent(this.IKTargetRoot, false);
  332. this.bodyEffector.target = new GameObject("IKTarget").transform;
  333. this.bodyEffector.target.SetParent(transform, false);
  334. }
  335. this.bodyEffector.effectChildNodes = false;
  336. this.IK.enabled = false;
  337. if (this.body.IsCrcBody)
  338. {
  339. Func<string, Transform, FullBodyIKMgr.BoneCrossBorder> func = delegate(string name, Transform parent)
  340. {
  341. GameObject gameObject = new GameObject(name);
  342. gameObject.transform.SetParent(parent, false);
  343. NativePlaneCollider nativePlaneCollider = gameObject.AddComponent<NativePlaneCollider>();
  344. nativePlaneCollider.planeStatus.direction = MathUtility.VectorType.Z;
  345. NativePlaneCollider nativePlaneCollider2 = gameObject.AddComponent<NativePlaneCollider>();
  346. nativePlaneCollider2.planeStatus.direction = MathUtility.VectorType.Z;
  347. nativePlaneCollider2.planeStatus.isDirectionInverse = true;
  348. Behaviour behaviour = nativePlaneCollider;
  349. bool enabled = false;
  350. nativePlaneCollider2.enabled = enabled;
  351. behaviour.enabled = enabled;
  352. return new FullBodyIKMgr.BoneCrossBorder(nativePlaneCollider, nativePlaneCollider2);
  353. };
  354. this.upperCrossBorder = func("UpperBody_Border", this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine3));
  355. this.lowerCrossBorder = func("LowerBody_Border", this.GetIKBone(FullBodyIKMgr.IKBoneType.Pelvis));
  356. }
  357. }
  358. private IKBodyOffsetCtrl AddBodyCtrl()
  359. {
  360. IKBodyOffsetCtrl ikbodyOffsetCtrl = new IKBodyOffsetCtrl(this);
  361. this.strIKCtrlPair[FullBodyIKMgr.IKEffectorTypeStrDic[FullBodyIKMgr.IKEffectorType.Body]] = ikbodyOffsetCtrl;
  362. this.BodyOffsetCtrl = ikbodyOffsetCtrl;
  363. return ikbodyOffsetCtrl;
  364. }
  365. private ALimbIKCtrl[] AddLimbIKCtrl(FullBodyIKMgr.IKEffectorType hand_foot, FullBodyIKMgr.IKEffectorType elbow_knee, FullBodyIKMgr.IKEffectorType shoulder_thigh, FullBodyBipedEffector handfoot_effector, FullBodyBipedEffector shoulderthigh_effector)
  366. {
  367. IKSolverFullBodyBiped solver = this.ik.solver;
  368. IKMappingLimb limbMapping = solver.GetLimbMapping(handfoot_effector);
  369. FBIKChain chain = solver.GetChain(handfoot_effector);
  370. ShoulderThighIKCtrl shoulderThighIKCtrl = new ShoulderThighIKCtrl(solver.GetEffector(shoulderthigh_effector), chain, limbMapping, this, shoulder_thigh);
  371. this.strIKCtrlPair[FullBodyIKMgr.IKEffectorTypeStrDic[shoulder_thigh]] = shoulderThighIKCtrl;
  372. ElbowKneeIKCtrl elbowKneeIKCtrl = new ElbowKneeIKCtrl(chain, limbMapping, this, elbow_knee);
  373. this.strIKCtrlPair[FullBodyIKMgr.IKEffectorTypeStrDic[elbow_knee]] = elbowKneeIKCtrl;
  374. HandFootIKCtrl handFootIKCtrl = new HandFootIKCtrl(solver.GetEffector(handfoot_effector), chain, limbMapping, this, hand_foot);
  375. this.strIKCtrlPair[FullBodyIKMgr.IKEffectorTypeStrDic[hand_foot]] = handFootIKCtrl;
  376. shoulderThighIKCtrl.SetChain(handFootIKCtrl, elbowKneeIKCtrl);
  377. elbowKneeIKCtrl.SetChain(handFootIKCtrl, shoulderThighIKCtrl);
  378. handFootIKCtrl.SetChain(elbowKneeIKCtrl, shoulderThighIKCtrl);
  379. return new ALimbIKCtrl[]
  380. {
  381. shoulderThighIKCtrl,
  382. elbowKneeIKCtrl,
  383. handFootIKCtrl
  384. };
  385. }
  386. private FreeFBIKCtrl AddFreeFBIKCtrl(FullBodyIKMgr.IKEffectorType effector_type, bool is_upper, FullBodyIKMgr.IKBoneType bend_bone = FullBodyIKMgr.IKBoneType.None)
  387. {
  388. FreeFBIKCtrl freeFBIKCtrl = new FreeFBIKCtrl(this, effector_type, is_upper, bend_bone);
  389. this.strIKCtrlPair[FullBodyIKMgr.IKEffectorTypeStrDic[effector_type]] = freeFBIKCtrl;
  390. return freeFBIKCtrl;
  391. }
  392. private PenisIKCtrl AddPenisIKCtrl()
  393. {
  394. FullBodyIKMgr.IKEffectorType key = FullBodyIKMgr.IKEffectorType.Penis;
  395. PenisIKCtrl penisIKCtrl = new PenisIKCtrl(this);
  396. this.strIKCtrlPair[FullBodyIKMgr.IKEffectorTypeStrDic[key]] = penisIKCtrl;
  397. return penisIKCtrl;
  398. }
  399. private MuneIKCtrl AddMuneIKCtrl(FullBodyIKMgr.IKEffectorType effector_type)
  400. {
  401. MuneIKCtrl muneIKCtrl = new MuneIKCtrl(this, effector_type);
  402. this.strIKCtrlPair[FullBodyIKMgr.IKEffectorTypeStrDic[effector_type]] = muneIKCtrl;
  403. return muneIKCtrl;
  404. }
  405. private MouthIKCtrl AddMouthIKCtrl()
  406. {
  407. MouthIKCtrl mouthIKCtrl = new MouthIKCtrl(this);
  408. this.strIKCtrlPair[FullBodyIKMgr.IKEffectorTypeStrDic[FullBodyIKMgr.IKEffectorType.Mouth]] = mouthIKCtrl;
  409. return mouthIKCtrl;
  410. }
  411. private void PlaneColiderSetUp()
  412. {
  413. this.FloorColliderList.Clear();
  414. this.WallColliderList.Clear();
  415. if (this.planeColliderTrans)
  416. {
  417. UnityEngine.Object.DestroyImmediate(this.planeColliderTrans.gameObject);
  418. }
  419. this.planeColliderTrans = new GameObject(string.Format("IKPlaneCollider_{0}[{1}]", this.chara.boMAN ? "Man" : "Maid", this.chara.ActiveSlotNo)).transform;
  420. this.planeColliderTrans.SetParent(base.transform, false);
  421. }
  422. private void ColiderStateReset()
  423. {
  424. this.floorColliderEnable = true;
  425. this.wallColliderEnable = false;
  426. float num = 0f;
  427. this.wallColliderZ = num;
  428. this.floorColliderY = num;
  429. foreach (NativePlaneCollider nativePlaneCollider in this.FloorColliderList)
  430. {
  431. if (nativePlaneCollider)
  432. {
  433. nativePlaneCollider.status.center.y = 0f;
  434. }
  435. }
  436. foreach (NativePlaneCollider nativePlaneCollider2 in this.WallColliderList)
  437. {
  438. if (nativePlaneCollider2)
  439. {
  440. nativePlaneCollider2.status.center.z = 0f;
  441. }
  442. }
  443. }
  444. public void AddFloorCollider(NativePlaneCollider floor_collider)
  445. {
  446. this.FloorColliderList.Add(floor_collider);
  447. }
  448. public void AddWallCollider(NativePlaneCollider wall_collider)
  449. {
  450. this.WallColliderList.Add(wall_collider);
  451. }
  452. public NativePlaneCollider GetFloorCollider(string ik_name)
  453. {
  454. ALimbIKCtrl ikctrl = this.GetIKCtrl<ALimbIKCtrl>(ik_name);
  455. if (!ikctrl)
  456. {
  457. return null;
  458. }
  459. return ikctrl.floorCollider;
  460. }
  461. public NativePlaneCollider GetWallCollider(string ik_name)
  462. {
  463. ALimbIKCtrl ikctrl = this.GetIKCtrl<ALimbIKCtrl>(ik_name);
  464. if (!ikctrl)
  465. {
  466. return null;
  467. }
  468. return ikctrl.wallCollider;
  469. }
  470. private void Update()
  471. {
  472. this.isUpdateEnd = false;
  473. if (this.bodyOffsetCtrl != null)
  474. {
  475. this.bodyOffsetCtrl.CharaPosReset();
  476. }
  477. }
  478. private void OnDisable()
  479. {
  480. this.AllIKDetach(0f);
  481. }
  482. private void OnDestroy()
  483. {
  484. this.DestroyIKObject();
  485. }
  486. public void DestroyIKObject()
  487. {
  488. if (this.ikTargetRoot)
  489. {
  490. UnityEngine.Object.DestroyImmediate(this.ikTargetRoot.gameObject);
  491. }
  492. if (this.planeColliderTrans)
  493. {
  494. UnityEngine.Object.DestroyImmediate(this.planeColliderTrans.gameObject);
  495. }
  496. if (this.upperCrossBorder != null && this.upperCrossBorder.left)
  497. {
  498. UnityEngine.Object.DestroyImmediate(this.upperCrossBorder.left.gameObject);
  499. }
  500. if (this.lowerCrossBorder != null && this.lowerCrossBorder.left)
  501. {
  502. UnityEngine.Object.DestroyImmediate(this.lowerCrossBorder.left.gameObject);
  503. }
  504. if (this.Mouth)
  505. {
  506. UnityEngine.Object.DestroyImmediate(this.Mouth);
  507. }
  508. if (this.NippleL)
  509. {
  510. UnityEngine.Object.DestroyImmediate(this.NippleL);
  511. }
  512. if (this.NippleR)
  513. {
  514. UnityEngine.Object.DestroyImmediate(this.NippleR);
  515. }
  516. }
  517. public void IKAttach(FullBodyIKMgr.IKEffectorType effector_type, IKAttachParam param)
  518. {
  519. this.IKAttach(FullBodyIKMgr.IKEffectorTypeStrDic[effector_type], param);
  520. }
  521. public void IKAttach(string ik_name, IKAttachParam param)
  522. {
  523. AIKCtrl ikctrl = this.GetIKCtrl(ik_name);
  524. if (!ikctrl)
  525. {
  526. return;
  527. }
  528. ikctrl.SetIKSetting(param);
  529. }
  530. public void SetPelvisPull(bool pull_on)
  531. {
  532. this.IsPelvisPull = pull_on;
  533. }
  534. public void IKDetach(string name)
  535. {
  536. AIKCtrl ikctrl = this.GetIKCtrl(name);
  537. if (!ikctrl)
  538. {
  539. return;
  540. }
  541. if (this.ReservedDetachList.Contains(ikctrl))
  542. {
  543. return;
  544. }
  545. ikctrl.Detach();
  546. }
  547. public void IKDetach(FullBodyIKMgr.IKEffectorType effector_type)
  548. {
  549. this.IKDetach(FullBodyIKMgr.IKEffectorTypeStrDic[effector_type]);
  550. }
  551. public void IKDetach(string name, float blendtime)
  552. {
  553. AIKCtrl ikctrl = this.GetIKCtrl(name);
  554. if (!ikctrl)
  555. {
  556. return;
  557. }
  558. if (this.ReservedDetachList.Contains(ikctrl))
  559. {
  560. return;
  561. }
  562. ikctrl.blendTime = blendtime;
  563. ikctrl.Detach();
  564. }
  565. public void IKDetach(FullBodyIKMgr.IKEffectorType effector_type, float blendtime)
  566. {
  567. this.IKDetach(FullBodyIKMgr.IKEffectorTypeStrDic[effector_type], blendtime);
  568. }
  569. public void AllIKDetach(float blendtime = 0f)
  570. {
  571. this.isIKActive = (blendtime > 0f);
  572. foreach (AIKCtrl aikctrl in this.strIKCtrlPair.Values)
  573. {
  574. aikctrl.blendTime = blendtime;
  575. aikctrl.Detach();
  576. }
  577. }
  578. public void RemoveReservedDetach(AIKCtrl ik_data)
  579. {
  580. this.ReservedDetachList.Remove(ik_data);
  581. }
  582. public void SetAllColliderEnable(bool is_enable)
  583. {
  584. foreach (AIKCtrl aikctrl in this.strIKCtrlPair.Values)
  585. {
  586. if (aikctrl is ALimbIKCtrl)
  587. {
  588. ALimbIKCtrl alimbIKCtrl = aikctrl as ALimbIKCtrl;
  589. alimbIKCtrl.colliderEnable = is_enable;
  590. }
  591. }
  592. }
  593. public void IKReset()
  594. {
  595. this.ColiderStateReset();
  596. this.ReservedDetachList.Clear();
  597. this.IsPelvisPull = false;
  598. this.ikExecOrder = 0;
  599. this.upperBorderEnable = false;
  600. this.lowerBorderEnable = false;
  601. foreach (AIKCtrl aikctrl in this.strIKCtrlPair.Values)
  602. {
  603. aikctrl.Reset();
  604. if (aikctrl.isIKExec)
  605. {
  606. this.ReservedDetachList.Add(aikctrl);
  607. }
  608. }
  609. }
  610. public void AllIKResetDetach(float blendtime = 0f)
  611. {
  612. this.ColiderStateReset();
  613. this.isIKActive = (blendtime > 0f);
  614. this.IsPelvisPull = false;
  615. this.ikExecOrder = 0;
  616. this.upperBorderEnable = false;
  617. this.lowerBorderEnable = false;
  618. foreach (AIKCtrl aikctrl in this.strIKCtrlPair.Values)
  619. {
  620. aikctrl.blendTime = blendtime;
  621. aikctrl.ResetDetach();
  622. }
  623. }
  624. public void AddPartner(Maid partner, bool with_partner = false)
  625. {
  626. if (!this.partnerList.Contains(partner) && partner != this.chara)
  627. {
  628. this.partnerList.Add(partner);
  629. if (with_partner)
  630. {
  631. partner.body0.fullBodyIK.AddPartner(this.chara, false);
  632. }
  633. }
  634. }
  635. public void RemovePartner(Maid partner, bool with_partner = false)
  636. {
  637. if (this.partnerList.Contains(partner))
  638. {
  639. this.partnerList.Remove(partner);
  640. if (partner.fullBodyIK && with_partner)
  641. {
  642. partner.fullBodyIK.RemovePartner(this.chara, false);
  643. }
  644. }
  645. }
  646. public void IKUpdate()
  647. {
  648. if (!this.IsPelvisPull)
  649. {
  650. this.bodyEffector.positionWeight = 1f;
  651. }
  652. else
  653. {
  654. this.bodyEffector.positionWeight = 0f;
  655. }
  656. this.bodyEffector.target.position = this.bodyEffector.bone.position;
  657. this.bodyEffector.target.rotation = this.bodyEffector.bone.rotation;
  658. this.isUpdateLate = false;
  659. if (this.ReservedDetachList.Count > 0)
  660. {
  661. for (int i = 0; i < this.ReservedDetachList.Count; i++)
  662. {
  663. this.ReservedDetachList[i].Detach();
  664. }
  665. this.ReservedDetachList.Clear();
  666. }
  667. if (this.body.IsCrcBody)
  668. {
  669. if (this.upperBorderEnable)
  670. {
  671. this.SetBorderCenter(this.upperCrossBorder, this.GetIKBone(FullBodyIKMgr.IKBoneType.Forearm_L), this.GetIKBone(FullBodyIKMgr.IKBoneType.Forearm_R));
  672. }
  673. if (this.lowerBorderEnable)
  674. {
  675. this.SetBorderCenter(this.lowerCrossBorder, this.GetIKBone(FullBodyIKMgr.IKBoneType.Calf_L), this.GetIKBone(FullBodyIKMgr.IKBoneType.Calf_R));
  676. }
  677. }
  678. this.BodyOffsetUpdate();
  679. if (this.isUpdateLate)
  680. {
  681. return;
  682. }
  683. foreach (AIKCtrl aikctrl in this.strIKCtrlPair.Values)
  684. {
  685. if (!(aikctrl is IKBodyOffsetCtrl))
  686. {
  687. aikctrl.TargetTransCpy();
  688. }
  689. }
  690. foreach (AIKCtrl aikctrl2 in this.strIKCtrlPair.Values)
  691. {
  692. if (!(aikctrl2 is IKBodyOffsetCtrl))
  693. {
  694. aikctrl2.ApplyIKSetting();
  695. }
  696. }
  697. if (!this.isUpdateLate)
  698. {
  699. if (this.isIKExec)
  700. {
  701. this.SolverUpdate();
  702. }
  703. else
  704. {
  705. foreach (AIKCtrl aikctrl3 in this.strIKCtrlPair.Values)
  706. {
  707. aikctrl3.OnPostIKUpdate();
  708. }
  709. }
  710. }
  711. }
  712. private void SetBorderCenter(FullBodyIKMgr.BoneCrossBorder cross_border, Transform left_bone, Transform right_bone)
  713. {
  714. NativePlaneCollider left = cross_border.left;
  715. NativePlaneCollider right = cross_border.right;
  716. Transform parent = left.transform.parent;
  717. float d = Mathf.Min(Vector3.Dot(left_bone.position - parent.position, left.worldDirection), 0f);
  718. float d2 = Mathf.Min(Vector3.Dot(right_bone.position - parent.position, right.worldDirection), 0f);
  719. left.planeStatus.center = left.localDirection * d;
  720. right.planeStatus.center = right.localDirection * d2;
  721. }
  722. private void BodyOffsetUpdate()
  723. {
  724. if (this.bodyOffsetCtrl.isCharaPosSetEnd)
  725. {
  726. return;
  727. }
  728. this.bodyOffsetCtrl.TargetTransCpy();
  729. this.bodyOffsetCtrl.ApplyIKSetting();
  730. if (this.isUpdateLate)
  731. {
  732. return;
  733. }
  734. if (this.bodyOffsetCtrl.isIKExec && this.isIKActive)
  735. {
  736. this.bodyOffsetCtrl.OnPostFullBodySolverUpdate();
  737. }
  738. foreach (AIKCtrl aikctrl in this.strIKCtrlPair.Values)
  739. {
  740. if (aikctrl is ALimbIKCtrl && !aikctrl.isIKExec)
  741. {
  742. ALimbIKCtrl alimbIKCtrl = aikctrl as ALimbIKCtrl;
  743. if (alimbIKCtrl.correctType != ALimbIKCtrl.BorderCorrectType.HalfBody)
  744. {
  745. alimbIKCtrl.HitCheck();
  746. }
  747. }
  748. }
  749. }
  750. private void SolverUpdate()
  751. {
  752. this.isUpdateEnd = true;
  753. if (this.isIKActive && this.isIKExec)
  754. {
  755. bool flag = false;
  756. foreach (AIKCtrl aikctrl in this.strIKCtrlPair.Values)
  757. {
  758. if (!(aikctrl is IKBodyOffsetCtrl))
  759. {
  760. flag = aikctrl.isNeedFullbodySolverUpdate;
  761. if (flag)
  762. {
  763. break;
  764. }
  765. }
  766. }
  767. if (flag)
  768. {
  769. Vector3 localPosition = this.ik.references.spine[1].localPosition;
  770. this.ik.solver.Update();
  771. this.ik.references.spine[1].localPosition = localPosition;
  772. }
  773. foreach (AIKCtrl aikctrl2 in this.strIKCtrlPair.Values)
  774. {
  775. if (!(aikctrl2 is IKBodyOffsetCtrl))
  776. {
  777. aikctrl2.OnPostFullBodySolverUpdate();
  778. }
  779. }
  780. }
  781. foreach (AIKCtrl aikctrl3 in this.strIKCtrlPair.Values)
  782. {
  783. aikctrl3.OnPostIKUpdate();
  784. }
  785. if (this.isIKActive)
  786. {
  787. this.onPostSolverUpdate.Invoke();
  788. }
  789. }
  790. public void LateIKUpdate()
  791. {
  792. this.IKUpdate();
  793. this.body.AutoTwist();
  794. this.body.IKAttachTargetUpdate();
  795. }
  796. public Transform GetIKBone(FullBodyIKMgr.IKEffectorType effector_type)
  797. {
  798. return this.GetIKBone(FullBodyIKMgr.IKEffectorBonePair[effector_type]);
  799. }
  800. public Transform GetIKBone(FullBodyIKMgr.IKBoneType boneType)
  801. {
  802. return (!this.IKBoneDic.ContainsKey(boneType)) ? null : this.IKBoneDic[boneType];
  803. }
  804. public Transform[] GetChainBonesToInit(FullBodyIKMgr.IKEffectorType effector_type)
  805. {
  806. return this.GetChainBonesToInit(FullBodyIKMgr.IKEffectorBonePair[effector_type]);
  807. }
  808. public Transform[] GetChainBonesToInit(FullBodyIKMgr.IKBoneType boneType)
  809. {
  810. Transform[] result = new Transform[0];
  811. switch (boneType)
  812. {
  813. case FullBodyIKMgr.IKBoneType.ChinkoNub:
  814. if (this.chara.boMAN)
  815. {
  816. if (this.body.IsCrcBody)
  817. {
  818. result = new Transform[]
  819. {
  820. this.GetIKBone(FullBodyIKMgr.IKBoneType.Chinko1),
  821. this.GetIKBone(FullBodyIKMgr.IKBoneType.Chinko2),
  822. this.GetIKBone(FullBodyIKMgr.IKBoneType.Chinko3),
  823. this.GetIKBone(FullBodyIKMgr.IKBoneType.Chinko4),
  824. this.GetIKBone(FullBodyIKMgr.IKBoneType.Chinko5),
  825. this.GetIKBone(FullBodyIKMgr.IKBoneType.Chinko6),
  826. this.GetIKBone(FullBodyIKMgr.IKBoneType.Chinko7),
  827. this.GetIKBone(FullBodyIKMgr.IKBoneType.ChinkoNub)
  828. };
  829. }
  830. else
  831. {
  832. result = new Transform[]
  833. {
  834. this.GetIKBone(FullBodyIKMgr.IKBoneType.Chinko1),
  835. this.GetIKBone(FullBodyIKMgr.IKBoneType.Chinko2),
  836. this.GetIKBone(FullBodyIKMgr.IKBoneType.ChinkoNub)
  837. };
  838. }
  839. }
  840. break;
  841. case FullBodyIKMgr.IKBoneType.Thigh_R:
  842. case FullBodyIKMgr.IKBoneType.Calf_R:
  843. case FullBodyIKMgr.IKBoneType.Foot_R:
  844. result = new Transform[]
  845. {
  846. this.GetIKBone(FullBodyIKMgr.IKBoneType.Thigh_R),
  847. this.GetIKBone(FullBodyIKMgr.IKBoneType.Calf_R),
  848. this.GetIKBone(FullBodyIKMgr.IKBoneType.Foot_R)
  849. };
  850. break;
  851. case FullBodyIKMgr.IKBoneType.Thigh_L:
  852. case FullBodyIKMgr.IKBoneType.Calf_L:
  853. case FullBodyIKMgr.IKBoneType.Foot_L:
  854. result = new Transform[]
  855. {
  856. this.GetIKBone(FullBodyIKMgr.IKBoneType.Thigh_L),
  857. this.GetIKBone(FullBodyIKMgr.IKBoneType.Calf_L),
  858. this.GetIKBone(FullBodyIKMgr.IKBoneType.Foot_L)
  859. };
  860. break;
  861. case FullBodyIKMgr.IKBoneType.Bust_L:
  862. case FullBodyIKMgr.IKBoneType.Bust_L_Sub:
  863. if (!this.chara.boMAN)
  864. {
  865. result = new Transform[]
  866. {
  867. this.GetIKBone(FullBodyIKMgr.IKBoneType.Bust_L),
  868. this.GetIKBone(FullBodyIKMgr.IKBoneType.Bust_L_Sub)
  869. };
  870. }
  871. break;
  872. case FullBodyIKMgr.IKBoneType.Bust_R:
  873. case FullBodyIKMgr.IKBoneType.Bust_R_Sub:
  874. if (!this.chara.boMAN)
  875. {
  876. result = new Transform[]
  877. {
  878. this.GetIKBone(FullBodyIKMgr.IKBoneType.Bust_R),
  879. this.GetIKBone(FullBodyIKMgr.IKBoneType.Bust_R_Sub)
  880. };
  881. }
  882. break;
  883. case FullBodyIKMgr.IKBoneType.Mouth:
  884. if (this.body.IsCrcBody)
  885. {
  886. result = new Transform[]
  887. {
  888. this.GetIKBone(FullBodyIKMgr.IKBoneType.Neck),
  889. this.GetIKBone(FullBodyIKMgr.IKBoneType.Head),
  890. this.GetIKBone(FullBodyIKMgr.IKBoneType.Mouth)
  891. };
  892. }
  893. break;
  894. default:
  895. switch (boneType)
  896. {
  897. case FullBodyIKMgr.IKBoneType.Neck:
  898. if (this.body.IsCrcBody)
  899. {
  900. result = new Transform[]
  901. {
  902. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine2),
  903. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine3),
  904. this.GetIKBone(FullBodyIKMgr.IKBoneType.Neck)
  905. };
  906. }
  907. else if (!this.chara.boMAN)
  908. {
  909. result = new Transform[]
  910. {
  911. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine2),
  912. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine3),
  913. this.GetIKBone(FullBodyIKMgr.IKBoneType.Neck)
  914. };
  915. }
  916. else
  917. {
  918. result = new Transform[]
  919. {
  920. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine1),
  921. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine2),
  922. this.GetIKBone(FullBodyIKMgr.IKBoneType.Neck)
  923. };
  924. }
  925. break;
  926. case FullBodyIKMgr.IKBoneType.Head:
  927. if (this.body.IsCrcBody)
  928. {
  929. result = new Transform[]
  930. {
  931. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine0),
  932. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine1),
  933. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine2),
  934. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine3),
  935. this.GetIKBone(FullBodyIKMgr.IKBoneType.Neck),
  936. this.GetIKBone(FullBodyIKMgr.IKBoneType.Head)
  937. };
  938. }
  939. else if (!this.chara.boMAN)
  940. {
  941. result = new Transform[]
  942. {
  943. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine0),
  944. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine1),
  945. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine2),
  946. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine3),
  947. this.GetIKBone(FullBodyIKMgr.IKBoneType.Neck),
  948. this.GetIKBone(FullBodyIKMgr.IKBoneType.Head)
  949. };
  950. }
  951. else
  952. {
  953. result = new Transform[]
  954. {
  955. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine0),
  956. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine1),
  957. this.GetIKBone(FullBodyIKMgr.IKBoneType.Spine2),
  958. this.GetIKBone(FullBodyIKMgr.IKBoneType.Neck),
  959. this.GetIKBone(FullBodyIKMgr.IKBoneType.Head)
  960. };
  961. }
  962. break;
  963. case FullBodyIKMgr.IKBoneType.UpperArm_R:
  964. case FullBodyIKMgr.IKBoneType.Forearm_R:
  965. case FullBodyIKMgr.IKBoneType.Hand_R:
  966. result = new Transform[]
  967. {
  968. this.GetIKBone(FullBodyIKMgr.IKBoneType.UpperArm_R),
  969. this.GetIKBone(FullBodyIKMgr.IKBoneType.Forearm_R),
  970. this.GetIKBone(FullBodyIKMgr.IKBoneType.Hand_R)
  971. };
  972. break;
  973. case FullBodyIKMgr.IKBoneType.UpperArm_L:
  974. case FullBodyIKMgr.IKBoneType.Forearm_L:
  975. case FullBodyIKMgr.IKBoneType.Hand_L:
  976. result = new Transform[]
  977. {
  978. this.GetIKBone(FullBodyIKMgr.IKBoneType.UpperArm_L),
  979. this.GetIKBone(FullBodyIKMgr.IKBoneType.Forearm_L),
  980. this.GetIKBone(FullBodyIKMgr.IKBoneType.Hand_L)
  981. };
  982. break;
  983. }
  984. break;
  985. }
  986. return result;
  987. }
  988. public AIKCtrl GetIKCtrl(string tag_name)
  989. {
  990. if (this.strIKCtrlPair.ContainsKey(tag_name))
  991. {
  992. return this.strIKCtrlPair[tag_name];
  993. }
  994. return null;
  995. }
  996. public T GetIKCtrl<T>(string tag_name) where T : AIKCtrl
  997. {
  998. AIKCtrl ikctrl = this.GetIKCtrl(tag_name);
  999. if (ikctrl != null && ikctrl is T)
  1000. {
  1001. return ikctrl as T;
  1002. }
  1003. return (T)((object)null);
  1004. }
  1005. public AIKCtrl GetIKCtrl(FullBodyIKMgr.IKEffectorType effector_type)
  1006. {
  1007. return this.GetIKCtrl(FullBodyIKMgr.IKEffectorTypeStrDic[effector_type]);
  1008. }
  1009. public T GetIKCtrl<T>(FullBodyIKMgr.IKEffectorType effector_type) where T : AIKCtrl
  1010. {
  1011. AIKCtrl ikctrl = this.GetIKCtrl(effector_type);
  1012. if (ikctrl != null && ikctrl is T)
  1013. {
  1014. return ikctrl as T;
  1015. }
  1016. return (T)((object)null);
  1017. }
  1018. public Transform GetSTFlagObj(string name)
  1019. {
  1020. if (this.NameFlagObjpair.ContainsKey(name))
  1021. {
  1022. return this.NameFlagObjpair[name];
  1023. }
  1024. Transform transform = this.STRoot.Find(name);
  1025. if (!transform)
  1026. {
  1027. transform = this.body.GetBone(name);
  1028. if (!transform)
  1029. {
  1030. Debug.LogErrorFormat("{0}は存在しません", new object[]
  1031. {
  1032. name
  1033. });
  1034. return null;
  1035. }
  1036. }
  1037. this.NameFlagObjpair.Add(name, transform);
  1038. return transform;
  1039. }
  1040. public static Dictionary<FullBodyIKMgr.IKBoneType, Transform> GetAllIKBoneDic(Maid chara)
  1041. {
  1042. if (chara == null)
  1043. {
  1044. return null;
  1045. }
  1046. DebugUtility.Assert.IsNotNull<TBody>(chara.body0, "[body0] it does not end load.");
  1047. string text = string.Empty;
  1048. if (chara.body0.IsCrcBody)
  1049. {
  1050. text = "Bip01";
  1051. }
  1052. else
  1053. {
  1054. text = ((!chara.boMAN) ? "Bip01" : "ManBip");
  1055. }
  1056. Dictionary<FullBodyIKMgr.IKBoneType, Transform> dictionary = new Dictionary<FullBodyIKMgr.IKBoneType, Transform>();
  1057. dictionary.Add(FullBodyIKMgr.IKBoneType.TopFixed, chara.body0.GetBone(text).parent);
  1058. dictionary.Add(FullBodyIKMgr.IKBoneType.Root, chara.body0.GetBone(text));
  1059. dictionary.Add(FullBodyIKMgr.IKBoneType.Pelvis, chara.body0.GetBone(text + " Pelvis"));
  1060. dictionary.Add(FullBodyIKMgr.IKBoneType.Spine0, chara.body0.GetBone(text + " Spine"));
  1061. if (chara.body0.IsCrcBody)
  1062. {
  1063. dictionary.Add(FullBodyIKMgr.IKBoneType.Spine1, chara.body0.GetBone(text + " Spine0a"));
  1064. dictionary.Add(FullBodyIKMgr.IKBoneType.Spine2, chara.body0.GetBone(text + " Spine1"));
  1065. dictionary.Add(FullBodyIKMgr.IKBoneType.Spine3, chara.body0.GetBone(text + " Spine1a"));
  1066. }
  1067. else if (!chara.boMAN)
  1068. {
  1069. dictionary.Add(FullBodyIKMgr.IKBoneType.Spine1, chara.body0.GetBone(text + " Spine0a"));
  1070. dictionary.Add(FullBodyIKMgr.IKBoneType.Spine2, chara.body0.GetBone(text + " Spine1"));
  1071. dictionary.Add(FullBodyIKMgr.IKBoneType.Spine3, chara.body0.GetBone(text + " Spine1a"));
  1072. }
  1073. else
  1074. {
  1075. dictionary.Add(FullBodyIKMgr.IKBoneType.Spine1, chara.body0.GetBone(text + " Spine1"));
  1076. dictionary.Add(FullBodyIKMgr.IKBoneType.Spine2, chara.body0.GetBone(text + " Spine2"));
  1077. }
  1078. dictionary.Add(FullBodyIKMgr.IKBoneType.Head, chara.body0.GetBone(text + " Head"));
  1079. dictionary.Add(FullBodyIKMgr.IKBoneType.Neck, chara.body0.GetBone(text + " Neck"));
  1080. dictionary.Add(FullBodyIKMgr.IKBoneType.UpperArm_R, chara.body0.GetBone(text + " R UpperArm"));
  1081. dictionary.Add(FullBodyIKMgr.IKBoneType.Forearm_R, chara.body0.GetBone(text + " R Forearm"));
  1082. dictionary.Add(FullBodyIKMgr.IKBoneType.Hand_R, chara.body0.GetBone(text + " R Hand"));
  1083. dictionary.Add(FullBodyIKMgr.IKBoneType.UpperArm_L, chara.body0.GetBone(text + " L UpperArm"));
  1084. dictionary.Add(FullBodyIKMgr.IKBoneType.Forearm_L, chara.body0.GetBone(text + " L Forearm"));
  1085. dictionary.Add(FullBodyIKMgr.IKBoneType.Hand_L, chara.body0.GetBone(text + " L Hand"));
  1086. dictionary.Add(FullBodyIKMgr.IKBoneType.Thigh_R, chara.body0.GetBone(text + " R Thigh"));
  1087. dictionary.Add(FullBodyIKMgr.IKBoneType.Calf_R, chara.body0.GetBone(text + " R Calf"));
  1088. dictionary.Add(FullBodyIKMgr.IKBoneType.Foot_R, chara.body0.GetBone(text + " R Foot"));
  1089. dictionary.Add(FullBodyIKMgr.IKBoneType.Thigh_L, chara.body0.GetBone(text + " L Thigh"));
  1090. dictionary.Add(FullBodyIKMgr.IKBoneType.Calf_L, chara.body0.GetBone(text + " L Calf"));
  1091. dictionary.Add(FullBodyIKMgr.IKBoneType.Foot_L, chara.body0.GetBone(text + " L Foot"));
  1092. if (chara.boMAN)
  1093. {
  1094. dictionary.Add(FullBodyIKMgr.IKBoneType.ChinkoCenter, chara.body0.GetBone("chinkoCenter"));
  1095. dictionary.Add(FullBodyIKMgr.IKBoneType.Chinko1, chara.body0.GetBone("chinko1"));
  1096. dictionary.Add(FullBodyIKMgr.IKBoneType.Chinko2, chara.body0.GetBone("chinko2"));
  1097. if (chara.body0.IsCrcBody)
  1098. {
  1099. dictionary.Add(FullBodyIKMgr.IKBoneType.Chinko3, chara.body0.GetBone("chinko3"));
  1100. dictionary.Add(FullBodyIKMgr.IKBoneType.Chinko4, chara.body0.GetBone("chinko4"));
  1101. dictionary.Add(FullBodyIKMgr.IKBoneType.Chinko5, chara.body0.GetBone("chinko5"));
  1102. dictionary.Add(FullBodyIKMgr.IKBoneType.Chinko6, chara.body0.GetBone("chinko6"));
  1103. dictionary.Add(FullBodyIKMgr.IKBoneType.Chinko7, chara.body0.GetBone("chinko7"));
  1104. }
  1105. dictionary.Add(FullBodyIKMgr.IKBoneType.ChinkoNub, chara.body0.GetBone("chinko_nub"));
  1106. }
  1107. else
  1108. {
  1109. dictionary.Add(FullBodyIKMgr.IKBoneType.Bust_L, chara.body0.GetBone("Mune_L"));
  1110. dictionary.Add(FullBodyIKMgr.IKBoneType.Bust_L_Sub, chara.body0.GetBone("Mune_L_sub"));
  1111. dictionary.Add(FullBodyIKMgr.IKBoneType.Bust_R, chara.body0.GetBone("Mune_R"));
  1112. dictionary.Add(FullBodyIKMgr.IKBoneType.Bust_R_Sub, chara.body0.GetBone("Mune_R_sub"));
  1113. }
  1114. dictionary.Add(FullBodyIKMgr.IKBoneType.Mouth, chara.body0.GetBone("_IK_mouth"));
  1115. return dictionary;
  1116. }
  1117. public static Dictionary<FullBodyIKMgr.IKEffectorType, string> GetBoneTypeStrDic(Maid chara)
  1118. {
  1119. return FullBodyIKMgr.GetBoneTypeStrDic(chara.boMAN);
  1120. }
  1121. public static Dictionary<FullBodyIKMgr.IKEffectorType, string> GetBoneTypeStrDic(bool isMan)
  1122. {
  1123. Dictionary<FullBodyIKMgr.IKEffectorType, string> dictionary = new Dictionary<FullBodyIKMgr.IKEffectorType, string>(FullBodyIKMgr.IKEffectorTypeStrDic);
  1124. if (!isMan)
  1125. {
  1126. dictionary.Remove(FullBodyIKMgr.IKEffectorType.Penis);
  1127. }
  1128. else
  1129. {
  1130. dictionary.Remove(FullBodyIKMgr.IKEffectorType.Bust_L);
  1131. dictionary.Remove(FullBodyIKMgr.IKEffectorType.Bust_R);
  1132. }
  1133. return dictionary;
  1134. }
  1135. public const float PULL_MIN_VALUE = 0.1f;
  1136. public static readonly Dictionary<FullBodyIKMgr.IKEffectorType, string> IKEffectorTypeStrDic = new Dictionary<FullBodyIKMgr.IKEffectorType, string>
  1137. {
  1138. {
  1139. FullBodyIKMgr.IKEffectorType.Body,
  1140. "体全体"
  1141. },
  1142. {
  1143. FullBodyIKMgr.IKEffectorType.Hand_R,
  1144. "右手"
  1145. },
  1146. {
  1147. FullBodyIKMgr.IKEffectorType.Forearm_R,
  1148. "右肘"
  1149. },
  1150. {
  1151. FullBodyIKMgr.IKEffectorType.UpperArm_R,
  1152. "右肩"
  1153. },
  1154. {
  1155. FullBodyIKMgr.IKEffectorType.Hand_L,
  1156. "左手"
  1157. },
  1158. {
  1159. FullBodyIKMgr.IKEffectorType.Forearm_L,
  1160. "左肘"
  1161. },
  1162. {
  1163. FullBodyIKMgr.IKEffectorType.UpperArm_L,
  1164. "左肩"
  1165. },
  1166. {
  1167. FullBodyIKMgr.IKEffectorType.Foot_R,
  1168. "右足"
  1169. },
  1170. {
  1171. FullBodyIKMgr.IKEffectorType.Calf_R,
  1172. "右膝"
  1173. },
  1174. {
  1175. FullBodyIKMgr.IKEffectorType.Thigh_R,
  1176. "右腿"
  1177. },
  1178. {
  1179. FullBodyIKMgr.IKEffectorType.Foot_L,
  1180. "左足"
  1181. },
  1182. {
  1183. FullBodyIKMgr.IKEffectorType.Calf_L,
  1184. "左膝"
  1185. },
  1186. {
  1187. FullBodyIKMgr.IKEffectorType.Thigh_L,
  1188. "左腿"
  1189. },
  1190. {
  1191. FullBodyIKMgr.IKEffectorType.Head,
  1192. "頭"
  1193. },
  1194. {
  1195. FullBodyIKMgr.IKEffectorType.Penis,
  1196. "ちんこ"
  1197. },
  1198. {
  1199. FullBodyIKMgr.IKEffectorType.Bust_L,
  1200. "左胸"
  1201. },
  1202. {
  1203. FullBodyIKMgr.IKEffectorType.Bust_R,
  1204. "右胸"
  1205. },
  1206. {
  1207. FullBodyIKMgr.IKEffectorType.Mouth,
  1208. "口"
  1209. }
  1210. };
  1211. public static readonly Dictionary<FullBodyIKMgr.IKEffectorType, FullBodyIKMgr.IKBoneType> IKEffectorBonePair = new Dictionary<FullBodyIKMgr.IKEffectorType, FullBodyIKMgr.IKBoneType>
  1212. {
  1213. {
  1214. FullBodyIKMgr.IKEffectorType.Body,
  1215. FullBodyIKMgr.IKBoneType.Root
  1216. },
  1217. {
  1218. FullBodyIKMgr.IKEffectorType.Hand_R,
  1219. FullBodyIKMgr.IKBoneType.Hand_R
  1220. },
  1221. {
  1222. FullBodyIKMgr.IKEffectorType.Forearm_R,
  1223. FullBodyIKMgr.IKBoneType.Forearm_R
  1224. },
  1225. {
  1226. FullBodyIKMgr.IKEffectorType.UpperArm_R,
  1227. FullBodyIKMgr.IKBoneType.UpperArm_R
  1228. },
  1229. {
  1230. FullBodyIKMgr.IKEffectorType.Hand_L,
  1231. FullBodyIKMgr.IKBoneType.Hand_L
  1232. },
  1233. {
  1234. FullBodyIKMgr.IKEffectorType.Forearm_L,
  1235. FullBodyIKMgr.IKBoneType.Forearm_L
  1236. },
  1237. {
  1238. FullBodyIKMgr.IKEffectorType.UpperArm_L,
  1239. FullBodyIKMgr.IKBoneType.UpperArm_L
  1240. },
  1241. {
  1242. FullBodyIKMgr.IKEffectorType.Foot_R,
  1243. FullBodyIKMgr.IKBoneType.Foot_R
  1244. },
  1245. {
  1246. FullBodyIKMgr.IKEffectorType.Calf_R,
  1247. FullBodyIKMgr.IKBoneType.Calf_R
  1248. },
  1249. {
  1250. FullBodyIKMgr.IKEffectorType.Thigh_R,
  1251. FullBodyIKMgr.IKBoneType.Thigh_R
  1252. },
  1253. {
  1254. FullBodyIKMgr.IKEffectorType.Foot_L,
  1255. FullBodyIKMgr.IKBoneType.Foot_L
  1256. },
  1257. {
  1258. FullBodyIKMgr.IKEffectorType.Calf_L,
  1259. FullBodyIKMgr.IKBoneType.Calf_L
  1260. },
  1261. {
  1262. FullBodyIKMgr.IKEffectorType.Thigh_L,
  1263. FullBodyIKMgr.IKBoneType.Thigh_L
  1264. },
  1265. {
  1266. FullBodyIKMgr.IKEffectorType.Head,
  1267. FullBodyIKMgr.IKBoneType.Head
  1268. },
  1269. {
  1270. FullBodyIKMgr.IKEffectorType.Penis,
  1271. FullBodyIKMgr.IKBoneType.ChinkoNub
  1272. },
  1273. {
  1274. FullBodyIKMgr.IKEffectorType.Bust_R,
  1275. FullBodyIKMgr.IKBoneType.Bust_R_Sub
  1276. },
  1277. {
  1278. FullBodyIKMgr.IKEffectorType.Bust_L,
  1279. FullBodyIKMgr.IKBoneType.Bust_L_Sub
  1280. },
  1281. {
  1282. FullBodyIKMgr.IKEffectorType.Mouth,
  1283. FullBodyIKMgr.IKBoneType.Mouth
  1284. }
  1285. };
  1286. [SerializeField]
  1287. private TBody Body;
  1288. [SerializeField]
  1289. private Transform IKTargetRoot;
  1290. [SerializeField]
  1291. private Transform STRoot;
  1292. [SerializeField]
  1293. private FullBodyBipedIK IK;
  1294. private Dictionary<FullBodyIKMgr.IKBoneType, Transform> IKBoneDic = new Dictionary<FullBodyIKMgr.IKBoneType, Transform>();
  1295. [SerializeField]
  1296. private IKBodyOffsetCtrl BodyOffsetCtrl;
  1297. private Transform NippleL;
  1298. private Transform NippleR;
  1299. private Transform Mouth;
  1300. private Dictionary<string, AIKCtrl> StrIKCtrlPair = new Dictionary<string, AIKCtrl>();
  1301. private Dictionary<string, Transform> NameFlagObjpair = new Dictionary<string, Transform>();
  1302. public bool isIKActive = true;
  1303. [HideInInspector]
  1304. public bool isUpdateLate;
  1305. public PermTempAction onPostSolverUpdate = new PermTempAction();
  1306. [SerializeField]
  1307. private float BlendTime;
  1308. private List<NativePlaneCollider> FloorColliderList = new List<NativePlaneCollider>();
  1309. private float FloorColliderY;
  1310. private List<NativePlaneCollider> WallColliderList = new List<NativePlaneCollider>();
  1311. private float WallColliderZ;
  1312. private HashSet<Maid> PartnerList = new HashSet<Maid>();
  1313. private List<AIKCtrl> ReservedDetachList = new List<AIKCtrl>();
  1314. private bool IsPelvisPull;
  1315. public int ikExecOrder;
  1316. public enum IKBoneType
  1317. {
  1318. None,
  1319. TopFixed,
  1320. Root,
  1321. Spine0,
  1322. Spine1,
  1323. Spine2,
  1324. Spine3,
  1325. Neck,
  1326. Head,
  1327. Clavicle_R,
  1328. UpperArm_R,
  1329. Forearm_R,
  1330. Hand_R,
  1331. Clavicle_L,
  1332. UpperArm_L,
  1333. Forearm_L,
  1334. Hand_L,
  1335. Pelvis,
  1336. ChinkoCenter,
  1337. Chinko1,
  1338. Chinko2,
  1339. Chinko3,
  1340. Chinko4,
  1341. Chinko5,
  1342. Chinko6,
  1343. Chinko7,
  1344. ChinkoNub,
  1345. Thigh_R,
  1346. Calf_R,
  1347. Foot_R,
  1348. Thigh_L,
  1349. Calf_L,
  1350. Foot_L,
  1351. Bust_L,
  1352. Bust_L_Sub,
  1353. Bust_R,
  1354. Bust_R_Sub,
  1355. Mouth
  1356. }
  1357. public enum IKEffectorType
  1358. {
  1359. Body,
  1360. Hand_R,
  1361. Forearm_R,
  1362. UpperArm_R,
  1363. Hand_L,
  1364. Forearm_L,
  1365. UpperArm_L,
  1366. Foot_R,
  1367. Calf_R,
  1368. Thigh_R,
  1369. Foot_L,
  1370. Calf_L,
  1371. Thigh_L,
  1372. Head,
  1373. Penis,
  1374. Bust_R,
  1375. Bust_L,
  1376. Mouth,
  1377. Finger_R0,
  1378. Finger_R1,
  1379. Finger_R2,
  1380. Finger_R3,
  1381. Finger_R4,
  1382. Finger_L0,
  1383. Finger_L1,
  1384. Finger_L2,
  1385. Finger_L3,
  1386. Finger_L4
  1387. }
  1388. public class BoneCrossBorder
  1389. {
  1390. public BoneCrossBorder(NativePlaneCollider left, NativePlaneCollider right)
  1391. {
  1392. this.left = left;
  1393. this.right = right;
  1394. }
  1395. public readonly NativePlaneCollider left;
  1396. public readonly NativePlaneCollider right;
  1397. }
  1398. }