public override void AddSolarMapMarks(MySolarSystemMapData data) { foreach (var objective in ActiveObjectives) { if (objective.Location != null && !MyGuiScreenGamePlay.Static.IsCurrentSector(objective.Location.Sector) && objective.ShowNavigationMark) { var missionMark = new MySolarSystemMapNavigationMark(objective.Location.Sector, objective.NameTemp.ToString(), null, MyHudConstants.MISSION_MARKER_COLOR, TransparentGeometry.MyTransparentMaterialEnum.SolarMapNavigationMark) { VerticalLineColor = MyHudConstants.MISSION_MARKER_COLOR.ToVector4(), DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_white }; data.NavigationMarks.Add(missionMark); } objective.AddSolarMapMarks(data); } if (Location != null && !MyGuiScreenGamePlay.Static.IsCurrentSector(Location.Sector) && ShowNavigationMark) { var missionMark = new MySolarSystemMapNavigationMark(Location.Sector, NameTemp.ToString(), null, MyHudConstants.ACTIVE_MISSION_SOLAR_MAP_COLOR, TransparentGeometry.MyTransparentMaterialEnum.SolarMapNavigationMark) { VerticalLineColor = MyHudConstants.MISSION_MARKER_COLOR.ToVector4(), DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_white }; data.NavigationMarks.Add(missionMark); } }
private void AddEntity(MySolarSystemMapData data, Vector3 posMillKm, float radiusMillKm, string name, MySolarSystemEntityEnum entityType, Color color, object entityData = null) { float radius = radiusMillKm * MyBgrCubeConsts.MILLION_KM; Vector3 offset; MyMwcVector3Int sector = MySolarSystemUtils.MillionKmToSectors(posMillKm, out offset); var entity = new MySolarSystemMapEntity(sector, offset, radius, name, entityType, color); entity.EntityData = entityData; data.Entities.Add(entity); }
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; }
private void GenerateStations(MyMwcVector3Int sector, MySolarSystemMapData solarData, MySolarSystemMapSectorData sectorData, List<MyMwcObjectBuilder_Base> addToList, Random rnd, MyDynamicAABBTree prunningStructure) { Dictionary<MyMwcVector3Int, MyMwcObjectBuilder_SectorObjectGroups> groupCache = new Dictionary<MyMwcVector3Int, MyMwcObjectBuilder_SectorObjectGroups>(); //List<MyImportantSolarObject> var objects = solarData.ImportantObjects.Where(o => o.NavigationMark.Sector.Equals(sector)); foreach(var obj in objects) { var size = MyPrefabContainerConstants.MAX_DISTANCE_FROM_CONTAINER_CENTER / 1000; Vector3? pos = FindEntityPosition(prunningStructure, rnd, size); if (pos.HasValue) { var templateSector = MyTemplateGroups.GetGroupSector(obj.TemplateGroup); MyMwcObjectBuilder_SectorObjectGroups groups; if (!groupCache.TryGetValue(templateSector, out groups)) { groups = LoadObjectGroups(templateSector); if (groups == null) { return; } groupCache.Add(templateSector, groups); } sectorData.Entities.Add(new MySolarSystemMapEntity(sector, pos.Value, size, "", MySolarSystemEntityEnum.OutpostIcon)); var group = rnd.Item(groups.Groups); IEnumerable<MyMwcObjectBuilder_PrefabBase> prefabs = group.GetPrefabBuilders(groups.Entities); IEnumerable<MyMwcObjectBuilder_Base> rootObjects = group.GetRootBuilders(groups.Entities); var objects3d = rootObjects.OfType<MyMwcObjectBuilder_Object3dBase>(); var faction = MyFactions.GetFactionBySector(sector); var objectPos = pos.Value; if (objects3d.Any()) { var firstPos = objects3d.First().PositionAndOrientation.Position; var offset = objectPos - firstPos; foreach (var o in objects3d) { // Clone var clone = o.Clone() as MyMwcObjectBuilder_Object3dBase; clone.PositionAndOrientation.Position += offset; clone.ClearEntityId(); if (clone is MyMwcObjectBuilder_PrefabContainer) { ((MyMwcObjectBuilder_PrefabContainer)clone).Faction = faction; } if (clone is MyMwcObjectBuilder_SpawnPoint) { ((MyMwcObjectBuilder_SpawnPoint)clone).Faction = faction; } addToList.Add(clone); } } else if(prefabs.Any()) { MyMwcObjectBuilder_PrefabContainer container = new MyMwcObjectBuilder_PrefabContainer(null, MyMwcObjectBuilder_PrefabContainer_TypesEnum.INSTANCE, prefabs.ToList(), 0, faction, null); var clone = container.Clone() as MyMwcObjectBuilder_PrefabContainer; // To clone children easily clone.ClearEntityId(); // Clear childs ids clone.PositionAndOrientation = new MyMwcPositionAndOrientation(objectPos, Vector3.Forward, Vector3.Up); addToList.Add(clone); } } //end of station generation if (pos.HasValue && rnd.Float(0, 1) < 0.5f) { //Create mysterious cube at 1% of stations var sizeMyst = size * 1.5f; Vector3? posMyst = FindEntityPosition(prunningStructure, rnd, sizeMyst, 1.0f, 1.0f, pos.Value); if (posMyst.HasValue) { CreateMysteriousCubes(posMyst.Value, addToList, rnd); } //Create some more int count = rnd.Next(5); for (int i = 0; i < count; i++) { var size2 = MyMwcSectorConstants.SECTOR_SIZE / 2; Vector3? pos2 = FindEntityPosition(prunningStructure, rnd, size2); if (pos2.HasValue) { CreateMysteriousCubes(pos2.Value, addToList, rnd); } } } } }
public MySolarSystemMapSectorData GenerateSectorObjectBuilders(MyMwcVector3Int sector, MySolarSystemMapData solarData, List<MyMwcObjectBuilder_Base> addToList, bool onlyStaticAsteroids) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("GenerateSectorEntities"); var sectorData = GenerateSectorEntities(solarData, sector, 0, int.MaxValue, onlyStaticAsteroids); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MyDynamicAABBTree prunningStructure = new MyDynamicAABBTree(Vector3.Zero); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Misc"); MyWeightDictionary<MyMwcVoxelMaterialsEnum> primaryMaterials; MyWeightDictionary<MyMwcVoxelMaterialsEnum> secondaryMaterials; MyMwcObjectBuilder_Sector sectorBuilder = addToList.FirstOrDefault(s => s.GetObjectBuilderType() == MyMwcObjectBuilderTypeEnum.Sector) as MyMwcObjectBuilder_Sector; if (sectorBuilder == null) { sectorBuilder = GetSectorBuilder(sectorData); addToList.Add(sectorBuilder); } //if (sectorBuilder != null) //{ // Vector3 kms = MySolarSystemUtils.SectorsToKm(sectorData.SectorPosition); // sectorBuilder.SunDistance = kms.Length(); //} MySector.Area = sectorData.Area; MinerWars.AppCode.Game.SolarSystem.MySolarSystemArea.AreaEnum? areaType = null; MyMwcVoxelMaterialsEnum? secondaryAsteroidMaterial = null; if (sectorData.Area.HasValue && sectorBuilder != null) { var area = MySolarSystemConstants.Areas[sectorData.Area.Value]; areaType = area.AreaType; secondaryAsteroidMaterial = area.SecondaryStaticAsteroidMaterial; primaryMaterials = new MyWeightDictionary<MyMwcVoxelMaterialsEnum>(area.SectorData.PrimaryAsteroidMaterials); secondaryMaterials = new MyWeightDictionary<MyMwcVoxelMaterialsEnum>(area.SectorData.SecondaryAsteroidMaterials); } else { primaryMaterials = new MyWeightDictionary<MyMwcVoxelMaterialsEnum>(MySolarSystemConstants.DefaultAsteroidMaterials); secondaryMaterials = new MyWeightDictionary<MyMwcVoxelMaterialsEnum>(MySolarSystemConstants.DefaultSecondaryMaterials); } Random rnd = new Random(m_seed); MyStaticAsteroidTypeSetEnum staticAsteroidsTypeset = MyStaticAsteroidTypeSetEnum.A | MyStaticAsteroidTypeSetEnum.B; var realSizes = sectorData.Entities.GroupBy(s => s.Radius).Select(s => new { Key = s.Key, Count = s.Count() }).ToArray(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("GenerateSectorObjectBuildersFromSolarEntities"); GenerateSectorObjectBuildersFromSolarEntities(sectorData.Entities, addToList, rnd, primaryMaterials, secondaryMaterials, staticAsteroidsTypeset, secondaryAsteroidMaterial, areaType); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); if (!onlyStaticAsteroids) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("GenerateStations"); GenerateStations(sector, solarData, sectorData, addToList, rnd, prunningStructure); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("GenerateBots"); GenerateBots(sectorData, addToList, rnd, prunningStructure); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); } return sectorData; }
/// <summary> /// Generates sector with entities from SolarMap and SectorId /// </summary> /// <param name="solarData">SolarMap data.</param> /// <param name="sector">Sector to generate.</param> /// <param name="minimalEntitySize">Minimal entity size. When far from sector, no need to display all entities.</param> /// <returns>MySolarSystemMapSectorData - collection of sector entities.</returns> public MySolarSystemMapSectorData GenerateSectorEntities(MySolarSystemMapData solarData, MyMwcVector3Int sector, float minimalEntitySize, int maxEntityCount, bool onlyStaticAsteroids) { MySolarSystemAreaEnum? customArea = null; if (IsSectorCustom(sector)) { customArea = GetCustomSectorArea(sector); } else if (IsSectorInForbiddenArea(sector)) { sector = MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.EARTH_POSITION); } MySolarSystemMapSectorData data; if (!solarData.SectorData.TryGetValue(sector, out data) || data.MinimalEntitySize > minimalEntitySize) { data = new MySolarSystemMapSectorData(sector, minimalEntitySize); solarData.SectorData[sector] = data; } // Apply all areas to sector, area tests whether it influents sector or not if (!customArea.HasValue) { foreach (var areaEnum in solarData.Areas) { var area = MySolarSystemConstants.Areas[areaEnum]; var interpolator = area.GetSectorInterpolator(data.SectorPosition); if (interpolator > 0 && interpolator > data.AreaInfluenceMultiplier) { data.Area = areaEnum; data.AreaInfluenceMultiplier = interpolator; } } } else { data.Area = customArea.Value; data.AreaInfluenceMultiplier = 1; } AddSectorEntities(data, minimalEntitySize, maxEntityCount, onlyStaticAsteroids); return data; }
public static void AddSolarMapMarks(MySolarSystemMapData data) { foreach (var mission in m_missions.Values.OfType<MyMission>()) { if (mission.Location != null && !MyGuiScreenGamePlay.Static.IsCurrentSector(mission.Location.Sector) && mission.ShowNavigationMark) { if (!mission.Flags.HasFlag(MyMissionFlags.HiddenInSolarMap) && mission.IsAvailable()) { bool isStory = mission.Flags.HasFlag(MyMissionFlags.Story); var missionMark = new MySolarSystemMapNavigationMark( mission.Location.Sector, MyTextsWrapper.Get(mission.Name).ToString(), mission.ID, /*isStory ? MyHudConstants.SOLAR_MAP_STORY_MISSION_MARKER_COLOR : */MyHudConstants.SOLAR_MAP_SIDE_MISSION_MARKER_COLOR, isStory ? TransparentGeometry.MyTransparentMaterialEnum.SolarMapStoryMission : TransparentGeometry.MyTransparentMaterialEnum.SolarMapSideMission) { //Description = mission.DescriptionTemp.ToString(), DirectionalTexture = mission.Flags.HasFlag(MyMissionFlags.Story) ? MyHudTexturesEnum.DirectionIndicator_blue : MyHudTexturesEnum.DirectionIndicator_white, IsBlinking = isStory, Text = isStory ? MyTextsWrapper.Get(MyTextsWrapperEnum.NewMission).ToString() : null, TextSize = isStory ? 0.9f : 0.7f, Font = isStory ? MyGuiManager.GetFontMinerWarsBlue() : MyGuiManager.GetFontMinerWarsWhite(), Importance = isStory ? 100 : 1 }; missionMark.VerticalLineColor = missionMark.Color.ToVector4(); data.NavigationMarks.Add(missionMark); } else { bool any = false; foreach (MyMissionBase value in m_missions.Values) { MyMission m = value as MyMission; if (m != null) { if (m.Location.Sector == mission.Location.Sector && m.IsAvailable()) { any = true; break; } } } if (!any && mission.IsCompleted() && !data.NavigationMarks.Contains(mission.Location.Sector)) { var missionMark = new MySolarSystemMapNavigationMark( mission.Location.Sector, MyTextsWrapper.Get(mission.Name).ToString(), null, Color.Gray, TransparentGeometry.MyTransparentMaterialEnum.SolarMapSideMission) { //Description = mission.DescriptionTemp.ToString(), DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_white, Text = "Completed", TextSize = 0.6f, }; missionMark.VerticalLineColor = missionMark.Color.ToVector4(); data.NavigationMarks.Add(missionMark); } } } } }
public override void AddUniverseEntities(MySolarSystemMapData data) { if (MyMissions.ActiveMission == null && MyMissions.GetAvailableMissions().Count == 0) { AddTemplateGroups(data); } const float maxObjCenterFromOrbit = 0.25f; Random rnd = new Random(0); float orbitRadius = OrbitProperties.AreaCenter.Length(); float baseAngle = MyMath.AngleTo(OrbitProperties.AreaCenter, Vector3.UnitZ).Y; //count of groups per orbit side float step = CalculateStep((OrbitProperties.MaxDistanceFromOrbitHigh + OrbitProperties.MaxDistanceFromOrbitLow) / 2); int testMaxCount = 0; for (float i = baseAngle - HalfAngle; i < baseAngle + HalfAngle; i += step) { float interpolator = 1 - Math.Abs((i - baseAngle) / HalfAngle); // (i + halfLen) / halfLen / 2; float maxDistFromOrbitAtAngle = MathHelper.SmoothStep(OrbitProperties.MaxDistanceFromOrbitLow, OrbitProperties.MaxDistanceFromOrbitHigh, interpolator); step = CalculateStep((OrbitProperties.MaxDistanceFromOrbitHigh + maxDistFromOrbitAtAngle) / 2); //Vector3 centerPos = new Vector3((float)Math.Sin(i) * distance, 0, (float)Math.Cos(i) * distance); //5 = billboards count in smaller group for (int j = 0; j < 2; j++) { Vector2 distFromOrbit = Vector2.Normalize(new Vector2(rnd.Float(-1, 1), rnd.Float(-1, 1))); //distFromOrbit = new Vector2(); distFromOrbit *= maxDistFromOrbitAtAngle * maxObjCenterFromOrbit; float dist = orbitRadius + distFromOrbit.X; float i2 = i + rnd.FloatCubic(-step * maxObjCenterFromOrbit, step * maxObjCenterFromOrbit); float x = (float)Math.Sin(i2) * dist; float z = (float)Math.Cos(i2) * dist; float y = distFromOrbit.Y; Vector3 pos = OrbitProperties.OrbitCenter + new Vector3(x, y, z); Vector3 offset; MyMwcVector3Int sector = MySolarSystemUtils.KmToSectors(pos, out offset); float size = maxDistFromOrbitAtAngle * (1 - maxObjCenterFromOrbit); if (this.SolarMapData != null) { Vector4 clr = new Vector4(this.SolarMapData.DustColor, 1.0f); Color color = rnd.Color(new Color(clr - this.SolarMapData.DustColorVariability), new Color(clr + this.SolarMapData.DustColorVariability)); data.Entities.Add(new MySolarSystemMapEntity(sector, offset, 2 * size, "Dust", MySolarSystemEntityEnum.DustField, color)); testMaxCount++; } if ((AreaType & AreaEnum.PostPlanet) != 0 && j % 2 == 0) { data.Entities.Add(new MySolarSystemMapEntity(sector, offset, size * (1 - maxObjCenterFromOrbit), "Asteroids", MySolarSystemEntityEnum.AsteroidField, Color.White)); testMaxCount++; } //AddEntity(m_data, pos, radius * wide * 4, name + " dust", MySolarSystemEntityEnum.Test1_Dust, rnd.Color(baseColor, colorVariation)); } } //Do not allow to solar area to add more than 1000 objects //System.Diagnostics.Debug.Assert(testMaxCount < 3000); MySolarAreaBorderLine newLine = new MySolarAreaBorderLine(); newLine.AreaCenter = OrbitProperties.AreaCenter; newLine.DistanceHigh = OrbitProperties.MaxDistanceFromOrbitHigh; newLine.DistanceLow = OrbitProperties.MaxDistanceFromOrbitLow; newLine.Spread = OrbitProperties.LongSpread; newLine.col = new Vector4(SolarMapData.DustColor, 1f); data.AreasBorderLines.Add(newLine); }
public void AddTemplateGroups(MySolarSystemMapData data) { return; // Template groups in solar map are disabled if (SolarMapData.TemplateGroups == null) return; Random rnd = new Random(0); foreach (var g in SolarMapData.TemplateGroups) { for (int i = 0; i < g.Count; i++) { var pos = GetRandomPosition(rnd); Vector3 offset; MyMwcVector3Int sector = MySolarSystemUtils.KmToSectors(pos, out offset); var mark = new MySolarSystemMapNavigationMark(sector, "", null, Color.White, TransparentGeometry.MyTransparentMaterialEnum.SolarMapOutpost); mark.Importance = g.Importance; mark.DrawVerticalLine = false; data.NavigationMarks.Add(mark); data.ImportantObjects.Add(new MyImportantSolarObject() { NavigationMark = mark, TemplateGroup = g.TemplateGroup }); //entities.Add(new MySolarSystemMapEntity(sector, offset, 0, "", MySolarSystemEntityEnum.OutpostIcon)); } } }
public void Draw(MySolarSystemMapCamera camera, MySolarSystemMapData solarData) { MyTransparentGeometry.ClearBillboards(); m_currentCamera = camera; m_currentSolarMapData = solarData; m_setup.ViewMatrix = camera.GetViewMatrixAtZero(); //m_setup.ViewMatrix *= Matrix.CreateTranslation(camera.Position); m_setup.CameraPosition = camera.Position; float nearClip = 0.1f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS; float farClip = 100000000 * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS; m_setup.ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MyCamera.FieldOfView, MyCamera.ForwardAspectRatio, nearClip, farClip); //m_setup.ProjectionMatrix = camera.GetProjectionMatrix(); MyTransparentGeometry.EnableColorize = true; MyTransparentGeometry.ColorizeColor = new Color(0.8f, 0.8f, 0.8f, 0.0f); MyTransparentGeometry.ColorizePlaneDistance = m_currentCamera.Position.Y + m_currentCamera.PositionSector.Y * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS; MyTransparentGeometry.ColorizePlaneNormal = Vector3.UnitY; MyRender.RegisterRenderModule(MyRenderModuleEnum.SolarMapGrid, "Solar map grid", DrawGrid, MyRenderStage.AlphaBlendPreHDR); MyRender.PushRenderSetupAndApply(m_setup, ref m_backup); m_texts.ClearAllAllocated(); AddBillboards(m_currentSolarMapData.Entities); AddAreasBorders(m_currentSolarMapData.AreasBorderLines); AddAreaTexts(m_currentSolarMapData.Areas); { //Add available missions AddNavigationMarks(m_currentSolarMapData.NavigationMarks); } if (MyFakes.DRAW_FACTION_AREAS_IN_SOLAR_MAP) { DrawFactionsDebug(); DrawEditedFactionDebug(); } MyHudText text = m_texts.Allocate(); if (text != null) { text.Start(MyGuiManager.GetFontMinerWarsWhite(), new Vector2( MyGuiManager.GetSafeFullscreenRectangle().X + MyGuiManager.GetSafeFullscreenRectangle().Width, MyGuiManager.GetSafeFullscreenRectangle().Y + MyGuiManager.GetSafeFullscreenRectangle().Height), Color.White, 1.0f, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); text.Append(m_currentCamera.TargetSector.ToString()); } Vector3 pos = new Vector3(m_currentCamera.TargetSector.X, m_currentCamera.TargetSector.Y, m_currentCamera.TargetSector.Z); int dist = (int)Math.Ceiling(SECTOR_RENDER_HALFSIZE); for (int x = (int)pos.X - dist; x <= (int)pos.X + dist; x++) { int y = 0; //for (int y = (int)pos.Y - dist; y <= (int)pos.Y + dist; y++) { for (int z = (int)pos.Z - dist; z <= (int)pos.Z + dist; z++) { var sectorPos = new MyMwcVector3Int(x, y, z); //float minSize = (x == pos.X && y == pos.Y && z == pos.Z) ? 1.5f : 3; //float minSize = 1.5f; int maxEntityCount = (x == pos.X && y == pos.Y && z == pos.Z) ? 150 : 100; //MySolarSystemMapSectorData sectorData; //if (!m_currentSolarMapData.SectorData.TryGetValue(sectorPos, out sectorData)) //{ // var g = new MySectorGenerator(MyGuiScreenSolarSystemMap.UNIVERSE_SEED); // sectorData = g.GenerateSectorEntities(m_currentSolarMapData, sectorPos, 0, maxEntityCount); // m_currentSolarMapData.SectorData[sectorPos] = sectorData; //} //AddBillboards(sectorData.Entities); } } } MyRender.Draw(); DrawTexts(); //DrawSolarDebug(); MyRender.PopRenderSetupAndRevert(m_backup); MyRender.UnregisterRenderModule(MyRenderModuleEnum.SolarMapGrid); //MyRender.UnregisterRenderModule(SOLAR_DEBUG_DRAW); MyRender.UnregisterRenderModule(MyRenderModuleEnum.SolarObjects); MyTransparentGeometry.EnableColorize = false; }
public void Generate(int sectorCacheCapacity) { m_data = new MySolarSystemMapData(sectorCacheCapacity); // Sun AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SUN_RADIUS, MyTextsWrapper.Get(MyTextsWrapperEnum.Sun).ToString(), MySolarSystemEntityEnum.Sun, Color.White); // Orbits (just orbit lines) AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.MERCURY_POSITION.Length(), "Mercury orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.VENUS_POSITION.Length(), "Venus orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.EARTH_POSITION.Length(), "Earth orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.MARS_POSITION.Length(), "Mars orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.JUPITER_POSITION.Length(), "Jupiter orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SATURN_POSITION.Length(), "Saturn orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.URANUS_POSITION.Length(), "Uranus orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.NEPTUNE_POSITION.Length(), "Neptune orbit", MySolarSystemEntityEnum.Orbit, Color.White); foreach (var a in MySolarSystemConstants.Areas) { a.Value.AddUniverseEntities(m_data); m_data.Areas.Add(a.Key); } if (MyFakes.ENABLE_RANDOM_STATIONS_IN_SOLAR_SYSTEM && MyMissions.ActiveMission == null && MyMissions.GetAvailableMissions().Count == 0) { foreach (var a in MyFactions.FactionAreas) { if (a.Key == CommonLIB.AppCode.ObjectBuilders.MyMwcObjectBuilder_FactionEnum.CSR) continue; foreach (var circle in a.Value) { Random r = new Random(circle.Position.GetHashCode() ^ circle.Radius.GetHashCode()); var radius = circle.Radius / 100000000; float count = MathHelper.Pi * radius * radius; count = MathHelper.Clamp(count, 0, 10); if (count < 1) { count = r.Next(0, 2); } for (int i = 0; i < count; i++) { float dist = rnd.Float() * circle.Radius; float angle = (float)(rnd.NextDouble() * 2 * MathHelper.Pi); float x = (float)Math.Sin(angle) * dist; float z = (float)Math.Cos(angle) * dist; var pos = circle.GetCenter() + new Vector3(x, 0, z); //pos = circle.GetCenter(); Vector3 offset; MyMwcVector3Int sector = MySolarSystemUtils.KmToSectors(pos, out offset); var mark = new MySolarSystemMapNavigationMark(sector, "", null, Color.White, MyTransparentMaterialEnum.SolarMapOutpost); mark.Importance = rnd.Next(2, 5) / 4.0f; mark.DrawVerticalLine = false; m_data.NavigationMarks.Add(mark); m_data.ImportantObjects.Add(new MyImportantSolarObject() { NavigationMark = mark, TemplateGroup = MyTemplateGroupEnum.RandomStations }); } } } } // Filip resize solar map const float factionMapScale = 1.75f; // Faction map - size of map is same as saturn orbit AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SATURN_POSITION.Length() / factionMapScale, "Faction map", MySolarSystemEntityEnum.FactionMap, Color.White); AddEntity(m_data, new Vector3(-352, 0, -40), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionRussian).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.IndianRed, MyTransparentMaterialEnum.FactionRussia); AddEntity(m_data, new Vector3(-432, 0, -628), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionRussian).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.IndianRed, MyTransparentMaterialEnum.FactionRussia); AddEntity(m_data, new Vector3(0, 0, 300), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionChineseShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Brown, MyTransparentMaterialEnum.FactionChina); AddEntity(m_data, new Vector3(-150, 0, 95), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionJapan).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.DeepSkyBlue, MyTransparentMaterialEnum.FactionJapan); AddEntity(m_data, new Vector3(300, 0, 108), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionFreeAsia).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.HotPink, MyTransparentMaterialEnum.FactionFreeAsia); AddEntity(m_data, new Vector3(300, 0, -40), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionSaudiShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Gold, MyTransparentMaterialEnum.FactionSaudi); AddEntity(m_data, new Vector3(220, 0, -180), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionEuroamericanShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.CornflowerBlue, MyTransparentMaterialEnum.FactionEAC); //AddEntity(m_data, new Vector3(65, 0, -135), 0, "CSR", MySolarSystemEntityEnum.FactionInfo, Color.DarkKhaki, MyTransparentMaterialEnum.FactionCSR); AddEntity(m_data, new Vector3(37, 0, -160), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionIndia).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.SandyBrown, MyTransparentMaterialEnum.FactionIndia); AddEntity(m_data, new Vector3(-30, 0, -160), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionChurchShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Yellow, MyTransparentMaterialEnum.FactionChurch); AddEntity(m_data, new Vector3(-85, 0, -150), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionOmnicorpShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.LightGreen, MyTransparentMaterialEnum.FactionOmnicorp); AddEntity(m_data, new Vector3(-108, 0, -358), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionFourthReichShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.LightSteelBlue, MyTransparentMaterialEnum.FactionFourthReich); // Some navigation marks for testing //AddNavigationMark(m_data, new MyMwcVector3Int(1000000, 0, 1000000), "Mark1"); //AddNavigationMark(m_data, new MyMwcVector3Int(3000000, 0, -1500000), "Mark2"); }
public override void AddUniverseEntities(MySolarSystemMapData data) { throw new NotImplementedException(); }