Example #1
0
        public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, bool drawOnTop = false, float collisionIgnoreTimer = 0f)
        {
            if (particleCount >= MaxParticles || prefab == null || prefab.Sprites.Count == 0)
            {
                return(null);
            }

            Vector2 particleEndPos = prefab.CalculateEndPosition(position, velocity);

            Vector2 minPos = new Vector2(Math.Min(position.X, particleEndPos.X), Math.Min(position.Y, particleEndPos.Y));
            Vector2 maxPos = new Vector2(Math.Max(position.X, particleEndPos.X), Math.Max(position.Y, particleEndPos.Y));

            Rectangle expandedViewRect = MathUtils.ExpandRect(cam.WorldView, MaxOutOfViewDist);

            if (minPos.X > expandedViewRect.Right || maxPos.X < expandedViewRect.X)
            {
                return(null);
            }
            if (minPos.Y > expandedViewRect.Y || maxPos.Y < expandedViewRect.Y - expandedViewRect.Height)
            {
                return(null);
            }

            if (particles[particleCount] == null)
            {
                particles[particleCount] = new Particle();
            }

            particles[particleCount].Init(prefab, position, velocity, rotation, hullGuess, drawOnTop, collisionIgnoreTimer);

            particleCount++;

            return(particles[particleCount - 1]);
        }
Example #2
0
        public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, bool drawOnTop = false, float collisionIgnoreTimer = 0f, Tuple <Vector2, Vector2> tracerPoints = null)
        {
            if (prefab == null || prefab.Sprites.Count == 0)
            {
                return(null);
            }

            if (particleCount >= MaxParticles)
            {
                for (int i = 0; i < particleCount; i++)
                {
                    if (particles[i].Prefab.Priority < prefab.Priority)
                    {
                        RemoveParticle(i);
                        break;
                    }
                }
                if (particleCount >= MaxParticles)
                {
                    return(null);
                }
            }

            Vector2 particleEndPos = prefab.CalculateEndPosition(position, velocity);

            Vector2 minPos = new Vector2(Math.Min(position.X, particleEndPos.X), Math.Min(position.Y, particleEndPos.Y));
            Vector2 maxPos = new Vector2(Math.Max(position.X, particleEndPos.X), Math.Max(position.Y, particleEndPos.Y));

            if (tracerPoints != null)
            {
                minPos = new Vector2(
                    Math.Min(Math.Min(minPos.X, tracerPoints.Item1.X), tracerPoints.Item2.X),
                    Math.Min(Math.Min(minPos.Y, tracerPoints.Item1.Y), tracerPoints.Item2.Y));
                maxPos = new Vector2(
                    Math.Max(Math.Max(maxPos.X, tracerPoints.Item1.X), tracerPoints.Item2.X),
                    Math.Max(Math.Max(maxPos.Y, tracerPoints.Item1.Y), tracerPoints.Item2.Y));
            }

            Rectangle expandedViewRect = MathUtils.ExpandRect(cam.WorldView, MaxOutOfViewDist);

            if (minPos.X > expandedViewRect.Right || maxPos.X < expandedViewRect.X)
            {
                return(null);
            }
            if (minPos.Y > expandedViewRect.Y || maxPos.Y < expandedViewRect.Y - expandedViewRect.Height)
            {
                return(null);
            }

            if (particles[particleCount] == null)
            {
                particles[particleCount] = new Particle();
            }

            particles[particleCount].Init(prefab, position, velocity, rotation, hullGuess, drawOnTop, collisionIgnoreTimer, tracerPoints: tracerPoints);

            particleCount++;

            return(particles[particleCount - 1]);
        }
Example #3
0
        public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null)
        {
            this.prefab = prefab;

            spriteIndex = Rand.Int(prefab.Sprites.Count);

            animState = 0;
            animFrame = 0;

            currentHull = Hull.FindHull(position, hullGuess);

            this.position = position;
            prevPosition  = position;

            drawPosition = position;

            velocity = MathUtils.IsValid(speed) ? speed : Vector2.Zero;

            if (currentHull != null && currentHull.Submarine != null)
            {
                velocity += ConvertUnits.ToDisplayUnits(currentHull.Submarine.Velocity);
            }

            this.rotation = rotation + Rand.Range(prefab.StartRotationMinRad, prefab.StartRotationMaxRad);
            prevRotation  = rotation;

            angularVelocity = Rand.Range(prefab.AngularVelocityMinRad, prefab.AngularVelocityMaxRad);

            totalLifeTime = prefab.LifeTime;
            lifeTime      = prefab.LifeTime;

            size = prefab.StartSizeMin + (prefab.StartSizeMax - prefab.StartSizeMin) * Rand.Range(0.0f, 1.0f);

            sizeChange = prefab.SizeChangeMin + (prefab.SizeChangeMax - prefab.SizeChangeMin) * Rand.Range(0.0f, 1.0f);

            color = new Color(prefab.StartColor, 1.0f);
            alpha = prefab.StartAlpha;

            velocityChange = prefab.VelocityChangeDisplay;

            OnChangeHull = null;

            if (prefab.DeleteOnCollision || prefab.CollidesWithWalls)
            {
                hullGaps = currentHull == null ? new List <Gap>() : currentHull.ConnectedGaps;
            }

            if (prefab.RotateToDirection)
            {
                this.rotation = MathUtils.VectorToAngle(new Vector2(velocity.X, -velocity.Y));

                prevRotation = rotation;
            }
        }
Example #4
0
        public Particle CreateParticle(string prefabName, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, float collisionIgnoreTimer = 0f, Tuple <Vector2, Vector2> tracerPoints = null)
        {
            ParticlePrefab prefab = FindPrefab(prefabName);

            if (prefab == null)
            {
                DebugConsole.ThrowError("Particle prefab \"" + prefabName + "\" not found!");
                return(null);
            }
            return(CreateParticle(prefab, position, velocity, rotation, hullGuess, collisionIgnoreTimer: collisionIgnoreTimer, tracerPoints: tracerPoints));
        }
Example #5
0
        public Particle CreateParticle(string prefabName, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null)
        {
            ParticlePrefab prefab = FindPrefab(prefabName);

            if (prefab == null)
            {
                DebugConsole.ThrowError("Particle prefab \"" + prefabName + "\" not found!");
                return(null);
            }

            return(CreateParticle(prefab, position, velocity, rotation, hullGuess));
        }
        public ParticleEmitterPrefab(XElement element)
        {
            Name = element.Name.ToString();

            ParticlePrefab = GameMain.ParticleManager.FindPrefab(element.GetAttributeString("particle", ""));

            if (element.Attribute("startrotation") == null)
            {
                AngleMin = element.GetAttributeFloat("anglemin", 0.0f);
                AngleMax = element.GetAttributeFloat("anglemax", 0.0f);
            }
            else
            {
                AngleMin = element.GetAttributeFloat("angle", 0.0f);
                AngleMax = AngleMin;
            }

            AngleMin = MathHelper.ToRadians(MathHelper.Clamp(AngleMin, -360.0f, 360.0f));
            AngleMax = MathHelper.ToRadians(MathHelper.Clamp(AngleMax, -360.0f, 360.0f));

            if (element.Attribute("scalemin") == null)
            {
                ScaleMin = 1.0f;
                ScaleMax = 1.0f;
            }
            else
            {
                ScaleMin = element.GetAttributeFloat("scalemin", 1.0f);
                ScaleMax = Math.Max(ScaleMin, element.GetAttributeFloat("scalemax", 1.0f));
            }

            if (element.Attribute("velocity") == null)
            {
                VelocityMin = element.GetAttributeFloat("velocitymin", 0.0f);
                VelocityMax = element.GetAttributeFloat("velocitymax", 0.0f);
            }
            else
            {
                VelocityMin = element.GetAttributeFloat("velocity", 0.0f);
                VelocityMax = VelocityMin;
            }

            EmitInterval                  = element.GetAttributeFloat("emitinterval", 0.0f);
            ParticlesPerSecond            = element.GetAttributeInt("particlespersecond", 0);
            ParticleAmount                = element.GetAttributeInt("particleamount", 0);
            HighQualityCollisionDetection = element.GetAttributeBool("highqualitycollisiondetection", false);
            CopyEntityAngle               = element.GetAttributeBool("copyentityangle", false);
        }
Example #7
0
        public ParticleEmitterPrefab(XElement element)
        {
            Name = element.Name.ToString();

            ParticlePrefab = GameMain.ParticleManager.FindPrefab(element.GetAttributeString("particle", ""));

            if (element.Attribute("startrotation") == null)
            {
                AngleMin = element.GetAttributeFloat("anglemin", 0.0f);
                AngleMax = element.GetAttributeFloat("anglemax", 0.0f);
            }
            else
            {
                AngleMin = element.GetAttributeFloat("angle", 0.0f);
                AngleMax = AngleMin;
            }

            AngleMin = MathHelper.ToRadians(MathHelper.Clamp(AngleMin, -360.0f, 360.0f));
            AngleMax = MathHelper.ToRadians(MathHelper.Clamp(AngleMax, -360.0f, 360.0f));

            if (element.Attribute("scalemin") == null)
            {
                ScaleMin = 1.0f;
                ScaleMax = 1.0f;
            }
            else
            {
                ScaleMin = element.GetAttributeFloat("scalemin", 1.0f);
                ScaleMax = Math.Max(ScaleMin, element.GetAttributeFloat("scalemax", 1.0f));
            }

            if (element.Attribute("velocity") == null)
            {
                VelocityMin = element.GetAttributeFloat("velocitymin", 0.0f);
                VelocityMax = element.GetAttributeFloat("velocitymax", 0.0f);
            }
            else
            {
                VelocityMin = element.GetAttributeFloat("velocity", 0.0f);
                VelocityMax = VelocityMin;
            }

            ParticlesPerSecond = element.GetAttributeInt("particlespersecond", 0);
            ParticleAmount     = element.GetAttributeInt("particleamount", 0);
        }
Example #8
0
        public ParticleEmitterPrefab(XElement element)
        {
            Name = element.Name.ToString();

            particlePrefab = GameMain.ParticleManager.FindPrefab(ToolBox.GetAttributeString(element, "particle", ""));

            if (element.Attribute("startrotation") == null)
            {
                AngleMin = ToolBox.GetAttributeFloat(element, "anglemin", 0.0f);
                AngleMax = ToolBox.GetAttributeFloat(element, "anglemax", 0.0f);
            }
            else
            {
                AngleMin = ToolBox.GetAttributeFloat(element, "angle", 0.0f);
                AngleMax = AngleMin;
            }

            AngleMin = MathHelper.ToRadians(AngleMin);
            AngleMax = MathHelper.ToRadians(AngleMax);

            if (element.Attribute("scalemin") == null)
            {
                ScaleMin = 1.0f;
                ScaleMax = 1.0f;
            }
            else
            {
                ScaleMin = ToolBox.GetAttributeFloat(element, "scalemin", 1.0f);
                ScaleMax = Math.Max(ScaleMin, ToolBox.GetAttributeFloat(element, "scalemax", 1.0f));
            }

            if (element.Attribute("velocity") == null)
            {
                VelocityMin = ToolBox.GetAttributeFloat(element, "velocitymin", 0.0f);
                VelocityMax = ToolBox.GetAttributeFloat(element, "velocitymax", 0.0f);
            }
            else
            {
                VelocityMin = ToolBox.GetAttributeFloat(element, "velocity", 0.0f);
                VelocityMax = VelocityMin;
            }

            ParticleAmount = ToolBox.GetAttributeInt(element, "particleamount", 1);
        }
Example #9
0
        public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null)
        {
            if (particleCount >= MaxParticles || prefab == null || GameMain.NilMod.DisableParticles || !GameMain.NilMod.RenderOther)
            {
                return(null);
            }

            if (((Rand.Range(1, 100) <= GameMain.NilMod.ParticleSpawnPercent) || GameMain.NilMod.ParticleWhitelist.Find(p => p == prefab.Name) != null))
            {
                Vector2 particleEndPos = prefab.CalculateEndPosition(position, velocity);

                Vector2 minPos = new Vector2(Math.Min(position.X, particleEndPos.X), Math.Min(position.Y, particleEndPos.Y));
                Vector2 maxPos = new Vector2(Math.Max(position.X, particleEndPos.X), Math.Max(position.Y, particleEndPos.Y));

                Rectangle expandedViewRect = MathUtils.ExpandRect(cam.WorldView, MaxOutOfViewDist);
                if (!(Screen.Selected is ParticleEditorScreen))
                {
                    if (minPos.X > expandedViewRect.Right || maxPos.X < expandedViewRect.X)
                    {
                        return(null);
                    }
                    if (minPos.Y > expandedViewRect.Y || maxPos.Y < expandedViewRect.Y - expandedViewRect.Height)
                    {
                        return(null);
                    }
                }

                if (particles[particleCount] == null)
                {
                    particles[particleCount] = new Particle();
                }

                particles[particleCount].Init(prefab, position, velocity, rotation, hullGuess);

                particleCount++;

                return(particles[particleCount - 1]);
            }
            else
            {
                return(null);
            }
        }
Example #10
0
        public void RemoveByPrefab(ParticlePrefab prefab)
        {
            if (particles == null)
            {
                return;
            }
            for (int i = particles.Length - 1; i >= 0; i--)
            {
                if (particles[i]?.Prefab == prefab)
                {
                    if (i < particleCount)
                    {
                        particleCount--;
                    }

                    Particle swap = particles[particleCount];
                    particles[particleCount] = null;
                    particles[i]             = swap;
                }
            }
        }
Example #11
0
        public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation = 0.0f, Hull hullGuess = null)
        {
            if (!Submarine.RectContains(MathUtils.ExpandRect(cam.WorldView, MaxOutOfViewDist), position))
            {
                return(null);
            }
            //if (!cam.WorldView.Contains(position)) return null;

            if (particleCount >= MaxParticles)
            {
                return(null);
            }

            if (particles[particleCount] == null)
            {
                particles[particleCount] = new Particle();
            }

            particles[particleCount].Init(prefab, position, speed, rotation, hullGuess);

            particleCount++;

            return(particles[particleCount - 1]);
        }
Example #12
0
        public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null, bool drawOnTop = false)
        {
            this.prefab = prefab;

            spriteIndex = Rand.Int(prefab.Sprites.Count);

            animState = 0;
            animFrame = 0;
            dragWait  = 0;
            dragVec   = Vector2.Zero;

            currentHull = Hull.FindHull(position, hullGuess);

            this.position = position;
            prevPosition  = position;

            drawPosition = position;

            velocity = MathUtils.IsValid(speed) ? speed : Vector2.Zero;

            if (currentHull?.Submarine != null)
            {
                velocity += ConvertUnits.ToDisplayUnits(currentHull.Submarine.Velocity);
            }

            this.rotation = rotation + Rand.Range(prefab.StartRotationMinRad, prefab.StartRotationMaxRad);
            prevRotation  = rotation;

            angularVelocity = Rand.Range(prefab.AngularVelocityMinRad, prefab.AngularVelocityMaxRad);

            totalLifeTime = prefab.LifeTime;
            lifeTime      = prefab.LifeTime;
            startDelay    = Rand.Range(prefab.StartDelayMin, prefab.StartDelayMax);

            size = prefab.StartSizeMin + (prefab.StartSizeMax - prefab.StartSizeMin) * Rand.Range(0.0f, 1.0f);

            sizeChange = prefab.SizeChangeMin + (prefab.SizeChangeMax - prefab.SizeChangeMin) * Rand.Range(0.0f, 1.0f);

            color       = prefab.StartColor;
            changeColor = prefab.StartColor != prefab.EndColor;

            velocityChange      = prefab.VelocityChangeDisplay;
            velocityChangeWater = prefab.VelocityChangeWaterDisplay;

            HighQualityCollisionDetection = false;

            OnChangeHull = null;

            subEmitters.Clear();
            hasSubEmitters = false;
            foreach (ParticleEmitterPrefab emitterPrefab in prefab.SubEmitters)
            {
                subEmitters.Add(new ParticleEmitter(emitterPrefab));
                hasSubEmitters = true;
            }

            if (prefab.UseCollision)
            {
                hullGaps = currentHull == null ? new List <Gap>() : currentHull.ConnectedGaps;
            }

            if (prefab.RotateToDirection)
            {
                this.rotation = MathUtils.VectorToAngle(new Vector2(velocity.X, -velocity.Y));

                prevRotation = rotation;
            }

            DrawOnTop = drawOnTop;
        }
Example #13
0
        public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null)
        {
            this.prefab = prefab;

            spriteIndex = Rand.Int(prefab.Sprites.Count);

            animState = 0;
            animFrame = 0;
            dragWait  = 0;
            dragVec   = Vector2.Zero;

            currentHull = Hull.FindHull(position, hullGuess);

            this.position = position;
            prevPosition  = position;

            drawPosition = position;

            velocity = MathUtils.IsValid(speed) ? speed : Vector2.Zero;

            if (currentHull != null && currentHull.Submarine != null)
            {
                velocity += ConvertUnits.ToDisplayUnits(currentHull.Submarine.Velocity);
            }

            this.rotation = rotation + Rand.Range(prefab.StartRotationMinRad, prefab.StartRotationMaxRad);
            prevRotation  = rotation;

            angularVelocity = Rand.Range(prefab.AngularVelocityMinRad, prefab.AngularVelocityMaxRad);

            if (GameMain.NilMod.ParticleWhitelist.Find(p => p == prefab.Name) != null)
            {
                totalLifeTime = prefab.LifeTime;
                lifeTime      = prefab.LifeTime;
            }
            else
            {
                totalLifeTime = prefab.LifeTime * GameMain.NilMod.ParticleLifeMultiplier;
                lifeTime      = prefab.LifeTime * GameMain.NilMod.ParticleLifeMultiplier;
            }

            size = prefab.StartSizeMin + (prefab.StartSizeMax - prefab.StartSizeMin) * Rand.Range(0.0f, 1.0f);

            sizeChange = prefab.SizeChangeMin + (prefab.SizeChangeMax - prefab.SizeChangeMin) * Rand.Range(0.0f, 1.0f);

            color = new Color(prefab.StartColor, 1.0f);
            alpha = prefab.StartAlpha;

            velocityChange      = prefab.VelocityChangeDisplay;
            velocityChangeWater = prefab.VelocityChangeWaterDisplay;

            OnChangeHull = null;

            subEmitters.Clear();
            foreach (ParticleEmitterPrefab emitterPrefab in prefab.SubEmitters)
            {
                subEmitters.Add(new ParticleEmitter(emitterPrefab));
            }

            if (prefab.DeleteOnCollision || prefab.CollidesWithWalls)
            {
                hullGaps = currentHull == null ? new List <Gap>() : currentHull.ConnectedGaps;
            }

            if (prefab.RotateToDirection)
            {
                this.rotation = MathUtils.VectorToAngle(new Vector2(velocity.X, -velocity.Y));

                prevRotation = rotation;
            }
        }
        private void Emit(Vector2 position, Hull hullGuess, float angle, float particleRotation, float velocityMultiplier, float sizeMultiplier, Color?colorMultiplier = null, ParticlePrefab overrideParticle = null)
        {
            angle += Rand.Range(Prefab.AngleMin, Prefab.AngleMax);

            Vector2 dir      = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
            Vector2 velocity = dir * Rand.Range(Prefab.VelocityMin, Prefab.VelocityMax) * velocityMultiplier;

            position += dir * Rand.Range(Prefab.DistanceMin, Prefab.DistanceMax);

            var particle = GameMain.ParticleManager.CreateParticle(overrideParticle ?? Prefab.ParticlePrefab, position, velocity, particleRotation, hullGuess, Prefab.DrawOnTop);

            if (particle != null)
            {
                particle.Size *= Rand.Range(Prefab.ScaleMin, Prefab.ScaleMax) * sizeMultiplier;
                particle.HighQualityCollisionDetection = Prefab.HighQualityCollisionDetection;
                if (colorMultiplier.HasValue)
                {
                    particle.ColorMultiplier = colorMultiplier.Value.ToVector4();
                }
                else if (Prefab.ColorMultiplier != Color.White)
                {
                    particle.ColorMultiplier = Prefab.ColorMultiplier.ToVector4();
                }
            }
        }
        public void Emit(float deltaTime, Vector2 position, Hull hullGuess = null, float angle = 0.0f, float particleRotation = 0.0f, float velocityMultiplier = 1.0f, float sizeMultiplier = 1.0f, float amountMultiplier = 1.0f, Color?colorMultiplier = null, ParticlePrefab overrideParticle = null)
        {
            emitTimer      += deltaTime * amountMultiplier;
            burstEmitTimer -= deltaTime;

            if (Prefab.ParticlesPerSecond > 0)
            {
                float emitInterval = 1.0f / Prefab.ParticlesPerSecond;
                while (emitTimer > emitInterval)
                {
                    Emit(position, hullGuess, angle, particleRotation, velocityMultiplier, sizeMultiplier, colorMultiplier, overrideParticle);
                    emitTimer -= emitInterval;
                }
            }

            if (burstEmitTimer > 0.0f)
            {
                return;
            }

            burstEmitTimer = Prefab.EmitInterval;
            for (int i = 0; i < Prefab.ParticleAmount * amountMultiplier; i++)
            {
                Emit(position, hullGuess, angle, particleRotation, velocityMultiplier, sizeMultiplier, colorMultiplier, overrideParticle);
            }
        }
Example #16
0
        public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null, bool drawOnTop = false, float collisionIgnoreTimer = 0f, Tuple <Vector2, Vector2> tracerPoints = null)
        {
            this.prefab = prefab;
            debugName   = $"Particle ({prefab.Name})";

            spriteIndex = Rand.Int(prefab.Sprites.Count);

            animState = 0;
            animFrame = 0;

            currentHull = Hull.FindHull(position, hullGuess);

            size = prefab.StartSizeMin + (prefab.StartSizeMax - prefab.StartSizeMin) * Rand.Range(0.0f, 1.0f);

            if (tracerPoints != null)
            {
                size     = new Vector2(Vector2.Distance(tracerPoints.Item1, tracerPoints.Item2), size.Y);
                position = (tracerPoints.Item1 + tracerPoints.Item2) / 2;
            }

            sizeChange = prefab.SizeChangeMin + (prefab.SizeChangeMax - prefab.SizeChangeMin) * Rand.Range(0.0f, 1.0f);

            this.position = position;
            prevPosition  = position;

            drawPosition = position;

            velocity = MathUtils.IsValid(speed) ? speed : Vector2.Zero;

            if (currentHull?.Submarine != null)
            {
                velocity += ConvertUnits.ToDisplayUnits(currentHull.Submarine.Velocity);
            }

            this.rotation = rotation + Rand.Range(prefab.StartRotationMinRad, prefab.StartRotationMaxRad);
            prevRotation  = rotation;

            angularVelocity = Rand.Range(prefab.AngularVelocityMinRad, prefab.AngularVelocityMaxRad);


            if (prefab.LifeTimeMin <= 0.0f)
            {
                totalLifeTime = prefab.LifeTime;
                lifeTime      = prefab.LifeTime;
            }
            else
            {
                totalLifeTime = Rand.Range(prefab.LifeTimeMin, prefab.LifeTime);
                lifeTime      = totalLifeTime;
            }

            startDelay = Rand.Range(prefab.StartDelayMin, prefab.StartDelayMax);

            UseMiddleColor  = prefab.UseMiddleColor;
            color           = prefab.StartColor;
            changeColor     = prefab.StartColor != prefab.EndColor;
            ColorMultiplier = Vector4.One;

            velocityChange      = prefab.VelocityChangeDisplay;
            velocityChangeWater = prefab.VelocityChangeWaterDisplay;

            HighQualityCollisionDetection = false;

            OnChangeHull = null;

            subEmitters.Clear();
            hasSubEmitters = false;
            foreach (ParticleEmitterPrefab emitterPrefab in prefab.SubEmitters)
            {
                subEmitters.Add(new ParticleEmitter(emitterPrefab));
                hasSubEmitters = true;
            }

            if (prefab.UseCollision)
            {
                hullGaps = currentHull == null ? new List <Gap>() : currentHull.ConnectedGaps;
            }

            if (prefab.RotateToDirection)
            {
                this.rotation = MathUtils.VectorToAngle(new Vector2(velocity.X, -velocity.Y));

                prevRotation = rotation;
            }

            DrawOnTop = drawOnTop;

            this.collisionIgnoreTimer = collisionIgnoreTimer;
        }