static ShieldManager()
 {
     ShieldManager.shieldList = new BatchRemovalCollection<Shield>();
     ShieldManager.PlanetaryShieldList = new BatchRemovalCollection<Shield>();
     ShieldManager.y = 0f;
     ShieldManager.z = 2.8f;
 }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.AnomaliesList != null)
                        this.AnomaliesList.Dispose();

                }
                this.AnomaliesList = null;
                this.disposed = true;
            }
        }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.MasterShipList != null)
                        this.MasterShipList.Dispose();

                }
                this.MasterShipList = null;
                this.disposed = true;
            }
        }
 public UniverseScreen(UniverseData data)
 {
     this.Size = data.Size;
     this.FTLModifier = data.FTLSpeedModifier;
     this.EnemyFTLModifier = data.EnemyFTLSpeedModifier;
     this.GravityWells = data.GravityWells;
     UniverseScreen.SolarSystemList = data.SolarSystemsList;
     this.MasterShipList = data.MasterShipList;
     this.playerShip = data.playerShip;
     this.PlayerLoyalty = this.playerShip.loyalty.data.Traits.Name;
     this.playerShip.loyalty.isPlayer = true;
     this.ShipToView = this.playerShip;
 }
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.Ships != null)
                        this.Ships.Dispose();

                }
                this.Ships = null;
                this.disposed = true;
            }
        }
 static ExplosionManager()
 {
     ExplosionManager.ExplosionList = new BatchRemovalCollection<Explosion>();
     ExplosionManager.fmt = "00000.##";
     ExplosionManager.random = new Random();
 }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.ActiveCombats != null)
                        this.ActiveCombats.Dispose();
                    if (this.OrbitalDropList != null)
                        this.OrbitalDropList.Dispose();
                    if (this.ConstructionQueue != null)
                        this.ConstructionQueue.Dispose();
                    if (this.BasedShips != null)
                        this.BasedShips.Dispose();
                    if (this.Projectiles != null)
                        this.Projectiles.Dispose();

                }
                this.ActiveCombats = null;
                this.OrbitalDropList = null;
                this.ConstructionQueue = null;
                this.BasedShips = null;
                this.Projectiles = null;
                this.disposed = true;
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.SalvoList != null)
                        this.SalvoList.Dispose();

                }
                this.SalvoList = null;
                this.disposed = true;
            }
        }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.CollidableObjects != null)
                        this.CollidableObjects.Dispose();
                    if (this.CollidableProjectiles != null)
                        this.CollidableProjectiles.Dispose();
                    if (this.Asteroids != null)
                        this.Asteroids.Dispose();
                    if (this.BeamList != null)
                        this.BeamList.Dispose();

                }
                this.CollidableObjects = null;
                this.CollidableProjectiles = null;
                this.Asteroids = null;
                this.BeamList = null;
                this.disposed = true;
            }
        }
 public void DrawOverlappingCirlces(List<Circle> CircleList, Color color, float Thickness)
 {
     BatchRemovalCollection<UniverseScreen.Intersection> removalCollection = new BatchRemovalCollection<UniverseScreen.Intersection>();
     foreach (Circle A in CircleList)
     {
         A.isChecked = true;
         bool flag = false;
         foreach (Circle B in CircleList)
         {
             Vector2[] vector2Array = this.Get2Intersections(A, B);
             if (vector2Array != null)
             {
                 UniverseScreen.Intersection intersection1 = new UniverseScreen.Intersection();
                 intersection1.C1 = A;
                 intersection1.C2 = B;
                 intersection1.inter = vector2Array[0];
                 UniverseScreen.Intersection intersection2 = new UniverseScreen.Intersection();
                 intersection2.C1 = A;
                 intersection2.C2 = B;
                 intersection2.inter = vector2Array[1];
                 flag = true;
                 if (!B.isChecked)
                 {
                     removalCollection.Add(intersection1);
                     removalCollection.Add(intersection2);
                 }
             }
         }
         if (!flag)
             Primitives2D.DrawCircle(this.ScreenManager.SpriteBatch, A.Center, A.Radius, 100, color, Thickness);
     }
     int num1 = 0;
     foreach (UniverseScreen.Intersection intersection in (List<UniverseScreen.Intersection>)removalCollection)
         ++num1;
     List<List<Vector2>> list1 = new List<List<Vector2>>();
     foreach (Circle circle in CircleList)
     {
         List<UniverseScreen.Intersection> list2 = new List<UniverseScreen.Intersection>();
         foreach (UniverseScreen.Intersection intersection in (List<UniverseScreen.Intersection>)removalCollection)
         {
             if (intersection.C1 == circle || intersection.C2 == circle)
                 list2.Add(intersection);
         }
         foreach (UniverseScreen.Intersection intersection in list2)
         {
             float num2 = Math.Abs(HelperFunctions.findAngleToTarget(circle.Center, intersection.inter)) - 90f;
             if ((double)num2 < 0.0)
                 num2 += 360f;
             intersection.Angle = num2;
         }
         IOrderedEnumerable<UniverseScreen.Intersection> orderedEnumerable = Enumerable.OrderBy<UniverseScreen.Intersection, float>((IEnumerable<UniverseScreen.Intersection>)list2, (Func<UniverseScreen.Intersection, float>)(inter => inter.Angle));
         for (int index = 0; index < Enumerable.Count<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable); ++index)
         {
             Vector2[] vector2Array = HelperFunctions.CircleIntersection(Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, index).C1, Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, index).C2);
             //Vector2 vector2_1 = new Vector2();
             //Vector2 vector2_2 = new Vector2();
             Vector2 C0;
             Vector2 C1;
             if (index < Enumerable.Count<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable) - 1)
             {
                 C0 = Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, index).inter;
                 C1 = Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, index + 1).inter;
             }
             else
             {
                 C0 = Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, index).inter;
                 C1 = Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, 0).inter;
             }
             float num2 = MathHelper.ToDegrees((float)Math.Asin((double)Vector2.Distance(C0, C1) / 2.0 / (double)circle.Radius) * 2f);
             //float num3 = 0.0f;
             if (float.IsNaN((double)Vector2.Distance(Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, index).C1.Center, Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, index).C2.Center) >= (double)vector2Array[2].Y ? 360f - num2 : num2))
                 //num3 = 180f;
             Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, index).AngularDistance = 360f;
             List<Vector2> myArc = Primitives2D.CreateMyArc(this.ScreenManager.SpriteBatch, circle.Center, circle.Radius, 50, Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, index).Angle, Enumerable.ElementAt<UniverseScreen.Intersection>((IEnumerable<UniverseScreen.Intersection>)orderedEnumerable, index).AngularDistance, C0, C1, color, Thickness, CircleList);
             list1.Add(myArc);
         }
     }
     List<Vector2> list3 = new List<Vector2>();
     foreach (List<Vector2> list2 in list1)
         list3.AddRange((IEnumerable<Vector2>)list2);
     foreach (Vector2 center in list3)
         Primitives2D.DrawCircle(this.ScreenManager.SpriteBatch, center, 2f, 10, color, 2f);
 }
 //Modified by McShooterz: not used before, changed to be used for exploding modules
 public void ExplodeAtModule(GameplayObject source, ShipModule HitModule, float damageAmount, float damageRadius)
 {
     if ((double)damageRadius <= 0.0 || HitModule.GetParent().dying || !HitModule.GetParent().Active)
         return;
     BatchRemovalCollection<ExplosionRay> removalCollection = new BatchRemovalCollection<ExplosionRay>();
     int num1 = 15;
     float num2 = (float)(360 / num1);
     for (int index = 0; index < num1; ++index)
         removalCollection.Add(new ExplosionRay()
         {
             Direction = HelperFunctions.findPointFromAngleAndDistance(Vector2.Zero, num2 * (float)index, 1f),
             Damage = damageAmount / (float)num1
         });
     List<ShipModule> list = new List<ShipModule>();
     list.Add(HitModule);
     foreach (ModuleSlot ModuleSlot in HitModule.GetParent().ModuleSlotList.Where(moduleSlot => Vector2.Distance(HitModule.Center, moduleSlot.module.Center) <= damageRadius).OrderBy(moduleSlot => Vector2.Distance(HitModule.Center, moduleSlot.module.Center)))
     {
         list.Add(ModuleSlot.module);
     }
     int num3 = 0;
     while ((double)num3 < (double)damageRadius)
     {
         foreach (ExplosionRay explosionRay in (List<ExplosionRay>)removalCollection)
         {
             if ((double)explosionRay.Damage > 0.0)
             {
                 foreach (ShipModule shipModule in list)
                 {
                     if (shipModule.Active && (double)shipModule.Health > 0.0)
                     {
                         Vector2 vector2_1 = HitModule.Center + explosionRay.Direction * (float)num3;
                         Vector2 vector2_2 = shipModule.Center - vector2_1;
                         if ((double)Vector2.Distance(vector2_1, shipModule.Center) <= 8.0 && (double)explosionRay.Damage > 0.0)
                         {
                             float health = shipModule.Health;
                             shipModule.Damage(source, explosionRay.Damage);
                             explosionRay.Damage -= health;
                         }
                     }
                 }
             }
         }
         num3 += 8;
     }
 }
 public void ShipExplode(GameplayObject source, float damageAmount, Vector2 position, float damageRadius)
 {
     if ((double)damageRadius <= 0.0)
         return;
     float num1 = damageRadius * damageRadius;
     Vector2 ExplosionCenter = new Vector2();
     ExplosionCenter = source.Center;
     BatchRemovalCollection<ExplosionRay> removalCollection = new BatchRemovalCollection<ExplosionRay>();
     int num4 = 15;
     float num5 = (float)(360 / num4);
     for (int index = 0; index < num4; ++index)
         removalCollection.Add(new ExplosionRay()
         {
             Direction = HelperFunctions.findPointFromAngleAndDistance(Vector2.Zero, num5 * (float)index, 1f),
             Damage = damageAmount / (float)num4
         });
     List<ShipModule> list;// = new List<ShipModule>();
     List<ModuleSlot> list1;// = new List<ModuleSlot>();
     foreach (GameplayObject gameplayObject1 in this.GetNearby(source))
     {
         try
         {
             if (gameplayObject1 != null)
             {
                 if (!(gameplayObject1 is Projectile))
                 {
                     Vector2 vector2_1 = Vector2.Zero;
                     if (gameplayObject1.Active)
                     {
                         if (gameplayObject1 != source)
                         {
                             if ((double)Vector2.Distance(gameplayObject1.Center, source.Center) <= (double)damageRadius + (double)gameplayObject1.Radius)
                             {
                                 Projectile projectile1 = source as Projectile;
                                 if (gameplayObject1 is Ship && projectile1 != null)
                                 {
                                     if (projectile1.Owner != null)
                                     {
                                         if ((gameplayObject1 as Ship).loyalty == projectile1.owner.loyalty)
                                             continue;
                                     }
                                     if (projectile1.Planet != null)
                                     {
                                         if (projectile1.Planet.Owner == (gameplayObject1 as Ship).loyalty)
                                             continue;
                                     }
                                 }
                                 if (gameplayObject1 is Ship && source != gameplayObject1)
                                 {
                                     if (source is Projectile && (double)(gameplayObject1 as Ship).shield_max > 0.0)
                                     {
                                         list = new List<ShipModule>();
                                         foreach (ModuleSlot moduleSlot in (gameplayObject1 as Ship).ModuleSlotList)
                                         {
                                             if ((double)moduleSlot.module.shield_power > 0.0 && moduleSlot.module.Active)
                                                 list.Add(moduleSlot.module);
                                         }
                                         float num2 = damageAmount;
                                         foreach (ShipModule shipModule in list)
                                         {
                                             if ((double)Vector2.Distance(ExplosionCenter, shipModule.Center) <= (double)damageRadius + (double)shipModule.shield_radius && (double)shipModule.shield_power > 0.0)
                                             {
                                                 num2 = damageAmount - shipModule.shield_power;
                                                 shipModule.Damage(source, damageAmount / 2f);
                                                 break;
                                             }
                                         }
                                         if ((double)num2 <= 0.0)
                                             break;
                                         damageAmount = num2;
                                     }
                                     list1 = new List<ModuleSlot>();
                                     foreach (ModuleSlot moduleSlot in (gameplayObject1 as Ship).ExternalSlots)
                                     {
                                         if (moduleSlot.module.Active && (double)Vector2.Distance(moduleSlot.module.Center, ExplosionCenter) <= (double)damageRadius + (double)moduleSlot.module.Radius)
                                             list1.Add(moduleSlot);
                                     }
                                     if (list1.Count == 0)
                                         break;
                                     IOrderedEnumerable<ModuleSlot> orderedEnumerable = Enumerable.OrderBy<ModuleSlot, float>((IEnumerable<ModuleSlot>)list1, (Func<ModuleSlot, float>)(moduleslot => Vector2.Distance(ExplosionCenter, moduleslot.module.Center)));
                                     int num3 = 0;
                                     while ((double)num3 < (double)damageRadius)
                                     {
                                         foreach (ExplosionRay explosionRay in (List<ExplosionRay>)removalCollection)
                                         {
                                             if ((double)explosionRay.Damage > 0.0)
                                             {
                                                 foreach (ModuleSlot moduleSlot in (IEnumerable<ModuleSlot>)orderedEnumerable)
                                                 {
                                                     if (moduleSlot.module.Active && (double)moduleSlot.module.Health > 0.0)
                                                     {
                                                         GameplayObject gameplayObject2 = (GameplayObject)moduleSlot.module;
                                                         Vector2 vector2_2 = ExplosionCenter + explosionRay.Direction * (float)num3;
                                                         Vector2 vector2_3 = gameplayObject2.Center - vector2_2;
                                                         if ((double)Vector2.Distance(vector2_2, gameplayObject2.Center) <= 8.0)
                                                         {
                                                             Projectile projectile2 = gameplayObject1 as Projectile;
                                                             if (gameplayObject2 != source && projectile2 == null)
                                                             {
                                                                 if (source is Ship || source is ShipModule && (source as ShipModule).GetParent() != gameplayObject1)
                                                                     vector2_1 += 3f * explosionRay.Damage * explosionRay.Direction;
                                                                 if ((double)(gameplayObject1 as Ship).yRotation > 0.0 && !(gameplayObject1 as Ship).dying)
                                                                 {
                                                                     (gameplayObject1 as Ship).yRotation += explosionRay.Damage / (float)Math.Pow((double)(gameplayObject1 as Ship).Mass, 1.3);
                                                                     if ((double)(gameplayObject1 as Ship).yRotation > (double)(gameplayObject1 as Ship).maxBank)
                                                                         (gameplayObject1 as Ship).yRotation = (gameplayObject1 as Ship).maxBank;
                                                                 }
                                                                 else if (!(gameplayObject1 as Ship).dying)
                                                                 {
                                                                     (gameplayObject1 as Ship).yRotation -= explosionRay.Damage / (float)Math.Pow((double)(gameplayObject1 as Ship).Mass, 1.3);
                                                                     if ((double)(gameplayObject1 as Ship).yRotation < -(double)(gameplayObject1 as Ship).maxBank)
                                                                         (gameplayObject1 as Ship).yRotation = -(gameplayObject1 as Ship).maxBank;
                                                                 }
                                                             }
                                                             if ((double)explosionRay.Damage > 0.0)
                                                             {
                                                                 float health = (gameplayObject2 as ShipModule).Health;
                                                                 (gameplayObject2 as ShipModule).Damage(source, explosionRay.Damage);
                                                                 explosionRay.Damage -= health;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         num3 += 8;
                                     }
                                     if ((double)vector2_1.Length() > 200.0)
                                         vector2_1 = Vector2.Normalize(vector2_1) * 200f;
                                     if (!float.IsNaN(vector2_1.X))
                                         gameplayObject1.Velocity += vector2_1;
                                 }
                                 else
                                 {
                                     if (gameplayObject1 is Ship && source == gameplayObject1)
                                         break;
                                     float num2 = (gameplayObject1.Center - position).LengthSquared();
                                     if ((double)num2 > 0.0)
                                     {
                                         if ((double)num2 <= (double)num1)
                                         {
                                             float num3 = (float)Math.Sqrt((double)num2);
                                             float damageAmount1 = damageAmount * (damageRadius - num3) / damageRadius;
                                             if ((double)damageAmount1 > 0.0)
                                                 gameplayObject1.Damage(source, damageAmount1);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         catch
         {
         }
     }
 }
        public void Explode(GameplayObject source, float damageAmount, Vector2 position, float damageRadius)
        {
            if (damageRadius <= 0.0)
                return;
            float num1 = damageRadius * damageRadius;
            Vector2 ExplosionCenter = new Vector2();
            ExplosionCenter = source.Center;
            if (source is ShipModule)
            {
                ShipModule shipModule = source as ShipModule;
                ExplosionCenter = (int)shipModule.XSIZE != 1 || (int)shipModule.YSIZE != 3 ? ((int)shipModule.XSIZE != 2 || (int)shipModule.YSIZE != 5 ? new Vector2(shipModule.Center.X - 8f + (float)(16 * (int)shipModule.XSIZE / 2), shipModule.Center.Y - 8f + (float)(16 * (int)shipModule.YSIZE / 2)) : new Vector2(shipModule.Center.X - 80f + (float)(16 * (int)shipModule.XSIZE / 2), shipModule.Center.Y - 8f + (float)(16 * (int)shipModule.YSIZE / 2))) : new Vector2(shipModule.Center.X - 50f + (float)(16 * (int)shipModule.XSIZE / 2), shipModule.Center.Y - 8f + (float)(16 * (int)shipModule.YSIZE / 2));
                Vector2 target = new Vector2(shipModule.Center.X - 8f, shipModule.Center.Y - 8f);
                float angleToTarget = HelperFunctions.findAngleToTarget(ExplosionCenter, target);
                Vector2 angleAndDistance = HelperFunctions.findPointFromAngleAndDistance(shipModule.Center, MathHelper.ToDegrees((source as ShipModule).Rotation) - angleToTarget, 8f * (float)Math.Sqrt(2.0));
                float num2 = (float)((int)shipModule.XSIZE * 16 / 2);
                float num3 = (float)((int)shipModule.YSIZE * 16 / 2);
                float distance = (float)Math.Sqrt((double)((float)Math.Pow((double)num2, 2.0) + (float)Math.Pow((double)num3, 2.0)));
                float radians = 3.141593f - (float)Math.Asin((double)num2 / (double)distance) + (source as ShipModule).GetParent().Rotation;
                ExplosionCenter = HelperFunctions.findPointFromAngleAndDistance(angleAndDistance, MathHelper.ToDegrees(radians), distance);
            }
            BatchRemovalCollection<ExplosionRay> removalCollection = new BatchRemovalCollection<ExplosionRay>();
            int num4 = 15;
            float num5 = (float)(360 / num4);
            for (int index = 0; index < num4; ++index)
                removalCollection.Add(new ExplosionRay()
                {
                    Direction = HelperFunctions.findPointFromAngleAndDistance(Vector2.Zero, num5 * (float)index, 1f),
                    Damage = damageAmount / (float)num4
                });
            List<ShipModule> list; //= new List<ShipModule>();
            List<ModuleSlot> list1; //= new List<ModuleSlot>();
            foreach (GameplayObject gameplayObject1 in this.GetNearby(source))
            {
                try
                {
                    if (gameplayObject1 != null)
                    {
                        if (!(gameplayObject1 is Projectile))
                        {
                            Vector2 vector2_1 = Vector2.Zero;
                            if (gameplayObject1.Active)
                            {
                                if (gameplayObject1 != source)
                                {
                                    if (Vector2.Distance(gameplayObject1.Center, source.Center) <= damageRadius + gameplayObject1.Radius)
                                    {
                                        Projectile projectile1 = source as Projectile;
                                        if (gameplayObject1 is Ship && projectile1 != null)
                                        {
                                            if (projectile1.Owner != null)
                                            {
                                                if ((gameplayObject1 as Ship).loyalty == projectile1.owner.loyalty)
                                                    continue;
                                            }
                                            if (projectile1.Planet != null)
                                            {
                                                if (projectile1.Planet.Owner == (gameplayObject1 as Ship).loyalty)
                                                    continue;
                                            }
                                        }
                                        if (gameplayObject1 is Ship && source != gameplayObject1)
                                        {
                                            if (source is Projectile && (double)(gameplayObject1 as Ship).shield_max > 0.0)
                                            {
                                                 list = new List<ShipModule>();
                                                foreach (ModuleSlot moduleSlot in (gameplayObject1 as Ship).ModuleSlotList)
                                                {
                                                    if ((double)moduleSlot.module.shield_power > 0.0 && moduleSlot.module.Active)
                                                        list.Add(moduleSlot.module);
                                                }
                                                float num2 = damageAmount;
                                                foreach (ShipModule shipModule in list)
                                                {
                                                    if (Vector2.Distance(ExplosionCenter, shipModule.Center) <= damageRadius + shipModule.shield_radius && shipModule.shield_power > 0.0)
                                                    {
                                                        num2 = damageAmount - shipModule.shield_power;

                                                        // Make sure explosions don't apply full damage when weapon is set to have penalty. Equally, applies bonus against armour from weapon.
                                                        if (shipModule.ModuleType == ShipModuleType.Armor)
                                                        {
                                                            if ((source as Projectile).isSecondary)
                                                            {
                                                                Weapon shooter = (source as Projectile).weapon;
                                                                ResourceManager.WeaponsDict.TryGetValue(shooter.SecondaryFire, out shooter);
                                                                damageAmount *= shooter.EffectVSShields;
                                                                //damageAmount *= (ResourceManager.GetWeapon(shooter.SecondaryFire).EffectVSShields);
                                                            }
                                                            else
                                                            {
                                                                damageAmount *= (source as Projectile).weapon.EffectVSShields;
                                                            }
                                                        }
                                                        // doesn't this mean explosions hit through shields? It's not applying the 'bleed' if shields drop from damage, but half of all damage impacting...
                                                        shipModule.Damage(source, damageAmount / 2f);
                                                        break;
                                                    }
                                                }
                                                if (num2 <= 0.0)
                                                    break;
                                                damageAmount = num2;
                                            }
                                            list1 = new List<ModuleSlot>();
                                            foreach (ModuleSlot moduleSlot in (gameplayObject1 as Ship).ModuleSlotList)
                                            {
                                                if (moduleSlot.module.Active && (double)Vector2.Distance(moduleSlot.module.Center, ExplosionCenter) <= damageRadius + moduleSlot.module.Radius)
                                                    list1.Add(moduleSlot);
                                            }
                                            if (list1.Count == 0)
                                                break;
                                            IOrderedEnumerable<ModuleSlot> orderedEnumerable = Enumerable.OrderBy<ModuleSlot, float>((IEnumerable<ModuleSlot>)list1, (Func<ModuleSlot, float>)(moduleslot => Vector2.Distance(ExplosionCenter, moduleslot.module.Center)));
                                            int num3 = 0;
                                            while (num3 < damageRadius)
                                            {
                                                foreach (ExplosionRay explosionRay in (List<ExplosionRay>)removalCollection)
                                                {
                                                    if (explosionRay.Damage > 0.0)
                                                    {
                                                        foreach (ModuleSlot moduleSlot in (IEnumerable<ModuleSlot>)orderedEnumerable)
                                                        {
                                                            if (moduleSlot.module.Active && moduleSlot.module.Health > 0.0)
                                                            {
                                                                GameplayObject gameplayObject2 = (GameplayObject)moduleSlot.module;
                                                                Vector2 vector2_2 = ExplosionCenter + explosionRay.Direction * num3;
                                                                Vector2 vector2_3 = gameplayObject2.Center - vector2_2;
                                                                if ((double)Vector2.Distance(vector2_2, gameplayObject2.Center) <= 8.0)
                                                                {
                                                                    Projectile projectile2 = gameplayObject1 as Projectile;
                                                                    if (gameplayObject2 != source && projectile2 == null)
                                                                    {
                                                                        if (source is Ship || source is ShipModule && (source as ShipModule).GetParent() != gameplayObject1)
                                                                            vector2_1 += 3f * explosionRay.Damage * explosionRay.Direction;
                                                                        if ((double)(gameplayObject1 as Ship).yRotation > 0.0 && !(gameplayObject1 as Ship).dying)
                                                                        {
                                                                            (gameplayObject1 as Ship).yRotation += explosionRay.Damage / (float)Math.Pow((double)(gameplayObject1 as Ship).Mass, 1.3);
                                                                            if ((gameplayObject1 as Ship).yRotation > (gameplayObject1 as Ship).maxBank)
                                                                                (gameplayObject1 as Ship).yRotation = (gameplayObject1 as Ship).maxBank;
                                                                        }
                                                                        else if (!(gameplayObject1 as Ship).dying)
                                                                        {
                                                                            (gameplayObject1 as Ship).yRotation -= explosionRay.Damage / (float)Math.Pow((double)(gameplayObject1 as Ship).Mass, 1.3);
                                                                            if ((gameplayObject1 as Ship).yRotation < -(gameplayObject1 as Ship).maxBank)
                                                                                (gameplayObject1 as Ship).yRotation = -(gameplayObject1 as Ship).maxBank;
                                                                        }
                                                                    }
                                                                    if ((double)explosionRay.Damage > 0.0)
                                                                    {
                                                                        float health = (gameplayObject2 as ShipModule).Health;
                                                                        if ((gameplayObject2 as ShipModule).ModuleType == ShipModuleType.Armor)
                                                                        {
                                                                            if ((source as Projectile).isSecondary)
                                                                            {
                                                                                Weapon shooter = (source as Projectile).weapon;
                                                                                ResourceManager.WeaponsDict.TryGetValue(shooter.SecondaryFire, out shooter);
                                                                                explosionRay.Damage *= shooter.EffectVsArmor;
                                                                                //explosionRay.Damage *= (ResourceManager.GetWeapon(shooter.SecondaryFire).EffectVsArmor);
                                                                            }
                                                                            else
                                                                            {
                                                                                explosionRay.Damage *= (source as Projectile).weapon.EffectVsArmor;
                                                                            }
                                                                        }
                                                                        (gameplayObject2 as ShipModule).Damage(source, explosionRay.Damage);
                                                                        explosionRay.Damage -= health;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                num3 += 8;
                                            }
                                            if ((double)vector2_1.Length() > 200.0)
                                                vector2_1 = Vector2.Normalize(vector2_1) * 200f;
                                            if (!float.IsNaN(vector2_1.X))
                                                gameplayObject1.Velocity += vector2_1;
                                        }
                                        else
                                        {
                                            if (gameplayObject1 is Ship && source == gameplayObject1)
                                                break;
                                            float num2 = (gameplayObject1.Center - position).LengthSquared();
                                            if (num2 > 0.0)
                                            {
                                                if (num2 <= num1)
                                                {
                                                    float num3 = (float)Math.Sqrt((double)num2);
                                                    float damageAmount1 = damageAmount * (damageRadius - num3) / damageRadius;
                                                    if (damageAmount1 > 0.0)
                                                        gameplayObject1.Damage(source, damageAmount1);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
            }
        }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.CollidableObjects != null)
                        this.CollidableObjects.Dispose();

                }
                this.CollidableObjects = null;
                this.disposed = true;
            }
        }
        private void Worker()
        {
            while (!this.ready)
            {
                if (this.firstRun)
                {
                    UniverseScreen.DeepSpaceManager = new SpatialManager();
                    BatchRemovalCollection<EmpireData> removalCollection = new BatchRemovalCollection<EmpireData>();
                    foreach (EmpireData empireData in ResourceManager.Empires)
                    {
                        if (!(empireData.Traits.Name == this.EmpireToRemoveName) && empireData.Faction == 0 && !empireData.MinorRace)
                            removalCollection.Add(empireData);
                    }
                    int num = removalCollection.Count - this.numOpponents;
                    for (int opponents = 0; opponents < num; ++opponents)
                    {
                        int index2 = (int)RandomMath.RandomBetween(0.0f, (float)(removalCollection.Count + 1));
                        if (index2 > removalCollection.Count - 1)
                            index2 = removalCollection.Count - 1;
                        removalCollection.RemoveAt(index2);
                    }

                    foreach (EmpireData data in (List<EmpireData>)removalCollection)
                    {
                        Empire empireFromEmpireData = this.CreateEmpireFromEmpireData(data);
                        this.data.EmpireList.Add(empireFromEmpireData);
                        switch (this.difficulty)
                        {
                            case UniverseData.GameDifficulty.Easy:
                                empireFromEmpireData.data.Traits.ProductionMod -= 0.25f;
                                empireFromEmpireData.data.Traits.ResearchMod -= 0.25f;
                                empireFromEmpireData.data.Traits.TaxMod -= 0.25f;
                                empireFromEmpireData.data.Traits.ModHpModifier -= 0.25f;
                                break;
                            case UniverseData.GameDifficulty.Hard:
                                empireFromEmpireData.data.FlatMoneyBonus += 10;
                                empireFromEmpireData.data.Traits.ProductionMod += 0.5f;
                                empireFromEmpireData.data.Traits.ResearchMod += 0.75f;
                                empireFromEmpireData.data.Traits.TaxMod += 0.5f;
                                //empireFromEmpireData.data.Traits.ModHpModifier += 0.5f;
                                empireFromEmpireData.data.Traits.ShipCostMod -= 0.2f;
                                break;
                            case UniverseData.GameDifficulty.Brutal:
                                empireFromEmpireData.data.FlatMoneyBonus += 50;
                                ++empireFromEmpireData.data.Traits.ProductionMod;
                                empireFromEmpireData.data.Traits.ResearchMod = 2.0f;
                                ++empireFromEmpireData.data.Traits.TaxMod;
                                //++empireFromEmpireData.data.Traits.ModHpModifier;
                                empireFromEmpireData.data.Traits.ShipCostMod -= 0.5f;
                                break;
                        }
                        EmpireManager.EmpireList.Add(empireFromEmpireData);
                    }
                    foreach (EmpireData data in ResourceManager.Empires)
                    {
                        if (data.Faction != 0 || data.MinorRace)
                        {
                            Empire empireFromEmpireData = this.CreateEmpireFromEmpireData(data);
                            this.data.EmpireList.Add(empireFromEmpireData);
                            EmpireManager.EmpireList.Add(empireFromEmpireData);
                        }
                    }
                    foreach (Empire empire in this.data.EmpireList)
                    {
                        foreach (Empire e in this.data.EmpireList)
                        {
                            if (empire != e)
                                empire.AddRelationships(e, new Relationship(e.data.Traits.Name));
                        }
                    }
                    foreach (Empire Owner in this.data.EmpireList)
                    {
                        if (!Owner.isFaction && !Owner.MinorRace)
                        {
                            SolarSystem solarSystem = new SolarSystem();
                            //Added by McShooterz: support for SolarSystems folder for mods
                            if (File.Exists(string.Concat(Ship_Game.ResourceManager.WhichModPath, "/SolarSystems/", Owner.data.Traits.HomeSystemName, ".xml")))
                            {
                                solarSystem = SolarSystem.GenerateSystemFromData((SolarSystemData)new XmlSerializer(typeof(SolarSystemData)).Deserialize((Stream)new FileInfo(string.Concat(Ship_Game.ResourceManager.WhichModPath, "/SolarSystems/", Owner.data.Traits.HomeSystemName, ".xml")).OpenRead()), Owner);
                                solarSystem.isStartingSystem = true;
                            }
                            else if (File.Exists("Content/SolarSystems/" + Owner.data.Traits.HomeSystemName + ".xml"))
                            {
                                solarSystem = SolarSystem.GenerateSystemFromData((SolarSystemData)new XmlSerializer(typeof(SolarSystemData)).Deserialize((Stream)new FileInfo("Content/SolarSystems/" + Owner.data.Traits.HomeSystemName + ".xml").OpenRead()), Owner);
                                solarSystem.isStartingSystem = true;
                            }
                            else
                            {
                                solarSystem.GenerateStartingSystem(Owner.data.Traits.HomeSystemName, Owner, this.scale);
                                solarSystem.isStartingSystem = true;
                            }
                            this.data.SolarSystemsList.Add(solarSystem);
                            if (Owner == this.playerEmpire)
                                this.PlayerSystem = solarSystem;

                        }
                    }
                    int SystemCount = 0;
                    if (Directory.Exists(Ship_Game.ResourceManager.WhichModPath + "/SolarSystems/Random"))
                    {
                        foreach (string system in Directory.GetFiles(Ship_Game.ResourceManager.WhichModPath + "/SolarSystems/Random"))
                        {
                            if (SystemCount > this.numSystems)
                                break;
                            SolarSystem solarSystem = new SolarSystem();
                            solarSystem = SolarSystem.GenerateSystemFromData((SolarSystemData)new XmlSerializer(typeof(SolarSystemData)).Deserialize((Stream)new FileInfo(system).OpenRead()), null);
                            this.data.SolarSystemsList.Add(solarSystem);
                            SystemCount++;
                        }
                    }
                    MarkovNameGenerator markovNameGenerator = new MarkovNameGenerator(File.ReadAllText("Content/NameGenerators/names.txt"), 3, 5);
                    SolarSystem solarSystem1 = new SolarSystem();
                    solarSystem1.GenerateCorsairSystem(markovNameGenerator.NextName);
                    solarSystem1.DontStartNearPlayer = true;
                    this.data.SolarSystemsList.Add(solarSystem1);
                    for (; SystemCount < this.numSystems; ++SystemCount)
                    {
                        SolarSystem solarSystem2 = new SolarSystem();
                        solarSystem2.GenerateRandomSystem(markovNameGenerator.NextName, this.data, this.scale);
                        this.data.SolarSystemsList.Add(solarSystem2);
                        ++this.counter;
                        this.percentloaded = (float)(this.counter / (this.numSystems * 2));
                    }
                    this.ThrusterEffect = this.ScreenManager.Content.Load<Effect>("Effects/Thrust");
                    foreach (SolarSystem solarSystem2 in this.data.SolarSystemsList)
                    {
                        if (solarSystem2.isStartingSystem || solarSystem2.DontStartNearPlayer)
                            solarSystem2.Position = this.GenerateRandom(this.data.Size.X / 4f);
                    }
                    foreach (SolarSystem solarSystem2 in this.data.SolarSystemsList)
                    {
                        if (!solarSystem2.isStartingSystem && !solarSystem2.DontStartNearPlayer)
                            solarSystem2.Position = this.GenerateRandom(350000f);
                    }
                    int count = this.data.SolarSystemsList.Count;
                    this.firstRun = false;
                }
                this.data.SolarSystemsList[this.systemToMake].spatialManager.Setup((int)(200000.0 * (double)this.scale), (int)(200000.0 * (double)this.scale), (int)(100000.0 * (double)this.scale), this.data.SolarSystemsList[this.systemToMake].Position);
                this.percentloaded = (float)(this.counter + this.systemToMake) / (float)(this.data.SolarSystemsList.Count * 2);
                foreach (Empire key in this.data.EmpireList)
                    this.data.SolarSystemsList[this.systemToMake].ExploredDict.Add(key, false);
                foreach (Planet planet in this.data.SolarSystemsList[this.systemToMake].PlanetList)
                {
                    planet.system = this.data.SolarSystemsList[this.systemToMake];
                    planet.Position += this.data.SolarSystemsList[this.systemToMake].Position;
                    planet.InitializeUpdate();
                    this.ScreenManager.inter.ObjectManager.Submit((ISceneObject)planet.SO);
                    foreach (Empire key in this.data.EmpireList)
                        planet.ExploredDict.Add(key, false);
                }
                foreach (Asteroid asteroid in (List<Asteroid>)this.data.SolarSystemsList[this.systemToMake].AsteroidsList)
                {
                    asteroid.Position3D.X += this.data.SolarSystemsList[this.systemToMake].Position.X;
                    asteroid.Position3D.Y += this.data.SolarSystemsList[this.systemToMake].Position.Y;
                    asteroid.Initialize();
                    this.ScreenManager.inter.ObjectManager.Submit((ISceneObject)asteroid.GetSO());
                }
                foreach (Moon moon in (List<Moon>)this.data.SolarSystemsList[this.systemToMake].MoonList)
                {
                    moon.Initialize();
                    this.ScreenManager.inter.ObjectManager.Submit((ISceneObject)moon.GetSO());
                }
                foreach (Ship ship in (List<Ship>)this.data.SolarSystemsList[this.systemToMake].ShipList)
                {
                    ship.Position = ship.loyalty.GetPlanets()[0].Position + new Vector2(6000f, 2000f);
                    ship.GetSO().World = Matrix.CreateTranslation(new Vector3(ship.Position, 0.0f));
                    ship.Initialize();
                    this.ScreenManager.inter.ObjectManager.Submit((ISceneObject)ship.GetSO());
                    foreach (Thruster thruster in ship.GetTList())
                    {
                        thruster.load_and_assign_effects(this.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", this.ThrusterEffect);
                        thruster.InitializeForViewing();
                    }
                }
                ++this.systemToMake;
                if (this.systemToMake == this.data.SolarSystemsList.Count)
                {
                    foreach (SolarSystem solarSystem1 in this.data.SolarSystemsList)
                    {
                        List<CreatingNewGameScreen.SysDisPair> list = new List<CreatingNewGameScreen.SysDisPair>();
                        foreach (SolarSystem solarSystem2 in this.data.SolarSystemsList)
                        {
                            if (solarSystem1 != solarSystem2)
                            {
                                float num1 = Vector2.Distance(solarSystem1.Position, solarSystem2.Position);
                                if (list.Count < 5)
                                {
                                    list.Add(new CreatingNewGameScreen.SysDisPair()
                                    {
                                        System = solarSystem2,
                                        Distance = num1
                                    });
                                }
                                else
                                {
                                    int index1 = 0;
                                    float num2 = 0.0f;
                                    for (int index2 = 0; index2 < 5; ++index2)
                                    {
                                        if ((double)list[index2].Distance > (double)num2)
                                        {
                                            index1 = index2;
                                            num2 = list[index2].Distance;
                                        }
                                    }
                                    if ((double)num1 < (double)num2)
                                        list[index1] = new CreatingNewGameScreen.SysDisPair()
                                        {
                                            System = solarSystem2,
                                            Distance = num1
                                        };
                                }
                            }
                        }
                        foreach (CreatingNewGameScreen.SysDisPair sysDisPair in list)
                            solarSystem1.FiveClosestSystems.Add(sysDisPair.System);
                    }
                    foreach (Empire index in this.data.EmpireList)
                    {
                        if (!index.isFaction && !index.MinorRace)
                        {
                            foreach (Planet planet1 in index.GetPlanets())
                            {
                                planet1.MineralRichness += GlobalStats.StartingPlanetRichness;
                                planet1.system.ExploredDict[index] = true;
                                planet1.ExploredDict[index] = true;
                                foreach (Planet planet2 in planet1.system.PlanetList)
                                    planet2.ExploredDict[index] = true;
                                if (planet1.system.OwnerList.Count == 0)
                                {
                                    planet1.system.OwnerList.Add(index);
                                    foreach (Planet planet2 in planet1.system.PlanetList)
                                        planet2.ExploredDict[index] = true;
                                }
                                if (planet1.HasShipyard)
                                {
                                    SpaceStation spaceStation = new SpaceStation();
                                    spaceStation.planet = planet1;
                                    planet1.Station = spaceStation;
                                    spaceStation.ParentSystem = planet1.system;
                                    spaceStation.LoadContent(this.ScreenManager);
                                }
                                string key1 = index.data.DefaultColonyShip;
                                if (GlobalStats.HardcoreRuleset)
                                    key1 = key1 + " STL";
                                Ship ship1 = ResourceManager.GetShip(key1);
                                ship1.Position = planet1.Position + new Vector2(-2000f, -2000f);
                                ship1.loyalty = index;
                                ship1.Initialize();
                                //Added by McShooterz: Starting ship support for automatic naming
                                if (GlobalStats.ActiveMod != null && Ship_Game.ResourceManager.ShipNames.CheckForName(ship1.loyalty.data.Traits.ShipType, ship1.Role))
                                    ship1.VanityName = Ship_Game.ResourceManager.ShipNames.GetName(ship1.loyalty.data.Traits.ShipType, ship1.Role);
                                ship1.DoOrbit(planet1);
                                ship1.GetSO().World = Matrix.CreateTranslation(new Vector3(ship1.Position, 0.0f));
                                ship1.isInDeepSpace = false;
                                ship1.SetSystem(planet1.system);
                                planet1.system.ShipList.Add(ship1);
                                planet1.system.spatialManager.CollidableObjects.Add((GameplayObject)ship1);
                                this.ScreenManager.inter.ObjectManager.Submit((ISceneObject)ship1.GetSO());
                                this.data.MasterShipList.Add(ship1);
                                index.AddShip(ship1);
                                foreach (Thruster thruster in ship1.GetTList())
                                {
                                    thruster.load_and_assign_effects(this.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", this.ThrusterEffect);
                                    thruster.InitializeForViewing();
                                }
                                string key2 = index.data.StartingScout;
                                if (GlobalStats.HardcoreRuleset)
                                    key2 = key2 + " STL";
                                Ship ship2 = ResourceManager.GetShip(key2);
                                ship2.Position = planet1.Position + new Vector2(-2500f, -2000f);
                                ship2.loyalty = index;
                                ship2.Initialize();
                                //Added by McShooterz: Starting ship support for automatic naming
                                if (GlobalStats.ActiveMod != null && Ship_Game.ResourceManager.ShipNames.CheckForName(ship2.loyalty.data.Traits.ShipType, ship2.Role))
                                    ship2.VanityName = Ship_Game.ResourceManager.ShipNames.GetName(ship2.loyalty.data.Traits.ShipType, ship2.Role);
                                ship2.DoOrbit(planet1);
                                ship2.GetSO().World = Matrix.CreateTranslation(new Vector3(ship2.Position, 0.0f));
                                ship2.isInDeepSpace = false;
                                ship2.SetSystem(planet1.system);
                                this.ScreenManager.inter.ObjectManager.Submit((ISceneObject)ship2.GetSO());
                                this.data.MasterShipList.Add(ship2);
                                planet1.system.spatialManager.CollidableObjects.Add((GameplayObject)ship2);
                                planet1.system.ShipList.Add(ship2);
                                index.AddShip(ship2);
                                foreach (Thruster thruster in ship2.GetTList())
                                {
                                    thruster.load_and_assign_effects(this.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", this.ThrusterEffect);
                                    thruster.InitializeForViewing();
                                }
                                if (index == this.playerEmpire)
                                {
                                    this.playerShip = ResourceManager.GetShip(this.playerEmpire.data.Traits.Prototype == 0 ? this.playerEmpire.data.StartingShip : this.playerEmpire.data.PrototypeShip);
                                    this.playerShip.Position = planet1.Position + new Vector2(350f, 0.0f);
                                    this.playerShip.Rotation = 0.0f;
                                    this.playerShip.SensorRange = 100000f;
                                    this.playerShip.loyalty = this.playerEmpire;
                                    this.playerShip.loyalty.AddShip(this.playerShip);
                                    this.playerShip.Initialize();
                                    //this.playerShip.GetAI().State = AIState.ManualControl;
                                    this.playerShip.DoOrbit(planet1);
                                    //Added by McShooterz: Starting ship support for automatic naming
                                    if (GlobalStats.ActiveModInfo != null && Ship_Game.ResourceManager.ShipNames.CheckForName(this.playerShip.loyalty.data.Traits.ShipType, this.playerShip.Role))
                                        this.playerShip.VanityName = Ship_Game.ResourceManager.ShipNames.GetName(this.playerShip.loyalty.data.Traits.ShipType, this.playerShip.Role);
                                    else
                                        this.playerShip.VanityName = "Perseverance";
                                    this.playerShip.GetSO().World = Matrix.CreateRotationY(this.playerShip.yBankAmount) * Matrix.CreateRotationZ(this.playerShip.Rotation) * Matrix.CreateTranslation(new Vector3(this.playerShip.Center, 0.0f));
                                    this.ScreenManager.inter.ObjectManager.Submit((ISceneObject)this.playerShip.GetSO());
                                    planet1.system.spatialManager.CollidableObjects.Add((GameplayObject)this.playerShip);
                                    this.playerShip.isInDeepSpace = false;
                                    this.playerShip.SetSystem(planet1.system);
                                    planet1.system.ShipList.Add(this.playerShip);
                                    this.data.MasterShipList.Add(this.playerShip);
                                    foreach (Thruster thruster in this.playerShip.GetTList())
                                    {
                                        thruster.load_and_assign_effects(this.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", this.ThrusterEffect);
                                        thruster.InitializeForViewing();
                                    }
                                    // Doctor: I think commenting this should completely stop all the recognition of the starter ship being the 'controlled' ship for the pie menu.
                                    this.data.playerShip = this.playerShip;
                                    //this.playerShip.PlayerShip = true;
                                    planet1.GovernorOn = false;
                                    planet1.colonyType = Planet.ColonyType.Colony;
                                }
                                else
                                {
                                    string str = index.data.StartingShip;
                                    if (GlobalStats.HardcoreRuleset)
                                        str = str + " STL";
                                    Ship ship3 = ResourceManager.GetShip(index.data.Traits.Prototype == 0 ? str : index.data.PrototypeShip);
                                    ship3.Position = planet1.Position + new Vector2(-2500f, -2000f);
                                    ship3.loyalty = index;
                                    ship3.Initialize();
                                    //Added by McShooterz: Starting ship support for automatic naming
                                    if (GlobalStats.ActiveMod != null && Ship_Game.ResourceManager.ShipNames.CheckForName(ship3.loyalty.data.Traits.ShipType, ship3.Role))
                                        ship3.VanityName = Ship_Game.ResourceManager.ShipNames.GetName(ship3.loyalty.data.Traits.ShipType, ship3.Role);
                                    ship3.DoOrbit(planet1);
                                    ship3.GetSO().World = Matrix.CreateTranslation(new Vector3(ship3.Position, 0.0f));
                                    this.ScreenManager.inter.ObjectManager.Submit((ISceneObject)ship3.GetSO());
                                    this.data.MasterShipList.Add(ship3);
                                    index.AddShip(ship3);
                                    index.GetForcePool().Add(ship3);
                                    planet1.system.spatialManager.CollidableObjects.Add((GameplayObject)ship3);
                                    ship3.isInDeepSpace = false;
                                    ship3.SetSystem(planet1.system);
                                    planet1.system.ShipList.Add(ship3);
                                    foreach (Thruster thruster in ship3.GetTList())
                                    {
                                        thruster.load_and_assign_effects(this.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", this.ThrusterEffect);
                                        thruster.InitializeForViewing();
                                    }
                                }
                            }
                        }
                    }
                    using (List<Empire>.Enumerator enumerator = this.data.EmpireList.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Empire empire = enumerator.Current;
                            if (!empire.isFaction && empire.data.Traits.BonusExplored > 0)
                            {
                                IOrderedEnumerable<SolarSystem> orderedEnumerable = Enumerable.OrderBy<SolarSystem, float>((IEnumerable<SolarSystem>)this.data.SolarSystemsList, (Func<SolarSystem, float>)(system => Vector2.Distance(empire.GetPlanets()[0].Position, system.Position)));
                                for (int index = 0; index < (this.data.SolarSystemsList.Count >= 20 ? empire.data.Traits.BonusExplored : this.data.SolarSystemsList.Count); ++index)
                                {
                                    Enumerable.ElementAt<SolarSystem>((IEnumerable<SolarSystem>)orderedEnumerable, index).ExploredDict[empire] = true;
                                    foreach (Planet planet in Enumerable.ElementAt<SolarSystem>((IEnumerable<SolarSystem>)orderedEnumerable, index).PlanetList)
                                        planet.ExploredDict[empire] = true;
                                }
                            }
                        }
                    }
                    this.ready = true;
                }
            }
        }
 public UniverseScreen(UniverseData data, string loyalty)
 {
     //this.perfavg2   = new List<float>();
     //this.perfavg3 = new List<float>();
     //this.perfavg4 = new List<float>();
     //this.perfavg5 = new List<float>();
     //this.perfavg = new List<float>();
     this.Size = data.Size;
     this.FTLModifier = data.FTLSpeedModifier;
     this.EnemyFTLModifier = data.EnemyFTLSpeedModifier;
     this.GravityWells = data.GravityWells;
     UniverseScreen.SolarSystemList = data.SolarSystemsList;
     this.MasterShipList = data.MasterShipList;
     this.loadFogPath = data.loadFogPath;
     this.PlayerLoyalty = loyalty;
     this.playerShip = data.playerShip;
     EmpireManager.GetEmpireByName(loyalty).isPlayer = true;
     this.ShipToView = this.playerShip;
     this.loading = true;
 }
 public static List<Vector2> CreateMyArc(SpriteBatch spriteBatch, Vector2 Center, float radius, int sides, float startingAngle, float degrees, Vector2 C0, Vector2 C1, Color c, float Thickness, List<Circle> Circles)
 {
     BatchRemovalCollection<Vector2> points = new BatchRemovalCollection<Vector2>();
     double curAngle = (double)MathHelper.ToRadians(startingAngle);
     double step = (double)(MathHelper.ToRadians(degrees) / (float)sides);
     for (double theta = curAngle + step; theta < curAngle + (double)MathHelper.ToRadians(degrees); theta = theta + step)
     {
         Vector2 r = new Vector2((float)((double)radius * Math.Cos(theta)), (float)((double)radius * Math.Sin(theta)));
         r = r + Center;
         points.Add(r);
     }
     foreach (Circle ToCheck in Circles)
     {
         foreach (Vector2 point in points)
         {
             if (!HelperFunctions.IsPointInCircle(ToCheck.Center, ToCheck.Radius - 2f, point))
             {
                 continue;
             }
             points.QueuePendingRemoval(point);
         }
     }
     points.ApplyPendingRemovals();
     if (points.Count > 2)
     {
         if (Vector2.Distance(C0, points[1]) >= Vector2.Distance(C0, points[points.Count - 1]))
         {
             points[0] = C1;
             points[points.Count - 1] = C0;
         }
         else
         {
             points[0] = C0;
             points[points.Count - 1] = C1;
         }
     }
     return points;
 }
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             if (this.starfield != null)
                 this.starfield.Dispose();
             if (this.DeepSpaceDone != null)
                 this.DeepSpaceDone.Dispose();
             if (this.EmpireDone != null)
                 this.EmpireDone.Dispose();
             if (this.DeepSpaceGateKeeper != null)
                 this.DeepSpaceGateKeeper.Dispose();
             if (this.ItemsToBuild != null)
                 this.ItemsToBuild.Dispose();
             if (this.WorkerBeginEvent != null)
                 this.WorkerBeginEvent.Dispose();
             if (this.WorkerCompletedEvent != null)
                 this.WorkerCompletedEvent.Dispose();
             if (this.anomalyManager != null)
                 this.anomalyManager.Dispose();
             if (this.bloomComponent != null)
                 this.bloomComponent.Dispose();
             if (this.ShipGateKeeper != null)
                 this.ShipGateKeeper.Dispose();
             if (this.SystemThreadGateKeeper != null)
                 this.SystemThreadGateKeeper.Dispose();
             if (this.FogMap != null)
                 this.FogMap.Dispose();
             if (this.MasterShipList != null)
                 this.MasterShipList.Dispose();
             if (this.EmpireGateKeeper != null)
                 this.EmpireGateKeeper.Dispose();
             if (this.BombList != null)
                 this.BombList.Dispose();
             if (this.flash != null)
                 this.flash.Dispose();
             if (this.lightning != null)
                 this.lightning.Dispose();
             if (this.neb_particles != null)
                 this.neb_particles.Dispose();
             if (this.photonExplosionParticles != null)
                 this.photonExplosionParticles.Dispose();
             if (this.projectileTrailParticles != null)
                 this.projectileTrailParticles.Dispose();
             if (this.sceneMap != null)
                 this.sceneMap.Dispose();
             if (this.shipListInfoUI != null)
                 this.shipListInfoUI.Dispose();
             if (this.smokePlumeParticles != null)
                 this.smokePlumeParticles.Dispose();
             if (this.sparks != null)
                 this.sparks.Dispose();
             if (this.star_particles != null)
                 this.star_particles.Dispose();
             if (this.engineTrailParticles != null)
                 this.engineTrailParticles.Dispose();
             if (this.explosionParticles != null)
                 this.explosionParticles.Dispose();
             if (this.explosionSmokeParticles != null)
                 this.explosionSmokeParticles.Dispose();
             if (this.fireTrailParticles != null)
                 this.fireTrailParticles.Dispose();
             if (this.fireParticles != null)
                 this.fireParticles.Dispose();
             if (this.flameParticles != null)
                 this.flameParticles.Dispose();
             if (this.beamflashes != null)
                 this.beamflashes.Dispose();
             if (this.dsbw != null)
                 this.dsbw.Dispose();
             if (this.SelectedShipList != null)
                 this.SelectedShipList.Dispose();
             if (this.NotificationManager != null)
                 this.NotificationManager.Dispose();
             if (this.FogMapTarget != null)
                 this.FogMapTarget.Dispose();
         }
         this.starfield = null;
         this.DeepSpaceDone = null;
         this.EmpireDone = null;
         this.DeepSpaceGateKeeper = null;
         this.ItemsToBuild = null;
         this.WorkerBeginEvent = null;
         this.WorkerCompletedEvent = null;
         this.anomalyManager = null;
         this.bloomComponent = null;
         this.ShipGateKeeper = null;
         this.SystemThreadGateKeeper = null;
         this.FogMap = null;
         this.MasterShipList = null;
         this.EmpireGateKeeper = null;
         this.BombList = null;
         this.flash = null;
         this.lightning = null;
         this.neb_particles = null;
         this.photonExplosionParticles = null;
         this.projectileTrailParticles = null;
         this.sceneMap = null;
         this.shipListInfoUI = null;
         this.smokePlumeParticles = null;
         this.sparks = null;
         this.star_particles = null;
         this.engineTrailParticles = null;
         this.explosionParticles = null;
         this.explosionSmokeParticles = null;
         this.fireTrailParticles = null;
         this.fireParticles = null;
         this.flameParticles = null;
         this.beamflashes = null;
         this.dsbw = null;
         this.SelectedShipList = null;
         this.NotificationManager = null;
         this.FogMapTarget = null;
     }
 }
 public static void DrawMyArc(SpriteBatch spriteBatch, Vector2 Center, float radius, int sides, float startingAngle, float degrees, Vector2 C0, Vector2 C1, Color c, float Thickness)
 {
     BatchRemovalCollection<Vector2> points = new BatchRemovalCollection<Vector2>();
     double curAngle = (double)MathHelper.ToRadians(startingAngle);
     double step = (double)(MathHelper.ToRadians(degrees) / (float)sides);
     for (double theta = curAngle; theta < curAngle + (double)MathHelper.ToRadians(degrees); theta = theta + step)
     {
         Vector2 r = new Vector2((float)((double)radius * Math.Cos(theta)), (float)((double)radius * Math.Sin(theta)));
         r = r + Center;
         points.Add(r);
     }
     if (points.Count > 0)
     {
         points[0] = C0;
         points.Add(C1);
     }
     Primitives2D.DrawMyPoints(spriteBatch, points, c, Thickness, radius);
 }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.NearbyShips != null)
                        this.NearbyShips.Dispose();
                    if (this.FriendliesNearby != null)
                        this.FriendliesNearby.Dispose();

                }
                this.NearbyShips = null;
                this.FriendliesNearby = null;
                this.disposed = true;
            }
        }
 public static void DrawMyArc(SpriteBatch spriteBatch, Vector2 Center, float radius, int sides, float startingAngle, float degrees, Vector2 C0, Vector2 C1, Color c, float Thickness, List<Circle> Circles)
 {
     BatchRemovalCollection<Vector2> points = new BatchRemovalCollection<Vector2>();
     double curAngle = (double)MathHelper.ToRadians(startingAngle);
     double step = (double)(MathHelper.ToRadians(degrees) / (float)sides);
     for (double theta = curAngle + step; theta < curAngle + (double)MathHelper.ToRadians(degrees); theta = theta + step)
     {
         Vector2 r = new Vector2((float)((double)radius * Math.Cos(theta)), (float)((double)radius * Math.Sin(theta)));
         r = r + Center;
         points.Add(r);
     }
     foreach (Circle ToCheck in Circles)
     {
         foreach (Vector2 point in points)
         {
             if (Vector2.Distance(point, ToCheck.Center) >= ToCheck.Radius - 5f)
             {
                 continue;
             }
             points.QueuePendingRemoval(point);
         }
     }
     points.ApplyPendingRemovals();
     if (points.Count > 0)
     {
         points[0] = C0;
         points[points.Count - 1] = C1;
     }
     Primitives2D.DrawMyPoints(spriteBatch, points, c, Thickness, radius);
 }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.TrustEntries != null)
                        this.TrustEntries.Dispose();
                    if (this.FearEntries != null)
                        this.FearEntries.Dispose();

                }
                this.TrustEntries = null;
                this.FearEntries = null;
                this.disposed = true;
            }
        }
 protected void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             if (this.TaskList != null)
                 this.TaskList.Dispose();
             if (this.DefensiveCoordinator != null)
                 this.DefensiveCoordinator.Dispose();
             if (this.Goals != null)
                 this.Goals.Dispose();
         }
         this.TaskList = null;
         this.DefensiveCoordinator = null;
         this.Goals = null;
         this.disposed = true;
     }
 }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.AgentList != null)
                        this.AgentList.Dispose();
                    if (this.MoleList != null)
                        this.MoleList.Dispose();

                }
                this.AgentList = null;
                this.MoleList = null;
                this.disposed = true;
            }
        }
        public void AutoArrange()
        {
            this.CenterShips.Clear();
            this.LeftShips.Clear();
            this.RightShips.Clear();
            this.ScreenShips.Clear();
            this.RearShips.Clear();
            this.CenterFlank.Clear();
            this.LeftFlank.Clear();
            this.RightFlank.Clear();
            this.ScreenFlank.Clear();
            this.RearFlank.Clear();
            this.AllFlanks.Add(this.CenterFlank);
            this.AllFlanks.Add(this.LeftFlank);
            this.AllFlanks.Add(this.RightFlank);
            this.AllFlanks.Add(this.ScreenFlank);
            this.AllFlanks.Add(this.RearFlank);
            BatchRemovalCollection<Ship> removalCollection = new BatchRemovalCollection<Ship>();
            foreach (Ship ship in (List<Ship>)this.Ships)
                removalCollection.Add(ship);
            foreach (Ship ship in (List<Ship>)removalCollection)
            {
                if (ship.Role == "scout")
                {
                    this.ScreenShips.Add(ship);
                    removalCollection.QueuePendingRemoval(ship);
                }
                if (ship.Role == "freighter")
                {
                    this.RearShips.Add(ship);
                    removalCollection.QueuePendingRemoval(ship);
                }
                if (ship.Role == "capital" || ship.Role == "carrier" || ship.Role == "cruiser")
                {
                    this.CenterShips.Add(ship);
                    removalCollection.QueuePendingRemoval(ship);
                }
            }
            removalCollection.ApplyPendingRemovals();
            IOrderedEnumerable<Ship> orderedEnumerable1 = Enumerable.OrderBy<Ship, float>((IEnumerable<Ship>)this.Ships, (Func<Ship, float>)(ship => ship.speed));
            this.speed = Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable1) > 0 ? Enumerable.ElementAt<Ship>((IEnumerable<Ship>)orderedEnumerable1, 0).speed : 200f;
            IOrderedEnumerable<Ship> orderedEnumerable2 = Enumerable.OrderByDescending<Ship, float>((IEnumerable<Ship>)removalCollection, (Func<Ship, float>)(ship => ship.GetStrength() + (float)ship.Size));
            int num1 = 0;
            foreach (Ship ship in (IEnumerable<Ship>)orderedEnumerable2)
            {
                if (num1 < 4)
                {
                    this.CenterShips.Add(ship);
                    ++num1;
                }
                else if (num1 < 7)
                {
                    this.LeftShips.Add(ship);
                    ++num1;
                }
                else if (num1 < 11)
                {
                    this.RightShips.Add(ship);
                    ++num1;
                }
                else if (num1 < 15)
                {
                    this.ScreenShips.Add(ship);
                    ship.FleetCombatStatus = FleetCombatStatus.Maintain;

                    ++num1;
                }
                if (num1 == 15)
                    num1 = 0;
            }
            IOrderedEnumerable<Ship> orderedEnumerable3 = Enumerable.OrderByDescending<Ship, int>((IEnumerable<Ship>)this.CenterShips, (Func<Ship, int>)(ship => ship.Size));
            Fleet.Squad squad1 = new Fleet.Squad();
            squad1.Fleet = this;
            for (int index = 0; index < Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable3); ++index)
            {
                if (squad1.Ships.Count < 4)
                    squad1.Ships.Add(Enumerable.ElementAt<Ship>((IEnumerable<Ship>)orderedEnumerable3, index));
                if (squad1.Ships.Count == 4 || index == Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable3) - 1)
                {
                    this.CenterFlank.Add(squad1);
                    squad1 = new Fleet.Squad();
                    squad1.Fleet = this;
                }
            }
            IOrderedEnumerable<Ship> orderedEnumerable4 = Enumerable.OrderByDescending<Ship, float>((IEnumerable<Ship>)this.LeftShips, (Func<Ship, float>)(ship => ship.speed));
            Fleet.Squad squad2 = new Fleet.Squad();
            squad2.Fleet = this;
            for (int index = 0; index < Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable4); ++index)
            {
                if (squad2.Ships.Count < 4)
                    squad2.Ships.Add(Enumerable.ElementAt<Ship>((IEnumerable<Ship>)orderedEnumerable4, index));
                if (squad2.Ships.Count == 4 || index == Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable4) - 1)
                {
                    this.LeftFlank.Add(squad2);
                    squad2 = new Fleet.Squad();
                    squad2.Fleet = this;
                }
            }
            IOrderedEnumerable<Ship> orderedEnumerable5 = Enumerable.OrderByDescending<Ship, float>((IEnumerable<Ship>)this.RightShips, (Func<Ship, float>)(ship => ship.speed));
            Fleet.Squad squad3 = new Fleet.Squad();
            squad3.Fleet = this;
            for (int index = 0; index < Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable5); ++index)
            {
                if (squad3.Ships.Count < 4)
                    squad3.Ships.Add(Enumerable.ElementAt<Ship>((IEnumerable<Ship>)orderedEnumerable5, index));
                if (squad3.Ships.Count == 4 || index == Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable5) - 1)
                {
                    this.RightFlank.Add(squad3);
                    squad3 = new Fleet.Squad();
                    squad3.Fleet = this;
                }
            }
            IOrderedEnumerable<Ship> orderedEnumerable6 = Enumerable.OrderByDescending<Ship, float>((IEnumerable<Ship>)this.ScreenShips, (Func<Ship, float>)(ship => ship.speed));
            Fleet.Squad squad4 = new Fleet.Squad();
            squad4.Fleet = this;
            for (int index = 0; index < Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable6); ++index)
            {
                if (squad4.Ships.Count < 4)
                    squad4.Ships.Add(Enumerable.ElementAt<Ship>((IEnumerable<Ship>)orderedEnumerable6, index));
                if (squad4.Ships.Count == 4 || index == Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable6) - 1)
                {
                    this.ScreenFlank.Add(squad4);
                    squad4 = new Fleet.Squad();
                    squad4.Fleet = this;
                }
            }
            IOrderedEnumerable<Ship> orderedEnumerable7 = Enumerable.OrderByDescending<Ship, float>((IEnumerable<Ship>)this.RearShips, (Func<Ship, float>)(ship => ship.speed));
            Fleet.Squad squad5 = new Fleet.Squad();
            squad5.Fleet = this;
            for (int index = 0; index < Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable7); ++index)
            {
                if (squad5.Ships.Count < 4)
                    squad5.Ships.Add(Enumerable.ElementAt<Ship>((IEnumerable<Ship>)orderedEnumerable7, index));
                if (squad5.Ships.Count == 4 || index == Enumerable.Count<Ship>((IEnumerable<Ship>)orderedEnumerable7) - 1)
                {
                    this.RearFlank.Add(squad5);
                    squad5 = new Fleet.Squad();
                    squad5.Fleet = this;
                }
            }
            this.Position = this.findAveragePosition();
            int num2 = 0;
            int num3 = 0;
            for (int index = 0; index < this.CenterFlank.Count; ++index)
            {
                if (index == 0)
                    this.CenterFlank[index].Offset = new Vector2(0.0f, 0.0f);
                else if (index % 2 == 1)
                {
                    ++num2;
                    this.CenterFlank[index].Offset = new Vector2((float)(num2 * -1400), 0.0f);
                }
                else
                {
                    ++num3;
                    this.CenterFlank[index].Offset = new Vector2((float)(num3 * 1400), 0.0f);
                }
            }
            int num4 = 0;
            int num5 = 0;
            for (int index = 0; index < this.ScreenFlank.Count; ++index)
            {
                if (index == 0)
                    this.ScreenFlank[index].Offset = new Vector2(0.0f, -2500f);
                else if (index % 2 == 1)
                {
                    ++num4;
                    this.ScreenFlank[index].Offset = new Vector2((float)(num4 * -1400), -2500f);
                }
                else
                {
                    ++num5;
                    this.ScreenFlank[index].Offset = new Vector2((float)(num5 * 1400), -2500f);
                }
            }
            int num6 = 0;
            int num7 = 0;
            for (int index = 0; index < this.RearFlank.Count; ++index)
            {
                if (index == 0)
                    this.RearFlank[index].Offset = new Vector2(0.0f, 2500f);
                else if (index % 2 == 1)
                {
                    ++num6;
                    this.RearFlank[index].Offset = new Vector2((float)(num6 * -1400), 2500f);
                }
                else
                {
                    ++num7;
                    this.RearFlank[index].Offset = new Vector2((float)(num7 * 1400), 2500f);
                }
            }
            for (int index = 0; index < this.LeftFlank.Count; ++index)
                this.LeftFlank[index].Offset = new Vector2((float)(-this.CenterFlank.Count * 1400 - (this.LeftFlank.Count == 1 ? 1400 : index * 1400)), 0.0f);
            for (int index = 0; index < this.RightFlank.Count; ++index)
                this.RightFlank[index].Offset = new Vector2((float)(this.CenterFlank.Count * 1400 + (this.RightFlank.Count == 1 ? 1400 : index * 1400)), 0.0f);
            this.AutoAssembleFleet(0.0f, new Vector2(0.0f, -1f));
            foreach (Ship s in (List<Ship>)this.Ships)
            {
                if (!s.InCombat)
                {
                    lock (s.GetAI().wayPointLocker)
                        s.GetAI().OrderThrustTowardsPosition(this.Position + s.FleetOffset, this.facing, new Vector2(0.0f, -1f), true);
                }
                FleetDataNode fleetDataNode = new FleetDataNode();
                fleetDataNode.SetShip(s);
                fleetDataNode.ShipName = s.Name;
                fleetDataNode.FleetOffset = s.RelativeFleetOffset;
                fleetDataNode.OrdersOffset = s.RelativeFleetOffset;
                this.DataNodes.Add(fleetDataNode);

            }

            //foreach (List<Fleet.Squad> list in this.AllFlanks)
            ////Parallel.ForEach(this.AllFlanks, list =>
            //{
            //    foreach (Fleet.Squad squad6 in list)
            //    {

            //        foreach (Ship ship in (List<Ship>)squad6.Ships)
            //        {
            //            foreach (FleetDataNode fleetDataNode in (List<FleetDataNode>)this.DataNodes)
            //            {
            //                if (ship == fleetDataNode.GetShip())
            //                    squad6.DataNodes.Add(fleetDataNode);
            //            }
            //        }
            //    }
            //}//);
        }
 private static List<Vector2> CreateMyCircle(Circle ToDraw, double radius, int sides, List<Circle> CircleList)
 {
     BatchRemovalCollection<Vector2> vectors = new BatchRemovalCollection<Vector2>();
     double step = 6.28318530717959 / (double)sides;
     for (double theta = 0; theta < 6.28318530717959; theta = theta + step)
     {
         Vector2 r = new Vector2((float)(radius * Math.Cos(theta)), (float)(radius * Math.Sin(theta)));
         vectors.Add(r);
     }
     Vector2 r1 = new Vector2((float)(radius * Math.Cos(0)), (float)(radius * Math.Sin(0)));
     r1 = r1 + ToDraw.Center;
     vectors.Add(r1);
     foreach (Circle ToCheck in CircleList)
     {
         foreach (Vector2 point in vectors)
         {
             if (Vector2.Distance(point, ToCheck.Center) >= ToCheck.Radius - 0.1f)
             {
                 continue;
             }
             vectors.QueuePendingRemoval(point);
         }
     }
     return vectors;
 }
Пример #27
0
 public static void Main()
 {
     BatchRemovalCollection <string> x = new BatchRemovalCollection <string>();
 }
        protected override void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.DataNodes != null)
                        this.DataNodes.Dispose();

                }
                this.DataNodes = null;
                this.disposed = true;
                base.Dispose(disposing);

            }
        }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.NotificationList != null)
                        this.NotificationList.Dispose();

                }
                this.NotificationList = null;
                this.disposed = true;
            }
        }
            protected void Dispose(bool disposing)
            {
                if (!disposed)
                {
                    if (disposing)
                    {
                        if (this.DataNodes != null)
                            this.DataNodes.Dispose();
                        if (this.Ships != null)
                            this.Ships.Dispose();

                    }
                    this.DataNodes = null;
                    this.Ships = null;
                    this.disposed = true;
                }
            }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.CometList != null)
                        this.CometList.Dispose();
                    if (this.waveOut != null)
                        this.waveOut.Dispose();
                    if (this.mp3FileReader != null)
                        this.mp3FileReader.Dispose();

                }
                this.CometList = null;
                this.waveOut = null;
                this.mp3FileReader = null;
                this.disposed = true;
            }
        }