Three-scope z-layer rendering pipeline (D-049): world z:0-900 inside CanvasGroup, insert overlay CanvasLayer 10, UI CanvasLayer 20, modal CanvasLayer 30. Y-sort contract enforced (entities z_index=0). Reserved ranges for VFX, airborne, lower floors documented in constants.gd. Sprint 6 client tickets: - #429: Cursor state machine — 4 states, 150ms transitions (D-056) - #430: Fog shader rebuild — 5-layer fragment shader, animated noise (D-059) - #432: Entity interaction list — vertical multi-verb, insert-styled (D-057) - #433: World radial menu — 2 spokes, drag-release + click-click (D-058) - #438: Inventory UI — 3x3 grid, 40x40px, 1-9 hotkeys (D-065) - #439: Stance indicator — color-coded HUD, C/X keybinds (D-053) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
52 lines
1.5 KiB
GDScript
52 lines
1.5 KiB
GDScript
extends Control
|
|
|
|
## D-053: Stance indicator — shows current movement stance on HUD.
|
|
## Sprint/Walk/Careful/Crouch. Color-coded for quick read.
|
|
## Lives on UILayer (z-layer 7).
|
|
|
|
const STANCE_COLORS := {
|
|
"Sprint": Color("#d45d5d"), # Red — fast, loud, dangerous
|
|
"Walk": Color("#c8d0e0"), # Default — neutral white-blue
|
|
"Careful": Color("#6bc9a6"), # Green — quiet, observant
|
|
"Crouch": Color("#e8c547"), # Amber — very quiet, slow
|
|
}
|
|
|
|
const STANCE_DEFAULT_COLOR := Color("#c8d0e0")
|
|
const BG_COLOR := Color(0.05, 0.05, 0.08, 0.5)
|
|
const FONT_SIZE := 13
|
|
const PADDING := Vector2(10, 6)
|
|
|
|
var _current_stance: String = "Walk"
|
|
|
|
|
|
func _ready() -> void:
|
|
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
func update_from_state() -> void:
|
|
var stance: String = GameState.player_stance
|
|
if stance == _current_stance:
|
|
return
|
|
_current_stance = stance
|
|
queue_redraw()
|
|
|
|
|
|
func _draw() -> void:
|
|
var font := ThemeDB.fallback_font
|
|
var text := _current_stance
|
|
var text_size := font.get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, FONT_SIZE)
|
|
var box_size := text_size + PADDING * 2
|
|
|
|
# Background
|
|
draw_rect(Rect2(Vector2.ZERO, box_size), BG_COLOR)
|
|
|
|
# Stance text
|
|
var color: Color = STANCE_COLORS.get(_current_stance, STANCE_DEFAULT_COLOR)
|
|
draw_string(font, PADDING + Vector2(0, text_size.y), text, HORIZONTAL_ALIGNMENT_LEFT, -1, FONT_SIZE, color)
|
|
|
|
|
|
# -- Public API ---------------------------------------------------------------
|
|
|
|
func get_current_stance() -> String:
|
|
return _current_stance
|