Skip to content

Commit

Permalink
Fixed bug where moons could spawn beyond the world limit
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwin99 committed Apr 23, 2020
1 parent a0d4b5a commit 9d06d1f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions SEWorldGenPlugin/Generator/SystemGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ private void GeneratePlanet(int index, long distance, int totalObjects, ref int
planet.PlanetRing = GenerateRing(def.SurfaceGravity, planet.Size);
planet.OffsetPosition = pos;
planet.CenterPosition = pos;
planet.PlanetMoons = GenerateMoons(planet.Size, def.SurfaceGravity, planet.DisplayName);
planet.PlanetMoons = GenerateMoons(planet.Size, def.SurfaceGravity, planet.DisplayName, distance);
planet.Generated = false;

m_objects.Add(planet);
}

private MyPlanetMoonItem[] GenerateMoons(float planetSize, float surfaceGravity, string planetName)
private MyPlanetMoonItem[] GenerateMoons(float planetSize, float surfaceGravity, string planetName, long distance)
{
if (MyRandom.Instance.NextFloat() > m_settings.PlanetSettings.MoonProbability) return new MyPlanetMoonItem[0];

Expand All @@ -221,6 +221,8 @@ private MyPlanetMoonItem[] GenerateMoons(float planetSize, float surfaceGravity,
var dist = planetSize * (i + 1) + planetSize / 2 * MyRandom.Instance.GetRandomFloat(0.5f, 1.5f);
var def = GetPlanetMoonDefinition(planetSize * 0.8f);

if (dist + distance > m_settings.WorldSize) return moons;

MyPlanetMoonItem item = new MyPlanetMoonItem();
item.Type = SystemObjectType.MOON;
item.DefName = def.Id.SubtypeName.ToString();
Expand Down

1 comment on commit 9d06d1f

@Death666Machine
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks =D

Please sign in to comment.