editor/AdvancedMappingTools/UI/SettingsClipboard.cs

Editor helper that acts as an in-memory clipboard for part generator settings. Serializes the settings to JSON via GeneratorRegistry, remembers which generator type they came from, and only pastes into a matching generator. Also has a stub doc comment about future on-disk presets.

namespace AdvancedMappingTools;

/// <summary>
/// Copies generator settings from one generated object to another in the same session.
/// The JSON is the same format the addon stores on the root part, so it can later be
/// written to disk as a named preset without changing this format.
/// </summary>
public static class SettingsClipboard
{
	static string _json;
	static string _generator;

	public static bool Has => !string.IsNullOrEmpty( _json );

	public static void Copy( IPartGenerator generator, GeneratorSettings settings )
	{
		if ( generator is null || settings is null ) return;

		_json = GeneratorRegistry.Save( settings );
		_generator = generator.Id;
	}

	public static bool Matches( IPartGenerator generator ) =>
		Has && generator is not null && _generator == generator.Id;

	public static GeneratorSettings Load( IPartGenerator generator ) =>
		Matches( generator ) ? GeneratorRegistry.Load( generator, _json ) : null;
}