Ejemplo n.º 1
0
    protected override void OnUpdate()
    {
        Entities.ForEach((Entity e, ref RigSpawner spawner) =>
        {
            if (EntityManager.HasComponent <RigDefinitionSetup>(spawner.RigPrefab))
            {
                var rigDefinition = EntityManager.GetComponentData <RigDefinitionSetup>(spawner.RigPrefab);
                if (!rigDefinition.Value.IsCreated)
                {
                    throw new System.ObjectDisposedException("RigDefinition is not Created");
                }

                RigEntityBuilder.SetupRigEntity(spawner.RigPrefab, EntityManager, rigDefinition.Value);
            }

            for (var x = 0; x < spawner.CountX; x++)
            {
                for (var y = 0; y < spawner.CountY; ++y)
                {
                    var rigInstance = EntityManager.Instantiate(spawner.RigPrefab);
                    var position    = new float3(x * 1.3F, 0, y * 1.3F);
                    EntityManager.SetComponentData(rigInstance, new Translation {
                        Value = position
                    });

                    if (m_Input != null)
                    {
                        m_Input.RegisterEntity(rigInstance);
                    }
                }
            }

            EntityManager.DestroyEntity(e);
        });
    }
Ejemplo n.º 2
0
    protected override void OnUpdate()
    {
        CompleteDependency();

        Entities
        .WithoutBurst()
        .WithStructuralChanges()
        .ForEach((Entity e, ref RigSpawner spawner) =>
        {
            for (var x = 0; x < spawner.CountX; x++)
            {
                for (var y = 0; y < spawner.CountY; ++y)
                {
                    var rigInstance = EntityManager.Instantiate(spawner.RigPrefab);
                    var translation = new float3(x * 1.3F, 0, y * 1.3F);
                    EntityManager.SetComponentData(rigInstance, new Translation {
                        Value = translation
                    });

                    if (m_Input != null)
                    {
                        m_Input.RegisterEntity(rigInstance);
                    }
                }
            }

            EntityManager.DestroyEntity(e);
        }).Run();
    }
Ejemplo n.º 3
0
    protected override void OnUpdate()
    {
        Entities.ForEach((Entity e, ref RigSpawner spawner) =>
        {
            for (var x = 0; x < spawner.CountX; x++)
            {
                for (var y = 0; y < spawner.CountY; ++y)
                {
                    var rigInstance = EntityManager.Instantiate(spawner.RigPrefab);
                    var position    = new float3(x * 1.3F, 0, y * 1.3F);
                    EntityManager.SetComponentData(rigInstance, new Translation {
                        Value = position
                    });

                    if (m_Input != null)
                    {
                        m_Input.RegisterEntity(rigInstance);
                    }
                }
            }

            EntityManager.DestroyEntity(e);
        });
    }