123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- 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<THair1>();
- 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<THair1>();
- }
- 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<THair1>();
- }
- 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;
- }
- }
- }
- public void DrawGizmos()
- {
- if (this.bodyhit == null)
- {
- return;
- }
- foreach (THitSphere thitSphere in this.bodyhit.spherelist)
- {
- if (thitSphere.t != null)
- {
- Gizmos.DrawWireSphere(thitSphere.t.TransformPoint(thitSphere.vs), thitSphere.len);
- }
- }
- }
- 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<THair1> 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<BoneScaleDef> m_listBoneScaleDef = new List<BoneScaleDef>();
- }
|