static void FKLateUpdatePostfix(FKCtrl __instance)
        {
            ChaControl chaControl = __instance.gameObject.GetComponent <ChaControl>();

            if (chaControl != null)
            {
                AdditionalAccessoryAdvancedParentController.ExternalUpdate(chaControl);
                AdditionalAccessoryAdvancedParentSkinnedMeshHelper.ExternalUpdate(chaControl, false, true, false, false);
            }
        }
        private void UpdateParent()
        {
            parentTransform = null;
            gameObject.transform.position         = Vector3.zero;
            gameObject.transform.eulerAngles      = Vector3.zero;
            gameObject.transform.localPosition    = Vector3.zero;
            gameObject.transform.localEulerAngles = Vector3.zero;


            if (meshHelper != null)
            {
                meshHelper.UnRegisterVertexListener(vertices[0], OnSkinnedMeshUpdate);
                vertices   = null;
                meshHelper = null;
            }

            if (altMeshHelper != null)
            {
                altMeshHelper.UnRegisterVertexListener(vertices[0], OnSkinnedMeshUpdate);
                altMeshHelper = null;
            }

            if (LinkParent != null && LinkParent.Length > 0)
            {
                if (LinkParent.IndexOf("|") > 0)
                {
                    try
                    {
#if DEBUG
                        Log.LogInfo($"Linking to Mesh Vertice at Transform location {LinkParent} | index {LinkParent.IndexOf("|")} Search: {LinkParent.Substring(0, LinkParent.IndexOf("|"))}");
#endif
                        parentTransform = ChaControl.gameObject.transform.Find(LinkParent.Substring(0, LinkParent.IndexOf("|")))?.transform;
                        if (parentTransform != null)
                        {
                            string   verticesString = LinkParent.Substring(LinkParent.IndexOf("|") + 1, LinkParent.Length - LinkParent.IndexOf("|") - 1);
                            string[] verticeStrings = verticesString.Split('|');
                            vertices = new int[verticeStrings.Length];
                            for (int i = 0; i < verticeStrings.Length; i++)
                            {
                                vertices[i] = int.Parse(verticeStrings[i]);
                            }

                            meshHelper            = parentTransform.gameObject.GetOrAddComponent <AdditionalAccessoryAdvancedParentSkinnedMeshHelper>();
                            meshHelper.ChaControl = ChaControl;
                            if (AnimatedBoneNames.Contains(parentTransform.gameObject.name) || ContainsCustomBones())
                            {
                                meshHelper.RenderAlways = true;
                            }

                            meshHelper.RegisterVertexListener(vertices[0], OnSkinnedMeshUpdate);

                            if (parentTransform.name == "o_tang")
                            {
                                altMeshHelper              = ChaControl.transform.Find("BodyTop/p_cf_body_00/n_o_root/n_body_base/N_mnpbset/N_tang/o_tang").gameObject.GetOrAddComponent <AdditionalAccessoryAdvancedParentSkinnedMeshHelper>();
                                altMeshHelper.ChaControl   = ChaControl;
                                altMeshHelper.RenderAlways = true;
                                altMeshHelper.RegisterVertexListener(vertices[0], OnSkinnedMeshUpdate);
                            }

#if DEBUG
                            Log.LogInfo($"Attaching to SM at {parentTransform} Vertices {vertices}");
#endif
                        }
                    }
                    catch
                    {
                        vertices        = null;
                        LinkParent      = null;
                        parentTransform = null;
                        meshHelper      = null;
                        altMeshHelper   = null;
                    }
                }
                else
                {
                    parentTransform = ChaControl.gameObject.transform.Find(LinkParent)?.transform;
                }
            }
#if DEBUG
            if (parentTransform)
            {
                Log.LogInfo($"Linked to {parentTransform}  {LinkParent}");
            }
            else
            {
                Log.LogInfo($"Parent Link Not Found {LinkParent}");
            }
#endif

            // Re-Check for dynamic bones in the parent hierarchy
            if (DynamicBone != null && DynamicBone.GetType() == typeof(DynamicBone))
            {
                AdditionalAccessoryControlDynamicBoneUpdateManager.UnRegisterDynamicBone((DynamicBone)DynamicBone, OnDynamicBoneUpdate);
            }
            else if (DynamicBone != null && DynamicBone.GetType() == typeof(DynamicBone_Ver02))
            {
                AdditionalAccessoryControlDynamicBoneUpdateManager.UnRegisterDynamicBone((DynamicBone_Ver02)DynamicBone, OnDynamicBoneV2Update);
            }

            DynamicBone = null;
            dynamicBonesInstantiated = true;
            if (parentTransform != null)
            {
                ScanForDynamicBone();
            }
        }
Exemplo n.º 3
0
 static void BoneControllerLateUpdatePostfix(BoneController __instance)
 {
     AdditionalAccessoryAdvancedParentController.ExternalUpdate(__instance.ChaControl);
     AdditionalAccessoryAdvancedParentSkinnedMeshHelper.ExternalUpdate(__instance.ChaControl, false, false, false, true);
 }
Exemplo n.º 4
0
 static void ChaControlLateUpdateForcePostfix(ChaControl __instance)
 {
     AdditionalAccessoryAdvancedParentController.ExternalUpdate(__instance);
     AdditionalAccessoryAdvancedParentSkinnedMeshHelper.ExternalUpdate(__instance, false, false, true, false);
 }