public MySolarSystemMapSectorData GenerateSector(MyMwcVector3Int sectorToGenerate, List<MyMwcObjectBuilder_Base> objectBuilders, List<BoundingSphere> safeAreas, bool onlyStaticAsteroids) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Solar generator"); MySolarSystemGenerator solarSystemGenerator = new MySolarSystemGenerator(MyGuiScreenSolarSystemMap.UNIVERSE_SEED); solarSystemGenerator.Generate(1024); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); BoundingSphere playerSafeArea = new BoundingSphere(MySession.PlayerShip.GetPosition(), 150); //smallship + mothership safeAreas.Add(playerSafeArea); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Sector generator"); MySectorGenerator sectorGenerator = new MySectorGenerator(MyGuiScreenSolarSystemMap.UNIVERSE_SEED ^ sectorToGenerate.GetHashCode(), safeAreas); MySolarSystemMapSectorData sectorData = sectorGenerator.GenerateSectorObjectBuilders(sectorToGenerate, solarSystemGenerator.SolarSystemData, objectBuilders, onlyStaticAsteroids); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MySector.UseGenerator = true; MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Sector data"); MySolarSectorData defaultSectorData = MySolarSystemConstants.GetDefaultArea().SectorData; MySolarSectorData currentSectorData = defaultSectorData; MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); if (sectorData.Area.HasValue) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Sector data interpolation"); var sectorData2 = MySolarSystemConstants.Areas[sectorData.Area.Value].SectorData; currentSectorData = sectorData2.InterpolateWith(defaultSectorData, 1 - sectorData.AreaInfluenceMultiplier); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); } MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMwcObjectBuilder_Sector"); SetSectorProperties(currentSectorData); MyBackgroundCube.ReloadContent(); MyDistantImpostors.ReloadContent(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); return sectorData; }
public MyGuiScreenSolarSystemMap(MyGuiScreenBase parent, MyMwcSectorIdentifier currentSector) : base(new Vector2(0.5f, 0.5f), null, Vector2.One) { m_parent = parent; m_enableBackgroundFade = false; DrawMouseCursor = true; m_currentSector = currentSector; m_closeOnEsc = true; Static = this; MySolarSystemGenerator generator = new MySolarSystemGenerator(UNIVERSE_SEED); generator.Generate(1024); m_data = generator.SolarSystemData; m_solarMapRender = new MySolarMapRenderer(); m_solarMapRender.PlayerSector = currentSector.Position; //MyMinerGame.SwitchPause(); m_particlesEnabled = TransparentGeometry.Particles.MyParticlesManager.Enabled; TransparentGeometry.Particles.MyParticlesManager.Enabled = false; //AddCaption(MyTextsWrapperEnum.SolarSystemMap); MySolarSystemMapNavigationMark playerNavigationMark = new MySolarSystemMapNavigationMark( currentSector.Position, "", null, MyHudConstants.SOLAR_MAP_PLAYER_MARKER_COLOR, MyTransparentMaterialEnum.SolarMapPlayer) { VerticalLineColor = MyHudConstants.SOLAR_MAP_PLAYER_MARKER_COLOR.ToVector4(), DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_green, Offset = new Vector3(0, 0.0f, 0), Text = MyClientServer.LoggedPlayer.GetDisplayName().ToString(), Importance = 50 }; m_data.NavigationMarks.Add(playerNavigationMark); if (MyGuiScreenGamePlay.Static.IsEditorStoryActive() || MyGuiScreenGamePlay.Static.GetPreviousGameType() == MyGuiScreenGamePlayType.EDITOR_STORY) { // Loads all marks, we want it for editor LoadMarks(false); } else { // Load only active marks MyMissions.AddSolarMapMarks(m_data); } if (MyMissions.ActiveMission != null) { MyMissions.ActiveMission.AddSolarMapMarks(m_data); } m_travelButton = new MyGuiControlButton(this, new Vector2(0.0f, 0.40f), new Vector2(650f / 1600f, 120f / 1200f), MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetTravelButtonTexture(), MyGuiManager.GetTravelButtonTexture(), MyGuiManager.GetTravelButtonTexture(), MyTextsWrapperEnum.Travel, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, MyGuiConstants.BACK_BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnTravelClick, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, false); m_travelButton.TextOffset = new Vector2(0, -0.0030f); m_travelButton.Visible = false; Controls.Add(m_travelButton); // target sector 0, 0, 0 // distance is 1.7 sectors from camera Vector3 sector; var mostImportantMark = m_data.NavigationMarks.GetMostImportant(); if (mostImportantMark != null) { sector = new Vector3(mostImportantMark.Sector.X, mostImportantMark.Sector.Y, mostImportantMark.Sector.Z); } else { sector = new Vector3(currentSector.Position.X, currentSector.Position.Y, currentSector.Position.Z); } sector.Y = 0; m_camera = new MySolarSystemMapCamera(sector * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS, 10000000.0f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS); m_camera.MinDistanceToTarget = 1.7f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS; m_camera.MaxDistanceToTarget = 1.2f * MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.NEPTUNE_POSITION.Length()) * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS; m_camera.MaxSector = MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.NEPTUNE_POSITION.Length()); MyGuiManager.FullscreenHudEnabled = true; }
/// <summary> /// Generates area data, sun color, dust color, etc. /// </summary> /// <returns></returns> private MySolarSystemMapSectorData GenerateSectorData() { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("GenerateSectorData"); MySolarSystemGenerator solarSystemGenerator = new MySolarSystemGenerator(MyGuiScreenSolarSystemMap.UNIVERSE_SEED); solarSystemGenerator.Generate(1); MySectorGenerator sectorGenerator = new MySectorGenerator(MyGuiScreenSolarSystemMap.UNIVERSE_SEED); MyMwcVector3Int sectorToGenerate = m_sectorIdentifier.Position; MySolarSystemMapSectorData sectorData = sectorGenerator.GenerateSectorEntities(solarSystemGenerator.SolarSystemData, sectorToGenerate, 0, int.MaxValue, true); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); return sectorData; }