#117: the crafter and the lab animate only while they are working
A factory whose cranes swing over an empty cradle reads as working on nothing, and a lab sweeping instruments over a vessel it is not studying reads the same way. The CLOCK stops rather than the drawing. Every moving element is a NeonPiece whose position is pushed from that clock, so a frozen clock leaves the building standing with its cranes parked; stopping apply_animation() instead would leave them wherever the last frame happened to put them, which is not the same thing as idle. The state is read by tree lookup rather than through the bare `GameState` identifier. These visual scripts are reached through a BuildingDefinition's visual_scene, which is preloaded while the definition catalog is still loading - early enough that the autoload is not in the global class table yet, and a bare reference fails to COMPILE the whole file. That failure also hung test_building_redraw_cost, because a visual that never built its pieces left a null crane being dereferenced every frame. Both animation tests now say what they mean: the redraw-cost test queues an order first, because its point is that animating is cheap rather than that it happens unprompted, and the crafter test additionally pins that an idle crafter really is still. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f9ed46746d
commit
39ad050dc6
5 changed files with 146 additions and 2 deletions
|
|
@ -32,6 +32,18 @@ const OUTPOST_COLOR: Color = Color(0.72, 0.86, 0.45)
|
|||
# #106. A cool grey-blue: this is the one structure that does no work at all,
|
||||
# it only decides what work the others do.
|
||||
const PLANNING_COLOR: Color = Color(0.62, 0.74, 0.92)
|
||||
# #116. Warm steel: the workshop is the only structure whose whole job is
|
||||
# looking after the others, and it should read as a yard rather than a plant.
|
||||
const WORKSHOP_COLOR: Color = Color(0.5, 0.95, 0.8)
|
||||
|
||||
# Workshop: an open service gantry with a cradle under it and drone berths
|
||||
# either side. Deliberately unenclosed - what it holds is other people's
|
||||
# buildings, arriving and leaving.
|
||||
const YARD_GANTRY_W: float = 96.0
|
||||
const YARD_GANTRY_H: float = 16.0
|
||||
const YARD_LEG_DROP: float = 58.0
|
||||
const YARD_CRADLE_R: float = 34.0
|
||||
const YARD_BERTH_X: float = 78.0
|
||||
|
||||
# Planning centre: a standing board with rows of tallies on it, flanked by
|
||||
# two slim pylons. Rectilinear on purpose - every other structure here is
|
||||
|
|
@ -140,7 +152,42 @@ var _flash_ring: NeonPiece = null
|
|||
var _wash: NeonPiece = null
|
||||
|
||||
|
||||
# #117: "The ship crafter and the ship lab should only animate when
|
||||
# something is being crafted in them."
|
||||
#
|
||||
# The clock stops rather than the drawing: every moving element is a NeonPiece
|
||||
# whose position is pushed from this clock, so a frozen clock leaves the
|
||||
# building standing exactly as it was with the cranes parked. Stopping
|
||||
# apply_animation() instead would leave them wherever the last frame put
|
||||
# them, which is not the same thing as idle.
|
||||
#
|
||||
# Default true: a mothership and a transport hub turn because that is what
|
||||
# they are, not because they have an order in hand.
|
||||
func is_working() -> bool:
|
||||
return true
|
||||
|
||||
|
||||
# The record this visual belongs to. The chain is Building -> VisualHost ->
|
||||
# this, and the id lives on the Building.
|
||||
# By tree lookup, not by the bare `GameState` identifier. These visual
|
||||
# scripts are reached through a BuildingDefinition's visual_scene, which is
|
||||
# preloaded while the definition catalog is still loading - early enough that
|
||||
# the autoload is not yet in the global class table, and a bare reference
|
||||
# fails to COMPILE the whole file. Same hazard GameState notes for WORLD_GEN.
|
||||
func _state() -> Node:
|
||||
var tree: SceneTree = get_tree()
|
||||
return tree.root.get_node_or_null("GameState") if tree != null else null
|
||||
|
||||
|
||||
func building_id() -> int:
|
||||
var host: Node = get_parent()
|
||||
var building: Node = host.get_parent() if host != null else null
|
||||
return int(building.building_id) if building != null and "building_id" in building else 0
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not is_working():
|
||||
return
|
||||
anim_time = fmod(anim_time + delta, CYCLE)
|
||||
phase_time += delta
|
||||
apply_animation()
|
||||
|
|
@ -387,6 +434,43 @@ func _draw_command_center() -> void:
|
|||
NeonDraw.draw_glowing_polygon(self, _diamond(Vector2.ZERO, CMD_SCREEN_RADIUS), readout, 0.9)
|
||||
|
||||
|
||||
func _draw_workshop() -> void:
|
||||
var c: Color = WORKSHOP_COLOR
|
||||
var lit: Color = Color(0.86, 1.0, 0.95)
|
||||
|
||||
# The gantry beam, and the legs it stands on.
|
||||
NeonDraw.draw_glowing_polygon(self, PackedVector2Array([
|
||||
Vector2(-YARD_GANTRY_W, -YARD_GANTRY_H - 40.0),
|
||||
Vector2(YARD_GANTRY_W, -YARD_GANTRY_H - 40.0),
|
||||
Vector2(YARD_GANTRY_W, -40.0), Vector2(-YARD_GANTRY_W, -40.0),
|
||||
]), c, 1.0)
|
||||
for side in [-1.0, 1.0]:
|
||||
var x: float = YARD_GANTRY_W * side * 0.82
|
||||
NeonDraw.draw_glowing_line(self, Vector2(x, -40.0),
|
||||
Vector2(x, YARD_LEG_DROP), c, 0.8, 0.42)
|
||||
# Cross-bracing, so it reads as a frame rather than two posts.
|
||||
NeonDraw.draw_glowing_line(self, Vector2(x, -40.0),
|
||||
Vector2(x * 0.35, YARD_LEG_DROP), c, 0.45, 0.26)
|
||||
|
||||
# The cradle: an open arc under the beam, with the thing being worked on
|
||||
# implied by the lit core rather than drawn.
|
||||
NeonDraw.draw_glowing_path(self, _arc(Vector2(0.0, 6.0), YARD_CRADLE_R,
|
||||
0.0, PI, 14), c, 0.85, 0.4)
|
||||
NeonDraw.draw_glowing_circle(self, Vector2(0.0, 6.0), 11.0, lit, 0.9)
|
||||
# A hoist line down from the beam to what is in the cradle.
|
||||
NeonDraw.draw_glowing_line(self, Vector2(0.0, -40.0), Vector2(0.0, -6.0),
|
||||
c, 0.6, 0.3)
|
||||
|
||||
# Drone berths, one either side, drawn as open brackets.
|
||||
for side in [-1.0, 1.0]:
|
||||
var berth: Vector2 = Vector2(YARD_BERTH_X * side, -70.0)
|
||||
NeonDraw.draw_glowing_path(self, PackedVector2Array([
|
||||
berth + Vector2(-14.0 * side, -12.0), berth + Vector2(6.0 * side, -12.0),
|
||||
berth + Vector2(6.0 * side, 12.0), berth + Vector2(-14.0 * side, 12.0),
|
||||
]), c, 0.7, 0.32)
|
||||
NeonDraw.draw_glowing_polygon(self, _diamond(berth, 7.0), lit, 0.85)
|
||||
|
||||
|
||||
func _draw_planning_center() -> void:
|
||||
var c: Color = PLANNING_COLOR
|
||||
var lit: Color = Color(0.88, 0.94, 1.0)
|
||||
|
|
|
|||
Loading…
Reference in a new issue