sprint cleanup: corpse_cremated signal, recipe_count, save_system

D: Workbench._last_consumed_ingredient transient field captures the
carried item before queue_free so cremation_pyre.on_craft_complete can
emit corpse_cremated with the real ref. Falls back to proximity scan.
Pawn._on_corpse_cremated null-guarded.

E: removed redundant r.ingredient_count = 0 from recipe_catalog. Field
kept on Recipe for save round-trip compat; nothing reads it functionally.

F: save_system._spawn_workbench simplified from 15 lines to 6 — let
from_dict do all field restoration. Fixed workbench.from_dict to call
_complete() instead of bare _completed=true, which was skipping light
enable + beauty register + designation clear.

Stale ingredient1/2 buffering comment in job_runner._tick_craft fixed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-05-16 18:23:22 +01:00
parent 2afca16299
commit cc6d60d044
6 changed files with 29 additions and 18 deletions

View file

@ -64,8 +64,12 @@ func on_craft_complete() -> void:
# Base Workbench cleanup (clears current_bill, resets work progress).
super.on_craft_complete()
# Find and consume the corpse that was hauled as ingredient.
var consumed_corpse = _find_consumed_corpse()
# Find the corpse that was hauled as ingredient. Prefer the transient
# reference set by JobRunner (reliable regardless of corpse tile position);
# fall back to proximity scan only if the field is somehow unset.
var consumed_corpse = _last_consumed_ingredient if _last_consumed_ingredient != null \
and is_instance_valid(_last_consumed_ingredient) \
else _find_consumed_corpse()
# Drop 1 ash item on an adjacent walkable tile (same pattern as
# Tree.fell() / Workbench output drops elsewhere in Phase 6).

View file

@ -131,6 +131,12 @@ var _light: PointLight2D = null
## completes or is interrupted. Not stocked by single-ingredient recipes.
var deposited_inputs: Dictionary = {}
## Transient: set by JobRunner._tick_craft to the carried ingredient node
## immediately before queue_free() so on_craft_complete() overrides (e.g.
## CremationPyre) can retrieve the consumed entity by reference rather than
## by proximity scan. Cleared by the caller after on_craft_complete returns.
var _last_consumed_ingredient = null
# ── lifecycle ─────────────────────────────────────────────────────────────────
@ -352,7 +358,11 @@ func from_dict(d: Dictionary) -> void:
label_text = str(d.get("label_text", "Workbench"))
accepted_skill = StringName(d.get("accepted_skill", "crafting"))
build_progress = int(d.get("build_progress", 0))
_completed = bool(d.get("completed", false))
# Use _complete() when already finished so side effects (light, beauty,
# designation clear) fire correctly on load — matching what on_build_tick()
# does during normal construction.
if bool(d.get("completed", false)):
_complete()
current_work_progress = int(d.get("current_work_progress", 0))
# Reconstruct bills from the saved array. Clear first so this is idempotent.
bills.clear()