using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Text.RegularExpressions; using UnityEngine; public class TBodySkin { public TBodySkin(TBody body_, string cate_, TBody.SlotID slot_id_, bool man) { this.boVisible = true; this.body = body_; this.Category = cate_; this.SlotId = slot_id_; this.m_bMan = man; this.m_trMaid = this.body.maid.transform; this.m_trMaidOffs = this.body.maid.m_goOffset.transform; this.bonehair = new TBoneHair_(this); this.TextureCache = new InfinityColorTextureCache(body_.maid); this.bonehair2 = new BoneHair2(this); this.bonehair3 = new BoneHair3(this); this.m_HairLengthCtrl = new TBodySkin.HairLengthCtrl(this); } public void AddRtMaterial(Material f_mat) { this.m_listRtMaterial.Add(f_mat); } public void DeleteObj() { this.m_ParentMPN = MPN.null_mpn; this.m_mp = null; this.m_animItem = null; this.body.MulTexRemove(this.Category); this.TextureCache.RemoveTexture(); this.m_listManAlphaMat.Clear(); this.m_HairLengthCtrl.NotExistThenClearHairLength(); this.listTrs = null; this.listTrsScr = null; this.trsBoneAttach = null; foreach (UnityEngine.Object @object in this.listDEL) { UnityEngine.Object.DestroyImmediate(@object); } this.listDEL = new List(); this.boMizugi = false; if (this.morph != null) { this.morph.DeleteObj(); this.morph = null; } this.boVisible = false; this.listMaskSlot = new List(); this.m_dicBackupShader.Clear(); if (this.bonehair != null) { this.bonehair.Init(); } if (this.bonehair2 != null) { this.bonehair2.Uninit(); } if (this.bonehair3 != null) { this.bonehair3.Uninit(); } if (this.obj != null) { this.obj_tr.parent = null; UnityEngine.Object.DestroyImmediate(this.obj); this.obj = null; this.obj_tr = null; } this.m_dicDelNodeParts.Clear(); this.m_dicParam.Clear(); this.m_dicParam2.Clear(); this.m_OriVert.Clear(); this.m_ParentMPN = MPN.null_mpn; this.m_mp = null; this.m_bHitFloorY = true; } public void NewParamSet(string A) { string[] stringList = UTY.GetStringList(A); string key = stringList[1]; int num = (stringList.Length - 2) / 2; KeyValuePair[] array = new KeyValuePair[num]; for (int i = 0; i < num; i++) { string value = stringList[3 + i * 2]; float key2 = float.Parse(stringList[2 + i * 2]); array[i] = new KeyValuePair(key2, value); } this.dicParamSet[key] = array; } public void SetParam(string f_strTag, string f_strValue) { if (this.m_dicParam.ContainsKey(f_strTag)) { this.m_dicParam[f_strTag] = f_strValue; } else { this.m_dicParam.Add(f_strTag, f_strValue); } } public string GetParam(string f_strTag) { string empty; this.m_dicParam.TryGetValue(f_strTag, out empty); if (empty == null) { empty = string.Empty; } return empty; } public void SetParam2(string f_strTag, string f_strValue) { if (this.m_dicParam2.ContainsKey(f_strTag)) { this.m_dicParam2[f_strTag] = f_strValue; } else { this.m_dicParam2.Add(f_strTag, f_strValue); } } public string GetParam2(string f_strTag) { string empty; this.m_dicParam2.TryGetValue(f_strTag, out empty); if (empty == null) { empty = string.Empty; } return empty; } public void SetMaterialProperty(MPN f_SrcMpn, int f_nMatNo, string f_strPropName, string f_strTypeName, string f_strValue, bool f_bEditSave) { if (this.obj == null) { return; } foreach (Transform transform in this.obj.transform.GetComponentsInChildren(true)) { Renderer component = transform.GetComponent(); if (component != null && component.material != null && f_nMatNo < component.materials.Length) { Material material = component.materials[f_nMatNo]; if (f_strTypeName == "DEFINE") { if (f_strValue == "0") { material.DisableKeyword(f_strPropName); } else if (f_strValue == "1") { material.EnableKeyword(f_strPropName); } } else { Type type = Assembly.Load("UnityEngine.dll").GetType(f_strTypeName); if (type == null) { type = Type.GetType(f_strTypeName, false, true); } if (type == null) { Debug.LogError("タイプ " + f_strTypeName + " は存在しません。"); return; } if (material.HasProperty(f_strPropName)) { material.SetFloat(f_strPropName, float.Parse(f_strValue)); if (f_bEditSave) { this.body.maid.SetMaterialProperty(f_SrcMpn, this.SlotId, f_nMatNo, f_strPropName, f_strTypeName, f_strValue); } else { MatPropSave materialProperty = this.body.maid.GetMaterialProperty(f_SrcMpn, this.SlotId); if (materialProperty != null) { this.SetMaterialProperty(f_SrcMpn, materialProperty.nMatNo, materialProperty.strPropName, materialProperty.strTypeName, materialProperty.strValue, true); } } } else { Debug.LogWarning(f_strPropName + "はありませんでした。"); } } } } } public string GetMaterialProperty(int f_nMatNo, string f_strPropName, string f_strType = "AUTO") { if (this.obj == null) { return string.Empty; } bool flag = f_strType == "DEFINE"; Transform[] componentsInChildren = this.obj.transform.GetComponentsInChildren(true); int i = 0; while (i < componentsInChildren.Length) { Transform transform = componentsInChildren[i]; Renderer component = transform.GetComponent(); if (component != null && component.material != null && f_nMatNo < component.materials.Length) { Material material = component.materials[f_nMatNo]; if (flag) { return (!material.IsKeywordEnabled(f_strPropName)) ? "0" : "1"; } return material.GetFloat(f_strPropName).ToString(); } else { i++; } } return string.Empty; } public void ChangeShader(int f_nMatNo, string f_strShaderFileName) { this.ChangeShader(f_nMatNo, Resources.Load("Shaders/" + f_strShaderFileName)); } private void ChangeShader(int f_nMatNo, Shader f_shader) { GameObject gameObject = this.obj; if (gameObject == null) { return; } foreach (Transform transform in gameObject.transform.GetComponentsInChildren(true)) { Renderer component = transform.GetComponent(); if (component != null && component.material != null && f_nMatNo < component.materials.Length) { if (!this.m_dicBackupShader.ContainsKey(f_nMatNo)) { this.m_dicBackupShader[f_nMatNo] = component.materials[f_nMatNo].shader; } Material material = component.materials[f_nMatNo]; int renderQueue = material.renderQueue; material.shader = f_shader; material.renderQueue = renderQueue; } } } public void RestoreShader() { foreach (KeyValuePair keyValuePair in this.m_dicBackupShader) { this.ChangeShader(keyValuePair.Key, keyValuePair.Value); } this.m_dicBackupShader.Clear(); } public bool EnablePartsPosEdit { get { return this.m_bEnablePartPosEdit; } set { if (this.m_bEnablePartPosEdit == value) { return; } if (value) { BoneAttachPos tbodySkinPos = this.body.maid.GetTBodySkinPos(this.m_ParentMPN, this.SlotId); if (tbodySkinPos != null && this.obj_tr != null) { Vector3 vector = tbodySkinPos.pss.position; this.obj_tr.localPosition = vector; this.m_vPosLocal = vector; Quaternion rotation = tbodySkinPos.pss.rotation; this.obj_tr.localRotation = rotation; this.m_qRotLocal = rotation; vector = tbodySkinPos.pss.scale; this.obj_tr.localScale = vector; this.m_vScaleRate = vector; } } else if (this.obj_tr != null) { this.obj_tr.localPosition = this.m_vDefPosLocal; this.obj_tr.localRotation = this.m_qDefRotLocal; this.obj_tr.localScale = this.m_vDefScaleLocal; } if (this.center_tr != null) { this.center_tr.localPosition = this.m_vCenterPosLocal; this.center_tr.localRotation = Quaternion.identity; this.center_tr.localScale = Vector3.one; } this.m_bEnablePartPosEdit = value; this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit); } } public bool GetAttachObjPointLocal(out Vector3 f_vPosLocal, out Quaternion f_vRotLocal, out Vector3 f_vScaleLocal) { f_vPosLocal = Vector3.zero; f_vRotLocal = Quaternion.identity; f_vScaleLocal = Vector3.zero; return false; } public bool SetAttachObjPointLocal(Vector3 f_vPosLocal, Quaternion f_vRotLocal, Vector3 f_vScaleLocal) { return false; } public bool CopyAttachObjPoint() { if (this.center_tr == null || this.obj_tr == null) { return false; } this.m_vTempAttachPointPos = this.obj_tr.localPosition; this.m_qTempAttachPointRot = this.obj_tr.localRotation; this.m_vTempAttachPointScale = this.obj_tr.localScale; return true; } public bool PastAttachObjPoint() { if (this.center_tr == null || this.obj_tr == null || !this.m_bEnablePartPosEdit) { return false; } Vector3 vector = this.m_vTempAttachPointPos; this.obj_tr.localPosition = vector; this.m_vPosLocal = vector; Quaternion qTempAttachPointRot = this.m_qTempAttachPointRot; this.obj_tr.localRotation = qTempAttachPointRot; this.m_qRotLocal = qTempAttachPointRot; vector = this.m_vTempAttachPointScale; this.obj_tr.localScale = vector; this.m_vScaleRate = vector; this.center_tr.localPosition = this.m_vCenterPosLocal; this.center_tr.localRotation = Quaternion.identity; this.center_tr.localScale = Vector3.one; this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit); return true; } public bool GetAttachCenterPointWorld(out Vector3 f_vPosWorld, out Quaternion f_vRotWorld, out Vector3 f_vScaleLocal) { if (this.center_tr == null) { f_vPosWorld = Vector3.zero; f_vRotWorld = Quaternion.identity; f_vScaleLocal = Vector3.zero; return false; } f_vPosWorld = this.center_tr.position; f_vRotWorld = this.center_tr.rotation; f_vScaleLocal = this.m_vScaleRate; return true; } public bool SetAttachCenterPointWorld(Vector3 f_vPosWorld, Quaternion f_vRotWorld, Vector3 f_vScaleLocal) { if (this.center_tr == null || !this.m_bEnablePartPosEdit) { return false; } Transform parent = this.center_tr.parent; Transform parent2 = this.obj_tr.parent; this.obj_tr.localPosition = (this.m_vPosLocal = this.m_vDefPosLocal); this.obj_tr.localRotation = (this.m_qRotLocal = this.m_qDefRotLocal); this.obj_tr.localScale = (this.m_vScaleRate = this.m_vDefScaleLocal); this.center_tr.localPosition = this.m_vCenterPosLocal; this.center_tr.localRotation = Quaternion.identity; this.center_tr.localScale = Vector3.one; this.center_tr.SetParent(this.obj_tr.parent, true); this.obj_tr.SetParent(this.center_tr, true); this.center_tr.position = f_vPosWorld; this.center_tr.rotation = f_vRotWorld; this.center_tr.localScale = f_vScaleLocal; this.obj_tr.SetParent(parent2, true); this.center_tr.SetParent(parent, true); this.center_tr.localPosition = this.m_vCenterPosLocal; this.center_tr.localRotation = Quaternion.identity; this.center_tr.localScale = Vector3.one; this.m_vPosLocal = this.obj_tr.localPosition; this.m_qRotLocal = this.obj_tr.localRotation; this.m_vScaleRate = this.obj_tr.localScale; this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit); return true; } public bool ResetAttachCenterPoint() { if (this.center_tr == null) { return false; } this.obj_tr.localPosition = (this.m_vPosLocal = this.m_vDefPosLocal); this.obj_tr.localRotation = (this.m_qRotLocal = this.m_qDefRotLocal); this.obj_tr.localScale = (this.m_vScaleRate = this.m_vDefScaleLocal); this.center_tr.localPosition = this.m_vCenterPosLocal; this.center_tr.localRotation = Quaternion.identity; this.center_tr.localScale = Vector3.one; this.body.maid.ClearTBodySkinPos(this.m_ParentMPN, this.SlotId); return true; } public void LoadHitcheckData(Transform body_bone, string fn, int rot, string tag) { this.bonehair.Init(); this.bonehair.LoadHitCheck(body_bone, fn + ".hitcheck", rot, tag); this.bonehair2.Init(); this.bonehair3.Init(); } public void Load(MPN mpn, Transform srcbody, Transform body1, Dictionary trans, string bonename, string filename, string slotname, string AttachSlot, int layer, bool f_bTemp) { this.DeleteObj(); if (mpn == MPN.accashi || mpn == MPN.shoes) { this.m_bHitFloorY = false; } this.m_ParentMPN = mpn; if (this.m_ParentMPN != MPN.null_mpn) { this.m_mp = this.body.maid.GetProp(this.m_ParentMPN); } this.m_bTemp = f_bTemp; this.boVisible = true; Vector3 position = srcbody.position; Quaternion rotation = srcbody.rotation; Vector3 localScale = srcbody.localScale; Vector3 position2 = body1.position; Quaternion rotation2 = body1.rotation; Vector3 localScale2 = body1.localScale; srcbody.position = Vector3.zero; srcbody.rotation = Quaternion.identity; srcbody.localScale = new Vector3(1f / srcbody.lossyScale.x, 1f / srcbody.lossyScale.y, 1f / srcbody.lossyScale.z); body1.position = Vector3.zero; body1.rotation = Quaternion.identity; body1.localScale = new Vector3(1f / body1.lossyScale.x, 1f / body1.lossyScale.y, 1f / body1.lossyScale.z); this.morph = new TMorph(this); GameObject gameObject = ImportCM.LoadSkinMesh_R(filename, this.morph, slotname, this, layer); if (this.m_bMan) { foreach (Transform transform in gameObject.GetComponentsInChildren(true)) { Renderer component = transform.GetComponent(); if (!(component == null) && component.materials != null) { foreach (Material material in component.materials) { if (material.shader.name == "CM3D2/Man") { this.m_listManAlphaMat.Add(material); } if (material.shader.name == "CM3D2/Mosaic") { material.SetFloat("_FloatValue1", 15f); } } } } } if (this.body.m_bNewPhyscs) { if (!this.bonehair2.InitGameObject(gameObject, mpn)) { bool bNoSkirt = this.bonehair3.InitGameObject(gameObject, mpn); this.bonehair.SearchGameObj(gameObject, bNoSkirt); } } else { this.bonehair.SearchGameObj(gameObject, false); } this.morph.InitGameObject(gameObject); gameObject.transform.parent = CMT.SearchObjName(srcbody, bonename, true); Vector3 localPosition = gameObject.transform.localPosition; Vector3 localScale3 = gameObject.transform.localScale; Quaternion localRotation = gameObject.transform.localRotation; gameObject.transform.parent = CMT.SearchObjName(body1, bonename, true); if (!string.IsNullOrEmpty(AttachSlot)) { this.AttachVisible = true; } if (AttachSlot == "ボーンにアタッチ" && (bonename == "_IK_handR" || bonename == "_IK_handL")) { localPosition = Vector3.zero; localRotation = Quaternion.identity; localScale3 = Vector3.one; } gameObject.transform.localPosition = localPosition; gameObject.transform.localRotation = localRotation; gameObject.transform.localScale = localScale3; this.obj = gameObject; this.obj_tr = this.obj.transform; this.listTrs = new List(200); this.listTrsScr = new List(4); CMT.BindTrans(this.listTrs, this.listTrsScr, trans, gameObject.transform); srcbody.position = position; srcbody.rotation = rotation; srcbody.localScale = localScale; body1.position = position2; body1.rotation = rotation2; body1.localScale = localScale2; this.ItemScaleReset(); this.OnChangeScreenSizeOrAA(); if (this.m_bMan) { this.ManColorUpdate(); } foreach (KeyValuePair keyValuePair in this.m_BonehairBodyhitScaleBackup) { this.bonehair.bodyhit.ScaleMune(keyValuePair.Key, keyValuePair.Value); } IEnumerator enumerator2 = this.morph.hash.Keys.GetEnumerator(); try { while (enumerator2.MoveNext()) { object obj = enumerator2.Current; string key = (string)obj; int f_nIdx = (int)this.morph.hash[key]; float f_fValue; if (this.body.m_MorphBlendValues.TryGetValue(key, out f_fValue)) { this.morph.SetBlendValues(f_nIdx, f_fValue); } } } finally { IDisposable disposable; if ((disposable = (enumerator2 as IDisposable)) != null) { disposable.Dispose(); } } this.morph.FixBlendValues(); this.m_vDefPosLocal = (this.m_vPosLocal = this.obj_tr.localPosition); this.m_qDefRotLocal = (this.m_qRotLocal = this.obj_tr.localRotation); this.m_vDefScaleLocal = (this.m_vScaleRate = this.obj_tr.localScale); 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)) { SkinnedMeshRenderer componentInChildren = this.obj_tr.GetComponentInChildren(true); if (componentInChildren != null) { Bounds bounds = componentInChildren.bounds; GameObject gameObject2 = new GameObject("center"); gameObject2.transform.SetParent(this.obj_tr, false); gameObject2.transform.position = bounds.center; GameObject gameObject3 = new GameObject("center2"); gameObject3.transform.SetParent(gameObject2.transform, false); gameObject3.transform.position = bounds.center; this.m_vCenterPosLocal = gameObject2.transform.localPosition; this.center_tr = gameObject2.transform; this.center_tr2 = gameObject3.transform; BoneAttachPos tbodySkinPos = this.body.maid.GetTBodySkinPos(this.m_ParentMPN, this.SlotId); if (tbodySkinPos != null) { this.m_vPosLocal = tbodySkinPos.pss.position; this.m_qRotLocal = tbodySkinPos.pss.rotation; this.m_vScaleRate = tbodySkinPos.pss.scale; this.m_bEnablePartPosEdit = tbodySkinPos.bEnable; if (this.m_bEnablePartPosEdit) { this.obj_tr.localPosition = tbodySkinPos.pss.position; this.obj_tr.localRotation = tbodySkinPos.pss.rotation; this.obj_tr.localScale = tbodySkinPos.pss.scale; } } else { this.body.maid.ClearTBodySkinPos(this.m_ParentMPN, this.SlotId); } } } this.m_HairLengthCtrl.NotExistThenClearHairLength(); 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)) { this.LayerCheck(this.obj); } } public void ItemScaleReset() { if (this.m_mp != null && this.m_mp.bNoScale) { Transform parent = this.obj_tr.parent; this.obj_tr.SetParent(null, true); this.obj_tr.localScale = Vector3.one; this.obj_tr.SetParent(parent, true); } } private void LayerCheck(GameObject goParent) { for (int i = 0; i < goParent.transform.childCount; i++) { this.LayerCheck(goParent.transform.GetChild(i).gameObject); } goParent.layer = LayerMask.NameToLayer("Face"); } public void SetVisibleFlag(bool boSetFlag, string name, Transform t = null, bool boTgt = false) { if (t.name.IndexOf(name) >= 0) { boTgt = true; } if (name == "_ALL_") { boTgt = true; } if (boTgt) { this.m_dicDelNodeBody[t.name] = boSetFlag; } IEnumerator enumerator = t.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform t2 = (Transform)obj; this.SetVisibleFlag(boSetFlag, name, t2, boTgt); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } } public void SetVisibleFlagParts(bool f_bSetFlag, string f_strTargetSlot, string f_strBoneName, Transform t = null, bool boTgt = false) { if (t.name.IndexOf(f_strBoneName) >= 0) { boTgt = true; } if (f_strBoneName == "_ALL_") { boTgt = true; } if (boTgt) { Dictionary dictionary; if (!this.m_dicDelNodeParts.TryGetValue(f_strTargetSlot, out dictionary)) { dictionary = new Dictionary(); this.m_dicDelNodeParts.Add(f_strTargetSlot, dictionary); } dictionary[t.name] = f_bSetFlag; } IEnumerator enumerator = t.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform t2 = (Transform)obj; this.SetVisibleFlagParts(f_bSetFlag, f_strTargetSlot, f_strBoneName, t2, boTgt); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } } public void CopyTrans() { for (int i = 0; i < this.listTrs.Count; i += 2) { this.listTrs[i].localRotation = this.listTrs[i + 1].localRotation; this.listTrs[i].localPosition = this.listTrs[i + 1].localPosition; } for (int j = 0; j < this.listTrsScr.Count; j += 2) { this.listTrsScr[j].localScale = this.listTrsScr[j + 1].localScale; } this.TightSkirt(); } public void TightSkirt() { } private void LookAtAxis(Transform f_trSrc, Vector3 f_vTargetPosWorld, TBodySkin.Axis f_axis, Vector3 f_vForwardWorld) { Vector3 position = f_trSrc.InverseTransformPoint(f_vTargetPosWorld); if (f_axis == TBodySkin.Axis.X) { position.x = 0f; } else if (f_axis == TBodySkin.Axis.Y) { position.y = 0f; } else { position.z = 0f; } Vector3 vector = f_trSrc.TransformPoint(position); Debug.DrawLine(vector, f_trSrc.position, Color.cyan); Quaternion lhs = Quaternion.FromToRotation(f_vForwardWorld, (vector - f_trSrc.position).normalized); f_trSrc.rotation = lhs * f_trSrc.rotation; } public void OnChangeScreenSizeOrAA() { bool flag = QualitySettings.antiAliasing != 0; if (this.obj == null) { return; } bool flag2 = !flag && !GameMain.Instance.MainCamera.IsBloomEnabled; if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode) { flag2 = false; } this.obj.GetComponentsInChildren(true, this.m_listRnederTemp); for (int i = 0; i < this.m_listRnederTemp.Count; i++) { Renderer renderer = this.m_listRnederTemp[i]; if (!(renderer.material == null)) { foreach (Material material in renderer.materials) { if (flag2) { material.EnableKeyword("UV_POS_REVERSE"); material.DisableKeyword("UV_POS_NORMAL"); } else { material.DisableKeyword("UV_POS_NORMAL"); material.DisableKeyword("UV_POS_REVERSE"); } } } } } private IEnumerator CoReFixBlendValues() { yield return null; this.morph.ResetBlendValues(); yield break; } public void ManColorUpdate() { for (int i = 0; i < this.m_listManAlphaMat.Count; i++) { Material material = this.m_listManAlphaMat[i]; material.SetFloat("_FloatValue2", (float)GameMain.Instance.CMSystem.ManAlpha / 100f); material.SetColor("_Color", this.body.maid.ManColor); } } public bool AnimationLoad(string f_strAnimName) { if (this.m_animItem == null) { this.m_animItem = this.obj.AddComponent(); } if (this.m_animItem.GetClip(f_strAnimName) == null) { string text = f_strAnimName; if (string.IsNullOrEmpty(Path.GetExtension(text))) { text += ".anm"; } AnimationClip animationClip = ImportCM.LoadAniClipNative(GameUty.FileSystem, text, true, true, true); if (animationClip == null) { NDebug.Assert("アニメーション " + text + " が見つかりません。", false); return false; } this.m_animItem.Stop(); this.m_animItem.AddClip(animationClip, f_strAnimName); this.m_animItem.clip = animationClip; this.m_animItem.playAutomatically = true; } this.m_animItem.Stop(); return true; } public bool AnimationPlay(string f_strAnimName, bool f_bLoop) { if (this.m_animItem == null) { Debug.LogError("まだアイテムアニメが読まれていません。"); return false; } this.m_animItem.Stop(); this.m_animItem.wrapMode = ((!f_bLoop) ? WrapMode.Once : WrapMode.Loop); if (this.m_animItem.GetClip(f_strAnimName) == null) { NDebug.Assert("アニメーション " + f_strAnimName + " は設定されていません。", false); return false; } this.m_animItem[f_strAnimName].time = 0f; this.m_animItem.Play(f_strAnimName); return true; } public bool AnimationStop() { if (this.m_animItem == null) { return false; } this.m_animItem.Stop(); return true; } public bool MaterialAnimatorAdd(int f_nMateNo) { Renderer componentInChildren = this.obj.GetComponentInChildren(); if (componentInChildren != null) { MaterialAnimator materialAnimator = componentInChildren.gameObject.AddComponent(); materialAnimator.m_nMateNo = f_nMateNo; materialAnimator.Init(); } return true; } public void Update() { if (this.obj == null) { return; } if (this.obj.activeSelf != this.boVisible) { CMT.SetActiveFlag(this.obj_tr, this.boVisible); if (this.boVisible) { this.body.StartCoroutine(this.CoReFixBlendValues()); } } if (!this.boVisible) { return; } if (this.trsBoneAttach != null) { this.obj_tr.position = this.trsBoneAttach.position; this.obj_tr.rotation = this.trsBoneAttach.rotation; } if (this.AttachName != null && this.body.goSlot[this.AttachSlotIdx].morph != null) { Vector3 position; Quaternion rotation; Vector3 vector; if (this.body.goSlot[this.AttachSlotIdx].morph.GetAttachPoint(this.AttachName, out position, out rotation, out vector, this.m_bTemp)) { if (!this.AttachVisible) { this.obj_tr.localScale = Vector3.one; this.AttachVisible = true; } this.obj_tr.position = position; this.obj_tr.rotation = rotation; this.obj_tr.localScale = new Vector3(this.m_vDefScaleLocal.x * vector.x, this.m_vDefScaleLocal.y * vector.y, this.m_vDefScaleLocal.z * vector.z); } else if (this.AttachVisible) { this.obj_tr.localScale = Vector3.zero; this.AttachVisible = false; } } Vector3 localScale = this.m_trMaid.localScale; Vector3 localScale2 = this.m_trMaidOffs.localScale; if (localScale.x < 0.998f || 1.002f < localScale.x || localScale2.x < 0.998f || 1.002f < localScale2.x) { this.m_trMaid.localScale = Vector3.one; this.m_trMaidOffs.localScale = Vector3.one; this.bonehair.Update(); this.bonehair3.UpdateSelf(); this.m_trMaid.localScale = localScale; this.m_trMaidOffs.localScale = localScale2; } else { this.bonehair.Update(); this.bonehair3.UpdateSelf(); } } public TBody body; public string Category; public TBody.SlotID SlotId; public bool boVisible = true; public List listMaskSlot = new List(); public GameObject obj; public Transform obj_tr; public Transform center_tr; public Transform center_tr2; private List listTrs; private List listTrsScr; public List listDEL = new List(); public Dictionary dicDel = new Dictionary(); private List m_listRtMaterial = new List(); public TMorph morph; public Dictionary m_dicDelNodeBody = new Dictionary(); public Dictionary> m_dicDelNodeParts = new Dictionary>(); public TBoneHair_ bonehair; public BoneHair2 bonehair2; public BoneHair3 bonehair3; public bool boMizugi; public Dictionary[]> dicParamSet = new Dictionary[]>(); private Dictionary m_dicParam = new Dictionary(); private Dictionary m_dicParam2 = new Dictionary(); public Transform trsBoneAttach; public string AttachName; public bool AttachVisible; public int AttachSlotIdx; private Quaternion AttachRotation; public Vector3 m_vDefScaleLocal; public Vector3 m_vScaleRate; public Vector3 m_vTempAttachPointScale; public Vector3 m_vDefPosLocal; public Vector3 m_vPosLocal; public Vector3 m_vCenterPosLocal; public Vector3 m_vTempAttachPointPos; public Quaternion m_qDefRotLocal; public Quaternion m_qRotLocal; public Quaternion m_qTempAttachPointRot; public int RID; public int SyojiType; public string m_strModelFileName = string.Empty; public MPN m_ParentMPN; public MaidProp m_mp; private bool m_bMan; private List m_listManAlphaMat = new List(); public InfinityColorTextureCache TextureCache; private bool m_bEnablePartPosEdit; public Dictionary m_BonehairBodyhitScaleBackup = new Dictionary(); public Dictionary m_dicTempAttachPoint = new Dictionary(); public bool m_bHitFloorY = true; private Transform m_trMaid; private Transform m_trMaidOffs; private Dictionary m_dicBackupShader = new Dictionary(); private bool m_bTemp; private Transform m_trThigh_L; private Transform m_trThigh_R; private Transform m_trCalf_L; private Transform m_trCalf_R; private Transform m_trFoot_L; private Transform m_trFoot_R; public TBodySkin.OriVert m_OriVert = new TBodySkin.OriVert(); public TBodySkin.HairLengthCtrl m_HairLengthCtrl; private Animation m_animItem; private List m_listRnederTemp = new List(4); public class HairLengthCtrl { public HairLengthCtrl(TBodySkin f_trTbodySkin) { this.m_tbskin = f_trTbodySkin; this.m_maid = this.m_tbskin.body.maid; } public bool IsHairLengthEditable { get { return this.m_dicHairLenght != null && this.m_dicHairLenght.Count != 0; } } public Dictionary HairLengthGroupList { get { return this.m_dicHairLenght; } } public void NotExistThenClearHairLength() { if (this.m_maid.NotExistThenClearHairLengthMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId)) { } this.m_dicHairLenght.Clear(); } public void SearchAndAddHairLengthTarget(string f_strGroupName, string f_strBoneSearchType, string f_strBoneName, Vector3 f_vScaleMin, Vector3 f_vScaleMax) { if (this.m_tbskin == null || this.m_tbskin.obj_tr == null) { NDebug.Assert("髪ボーン拡縮検索 親が未だありません。", false); } string pattern = f_strBoneName.Replace("*", ".*"); TBodySkin.HairLengthCtrl.SerchMode mode = TBodySkin.HairLengthCtrl.SerchMode.ALL; if (f_strBoneSearchType == "fbrother") { mode = TBodySkin.HairLengthCtrl.SerchMode.FIRST_BROTHER; } else if (f_strBoneSearchType == "fchild") { mode = TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD; } else if (f_strBoneSearchType == "all") { mode = TBodySkin.HairLengthCtrl.SerchMode.ALL; } else { NDebug.Assert("髪ボーン検索タイプが不正です。 " + f_strBoneSearchType, false); } this.SearchObjName(f_strGroupName, this.m_tbskin.obj_tr, new Regex(pattern), mode); TBodySkin.HairLengthCtrl.HairLength hairLength; if (this.m_dicHairLenght.TryGetValue(f_strGroupName, out hairLength)) { hairLength.vScaleMin = f_vScaleMin; hairLength.vScaleMax = f_vScaleMax; } float lengthRate = 0.5f; if (this.m_maid.GetHairLengthFromMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId, f_strGroupName, out lengthRate)) { hairLength.SetLengthRate(lengthRate); } else { this.m_maid.ClearHairLengthMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId); } this.HairLenghtBlend(); } private Transform SearchObjName(string f_strGroupName, Transform t, Regex regex, TBodySkin.HairLengthCtrl.SerchMode mode) { string name = t.name; if (regex.IsMatch(name)) { TBodySkin.HairLengthCtrl.HairLength hairLength; if (!this.m_dicHairLenght.TryGetValue(f_strGroupName, out hairLength)) { hairLength = new TBodySkin.HairLengthCtrl.HairLength(this.m_tbskin, f_strGroupName); this.m_dicHairLenght[f_strGroupName] = hairLength; } hairLength.listTarget.Add(new TBodySkin.HairLengthCtrl.HairLengthTarget { trTarget = t, vScaleDef = t.localScale }); if (mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_BROTHER || mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD) { return t; } } for (int i = 0; i < t.childCount; i++) { Transform child = t.GetChild(i); Transform transform = this.SearchObjName(f_strGroupName, child, regex, mode); if (transform != null && mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD) { return transform; } } return null; } public void HairLenghtBlend() { foreach (KeyValuePair keyValuePair in this.m_dicHairLenght) { float lengthRate = keyValuePair.Value.GetLengthRate(); for (int i = 0; i < keyValuePair.Value.listTarget.Count; i++) { TBodySkin.HairLengthCtrl.HairLengthTarget hairLengthTarget = keyValuePair.Value.listTarget[i]; Vector3 localScale = hairLengthTarget.vScaleDef; if (lengthRate < 0.5f) { localScale = Vector3.Lerp(keyValuePair.Value.vScaleMin, hairLengthTarget.vScaleDef, lengthRate / 0.5f); } else if (0.5f < lengthRate) { localScale = Vector3.Lerp(hairLengthTarget.vScaleDef, keyValuePair.Value.vScaleMax, (lengthRate - 0.5f) / 0.5f); } hairLengthTarget.trTarget.localScale = localScale; } } } private Dictionary m_dicHairLenght = new Dictionary(); private TBodySkin m_tbskin; private Maid m_maid; public class HairLengthTarget { public Transform trTarget; public Vector3 vScaleDef; } public class HairLength { public HairLength(TBodySkin f_tbskin, string f_strGroupName) { this.m_tbskin = f_tbskin; this.strGroupName = f_strGroupName; } public float GetLengthRate() { return this.fLenghtRate; } public void SetLengthRate(float f_fRate) { Maid maid = this.m_tbskin.body.maid; MPN parentMPN = this.m_tbskin.m_ParentMPN; TBody.SlotID slotId = this.m_tbskin.SlotId; string f_strName = this.strGroupName; this.fLenghtRate = f_fRate; maid.SetHairLengthSaveToMP(parentMPN, slotId, f_strName, f_fRate); } private TBodySkin m_tbskin; private string strGroupName; private float fLenghtRate = 0.5f; public Vector3 vScaleMin; public Vector3 vScaleMax; public List listTarget = new List(); } private enum SerchMode { FIRST_CHILD, FIRST_BROTHER, ALL } } public class OriVert { public void Clear() { this.VCount = 0; this.vOriVert = null; this.vOriNorm = null; this.nSubMeshCount = 0; this.nSubMeshOriTri = null; this.bwWeight = null; } public int VCount; public Vector3[] vOriVert; public Vector3[] vOriNorm; public int nSubMeshCount; public int[][] nSubMeshOriTri; public BoneWeight[] bwWeight; } private enum Axis { X, Y, Z } }