public void LoadGraphics() { this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, (float)this.ScreenManager.GraphicsDevice.Viewport.Width / (float)this.ScreenManager.GraphicsDevice.Viewport.Height, 1000f, 3E+07f); this.Frustum = new BoundingFrustum(this.view * this.projection); this.mmHousing = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 276, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 256, 276, 256); this.MinimapDisplayRect = new Rectangle(this.mmHousing.X + 61, this.mmHousing.Y + 43, 200, 200); this.minimap = new MiniMap(this.mmHousing); this.mmButtons = new MinimapButtons(this.mmHousing, this.EmpireUI); this.mmShowBorders = new Rectangle(this.MinimapDisplayRect.X, this.MinimapDisplayRect.Y - 25, 32, 32); this.mmDSBW = new Rectangle(this.mmShowBorders.X + 32, this.mmShowBorders.Y, 64, 32); this.mmAutomation = new Rectangle(this.mmDSBW.X + this.mmDSBW.Width, this.mmShowBorders.Y, 96, 32); this.mmShipView = new Rectangle(this.MinimapDisplayRect.X - 32, this.MinimapDisplayRect.Y, 32, 105); this.mmGalaxyView = new Rectangle(this.mmShipView.X, this.mmShipView.Y + 105, 32, 105); this.SectorMap = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 300, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 150, 150, 150); this.GalaxyMap = new Rectangle(this.SectorMap.X + this.SectorMap.Width, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 150, 150, 150); this.SelectedStuffRect = new Rectangle(0, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 247, 407, 242); this.ShipInfoUIElement = new ShipInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.sInfoUI = new SystemInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.pInfoUI = new PlanetInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.shipListInfoUI = new ShipListInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.vuiElement = new VariableUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.SectorSourceRect = new Rectangle((this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 720) / 2, (this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 720) / 2, 720, 720); this.EmpireUI = new EmpireUIOverlay(this.player, this.ScreenManager.GraphicsDevice, this); this.bloomComponent = new BloomComponent(this.ScreenManager); this.bloomComponent.LoadContent(); this.aw = new AutomationWindow(this.ScreenManager, this); PresentationParameters presentationParameters = this.ScreenManager.GraphicsDevice.PresentationParameters; int backBufferWidth = presentationParameters.BackBufferWidth; int backBufferHeight = presentationParameters.BackBufferHeight; SurfaceFormat backBufferFormat = presentationParameters.BackBufferFormat; this.sceneMap = new ResolveTexture2D(this.ScreenManager.GraphicsDevice, backBufferWidth, backBufferHeight, 1, backBufferFormat); this.MainTarget = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.LightsTarget = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.MiniMapSector = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.BorderRT = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.StencilRT = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); if (this.loadFogPath == null) { this.FogMap = ResourceManager.TextureDict["Textures/UniverseFeather"]; } else { using (FileStream fileStream = File.OpenRead(folderPath + "/StarDrive/Saved Games/Fog Maps/" + this.loadFogPath + ".png")) this.FogMap = Texture2D.FromFile(this.ScreenManager.GraphicsDevice, (Stream)fileStream); } this.FogMapTarget = new RenderTarget2D(this.ScreenManager.GraphicsDevice, 512, 512, 1, backBufferFormat, this.ScreenManager.GraphicsDevice.PresentationParameters.MultiSampleType, presentationParameters.MultiSampleQuality); this.basicFogOfWarEffect = this.ScreenManager.Content.Load<Effect>("Effects/BasicFogOfWar"); this.LoadMenu(); MuzzleFlashManager.universeScreen = this; DroneAI.universeScreen = this; MuzzleFlashManager.flashModel = this.ScreenManager.Content.Load<Model>("Model/Projectiles/muzzleEnergy"); MuzzleFlashManager.FlashTexture = this.ScreenManager.Content.Load<Texture2D>("Model/Projectiles/Textures/MuzzleFlash_01"); ExplosionManager.universeScreen = this; FTLManager.universeScreen = this; FTLManager.FTLTexture = this.ScreenManager.Content.Load<Texture2D>("Textures/Ships/FTL"); this.anomalyManager = new AnomalyManager(); ShipDesignScreen.screen = this; Fleet.screen = this; Bomb.screen = this; Anomaly.screen = this; PlanetScreen.screen = this; MinimapButtons.screen = this; Projectile.contentManager = this.ScreenManager.Content; Projectile.universeScreen = this; ShipModule.universeScreen = this; Asteroid.universeScreen = this; Empire.universeScreen = this; SpaceJunk.universeScreen = this; ResourceManager.universeScreen = this; Planet.universeScreen = this; Weapon.universeScreen = this; Ship.universeScreen = this; ArtificialIntelligence.universeScreen = this; MissileAI.universeScreen = this; Moon.universeScreen = this; CombatScreen.universeScreen = this; FleetDesignScreen.screen = this; this.xnaPlanetModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/planet"); this.atmoModel = this.ScreenManager.Content.Load<Model>("Model/sphere"); this.AtmoEffect = this.ScreenManager.Content.Load<Effect>("Effects/PlanetHalo"); this.cloudTex = this.ScreenManager.Content.Load<Texture2D>("Model/SpaceObjects/earthcloudmap"); this.RingTexture = this.ScreenManager.Content.Load<Texture2D>("Model/SpaceObjects/planet_rings"); this.ThrusterEffect = this.ScreenManager.Content.Load<Effect>("Effects/Thrust"); this.listener = new AudioListener(); this.SunModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/star_plane"); this.NebModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/star_plane"); this.ScreenRectangle = new Rectangle(0, 0, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight); this.starfield = new Starfield(Vector2.Zero, this.ScreenManager.GraphicsDevice, this.ScreenManager.Content); this.starfield.LoadContent(); //fbedard: new button for ShipsInCombat this.ShipsInCombat = new UIButton(); ShipsInCombat.Rect = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 275, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 280, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height); ShipsInCombat.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu"]; ShipsInCombat.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_hover"]; ShipsInCombat.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_pressed"]; ShipsInCombat.Text = "Ships: 0"; ShipsInCombat.Launches = "ShipsInCombat"; //fbedard: new button for PlanetsInCombat this.PlanetsInCombat = new UIButton(); PlanetsInCombat.Rect = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 135, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 280, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height); PlanetsInCombat.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu"]; PlanetsInCombat.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_hover"]; PlanetsInCombat.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_pressed"]; PlanetsInCombat.Text = "Planets: 0"; PlanetsInCombat.Launches = "PlanetsInCombat"; }
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]); } }