Carry indicator: draw the actual item shape, scaled down
Pawns hauling items previously showed a 7×7 hue-coloured square — no hint of what they were actually carrying. Now the carry indicator calls Item.draw_item_shape(self, type) at 0.55× scale (~7px effective), positioned at the pawn's upper-right (chest-height). Refactor: _draw_item_shape (instance method) → Item.draw_item_shape (static, takes a CanvasItem target). Item._draw() and Pawn._draw() both call it. Also added shapes for the 5 atlas-backed types (wood / stone / plank / iron_ore / gold) so the carry indicator works for mining + carpenter outputs too — the on-floor visual still uses the bundle atlas via the Sprite2D child.
This commit is contained in:
parent
ab4d62889b
commit
c7f97e2c7a
2 changed files with 127 additions and 102 deletions
|
|
@ -1176,12 +1176,20 @@ func _draw() -> void:
|
|||
if _selected:
|
||||
draw_arc(Vector2.ZERO, 10.0, 0.0, TAU, 32, Color(1.0, 0.9, 0.2, 0.85), 2.0)
|
||||
|
||||
# Phase 4 — carry indicator: small coloured square at upper-right of body.
|
||||
# Carry indicator — draw a shrunk version of the actual item shape at the
|
||||
# pawn's upper-right ("held out at chest height"). Uses Item.draw_item_shape
|
||||
# at 0.55× scale (the shapes are authored for a 12×12 box; 0.55× → ~7×7).
|
||||
# Falls back to a hue-hashed square if the item type isn't shape-registered.
|
||||
if carried_item != null:
|
||||
var ci_hue := float(carried_item.item_type.hash() % 360) / 360.0
|
||||
var ci_color := Color.from_hsv(ci_hue, 0.6, 0.85)
|
||||
draw_rect(Rect2(6, -10, 7, 7), ci_color)
|
||||
draw_rect(Rect2(6, -10, 7, 7), Color(0, 0, 0, 0.7), false, 1.0)
|
||||
var ci_center := Vector2(7.0, -12.0)
|
||||
var ci_scale := 0.55
|
||||
draw_set_transform(ci_center, 0.0, Vector2(ci_scale, ci_scale))
|
||||
if not Item.draw_item_shape(self, carried_item.item_type):
|
||||
var ci_hue := float(carried_item.item_type.hash() % 360) / 360.0
|
||||
var ci_color := Color.from_hsv(ci_hue, 0.6, 0.85)
|
||||
draw_rect(Rect2(-6, -6, 12, 12), ci_color)
|
||||
draw_rect(Rect2(-6, -6, 12, 12), Color(0, 0, 0, 0.7), false, 1.0)
|
||||
draw_set_transform(Vector2.ZERO, 0.0, Vector2.ONE)
|
||||
|
||||
|
||||
# ── helpers ─────────────────────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue