Files

43 lines
1.8 KiB
GDScript

# Original low-resolution procedural greybox: 96x40 integer logical pixels.
# This is state-dependent machine motion, not a finished character animation.
extends Control
var model: RefCounted
var reduced_motion: bool = false
var pulse: float = 0.0
func _process(delta: float) -> void:
pulse = maxf(0.0, pulse - delta)
queue_redraw()
func _draw() -> void:
if model == null:
return
var zoom: int = maxi(1, int(minf(size.x / 96.0, size.y / 40.0)))
var origin := Vector2(floor((size.x - 96 * zoom) / 2.0), floor((size.y - 40 * zoom) / 2.0))
draw_set_transform(origin, 0.0, Vector2(zoom, zoom))
draw_rect(Rect2(0, 0, 96, 40), Color("182d38"))
draw_rect(Rect2(0, 30, 96, 10), Color("29434c"))
for x in range(0, 96, 8):
draw_rect(Rect2(x, 30, 7, 1), Color("40626b"))
# Storage fill is authoritative, not a random idle animation.
draw_rect(Rect2(7, 16, 23, 15), Color("725b43"))
var fill: int = int(18.0 * model.stock / model.capacity)
var fill_rows: int = int(fill / 2.0)
draw_rect(Rect2(10, 28 - fill_rows, 17, fill_rows), Color("dab66d"))
# Machine color expresses heat and persistent chapter.
var machine_color := Color("dd8f64") if model.heat > 2 else Color("79ad91")
draw_rect(Rect2(62, 12, 21, 19), machine_color)
draw_rect(Rect2(65, 15, 15, 6), Color("12242d"))
for i in range(model.chapter + 1):
draw_rect(Rect2(66 + i * 4, 17, 2, 2), Color("f5d78e"))
var working: bool = model.workers > 0 and model.stock < model.capacity
var phase: int = 0 if reduced_motion or not working else int(model.elapsed * 4.0)
draw_rect(Rect2(65 + phase * 3, 24, 3, 3), Color("f5d78e"))
for i in range(model.workers):
var step: int = 0 if reduced_motion or not working else phase % 2
draw_rect(Rect2(38 + i * 6, 23 - step, 4, 7), Color("93baca"))
if pulse > 0.0:
draw_rect(Rect2(13, 9, 9, 3), Color("f5d78e"))
draw_set_transform(Vector2.ZERO)