0.2.0-dev Download ZIP
23 lines ·718 B Raw
| 1 | using Godot; |
| 2 | |
| 3 | namespace EvilEngine.Client.World; |
| 4 | |
| 5 | public partial class Crosshair : Control |
| 6 | { |
| 7 | private const float Arm = 7; |
| 8 | private const float Gap = 3; |
| 9 | |
| 10 | public override void _Ready() |
| 11 | { |
| 12 | MouseFilter = MouseFilterEnum.Ignore; |
| 13 | GetViewport().SizeChanged += QueueRedraw; |
| 14 | } |
| 15 | |
| 16 | public override void _Draw() |
| 17 | { |
| 18 | var middle = (GetViewportRect().Size / 2).Floor(); |
| 19 | foreach (var (width, colour) in new[] { (4f, new Color(0, 0, 0, 0.6f)), (2f, new Color(1, 1, 1, 0.9f)) }) |
| 20 | foreach (var direction in new[] { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right }) |
| 21 | DrawLine(middle + direction * Gap, middle + direction * (Gap + Arm), colour, width); |
| 22 | } |
| 23 | } |