Ejemplo n.º 1
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        GameDebug.Log(string.Format("Convert Item:{0}", this));

        dstManager.AddComponentData(entity, Item.InputState.Default);

        AbilityCollectionAuthoring.AddAbilityComponents(entity, dstManager, conversionSystem, abilities);



        var runtimeBoneRef = RuntimeBoneReference.Default;

        runtimeBoneRef.ReferenceRig = RigDefinitionAsset.ConvertRig(attachBone2.RigAsset);
        runtimeBoneRef.BoneIndex    = attachBone2.BoneIndex;
        RigAttacher.AddRigAttacher(entity, dstManager, runtimeBoneRef);
    }
Ejemplo n.º 2
0
        void ConvertAttahments(RigBasedAssetAuthoring assetAuthoring, Entity assetEntity, RigComponent rigComponent, BlobAssetReference <RigDefinition> rig)
        {
            var attachmentInfos   = new List <AttachmentData>();
            var rigComponentBones = new List <Transform>(rigComponent.Bones);

            for (int nBone = 0; nBone < rigComponentBones.Count; nBone++)
            {
                var localBone = rigComponentBones[nBone];
                for (int nChild = 0; nChild < localBone.childCount; nChild++)
                {
                    var child = localBone.GetChild(nChild);

                    // Ignore children that are also bones
                    if (rigComponentBones.Contains(child))
                    {
//                        GameDebug.Log("bone" + child + " should not be attached");
                        continue;
                    }
                    attachmentInfos.Add(new AttachmentData {
                        go        = child.gameObject,
                        boneIndex = nBone,
                    });
                }
            }


            if (attachmentInfos.Count > 0)
            {
                DstEntityManager.AddBuffer <RigBasedAsset.Attachment>(assetEntity);
            }

            // Find objects attached to bones
            for (int i = 0; i < attachmentInfos.Count; i++)
            {
                var attachmentInfo   = attachmentInfos[i];
                var attachmentEntity = GetPrimaryEntity(attachmentInfo.go);

                var assetAttachments = DstEntityManager.GetBuffer <RigBasedAsset.Attachment>(assetEntity);
                assetAttachments.Add(new RigBasedAsset.Attachment()
                {
                    Value = attachmentEntity
                });

                DstEntityManager.AddComponentData(attachmentEntity, new RigAttacher.AttachEntity()
                {
                    Value = attachmentEntity,
                });


                // Remove from parent
                if (DstEntityManager.HasComponent <Parent>(attachmentEntity))
                {
                    DstEntityManager.RemoveComponent <Parent>(attachmentEntity);
                }
                if (DstEntityManager.HasComponent <LocalToParent>(attachmentEntity))
                {
                    DstEntityManager.RemoveComponent <LocalToParent>(attachmentEntity);
                }
                if (!DstEntityManager.HasComponent <Static>(attachmentEntity))
                {
                    DstEntityManager.AddComponent <Static>(attachmentEntity);
                }

                // Add rig attacher
                var boneRef = RuntimeBoneReference.Default;
                boneRef.BoneIndex    = attachmentInfo.boneIndex;
                boneRef.ReferenceRig = rig;
                RigAttacher.AddRigAttacher(attachmentEntity, DstEntityManager, boneRef);


                GameDebug.Log("  Found attrachment:{0} on bone:{1} rig:{2}", attachmentInfo.go, boneRef.BoneIndex, rigComponent);
            }
        }