Skip to content

Commit

Permalink
Added back planet coordinate spawning
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwin99 committed Sep 13, 2021
1 parent f5403ff commit 3c620db
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion SEWorldGenPlugin/GUI/AdminMenu/SubMenus/MyPlanetSpawnMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public class MyPlanetSpawnMenu : MyPluginAdminMenuSubMenu
/// </summary>
private MyGuiControlButton m_spawnPlanetButton;

/// <summary>
/// Button to spawn the planet at a given coordinate
/// </summary>
private MyGuiControlButton m_spawnAtCoordButton;

public override void Close()
{
}
Expand Down Expand Up @@ -87,20 +92,60 @@ public override void RefreshInternals(MyGuiControlParentTableLayout parent, floa
parent.AddTableRow(new MyGuiControlLabel(text: "Name"));
parent.AddTableRow(m_nameBox);


parent.AddTableSeparator();

m_spawnPlanetButton = MyPluginGuiHelper.CreateDebugButton(maxWidth, "Spawn planet", delegate (MyGuiControlButton button)
{
OnSpawnPlanet();
});
m_spawnPlanetButton.Enabled = true;
m_spawnPlanetButton.SetToolTip("Activates the mode to spawn the planet where you place it");

parent.AddTableSeparator();
m_spawnAtCoordButton = MyPluginGuiHelper.CreateDebugButton(maxWidth, "Spawn planet at coordinates", delegate (MyGuiControlButton button)
{
OnSpawnPlanetCoord();
});

parent.AddTableRow(m_spawnPlanetButton);

parent.AddTableRow(m_spawnAtCoordButton);

LoadPlanetDefs();
}

/// <summary>
/// Spawns the planet at a fixed coordinate
/// </summary>
private void OnSpawnPlanetCoord()
{
StringBuilder name = new StringBuilder();
m_nameBox.GetText(name);
if (name.ToString().Trim().Length <= 3)
{
MyPluginGuiHelper.DisplayError("The name must be at least 4 letters long", "Error");
return;
}

MyGuiScreenDialogCoordinate coordinateInput = new MyGuiScreenDialogCoordinate("Planet coordinate");

coordinateInput.OnConfirmed += delegate (Vector3D coord)
{
MySystemPlanet p = new MySystemPlanet()
{
CenterPosition = coord,
SubtypeId = ((MyPlanetGeneratorDefinition)m_planetDefList.GetLastSelected().UserData).Id.SubtypeId.ToString(),
Generated = false,
DisplayName = name.ToString().Trim(),
Diameter = m_planetSizeSlider.Value
};

SpawnPlanet(p, coord);
};

MyGuiSandbox.AddScreen(coordinateInput);
}

/// <summary>
/// Action to spawn a planet
/// </summary>
Expand Down

0 comments on commit 3c620db

Please sign in to comment.