Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / tileSetEditorTerrain / up / TerrainBrush.cs
@小李xl 小李xl on 4 Jan 2024 827 bytes 调整TileSet编辑器地形面板布局
using Godot;

namespace UI.TileSetEditorTerrain;

public partial class TerrainBrush : Control
{
    public Control TerrainRoot { get; set; }
    

    public override void _Process(double delta)
    {
        QueueRedraw();
    }

    public override void _Draw()
    {
        //绘制区域
        DrawRect(
            new Rect2(Vector2.Zero, TerrainRoot.Size.AsVector2I()), new Color(1, 1, 0, 0.5f), false,
            2f / TerrainRoot.Scale.X
        );
        
        //绘制鼠标悬停区域
        if (TerrainRoot.IsMouseInRect())
        {
            var pos = Utils.GetMouseCellPosition(TerrainRoot) * GameConfig.TileCellSize;
            DrawRect(
                new Rect2(pos,GameConfig.TileCellSizeVector2I),
                Colors.Green, false, 3f / TerrainRoot.Scale.X
            );
        }
    }
}