Пример #1
0
        /// <summary>
        /// ゲームオブジェクトとしての子オブジェクトは、変換プロセスにて、すべてエンティティとして生成されるようす。
        /// physics もそれをあてにするようなので、ボーンもそれに乗っかろうと思う。
        /// </summary>
        static Entity[] addComponentsBoneEntities
            (GameObjectConversionSystem gcs, Transform[] bones)
        {
            var em = gcs.DstEntityManager;

            return(bones
                   .Select(bone => gcs.TryGetPrimaryEntity(bone))
                   //.Select( existsEnt => existsEnt != Entity.Null ? addComponents_(existsEnt) : create_() )
                   .Do(ent => addComponents_(ent))
                   .ToArray());

            Entity addComponents_(Entity exists_)
            {
                var addtypes = new ComponentTypes
                               (
                    typeof(Bone.RelationLinkData),
                    typeof(Bone.LocalValueData),// 回転と移動をわけたほうがいいか?
                    typeof(Translation),
                    typeof(Rotation)
                               );

                em.AddComponents(exists_, addtypes);

                return(exists_);
            }
        }
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var attachToTransformEntity = conversionSystem.TryGetPrimaryEntity(TransformToAttachTo);

        if (MaintainOffset)
        {
            // We don't take a shortcut by computing
            // l2pMatrix = TransformToAttachTo.worldToLocalMatrix * transform.localToWorldMatrix
            // because the Transform system computes the LocalToParent from the TRS components,
            // but not the other way around.
            // Setting only the LocalToParent matrix will result in it being overriden by the
            // TRS after the conversion.

            var t = TransformToAttachTo.InverseTransformPoint(transform.position);
            var r = TransformToAttachTo.worldToLocalMatrix.rotation * transform.rotation;
            var s = Vector3.Scale(TransformToAttachTo.worldToLocalMatrix.lossyScale, transform.lossyScale);

            AttachTo(entity, attachToTransformEntity, dstManager, t, r, s);
        }
        else
        {
            AttachTo(entity, attachToTransformEntity, dstManager,
                     transform.position, transform.rotation, transform.lossyScale);
        }
    }
Пример #3
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var animPrefab = conversionSystem.TryGetPrimaryEntity(animObj);
        var animCom    = animObj.GetComponent <Animator>();

        dstManager.AddComponentData <AnimatorComponent>(entity, new AnimatorComponent()
        {
        });
    }
Пример #4
0
 public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
 {
     dstManager.AddComponentData(entity, new Faction
     {
         name = name,
         remainingReinforcements = totalUnits,
         maxFieldUnits           = maxUnitsAtOnce,
         spawnWeightInverse      = spawnWeightInverse,
         aiPrefab     = conversionSystem.GetPrimaryEntity(aiShipPrefab),
         playerPrefab = conversionSystem.TryGetPrimaryEntity(playerShipPrefab)
     });
     dstManager.AddComponent <FactionTag>(entity);
 }
Пример #5
0
        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            dstManager.AddComponentData(entity, new WormholeDestination {
                wormholeDestination = conversionSystem.TryGetPrimaryEntity(otherEnd)
            });
            dstManager.AddComponent <WormholeTag>(entity);

            dstManager.AddComponentData(entity, new GravityWarpZone
            {
                swarchschildRadius = swarchschildRadius,
                maxW = maxW
            });
            dstManager.AddComponentData(entity, new GravityWarpZoneRadius {
                radius = gravityWarpZoneRadius
            });
            dstManager.AddComponent <GravityWarpZoneTag>(entity);
        }
Пример #6
0
        static void addMainEntityLinkForCollider
            (GameObjectConversionSystem gcs, GameObject main, Transform[] bones)
        {
            var em         = gcs.DstEntityManager;
            var mainEntity = gcs.GetPrimaryEntity(main);

            var qBoneWithCollider = bones
                                    .Where(bone => bone.GetComponent <PhysicsShapeAuthoring>() != null)
                                    .Select(bone => gcs.TryGetPrimaryEntity(bone));

            foreach (var ent in qBoneWithCollider)
            {
                em.AddComponentData(ent, new Bone.MainEntityLinkData {
                    MainEntity = mainEntity
                });
            }
        }
Пример #7
0
    public override void AddGraphSetupComponent(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        if (dstManager.HasComponent<Rig>(entity))
        {
            var srcRigPrefab = conversionSystem.TryGetPrimaryEntity(SourceRigPrefab);
            var srcRigDefinition = dstManager.GetComponentData<Rig>(srcRigPrefab);
            var dstRigDefinition = dstManager.GetComponentData<Rig>(entity);

            var graphSetup = new RetargetSetup
            {
                SrcClip = ClipBuilder.AnimationClipToDenseClip(SourceClip),
                SrcRig = srcRigDefinition.Value,
                RemapTable = m_RemapQuery.ToRigRemapTable(srcRigDefinition.Value, dstRigDefinition.Value)
            };

            dstManager.AddComponentData(entity, graphSetup);
        }
    }
Пример #8
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var srcRigComponent  = SourceRigPrefab.GetComponent <RigComponent>();
        var dstRigComponent  = GetComponent <RigComponent>();
        var srcRigPrefab     = conversionSystem.TryGetPrimaryEntity(SourceRigPrefab);
        var srcRigDefinition = dstManager.GetComponentData <Rig>(srcRigPrefab);

        StringHash binding   = RemapLocalToRoot.transform.name;
        var        overrides = new Unity.Animation.RigRemapUtils.OffsetOverrides(1, Allocator.Temp);

        overrides.AddTranslationOffsetOverride(binding, new RigTranslationOffset {
            Rotation = quaternion.identity, Scale = 1f, Space = RigRemapSpace.LocalToRoot
        });
        overrides.AddRotationOffsetOverride(binding, new RigRotationOffset {
            PreRotation = quaternion.identity, PostRotation = quaternion.identity, Space = RigRemapSpace.LocalToRoot
        });

        var customHasher = new BindingHashGenerator
        {
            TransformBindingHashFunction = BindingHashGlobals.TransformBindingHashName,
            GenericBindingHashFunction   = BindingHashGlobals.GenericBindingHashName
        };

        var setup = new RigRemapSetup
        {
            SrcClip = SourceClip.ToDenseClip(),
            SrcRig  = srcRigDefinition.Value,

            // Automatically create a remap table based on matching rig component properties. This example uses two hierarchies that are
            // different but have matching transform names. For this specific case, we'll use a custom BindingHashGenerator (lines 33-37) to hash only transform names instead
            // of the default hashing strategy to find matching entries. Given we are remapping the srcRig (TerraFormerLOD1) to
            // a sub rig part (HandRigLOD0) we override the remapping offsets of the RightHand transform to perform operations in
            // LocalToRoot space (lines 29-32) in order to displace the hand at the wanted position/rotation.
            RemapTable = Unity.Animation.Hybrid.RigRemapUtils.CreateRemapTable(
                srcRigComponent, dstRigComponent, Unity.Animation.RigRemapUtils.ChannelFilter.All, overrides, customHasher
                )
        };

        dstManager.AddComponentData(entity, setup);

        dstManager.AddComponent <DeltaTime>(entity);
    }
Пример #9
0
 public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
 {
     if (destroyAllFactions)
     {
         dstManager.AddComponent <LastAliveObjectiveTag>(entity);
     }
     else
     {
         var factions = dstManager.AddBuffer <DestroyFactionObjective>(entity);
         foreach (var f in factionsToDestroy)
         {
             if (f != null)
             {
                 factions.Add(new DestroyFactionObjective {
                     factionToDestroy = conversionSystem.TryGetPrimaryEntity(f)
                 });
             }
         }
     }
 }
Пример #10
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var dstRig = GetComponent <RigComponent>();
        var srcRig = SourceRigPrefab.GetComponent <RigComponent>();
        var query  = CreateRemapQuery(srcRig, dstRig, RetargetMap);

        var srcRigPrefab     = conversionSystem.TryGetPrimaryEntity(SourceRigPrefab);
        var srcRigDefinition = dstManager.GetComponentData <Rig>(srcRigPrefab);
        var dstRigDefinition = dstManager.GetComponentData <Rig>(entity);

        var setup = new RigRemapSetup
        {
            SrcClip    = SourceClip.ToDenseClip(),
            SrcRig     = srcRigDefinition.Value,
            RemapTable = query.ToRigRemapTable(srcRigDefinition.Value, dstRigDefinition.Value)
        };

        dstManager.AddComponentData(entity, setup);

        dstManager.AddComponent <DeltaTime>(entity);
    }
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var srcRigPrefab     = conversionSystem.TryGetPrimaryEntity(SourceRigPrefab);
        var srcRigDefinition = dstManager.GetComponentData <Rig>(srcRigPrefab);
        var dstRigDefinition = dstManager.GetComponentData <Rig>(entity);

        var setup = new RigRemapSetup
        {
            SrcClip = SourceClip.ToDenseClip(),
            SrcRig  = srcRigDefinition.Value,

            // Automatically create a remap table based on matching rig definition bindings.
            // This is useful for LOD setups which define matching skeleton hierarchies.
            // This example uses the TerraFormerLOD1 (srcRigDefinition) which animates 31 bones and the animation data is remapped
            // to TerraFormerLOD0 (dstRigDefinition) containing 131 bones.
            RemapTable = Unity.Animation.RigRemapUtils.CreateRemapTable(srcRigDefinition.Value, dstRigDefinition.Value)
        };

        dstManager.AddComponentData(entity, setup);

        dstManager.AddComponent <DeltaTime>(entity);
    }
Пример #12
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var rigPrefab = conversionSystem.TryGetPrimaryEntity(RigPrefab);

        if (rigPrefab == Entity.Null)
        {
            throw new Exception($"Something went wrong while creating an Entity for the rig prefab: {RigPrefab.name}");
        }

        if (GraphPrefab != null)
        {
            var rigComponent = RigPrefab.GetComponent <RigComponent>();
            GraphPrefab.PreProcessData(rigComponent);
            GraphPrefab.AddGraphSetupComponent(rigPrefab, dstManager, conversionSystem);
        }

        dstManager.AddComponentData(entity, new RigSpawner
        {
            RigPrefab = rigPrefab,
            CountX    = CountX,
            CountY    = CountY,
        });
    }
Пример #13
0
        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            dstManager.AddComponentData(entity, new ShipSpeedStats
            {
                topSpeed     = topSpeed,
                boostSpeed   = boostSpeed,
                reverseSpeed = reverseSpeed,
                turnSpeed    = math.radians(turnSpeed),

                acceleration      = acceleration,
                deceleration      = deceleration,
                boostAcceleration = boostAcceleration,

                boostCapacity     = boostCapacity,
                boostDepleteRate  = boostDepletionRate,
                boostRechargeRate = boostRechargeRate
            });
            dstManager.AddComponentData(entity, new ShipBoostTank {
                boost = initialBoost
            });
            dstManager.AddComponentData(entity, new Speed {
                speed = 0f
            });

            dstManager.AddComponentData(entity, new ShipHealth {
                health = health
            });
            dstManager.AddComponentData(entity, new Damage {
                damage = collisionDamageToOther
            });
            dstManager.AddComponentData(entity, new CameraMountPoint {
                mountPoint = conversionSystem.TryGetPrimaryEntity(cameraMountPoint)
            });
            dstManager.AddComponentData(entity, new ShipExplosionPrefab {
                explosionPrefab = conversionSystem.TryGetPrimaryEntity(explosionPrefab)
            });
            var gunBuffer = dstManager.AddBuffer <ShipGunPoint>(entity);

            foreach (var gunTip in gunTips)
            {
                gunBuffer.Add(new ShipGunPoint {
                    gun = conversionSystem.GetPrimaryEntity(gunTip)
                });
            }

            dstManager.AddComponentData(entity, new ShipReloadTime
            {
                bulletReloadTime    = 0f,
                maxBulletReloadTime = math.rcp(fireRate),
                bulletsRemaining    = bulletsPerClip,
                bulletsPerClip      = bulletsPerClip,
                clipReloadTime      = clipReloadTime,
                maxClipReloadTime   = clipReloadTime
            });
            dstManager.AddComponentData(entity, new ShipBulletPrefab {
                bulletPrefab = conversionSystem.TryGetPrimaryEntity(bulletPrefab)
            });

            dstManager.AddComponent <ShipDesiredActions>(entity);
            dstManager.AddComponent <ShipTag>(entity);
        }