public void AddAsteroid(Vector3 position, asteroidInfo asteroidType)
        {
            Hulk item = new Hulk();

            item.modelMesh = asteroidType.model;
            item.Position  = position;

            item.Rotation = Quaternion.CreateFromYawPitchRoll(
                Helpers.randFloat(-3, 3),
                Helpers.randFloat(-3, 3),
                Helpers.randFloat(-3, 3));

            item.permanent = true;
            item.BSphere   = new BoundingSphere(item.Position, FrameworkCore.ModelArray[(int)item.modelMesh].Meshes[0].BoundingSphere.Radius);

            item.CollisionSpheres = new CollisionSphere[asteroidType.collisionSpheres.Length];

            for (int i = 0; i < asteroidType.collisionSpheres.Length; i++)
            {
                item.CollisionSpheres[i] = new CollisionSphere(asteroidType.collisionSpheres[i].sphere,
                                                               asteroidType.collisionSpheres[i].offset);
            }

            item.UpdateCollisionSpheres();


            hulks.Add(item);
        }
        public virtual void Draw(GameTime gameTime, Camera camera, PlayerCommander curPlayer)
        {
            if (hulks.Count <= 0)
            {
                return;
            }

            for (int i = 0; i < hulks.Count; i++)
            {
                if (!Helpers.IsHulk(hulks[i]))
                {
                    continue;
                }

                Hulk item = (Hulk)hulks[i];


                if (!FrameworkCore.HideHud)
                {
                    if (!FrameworkCore.level.isDemo)
                    {
                        Vector3 gridPos = item.Position;
                        gridPos.Y = curPlayer.GridAltitude;
                        Color lineColor = new Color(96, 96, 96, 160);

                        //The rod line attached to asteroids/rubble/etc.
                        FrameworkCore.lineRenderer.Draw(item.Position, gridPos, lineColor);

                        Helpers.DrawDiamond(gridPos, .5f, lineColor); //BC 3-28-2019 New addition to 2019 build.
                        //Helpers.DrawDiamond(gridPos, item.BSphere.Radius, lineColor);
                        //FrameworkCore.pointRenderer.Draw(gridPos, 6, new Color(0, 0, 0, 128));
                        //FrameworkCore.pointRenderer.Draw(gridPos, 4, lineColor);
                    }
                }
                //FrameworkCore.discRenderer.Draw(1.5f, gridPos, lineColor);



                Matrix worldMatrix = Matrix.CreateFromQuaternion(item.Rotation);
                worldMatrix.Translation = item.Position;

                FrameworkCore.meshRenderer.Draw(item.modelMesh, worldMatrix, camera);

                if (FrameworkCore.debugMode)
                {
                    for (int k = 0; k < item.CollisionSpheres.Length; k++)
                    {
                        BoundingSphere sphere = item.CollisionSpheres[k].sphere;
                        FrameworkCore.sphereRenderer.Draw(sphere, Matrix.Identity, Color.LimeGreen);
                    }
                }
            }
        }
        /// <summary>
        /// When a ship gets blown up, spawn chunks.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="ShipOwner"></param>
        /// <param name="position"></param>
        /// <param name="MoveDir"></param>
        public void AddHulk(ModelType model, SpaceShip ShipOwner, Vector3 position, Vector3 MoveDir)
        {
            MoveDir.Normalize();

            Hulk item = new Hulk();

            item.modelMesh = model;
            item.Position  = position;
            item.moveDir   = MoveDir;

            item.shipOwner = ShipOwner;

            Matrix lookAt = Matrix.CreateLookAt(item.Position, item.Position + MoveDir, Vector3.Up);

            item.Rotation = Quaternion.CreateFromRotationMatrix(Matrix.Invert(lookAt));


            float lifeTimeModifier = Helpers.randFloat(1.25f, 1.75f);

            item.lifeTime = (int)(Helpers.MAXROUNDTIME * lifeTimeModifier);
            item.speed    = MathHelper.Lerp(8, 12, (float)FrameworkCore.r.NextDouble());;
            item.BSphere  = new BoundingSphere(item.Position, 2f);

            float x = 0;
            float y = 0;

            if ((float)FrameworkCore.r.NextDouble() > 0.5f)
            {
                x = MathHelper.Lerp(-0.0008f, 0.0008f, (float)FrameworkCore.r.NextDouble());
                y = MathHelper.Lerp(-0.0004f, 0.004f, (float)FrameworkCore.r.NextDouble());
            }
            else
            {
                x = MathHelper.Lerp(-0.0004f, 0.0004f, (float)FrameworkCore.r.NextDouble());
                y = MathHelper.Lerp(-0.0008f, 0.0008f, (float)FrameworkCore.r.NextDouble());
            }

            item.angularVelocity  = new Vector3(x, y, 0);
            item.CollisionSpheres = new CollisionSphere[1]
            {
                new CollisionSphere(new BoundingSphere(item.Position, 2f), Vector3.Zero)
            };

            item.emitter = FrameworkCore.Particles.CreateHulkEmitter(item.Position);

            hulks.Add(item);



            FrameworkCore.playbackSystem.AddItem(item, objectType.hulk, ShipOwner.owner.ShipColor);
        }
        public void Update(GameTime gameTime)
        {
            //check if we have any hulks in our list.
            if (hulks.Count <= 0)
            {
                return;
            }

            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            for (int i = 0; i < hulks.Count; i++)
            {
                if (!Helpers.IsHulk(hulks[i]))
                {
                    continue;
                }


                Hulk item = (Hulk)hulks[i];

                //update position.
                item.Position += (item.speed * item.moveDir) * dt;


                if (item.angularVelocity != Vector3.Zero)
                {
                    float time = item.lifeTime;
                    item.Rotation = Quaternion.CreateFromYawPitchRoll(
                        item.angularVelocity.X * time,
                        item.angularVelocity.Y * time,
                        item.angularVelocity.Z * time);
                }


                if (item.speed > 0)
                {
                    if (item.debrisTimer <= 0)
                    {
                        item.debrisTimer = FrameworkCore.r.Next(200, 500);
                        FrameworkCore.debrisManager.AddHulkTrail(item.Position, item.moveDir);
                    }
                    else
                    {
                        item.debrisTimer -= (int)gameTime.ElapsedGameTime.TotalMilliseconds;
                    }
                }



                item.UpdateCollisionSpheres();

                if (item.emitter != null)
                {
                    item.emitter.Update(gameTime, item.Position);
                }

                //update lifetime. Remove from list if it expires.
                if (!item.permanent)
                {
                    item.lifeTime -= (int)gameTime.ElapsedGameTime.TotalMilliseconds;
                    if (item.lifeTime <= 0)
                    {
                        KillHulk(item);
                        //hulks.Remove(item);
                        //FrameworkCore.playbackSystem.KillItem(item);
                    }
                }
            }
        }