public override void LoadContent()
        {
            GlobalStats.ResearchRootUIDToDisplay = "Colonization";
            SystemInfoUIElement.SysFont = Fonts.Arial12Bold;
            SystemInfoUIElement.DataFont = Fonts.Arial10;
            this.NotificationManager = new NotificationManager(this.ScreenManager, this);
            this.aw = new AutomationWindow(this.ScreenManager, this);
            for (int index = 0; (double)index < (double)this.Size.X / 5000.0; ++index)
            {
                NebulousOverlay nebulousOverlay = new NebulousOverlay();
                float z = RandomMath.RandomBetween(-200000f, -2E+07f);
                nebulousOverlay.Path = "Textures/smoke";
                nebulousOverlay.Position = new Vector3(RandomMath.RandomBetween(-0.5f * this.Size.X, this.Size.X + 0.5f * this.Size.X), RandomMath.RandomBetween(-0.5f * this.Size.X, this.Size.X + 0.5f * this.Size.X), z);
                float radians = RandomMath.RandomBetween(0.0f, 6.283185f);
                nebulousOverlay.Scale = RandomMath.RandomBetween(10f, 100f);
                nebulousOverlay.WorldMatrix = Matrix.CreateScale(50f) * Matrix.CreateScale(nebulousOverlay.Scale) * Matrix.CreateRotationZ(radians) * Matrix.CreateTranslation(nebulousOverlay.Position);
                this.Stars.Add(nebulousOverlay);
            }
            this.LoadGraphics();
            UniverseScreen.DeepSpaceManager.Setup((int)this.Size.X, (int)this.Size.Y, (int)(500000.0 * (double)this.GameScale), new Vector2(this.Size.X / 2f, this.Size.Y / 2f));
            UniverseScreen.ShipSpatialManager.Setup((int)this.Size.X, (int)this.Size.Y, (int)(500000.0 * (double)this.GameScale), new Vector2(this.Size.X / 2f, this.Size.Y / 2f));
            this.DoParticleLoad();
            this.bg3d = new Background3D(this);
            this.starfield = new Starfield(Vector2.Zero, this.ScreenManager.GraphicsDevice, this.ScreenManager.Content);
            this.starfield.LoadContent();
            GameplayObject.audioListener = this.listener;
            Weapon.audioListener = this.listener;
            GameplayObject.audioListener = this.listener;
            this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, (float)this.ScreenManager.GraphicsDevice.Viewport.Width / (float)this.ScreenManager.GraphicsDevice.Viewport.Height, 1000f, 3E+07f);
            this.SetLighting(this.UseRealLights);
            foreach (SolarSystem solarSystem in UniverseScreen.SolarSystemList)
            {
                foreach (string FleetUID in solarSystem.DefensiveFleets)
                {
                    Fleet defensiveFleetAt = HelperFunctions.CreateDefensiveFleetAt(FleetUID, EmpireManager.GetEmpireByName("The Remnant"), solarSystem.PlanetList[0].Position);
                    MilitaryTask militaryTask = new MilitaryTask();
                    militaryTask.AO = solarSystem.PlanetList[0].Position;
                    militaryTask.AORadius = 120000f;
                    militaryTask.type = MilitaryTask.TaskType.DefendSystem;
                    defensiveFleetAt.Task = militaryTask;
                    defensiveFleetAt.TaskStep = 3;
                    militaryTask.WhichFleet = EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10;
                    EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().TryAdd(EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10, defensiveFleetAt);
                    EmpireManager.GetEmpireByName("The Remnant").GetGSAI().TaskList.Add(militaryTask);
                    militaryTask.Step = 2;
                }
                if (GlobalStats.ActiveModInfo != null && GlobalStats.ActiveModInfo.customRemnantElements)
                {
                    foreach (Planet p in solarSystem.PlanetList)
                    {
                        foreach (string FleetUID in p.PlanetFleets)
                        {
                            Fleet planetFleetAt = HelperFunctions.CreateDefensiveFleetAt(FleetUID, EmpireManager.GetEmpireByName("The Remnant"), p.Position);
                            MilitaryTask militaryTask = new MilitaryTask();
                            militaryTask.AO = solarSystem.PlanetList[0].Position;
                            militaryTask.AORadius = 120000f;
                            militaryTask.type = MilitaryTask.TaskType.DefendSystem;
                            planetFleetAt.Task = militaryTask;
                            planetFleetAt.TaskStep = 3;
                            militaryTask.WhichFleet = EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10;
                            EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().TryAdd(EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10, planetFleetAt);
                            EmpireManager.GetEmpireByName("The Remnant").GetGSAI().TaskList.Add(militaryTask);
                            militaryTask.Step = 2;
                        }
                    }
                }

                foreach (SolarSystem.FleetAndPos fleetAndPos in solarSystem.FleetsToSpawn)
                {
                    Fleet defensiveFleetAt = HelperFunctions.CreateDefensiveFleetAt(fleetAndPos.fleetname, EmpireManager.GetEmpireByName("The Remnant"), solarSystem.Position + fleetAndPos.Pos);
                    MilitaryTask militaryTask = new MilitaryTask();
                    militaryTask.AO = solarSystem.Position + fleetAndPos.Pos;
                    militaryTask.AORadius = 75000f;
                    militaryTask.type = MilitaryTask.TaskType.DefendSystem;
                    defensiveFleetAt.Task = militaryTask;
                    defensiveFleetAt.TaskStep = 3;
                    militaryTask.WhichFleet = EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10;
                    EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().TryAdd(EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10, defensiveFleetAt);
                    EmpireManager.GetEmpireByName("The Remnant").GetGSAI().TaskList.Add(militaryTask);
                    militaryTask.Step = 2;
                }
                foreach (string key in solarSystem.ShipsToSpawn)
                    ResourceManager.CreateShipAt(key, EmpireManager.GetEmpireByName("The Remnant"), solarSystem.PlanetList[0], true);
                foreach (Planet p in solarSystem.PlanetList)
                {
                    if (p.Owner != null)
                    {
                        foreach (string key in p.Guardians)
                            ResourceManager.CreateShipAt(key, p.Owner, p, true);
                    }
                    else
                    {
                        //Added by McShooterz: alternate hostile fleets populate universe
                        if (GlobalStats.ActiveModInfo != null && ResourceManager.HostileFleets.Fleets.Count > 0)
                        {
                            if (p.Guardians.Count > 0)
                            {
                                int randomFleet = HelperFunctions.GetRandomIndex(ResourceManager.HostileFleets.Fleets.Count);
                                foreach (string ship in ResourceManager.HostileFleets.Fleets[randomFleet].Ships)
                                {
                                    ResourceManager.CreateShipAt(ship, EmpireManager.GetEmpireByName(ResourceManager.HostileFleets.Fleets[randomFleet].Empire), p, true);
                                }
                            }
                        }
                        else
                        {
                            foreach (string key in p.Guardians)
                                ResourceManager.CreateShipAt(key, EmpireManager.GetEmpireByName("The Remnant"), p, true);
                            if (p.CorsairPresence)
                            {
                                ResourceManager.CreateShipAt("Corsair Asteroid Base", EmpireManager.GetEmpireByName("Corsairs"), p, true).TetherToPlanet(p);
                                ResourceManager.CreateShipAt("Corsair", EmpireManager.GetEmpireByName("Corsairs"), p, true);
                                ResourceManager.CreateShipAt("Captured Gunship", EmpireManager.GetEmpireByName("Corsairs"), p, true);
                                ResourceManager.CreateShipAt("Captured Gunship", EmpireManager.GetEmpireByName("Corsairs"), p, true);
                            }
                        }
                    }
                }
                foreach (Anomaly anomaly in solarSystem.AnomaliesList)
                {
                    if (anomaly.type == "DP")
                        this.anomalyManager.AnomaliesList.Add((Anomaly)new DimensionalPrison(solarSystem.Position + anomaly.Position));
                }
            }
            float num = 10f;
            Matrix matrix = this.view;
            this.MaxCamHeight = 4E+07f;
            while ((double)num < (double)(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth + 50))
            {
                Vector2 vector2_1 = new Vector2(this.Size.X / 2f, this.Size.Y / 2f);
                Matrix view = Matrix.CreateTranslation(0.0f, 0.0f, 0.0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f)) * Matrix.CreateRotationX(MathHelper.ToRadians(0.0f)) * Matrix.CreateLookAt(new Vector3(-vector2_1.X, vector2_1.Y, this.MaxCamHeight), new Vector3(-vector2_1.X, vector2_1.Y, 0.0f), new Vector3(0.0f, -1f, 0.0f));
                Vector3 vector3_1 = this.ScreenManager.GraphicsDevice.Viewport.Project(Vector3.Zero, this.projection, view, Matrix.Identity);
                Vector2 vector2_2 = new Vector2(vector3_1.X, vector3_1.Y);
                Vector3 vector3_2 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(this.Size, 0.0f), this.projection, view, Matrix.Identity);
                num = new Vector2(vector3_2.X, vector3_2.Y).X - vector2_2.X;
                if ((double)num < (double)(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth + 50))
                    this.MaxCamHeight -= 0.1f * this.MaxCamHeight;
            }
            if (MaxCamHeight > 23000000) MaxCamHeight = 23000000;
            if (!this.loading)
            {
                this.camPos.X = this.playerShip.Center.X;
                this.camPos.Y = this.playerShip.Center.Y;
                this.camHeight = 2750f;
            }
            this.transitionDestination = new Vector3(this.camPos.X, this.camPos.Y, this.camHeight);
            foreach (NebulousOverlay nebulousOverlay in this.Stars)
                this.star_particles.AddParticleThreadA(nebulousOverlay.Position, Vector3.Zero);
            if (this.MultiThread)
            {
                this.WorkerThread = new Thread(new ThreadStart(this.Worker));
                this.WorkerThread.IsBackground = true;
                this.WorkerThread.Start();
                //this.ShipUpdateThread = new Thread(new ThreadStart(this.ShipUpdater));
                //this.ShipUpdateThread.IsBackground = true;
            #if !ALTERTHREAD
                this.SystemResetEvents = new ManualResetEvent[4];
                this.SystemGateKeeper = new AutoResetEvent[4];
                List<SolarSystem> list1 = new List<SolarSystem>();
                List<SolarSystem> list2 = new List<SolarSystem>();
                List<SolarSystem> list3 = new List<SolarSystem>();
                List<SolarSystem> list4 = new List<SolarSystem>();
                Rectangle rect1 = new Rectangle(0, 0, (int)this.Size.X / 2, (int)this.Size.Y / 2);
                Rectangle rect2 = new Rectangle((int)this.Size.X / 2, 0, (int)this.Size.X / 2, (int)this.Size.Y / 2);
                Rectangle rect3 = new Rectangle(0, (int)this.Size.Y / 2, (int)this.Size.X / 2, (int)this.Size.Y / 2);
                Rectangle rect4 = new Rectangle((int)this.Size.X / 2, (int)this.Size.Y / 2, (int)this.Size.X / 2, (int)this.Size.Y / 2);
                this.SystemResetEvents[0] = new ManualResetEvent(false);
                this.SystemGateKeeper[0] = new AutoResetEvent(false);
                this.SystemResetEvents[1] = new ManualResetEvent(false);
                this.SystemGateKeeper[1] = new AutoResetEvent(false);
                this.SystemResetEvents[2] = new ManualResetEvent(false);
                this.SystemGateKeeper[2] = new AutoResetEvent(false);
                this.SystemResetEvents[3] = new ManualResetEvent(false);
                this.SystemGateKeeper[3] = new AutoResetEvent(false);
                for (int index = 0; index < UniverseScreen.SolarSystemList.Count; ++index)
                {
                    if (HelperFunctions.CheckIntersection(rect1, UniverseScreen.SolarSystemList[index].Position))
                    {
                        UniverseScreen.SolarSystemList[index].IndexOfResetEvent = 0;
                        list1.Add(UniverseScreen.SolarSystemList[index]);
                    }
                    if (HelperFunctions.CheckIntersection(rect2, UniverseScreen.SolarSystemList[index].Position))
                    {
                        UniverseScreen.SolarSystemList[index].IndexOfResetEvent = 1;
                        list2.Add(UniverseScreen.SolarSystemList[index]);
                    }
                    if (HelperFunctions.CheckIntersection(rect3, UniverseScreen.SolarSystemList[index].Position))
                    {
                        UniverseScreen.SolarSystemList[index].IndexOfResetEvent = 2;
                        list3.Add(UniverseScreen.SolarSystemList[index]);
                    }
                    if (HelperFunctions.CheckIntersection(rect4, UniverseScreen.SolarSystemList[index].Position))
                    {
                        UniverseScreen.SolarSystemList[index].IndexOfResetEvent = 3;
                        list4.Add(UniverseScreen.SolarSystemList[index]);
                    }
                }
                Thread thread1 = new Thread(new ParameterizedThreadStart(this.SystemUpdater));
                this.SystemUpdateThreadList.Add(thread1);
                thread1.Start((object)list1);
                thread1.IsBackground = true;
                Thread thread2 = new Thread(new ParameterizedThreadStart(this.SystemUpdater));
                this.SystemUpdateThreadList.Add(thread2);
                thread2.Start((object)list2);
                thread2.IsBackground = true;
                Thread thread3 = new Thread(new ParameterizedThreadStart(this.SystemUpdater));
                this.SystemUpdateThreadList.Add(thread3);
                thread3.Start((object)list3);
                thread3.IsBackground = true;
                Thread thread4 = new Thread(new ParameterizedThreadStart(this.SystemUpdater));
                this.SystemUpdateThreadList.Add(thread4);
                thread4.Start((object)list4);
                thread4.IsBackground = true;
            #endif
                //Thread thread5 = new Thread(new ThreadStart(this.DeepSpaceThread));
               // this.SystemUpdateThreadList.Add(thread5);
               // thread5.Start();
               // thread5.IsBackground = true;
                //Thread thread6 = new Thread(new ThreadStart(this.EmpireThread));
                //this.SystemUpdateThreadList.Add(thread6);
                //thread6.Start();
                //thread6.IsBackground = true;

            }
            this.PlanetsDict.Clear();
            this.SolarSystemDict.Clear();
            foreach (SolarSystem solarSystem in UniverseScreen.SolarSystemList)
            {
                this.SolarSystemDict.Add(solarSystem.guid, solarSystem);
                foreach (Planet planet in solarSystem.PlanetList)
                    this.PlanetsDict.Add(planet.guid, planet);
            }
            foreach (Ship ship in (List<Ship>)this.MasterShipList)
            {
                if (ship.TetherGuid != Guid.Empty)
                    ship.TetherToPlanet(this.PlanetsDict[ship.TetherGuid]);
            }
        }
 public void GenerateArm(int numOfStars, float rotation)
 {
     Random random = new Random();
     Vector2 vector2 = new Vector2(this.Size.X / 2f, this.Size.Y / 2f);
     float num1 = (float)((double)(6f / (float)numOfStars) * 2.0 * 3.14159274101257);
     for (int index = 120; index < numOfStars; ++index)
     {
         float num2 = (float)Math.Pow((double)this.Size.X - 0.100000001490116 * (double)this.Size.X, (double)((float)index / (float)numOfStars));
         float num3 = (float)index * num1 + rotation;
         float x = vector2.X + (float)Math.Cos((double)num3) * num2;
         float y = vector2.Y + (float)Math.Sin((double)num3) * num2;
         NebulousOverlay nebulousOverlay = new NebulousOverlay();
         float z = RandomMath.RandomBetween(50000f, 450000f) - num2;
         if ((double)z < 0.0)
             z = RandomMath.RandomBetween(25000f, 50000f);
         if ((double)RandomMath.RandomBetween(0.0f, 100f) > 50.0)
             z *= -1f;
         double num4 = (double)RandomMath.RandomBetween(0.0f, 100f);
         nebulousOverlay.Path = "Textures/smoke";
         nebulousOverlay.Position = new Vector3(x, y, z);
         float radians = RandomMath.RandomBetween(0.0f, 6.283185f);
         nebulousOverlay.Scale = RandomMath.RandomBetween(10f, 100f);
         nebulousOverlay.WorldMatrix = Matrix.CreateScale(50f) * Matrix.CreateScale(nebulousOverlay.Scale) * Matrix.CreateRotationZ(radians) * Matrix.CreateTranslation(nebulousOverlay.Position);
         this.NebulousShit.Add(nebulousOverlay);
     }
     for (int index = 135; index < numOfStars; ++index)
     {
         float num2 = (float)Math.Pow((double)this.Size.X - 0.100000001490116 * (double)this.Size.X, (double)((float)index / (float)numOfStars));
         float num3 = (float)index * num1 + rotation;
         float x = vector2.X + (float)Math.Cos((double)num3) * num2 + RandomMath.RandomBetween(-200000f, 200000f);
         float y = vector2.Y + (float)Math.Sin((double)num3) * num2 + RandomMath.RandomBetween(-100000f, 100000f);
         NebulousOverlay nebulousOverlay = new NebulousOverlay();
         float z = RandomMath.RandomBetween(250000f, 800000f) - num2;
         if ((double)z < 50000.0)
             z = RandomMath.RandomBetween(100000f, 400000f);
         if ((double)RandomMath.RandomBetween(0.0f, 100f) > 50.0)
             z *= -1f;
         double num4 = (double)RandomMath.RandomBetween(0.0f, 100f);
         nebulousOverlay.Path = "Textures/smoke";
         nebulousOverlay.Position = new Vector3(x, y, z);
         float radians = RandomMath.RandomBetween(0.0f, 6.283185f);
         nebulousOverlay.Scale = RandomMath.RandomBetween(100f, 200f);
         nebulousOverlay.WorldMatrix = Matrix.CreateScale(50f) * Matrix.CreateScale(nebulousOverlay.Scale) * Matrix.CreateRotationZ(radians) * Matrix.CreateTranslation(nebulousOverlay.Position);
         this.NebulousShit.Add(nebulousOverlay);
     }
     for (int index1 = 0; index1 < 5; ++index1)
     {
         for (int index2 = 130; index2 < numOfStars; ++index2)
         {
             float num2 = (float)Math.Pow((double)this.Size.X - 0.100000001490116 * (double)this.Size.X, (double)((float)index2 / (float)numOfStars));
             float num3 = (float)index2 * num1 + rotation;
             float x = vector2.X + (float)Math.Cos((double)num3) * num2 + RandomMath.RandomBetween(-200000f, 200000f);
             float y = vector2.Y + (float)Math.Sin((double)num3) * num2 + RandomMath.RandomBetween(-100000f, 100000f);
             NebulousOverlay nebulousOverlay = new NebulousOverlay();
             float z = RandomMath.RandomBetween(250000f, 800000f) - num2;
             if ((double)z < 50000.0)
                 z = RandomMath.RandomBetween(50000f, 200000f);
             if ((double)RandomMath.RandomBetween(0.0f, 100f) > 50.0)
                 z *= -1f;
             nebulousOverlay.Path = "Textures/smoke";
             nebulousOverlay.Position = new Vector3(x, y, z);
             float radians = RandomMath.RandomBetween(0.0f, 6.283185f);
             nebulousOverlay.Scale = RandomMath.RandomBetween(10f, 50f);
             nebulousOverlay.WorldMatrix = Matrix.CreateScale(50f) * Matrix.CreateScale(nebulousOverlay.Scale) * Matrix.CreateRotationZ(radians) * Matrix.CreateTranslation(nebulousOverlay.Position);
             this.NebulousShit.Add(nebulousOverlay);
         }
     }
 }