2026-05-10 18:07:28 -07:00
|
|
|
using Godot;
|
|
|
|
|
using Theriapolis.Core;
|
|
|
|
|
|
|
|
|
|
namespace Theriapolis.GodotHost.Rendering;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Player marker — small dot with a thin facing tick. Drawn at
|
|
|
|
|
/// <see cref="C.PLAYER_MARKER_SCREEN_PX"/>/2 wp; the owner sets
|
|
|
|
|
/// <see cref="Node2D.Scale"/> = 1/zoom every frame so the on-screen size
|
2026-05-10 19:51:44 -07:00
|
|
|
/// stays constant across the seamless zoom range. Facing is driven by
|
|
|
|
|
/// the owner via <see cref="Node2D.Rotation"/>; the tick is drawn along
|
|
|
|
|
/// the local +X axis so rotating the node rotates the tick without
|
|
|
|
|
/// invalidating the cached <c>_Draw</c> commands.
|
2026-05-10 18:07:28 -07:00
|
|
|
/// </summary>
|
|
|
|
|
public partial class PlayerMarker : Node2D
|
|
|
|
|
{
|
|
|
|
|
private const float RadiusWorldPx = C.PLAYER_MARKER_SCREEN_PX * 0.5f;
|
|
|
|
|
private const float FacingTickPx = RadiusWorldPx * 1.4f;
|
|
|
|
|
|
2026-05-10 19:51:44 -07:00
|
|
|
private bool _showFacingTick = true;
|
2026-05-10 18:07:28 -07:00
|
|
|
|
2026-05-10 19:51:44 -07:00
|
|
|
/// <summary>When true, draws a small tick along the local +X axis
|
|
|
|
|
/// so the player can read facing without a full sprite. Hidden at
|
|
|
|
|
/// low zoom to avoid clutter. Triggers <see cref="CanvasItem.QueueRedraw"/>
|
|
|
|
|
/// on change.</summary>
|
|
|
|
|
public bool ShowFacingTick
|
|
|
|
|
{
|
|
|
|
|
get => _showFacingTick;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_showFacingTick == value) return;
|
|
|
|
|
_showFacingTick = value;
|
|
|
|
|
QueueRedraw();
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-10 18:07:28 -07:00
|
|
|
|
|
|
|
|
public override void _Draw()
|
|
|
|
|
{
|
|
|
|
|
DrawCircle(Vector2.Zero, RadiusWorldPx, new Color(0, 0, 0, 0.78f));
|
|
|
|
|
DrawCircle(Vector2.Zero, RadiusWorldPx * 0.85f, new Color(0.86f, 0.31f, 0.24f));
|
|
|
|
|
|
2026-05-10 19:51:44 -07:00
|
|
|
if (_showFacingTick)
|
2026-05-10 18:07:28 -07:00
|
|
|
{
|
2026-05-10 19:51:44 -07:00
|
|
|
DrawLine(
|
|
|
|
|
new Vector2(RadiusWorldPx * 0.4f, 0),
|
|
|
|
|
new Vector2(FacingTickPx, 0),
|
|
|
|
|
new Color(1f, 0.96f, 0.86f),
|
|
|
|
|
width: RadiusWorldPx * 0.18f,
|
|
|
|
|
antialiased: false);
|
2026-05-10 18:07:28 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|