Editor/Tools/PathTool.cs
// Copyright (c) 2026 SubZero Studios LLC. All rights reserved.

using Sandbox;

namespace Editor.SubTerrain;

/// <summary>
/// Keeps the click height along the stroke. Paint Texture Path is the control-map path.
/// </summary>
[Title( "Path" )]
[Icon( "route" )]
[Alias( "subterrain_path" )]
[Group( "1" )]
[Order( 6 )]
public class SubPathTool : SubTerrainBaseBrushTool
{
	Vector3 _startLocal;

	public SubPathTool( SubTerrainTool parent ) : base( parent )
	{
		Mode = SubTerrainSculptMode.Path;
	}

	protected override void OnStrokeStart( Terrain terrain, Vector3 hitPosition )
	{
		_startLocal = hitPosition;
		SlopeStartUV = new Vector2( hitPosition.x, hitPosition.y ) / terrain.Storage.TerrainSize;
		SlopeStartHeight01 = hitPosition.z / terrain.Storage.TerrainHeight;
	}

	protected override void DrawToolOverlay( Terrain terrain, Vector3 worldCenter )
	{
		if ( !_dragging )
			return;

		var startWorld = terrain.WorldTransform.PointToWorld( _startLocal );
		Gizmo.Draw.Color = Color.FromBytes( 120, 200, 250 );
		Gizmo.Draw.Line( startWorld, worldCenter );
	}
}