/// <summary> /// Action to spawn a planet /// </summary> /// <param name="coordSpawn">If the planet should be spawned at coordinates instead of direct placement</param> private void OnSpawnPlanet(bool coordSpawn = false) { 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; } if (coordSpawn) { 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); return; } float size = m_planetSizeSlider.Value; MySystemPlanet planet = new MySystemPlanet() { CenterPosition = Vector3D.Zero, SubtypeId = ((MyPlanetGeneratorDefinition)m_planetDefList.GetLastSelected().UserData).Id.SubtypeId.ToString(), Generated = false, DisplayName = name.ToString().Trim(), Diameter = size }; MyPluginItemsClipboard.Static.Activate(planet, SpawnPlanet, size); CloseScreenNow(); }