Exemplo n.º 1
0
        public override Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent)
        {
            var name = ComputeNewName(parent, "Smoke particle system");

            var component = new ParticleSystemComponent();
            var emitter   = new ParticleEmitter {
                ParticleLifetime = new Vector2(1, 2)
            };


            // 20 Particle per second
            var spawner = new SpawnerPerSecond {
                SpawnCount = 20
            };

            emitter.Spawners.Add(spawner);

            // Size
            var randSize = new InitialSizeSeed {
                RandomSize = new Vector2(0.35f, 0.55f)
            };

            emitter.Initializers.Add(randSize);

            // Position
            var randPos = new InitialPositionSeed
            {
                PositionMin = new Vector3(-0.2f, 0, -0.2f),
                PositionMax = new Vector3(0.2f, 0, 0.2f)
            };

            emitter.Initializers.Add(randPos);

            // Velocity
            var randVel = new InitialVelocitySeed
            {
                VelocityMin = new Vector3(-0.5f, 1f, -0.5f),
                VelocityMax = new Vector3(0.5f, 3, 0.5f)
            };

            emitter.Initializers.Add(randVel);

            component.ParticleSystem.Emitters.Add(emitter);

            return(CreateEntityWithComponent(name, component));
        }