public override void HandleCollisions(CollisionBody collider, CollisionType colliderType)
 {
     if (collider is Projectile)
     {
         Projectile collidingProjectile = collider as Projectile;
         health -= 1;
         if (health <= 0)
         {
             DropPowerUp(1, new Vector2(Width / 2f, Height / 2f));
             SpawnGore(Main.random.Next(8, 10 + 1), Width, Height, Main.random.Next(1, 2 + 1));
             GenerateSmoke(Color.Orange, Color.Gray, Width, Height, 16);
             if (beam != null)
             {
                 beam.DestroyInstance(beam);
                 beam = null;
             }
             DestroyInstance(this);
         }
         Explosion.NewExplosion(collidingProjectile.position, Vector2.Zero);
         collidingProjectile.DestroyInstance(collidingProjectile);
     }
     if (collider is Asteroid)
     {
         Asteroid collidingAsteroid = collider as Asteroid;
         collidingAsteroid.health -= 2;
         Explosion.NewExplosion(collidingAsteroid.position, Vector2.Zero);
         DropPowerUp(1, new Vector2(Width / 2f, Height / 2f));
         SpawnGore(Main.random.Next(8, 10 + 1), Width, Height, Main.random.Next(1, 2 + 1));
         GenerateSmoke(Color.Orange, Color.Gray, Width, Height, 16);
         if (beam != null)
         {
             beam.DestroyInstance(beam);
             beam = null;
         }
         DestroyInstance(this);
     }
 }
        public override void Update()
        {
            AnimateShip();
            CollisionBody[] bodiesArray = Main.activeProjectiles.ToArray();
            DetectCollisions(bodiesArray.ToList());

            if (beamSoundInstance == null)
            {
                beamSoundInstance = beamSound.CreateInstance();
            }

            Vector2 velocity = Vector2.Zero;

            if (position.Y < 40f)
            {
                velocity.Y = 0.3f;
            }

            if (!shootingBeam)
            {
                if (Main.player.position.X > position.X + 8f)
                {
                    velocity.X = 0.1f;
                }
                else if (Main.player.position.X < position.X - 8f)
                {
                    velocity.X = -0.1f;
                }
                else
                {
                    beamChargeUpTimer++;
                    if (beamChargeUpTimer >= 4 * 60)
                    {
                        shootingBeam      = true;
                        beam              = StasisBeam.NewBeam(position + shootOffset);
                        beamChargeUpTimer = 0;
                    }
                }
            }
            else
            {
                velocity.X = 0;
            }


            position += velocity;
            hitbox.X  = (int)position.X;
            hitbox.Y  = (int)position.Y;
            center    = position + new Vector2(Width / 2f, Height / 2f);

            if (shootingBeam)
            {
                beamDurationTimer++;
                if (beamDurationTimer >= 9 * 60)
                {
                    shootingBeam      = false;
                    beamDurationTimer = 0;

                    if (beam != null)
                    {
                        beam.DestroyInstance(beam);
                        beam = null;
                    }
                }
                if (beamSoundInstance.State != SoundState.Playing)
                {
                    beamSoundInstance.Play();
                }

                if (beam != null)
                {
                    beam.position = position + shootOffset;
                }
            }
            else
            {
                if (beamSoundInstance.State == SoundState.Playing)
                {
                    beamSoundInstance.Stop();
                }
            }
        }