using System; using System.Collections.Generic; using UnityEngine; public class TBoneHair_ { public TBoneHair_(TBodySkin bs) { this.bodyskin = bs; if (bs != null) { this.body = bs.body; } } public void SearchGameObj(GameObject obj, bool bNoSkirt = false) { if (this.bodyhit == null) { return; } this.hair1list = new List(); this.SkirtList = new THair1[24]; this.SkirtListDBL = new THair1[48]; this.boSkirt = false; this.m_listBoneScaleDef.Clear(); Transform transform = obj.transform; for (int i = 0; i < transform.childCount; i++) { this.SearchHair(transform.GetChild(i).transform, transform, bNoSkirt); } int num = 0; int num2 = 0; for (int j = 0; j < 24; j++) { if (this.SkirtList[j] != null) { if (num2 == 0) { num2 = this.SkirtList[j].hplist.Count; } else if (num2 != this.SkirtList[j].hplist.Count) { Debug.LogError("Skirt Bone Count ERROR!!"); break; } num++; } } if (1 <= num && num < 12) { Debug.LogError("error. skirt 12 > " + num); } if (12 <= num) { this.m_nSkirtCountW = num; this.m_nSkirtCountH = this.m_nSkirtCountW * 2; this.boSkirt = true; for (int k = 0; k < this.m_nSkirtCountW; k++) { this.SkirtList[k].SetPair(this.SkirtList[(k + this.m_nSkirtCountW - 1) % this.m_nSkirtCountW], this.SkirtList[(k + 1) % this.m_nSkirtCountW]); } for (int l = 0; l < this.m_nSkirtCountW; l++) { this.SkirtListDBL[l * 2] = this.SkirtList[l]; } for (int m = 0; m < this.m_nSkirtCountW; m++) { this.SkirtListDBL[m * 2 + 1] = new THair1(this, this.SkirtList[m].root, this.SkirtList[m].root_oya, this.bodyhit, this.SkirtList[m], this.SkirtList[(m + 1) % this.m_nSkirtCountW]); } for (int n = 0; n < this.m_nSkirtCountH; n++) { this.SkirtListDBL[n].SetPair(this.SkirtListDBL[(n + this.m_nSkirtCountH - 1) % this.m_nSkirtCountH], this.SkirtListDBL[(n + 1) % this.m_nSkirtCountH]); } for (int num3 = 0; num3 < this.m_nSkirtCountH; num3++) { this.SkirtListDBL[num3].CheckPair(num3); } } this.m_bEnable = true; } private void SearchHair(Transform t, Transform t_oya, bool bNoSkirt = false) { bool flag = false; if (t.transform.childCount == 0) { return; } HairMode hairMode = HairMode.non; Vector3 softG = new Vector3(0f, -0.003f, 0f); float num = 0.05f; float p = 0.5f; int num2 = -1; if (t.name.Contains("_yure_")) { if (t.name.Contains("_skirt_") && !bNoSkirt) { for (int i = 1; i <= 24; i++) { if (t.name.Contains(i.ToString("D2"))) { num2 = i - 1; break; } } if (num2 >= 0) { hairMode = HairMode.skrt; } } else if (t.name.Contains("_yure_hair_")) { hairMode = HairMode.hair; } else if (t.name.Contains("_yure_soft_")) { hairMode = HairMode.ribbon; } else if (t.name.Contains("_yure_hard_")) { hairMode = HairMode.ribbon; } } if (hairMode != HairMode.non) { if (this.JumpChkT == null) { this.JumpChkT = t; } if (hairMode == HairMode.skrt && (t.localScale.x < 0.999f || 1.001f < t.localScale.x || t.localScale.y < 0.999f || 1.001f < t.localScale.y || t.localScale.z < 0.999f || 1.001f < t.localScale.z)) { this.m_listBoneScaleDef.Add(new BoneScaleDef(t, t.localPosition, t.localRotation, t.localScale)); t.localScale = Vector3.one; Transform transform = t; while (transform.childCount != 0) { transform = transform.GetChild(0); this.m_listBoneScaleDef.Add(new BoneScaleDef(transform, transform.localPosition, transform.localRotation, transform.localScale)); transform.localScale = Vector3.one; } } THair1 thair = new THair1(this, t, t_oya, this.bodyhit, null, null); if (thair.hplist.Count <= 2) { Debug.LogError(t.name + " " + thair.hplist.Count); } thair.Mode = hairMode; if (hairMode != HairMode.hair) { if (hairMode == HairMode.ribbon) { if (t.name.Contains("_yure_hard_")) { thair.boHard = true; } if (thair.pointCount == 1) { p = 10f; if (thair.boHard) { num *= 2f; } } } else if (hairMode == HairMode.skrt) { num = 0.05f; p = 0.3f; softG = new Vector3(0f, -0.01f, 0f); } } thair.SoftG = softG; if (hairMode == HairMode.skrt) { this.SkirtList[num2] = thair; } else { thair.KusariIDX = this.hair1list.Count; this.hair1list.Add(thair); } int num3 = 0; foreach (THp thp in thair.hplist) { Transform t2 = thp.t; if (t2.name.Contains("_yure_")) { if (t2.name.Contains("_skirt_")) { num = 0.5f; p = 0.9f; if (t2.name.Contains("_h_")) { num = 0.95f; p = 99999f; } } else if (t2.name.Contains("_yure_hair_")) { num = 0.05f; p = 0.3f; if (t2.name.Contains("_h_")) { num = 0.5f; p = 3f; } if (t2.name.Contains("_h50_")) { num = 0.1f; p = 1f; } } else if (t2.name.Contains("_yure_soft_")) { num = 0.05f; p = 0.5f; } else if (t2.name.Contains("_yure_hard_")) { num = 0.1f; p = 1f; } } float softPer = Mathf.Pow((float)num3 / (float)thair.hplist.Count, p); thp.SoftPer = softPer; thp.SoftTgtG = num; num3++; } flag = true; } if (!flag) { for (int j = 0; j < t.childCount; j++) { this.SearchHair(t.GetChild(j), t, bNoSkirt); } } } public void Init() { this.m_bEnable = false; this.hair1list = new List(); } public void LoadHitCheck(Transform root, string fn, int rot, string tag) { this.bodyhit = new TBodyHit(); this.bodyhit.LoadSphereFromFile(root, fn, tag); this.bodyhit.RotOffset = (float)rot; } public void SaveData(Transform rootBody, string SaveName) { this.bodyhit = new TBodyHit(); this.bodyhit.SetSphere(rootBody, SaveName); this.hair1list = new List(); } public void Update() { if (!this.m_bEnable || this.bodyhit == null) { return; } bool upDefTgt = false; if (this.JumpChkT != null) { upDefTgt = ((this.JumpChkPos - this.JumpChkT.position).magnitude > 0.1f); this.JumpChkPos = this.JumpChkT.position; } if (this.m_listBoneScaleDef.Count != 0) { for (int i = 0; i < this.m_listBoneScaleDef.Count; i++) { BoneScaleDef boneScaleDef = this.m_listBoneScaleDef[i]; boneScaleDef.trTarget.localPosition = boneScaleDef.vBackPos; boneScaleDef.trTarget.localRotation = boneScaleDef.qBackRot; boneScaleDef.trTarget.localScale = boneScaleDef.vBackScale; } } this.bodyhit.PreUpdate(); this.boneAxis = this.boneAxis0; for (int j = 0; j < this.hair1list.Count; j++) { this.hair1list[(j + 4) % this.hair1list.Count].SetUpDefTgt(upDefTgt); } for (int k = 0; k < this.hair1list.Count; k++) { this.hair1list[(k + 4) % this.hair1list.Count].Calc(this.bodyhit); } for (int l = 0; l < this.hair1list.Count; l++) { this.hair1list[(l + 4) % this.hair1list.Count].Proc(this.bodyhit); } if (this.boSkirt) { this.bodyhit.SkirtFT = 1f + this.body.JumpDis * 0.5f; for (int m = 0; m < 2; m++) { for (int n = 0; n < this.m_nSkirtCountW; n++) { this.SkirtListDBL[n * 2].SetUpDefTgt(upDefTgt); } for (int num = 0; num < this.m_nSkirtCountW; num++) { this.SkirtListDBL[num * 2 + 1].SetUpDefTgt(upDefTgt); } for (int num2 = 1; num2 < this.SkirtListDBL[0].hplist.Count; num2++) { for (int num3 = 0; num3 < this.m_nSkirtCountH; num3++) { this.SkirtListDBL[num3].Calc_skirt2(num2); } } for (int num4 = 1; num4 < this.SkirtListDBL[0].hplist.Count; num4++) { for (int num5 = 0; num5 < this.m_nSkirtCountH; num5++) { this.SkirtListDBL[num5].Calc_skirt_up(num4); } } for (int num6 = 1; num6 < this.SkirtListDBL[0].hplist.Count; num6++) { for (int num7 = 0; num7 < this.m_nSkirtCountH; num7++) { int num8 = (num7 + this.m_nSkirtCountW) % this.m_nSkirtCountH; this.SkirtListDBL[num8].Calc_skirt_pair(num6); } } for (int num9 = 0; num9 < this.m_nSkirtCountH; num9++) { this.SkirtListDBL[num9].Proc(this.bodyhit); } } } if (this.m_listBoneScaleDef.Count != 0) { for (int num10 = 0; num10 < this.m_listBoneScaleDef.Count; num10++) { BoneScaleDef boneScaleDef2 = this.m_listBoneScaleDef[num10]; boneScaleDef2.vBackPos = boneScaleDef2.trTarget.localPosition; boneScaleDef2.qBackRot = boneScaleDef2.trTarget.localRotation; boneScaleDef2.vBackScale = boneScaleDef2.trTarget.localScale; } } if (this.m_listBoneScaleDef.Count != 0) { for (int num11 = 0; num11 < this.m_listBoneScaleDef.Count; num11++) { BoneScaleDef boneScaleDef3 = this.m_listBoneScaleDef[num11]; boneScaleDef3.trTarget.localPosition = boneScaleDef3.vDefPos; boneScaleDef3.trTarget.localRotation = boneScaleDef3.qDefRot; boneScaleDef3.trTarget.localScale = boneScaleDef3.vDefScale; } } } private Transform JumpChkT; private Vector3 JumpChkPos = new Vector3(0f, 0f, 0f); public Transform[] trsKusari = new Transform[24]; public TBody body; public TBodySkin bodyskin; public bool boSkirt; private List hair1list; public const int SKIRT_W_MAX = 24; public const int SKIRT_H_MAX = 48; private int m_nSkirtCountW; private int m_nSkirtCountH; private THair1[] SkirtList; private THair1[] SkirtListDBL = new THair1[24]; public TBodyHit bodyhit; public Vector3 boneAxis0 = new Vector3(-90f, 0f, 0f); public Vector3 boneAxis = new Vector3(-90f, 0f, 0f); private bool m_bEnable; private List m_listBoneScaleDef = new List(); }