Editor UI menu actions for the Architecture tool. It adds two menu commands: one to clear generated architecture geometry from the active SceneEditorSession with undo support, and one to write a default ArchKit to storage and log the result.
using System.Linq;
using Editor;
using Sandbox;
namespace Sunless.Architecture;
public static class ArchMenu
{
// Rebuild and bake live on the dock; this menu is what you reach without the tool up.
[Menu( "Editor", "Risk of Pain/Architecture/Delete Generated Geometry", "delete" )]
public static void Clear()
{
var scene = SceneEditorSession.Active?.Scene;
if ( scene is null )
{
return;
}
using ( SceneEditorSession.Active.UndoScope( "Clear Architecture" ).WithGameObjectDestructions( ArchScene.FindRoot( scene ) ).Push() )
{
ArchScene.Clear( scene );
}
}
[Menu( "Editor", "Risk of Pain/Architecture/Write Default Kit", "inventory_2" )]
public static void WriteDefaultKit()
{
var kit = new ArchKit { Name = "default" };
if ( ArchStorage.SaveKit( kit ) )
{
Log.Info( $"Architecture: wrote {ArchStorage.KitPathFor( kit.Name )} with {kit.Openings.Count} openings and {kit.Profiles.Count} profiles." );
}
}
}