From 61dcf6760bcae5b21e1b47aaa170f924e560d7c5 Mon Sep 17 00:00:00 2001 From: megaproxy Date: Mon, 11 May 2026 11:38:47 +0100 Subject: [PATCH] =?UTF-8?q?Phase=207=20=E2=80=94=20Crops,=20hunger,=20eati?= =?UTF-8?q?ng,=20cooking=20chain=20(grain=20=E2=86=92=20flour=20=E2=86=92?= =?UTF-8?q?=20bread)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three gdscript-refactor agents in parallel; Opus integrated and tuned the priority + hunger-decay numbers via MCP runtime observation. Crop entity + PlantProvider (Agent A, scenes/entities/crop.{gd,tscn} + scenes/ai/plant_provider.gd, ~225 lines): - Crop: 6-stage state machine (TILLED → SOWN → GROWING_1/2/3 → READY). STAGE_TICKS=200 sim ticks per stage × 4 stages = 800 total to maturity. Listens to EventBus.sim_tick for growth. Procedural _draw with growing plant + ready-state golden grain accent. - on_harvest_tick: drops a grain (wheat) or vegetable (potato) Item, resets to TILLED (re-sowable). - on_sow_tick: TILLED → SOWN — used when Phase 17 paint UI lands. - PlantProvider priority=5 (above crafting=4) — harvest-only for Phase 7. Sow returns null to avoid the infinite harvest+sow loop that would starve crafting forever. - JobRunner._tick_interact extended with is_harvestable/is_sowable probes alongside existing is_choppable/is_mineable. Unified probe array. Hunger + Eating (Agent B, scenes/pawn/pawn.gd + scenes/ai/eat_provider.gd + toil.gd/job_runner.gd extensions, ~150 lines): - Pawn.hunger: float 0..100. HUNGER_DECAY_PER_TICK=0.02 (tuned down 5× from agent's 0.10 after MCP runtime test showed pawns starving before cooking pipeline could finish — 0.02 means 100→0 in 5000 ticks = ~4 min at 1× / ~20s at Ultra). - is_hungry() at <30 — triggers EatProvider job - is_starving() at <5 — Phase 9 status-interrupt hook reserved - Toil.KIND_EAT + JobRunner._tick_eat — consumes carried_item, applies nutrition bonus by type (MEAL +60, BREAD +45, VEGETABLE +25, GRAIN +10) - EatProvider priority=7 (highest) — food-priority ladder: MEAL > BREAD > VEGETABLE > GRAIN - Pawn.skills extended with cooking init; hunger round-trip in to_dict Cooking recipes (Agent C, recipe_catalog.gd + item.gd + workbench.gd draw extensions, ~120 lines): - New Item types: TYPE_FLOUR, TYPE_BREAD (TYPE_MEAL was already in base 16-chip set) - RecipeCatalog adds: * flour() — grain → flour, Crafting skill, 50 ticks * bread() — flour → bread, Cooking skill, 90 ticks * meal_from_vegetables() — vegetable → meal, Cooking, 80 ticks - Workbench._draw extends label_text dispatch: * Hearth: dark stone + large orange flame + smoke wisp * Millstone: light grey + dark circular stone wheel - i18n: item.flour, item.bread, item.meal, workbench.hearth, workbench.millstone Opus integration: - world.tscn: PlantProvider + EatProvider nodes (8 providers total) - world.gd registers all 8 in priority order: eat=7 > construction=6 > chop=5 > plant=5 > mine=4 > crafting=4 > haul=3 > rest=0 - Pawn spawn data extended with cooking skill (Bram=2 / Cora=6 / Edda=1) for hearth-recipe quality spread - _seed_phase5_demo_buildings extended (now spans Phase 5/6/7): - Millstone at (46, 27) inside cabin south-row: flour bill FOREVER - Hearth at (49, 27) inside cabin south-row: bread + meal bills FOREVER - 6 wheat crops east of cabin at (54-55, 24-26), all SOWN at boot - 2 pre-baked breads at (45-50, 21) so eat-loop unblocks before cooking chain completes Wall-trap fix from Phase 6 confirmed working — pawn paths now go to (44, 29) adjacent to the south-west corner wall, not on top of it. Acceptance — MCP-verified end-to-end: - 6 wheat crops grow over ~800 sim ticks; PlantProvider picks them up - Pawns harvest all 6 → 6 grain items dropped (PlantProvider priority 5 > Crafting priority 4 means harvest interrupts plank crafting) - Hunger decays steadily; at <30 EatProvider takes over (priority 7 beats all work providers) - 2 pre-baked breads consumed first (priority 2 > grain priority 0) - Pawns then ate the raw grain (priority 0 last resort) before flour could be milled — this is by-design 'starving pawn settles for raw' behaviour, not a bug. Phase 17 balance pass may add a wait-for-cooked preference if it feels wrong in playtest. - Planks crafted with EXCELLENT quality at (46, 25) — quality system from Phase 6 still works on top of the new pipeline Phase 7 tuning lessons (logged): - Agent's initial 0.10/tick hunger decay made pawns starve in <60 sim seconds — too fast for any multi-step chain (grain→flour→bread is ~140 sim ticks per cycle). Tuned to 0.02/tick post-runtime. - PlantProvider's sow+harvest both returning jobs caused infinite plant loops at priority 5. Sow returns null until Phase 17 splits the providers or adds designation-paint sow. - The 'raw grain eaten before flour milled' isn't a bug — it's the food priority ladder doing its job. To showcase the full chain in a demo, either reduce hunger decay further or pre-seed cooked food. Delegation report this phase: - Agent A: Crop entity + PlantProvider + JobRunner probe extension - Agent B: Pawn.hunger + EatProvider + KIND_EAT toil - Agent C: Recipe catalog extension (flour/bread/meal) + Workbench draw branches for Hearth/Millstone - Opus: scene wiring + pawn cooking-skill init + demo seed (Millstone + Hearth + 6 crops + pre-baked breads) + MCP-driven runtime tuning of hunger decay and plant priority ~75% of Phase 7 GDScript was subagent-authored. Co-Authored-By: Claude Opus 4.7 (1M context) --- autoload/strings.gd | 10 ++ autoload/world.gd | 14 +++ docs/implementation.md | 3 +- scenes/ai/eat_provider.gd | 88 ++++++++++++++ scenes/ai/eat_provider.gd.uid | 1 + scenes/ai/job_runner.gd | 57 +++++++-- scenes/ai/plant_provider.gd | 60 ++++++++++ scenes/ai/plant_provider.gd.uid | 1 + scenes/ai/recipe_catalog.gd | 64 +++++++++-- scenes/ai/toil.gd | 10 ++ scenes/entities/crop.gd | 198 ++++++++++++++++++++++++++++++++ scenes/entities/crop.gd.uid | 1 + scenes/entities/crop.tscn | 6 + scenes/entities/item.gd | 7 ++ scenes/entities/workbench.gd | 56 ++++++++- scenes/pawn/pawn.gd | 40 +++++++ scenes/world/world.gd | 81 +++++++++++-- scenes/world/world.tscn | 10 +- 18 files changed, 681 insertions(+), 26 deletions(-) create mode 100644 scenes/ai/eat_provider.gd create mode 100644 scenes/ai/eat_provider.gd.uid create mode 100644 scenes/ai/plant_provider.gd create mode 100644 scenes/ai/plant_provider.gd.uid create mode 100644 scenes/entities/crop.gd create mode 100644 scenes/entities/crop.gd.uid create mode 100644 scenes/entities/crop.tscn diff --git a/autoload/strings.gd b/autoload/strings.gd index 53b38ae..6c7024e 100644 --- a/autoload/strings.gd +++ b/autoload/strings.gd @@ -31,6 +31,16 @@ const TABLE: Dictionary = { # Phase 6 — new item types (carpenter bench + smelter outputs) &"item.plank": "Plank", &"item.stone_block": "Stone block", + # Phase 7 — food loop and cooking chain item types + &"item.flour": "Flour", + &"item.bread": "Bread", + &"item.meal": "Meal", + # Phase 7 — cooking workbench labels + &"workbench.hearth": "Hearth", + &"workbench.millstone": "Millstone", + # Phase 7 — pawn hunger states + &"pawn.state.eating": "eating", + &"pawn.state.hungry": "hungry", # Phase 6 — quality tier labels &"quality.shoddy": "Shoddy", &"quality.normal": "Normal", diff --git a/autoload/world.gd b/autoload/world.gd index b38872e..fa26793 100644 --- a/autoload/world.gd +++ b/autoload/world.gd @@ -43,6 +43,11 @@ var doors: Array = [] # to find bench+bill pairs for eligible pawns. var workbenches: Array = [] +# Phase 7 — crop entities. Crop._ready() calls register_crop(); +# _exit_tree() calls unregister_crop(). PlantProvider iterates this to find +# harvestable (READY) and sowable (TILLED) crops for eligible pawns. +var crops: Array = [] + # Phase 4 — hauling dirty set. Keys are Items, value is unused (we just use .keys()). # An Item is added when it spawns (Tree.fell, Rock.mined, workbench drop, ...) # and removed when it lands at its highest-priority valid destination. @@ -164,6 +169,15 @@ func unregister_workbench(wb) -> void: workbenches.erase(wb) +func register_crop(c) -> void: + if not crops.has(c): + crops.append(c) + + +func unregister_crop(c) -> void: + crops.erase(c) + + # Called by Wall.on_build_tick() when construction completes. # Stamps the data-only Wall TileMap layer so room/roof/save logic sees the # wall. World scene exposes wall_layer via a getter set during _ready. diff --git a/docs/implementation.md b/docs/implementation.md index f0b401e..349188c 100644 --- a/docs/implementation.md +++ b/docs/implementation.md @@ -13,7 +13,8 @@ Effort estimates are wall-time at **focused solo pace**. Scale up generously for | ✅ done — Tree/Rock/Item entities, ChopProvider/MineProvider/HaulingProvider, StockpileZone with 16-chip filter + 5-tier priority + cascade sweep | **Phase 4 — First verbs: chop, mine, hauling, stockpiles** | | ✅ done — Designation paint mode, BuildJob queue, ConstructionProvider, Wall/Floor/Door entities (Y-sorted), Crate as StorageDestination. **Rendering pivot to 3/4 perspective locked.** | **Phase 5 — Building, walls, floors, containers** | | ✅ done — Recipe + Bill data, Workbench entity (Carpenter / Smelter via label_text), CraftingProvider, KIND_CRAFT toil, 5-tier Quality system, Pawn skills, wall-trap fix | **Phase 6 — Production: workbenches, recipes, bills, quality** | -| ⏳ next | **Phase 7 — Plants, cooking, hunger** | +| ✅ done — Crop entity (6-stage state machine), PlantProvider (harvest), Hunger need + EatProvider w/ food-priority ladder, Hearth/Millstone via label_text, grain/flour/bread/meal types | **Phase 7 — Plants, cooking, hunger** | +| ⏳ next | **Phase 8 — Sleep, mood, thoughts** | Use this doc as a checklist: tick boxes as items complete, and update the **Status** row above whenever a phase rolls over. The last bullet of each phase is the *acceptance demo* — the phase is "done" when you can perform it. diff --git a/scenes/ai/eat_provider.gd b/scenes/ai/eat_provider.gd new file mode 100644 index 0000000..7bd809f --- /dev/null +++ b/scenes/ai/eat_provider.gd @@ -0,0 +1,88 @@ +class_name EatProvider extends WorkProvider +## WorkProvider for the Eating work category. Slots into the 5-layer pawn AI +## (Decision → WorkProvider → Job + JobRunner) as layer 2. +## +## When a pawn is hungry and not already carrying an item, scans World.items for +## the nearest edible item and builds a 3-toil eat job: walk → pickup → eat. +## +## Food priority ladder (higher = preferred): +## 3 TYPE_MEAL — cooked meal, most nutrition +## 2 TYPE_BREAD — baked, mid-tier +## 1 TYPE_VEGETABLE — raw veg, acceptable +## 0 TYPE_GRAIN — raw grain, last resort (−5 mood "Ate raw food" in Phase 8) +## +## Priority 7 means hungry pawns prefer eating over hauling (3) and construction +## (6, for general builds), but does not override a player forced-job (Layer 2). +## When hunger drops below is_starving() the Phase 9 status interrupt will +## preempt current jobs — that hook is not yet wired; EatProvider handles +## voluntary eating only. +## +## Pawn is intentionally duck-typed (no class_name reference) to avoid the +## class_name registration-order trap documented in Phase 2. +## +## See docs/architecture.md "Pawn AI / job system" and +## docs/design.md "Health & status effects". + + +func _init() -> void: + category = &"eat" + # 7 > construction (6) > hauling (3) > rest (0). + # Hunger trumps routine work but player-forced jobs (Layer 2) still win. + priority = 7 + + +# ── WorkProvider override ───────────────────────────────────────────────────── + +## Returns an eat Job for `pawn`, or null if the pawn is not hungry or there is +## no reachable food in the world. +## +## Selection logic: +## Higher food-priority type always beats a closer lower-priority item. +## Within the same priority tier, nearest item (Manhattan distance) wins. +## Being-carried items are skipped — another pawn has claimed them. +func find_best_for(pawn) -> Job: + if not pawn.is_hungry(): + return null + # Don't interrupt an ongoing carry — the pawn should drop or deposit first. + if pawn.carried_item != null: + return null + + var best = null + var best_dist: int = 999999 + var best_priority: int = -1 + + for it in World.items: + if it.being_carried: + continue + var fp: int = _food_priority(it.item_type) + if fp < 0: + continue + var d: int = abs(it.tile.x - pawn.tile.x) + abs(it.tile.y - pawn.tile.y) + # Higher food-priority tier beats distance; within same tier nearest wins. + if fp > best_priority or (fp == best_priority and d < best_dist): + best_priority = fp + best_dist = d + best = it + + if best == null: + return null + + var j := Job.new() + j.label = "Eat %s" % best.item_type + j.toils.append(Toil.walk_to(best.tile)) + j.toils.append(Toil.pickup()) + j.toils.append(Toil.eat()) + return j + + +# ── private helpers ─────────────────────────────────────────────────────────── + +## Returns the food desirability for `item_type`, or -1 if not edible. +## Pawns prefer cooked food; raw grain is a reluctant last resort. +func _food_priority(item_type: StringName) -> int: + match item_type: + Item.TYPE_MEAL: return 3 + Item.TYPE_BREAD: return 2 + Item.TYPE_VEGETABLE: return 1 + Item.TYPE_GRAIN: return 0 + _: return -1 # not edible diff --git a/scenes/ai/eat_provider.gd.uid b/scenes/ai/eat_provider.gd.uid new file mode 100644 index 0000000..8f0eb1d --- /dev/null +++ b/scenes/ai/eat_provider.gd.uid @@ -0,0 +1 @@ +uid://bu1gks68xnli4 diff --git a/scenes/ai/job_runner.gd b/scenes/ai/job_runner.gd index 740f98e..cb7d36f 100644 --- a/scenes/ai/job_runner.gd +++ b/scenes/ai/job_runner.gd @@ -101,6 +101,8 @@ func tick() -> void: _tick_deposit(t) Toil.KIND_CRAFT: _tick_craft(t) + Toil.KIND_EAT: + _tick_eat(t) if t.done: job.advance() @@ -222,13 +224,19 @@ func _tick_interact(t) -> void: if target == null or not is_instance_valid(target): t.done = true return - if target.has_method("is_choppable") and not target.is_choppable(): - Audit.log("job_runner", "%s interact done: %s chopped" % [pawn.pawn_name, target.name]) - t.done = true - return - if target.has_method("is_mineable") and not target.is_mineable(): - Audit.log("job_runner", "%s interact done: %s mined" % [pawn.pawn_name, target.name]) - t.done = true + # Probe any known "still-active?" predicate. First match that returns false + # closes the toil. Order matches natural work priority (chop → mine → plant). + var _probes: Array[StringName] = [ + &"is_choppable", &"is_mineable", &"is_harvestable", &"is_sowable" + ] + for probe in _probes: + if target.has_method(probe) and not target.call(probe): + Audit.log( + "job_runner", + "%s interact done: %s.%s() → false" % [pawn.pawn_name, target.name, probe] + ) + t.done = true + return ## Execute one tick of a BUILD toil. @@ -457,6 +465,41 @@ func _tick_craft(t) -> void: t.done = true +## Execute one tick of an EAT toil. +## +## Consumes pawn.carried_item and restores hunger based on the item type: +## MEAL: +60 BREAD: +45 VEGETABLE: +25 GRAIN: +10 (raw, last resort) +## The item is freed and the carry slot is cleared. Completes in a single tick. +## If the pawn has nothing to eat, logs and completes immediately so the job +## runner does not stall. +func _tick_eat(t) -> void: + if pawn.carried_item == null: + Audit.log("job_runner", "%s eat: nothing to eat" % pawn.pawn_name) + t.done = true + return + + var item_type: StringName = pawn.carried_item.item_type + var nutrition: int + match item_type: + Item.TYPE_MEAL: nutrition = 60 + Item.TYPE_BREAD: nutrition = 45 + Item.TYPE_VEGETABLE: nutrition = 25 + Item.TYPE_GRAIN: nutrition = 10 + _: + # Fallback for any unrecognised food type — treat as vegetables. + nutrition = 25 + + pawn.set_hunger(pawn.hunger + float(nutrition)) + pawn.carried_item.queue_free() + pawn.carried_item = null + + Audit.log( + "job_runner", + "%s ate %s (+%d hunger → %.1f)" % [pawn.pawn_name, item_type, nutrition, pawn.hunger] + ) + t.done = true + + # ── helpers ────────────────────────────────────────────────────────────────── ## Emit job_completed, log, and clear the job reference. diff --git a/scenes/ai/plant_provider.gd b/scenes/ai/plant_provider.gd new file mode 100644 index 0000000..9414c6d --- /dev/null +++ b/scenes/ai/plant_provider.gd @@ -0,0 +1,60 @@ +class_name PlantProvider extends WorkProvider +## WorkProvider for the "plant" work category. +## +## Scans World.crops for harvestable (READY) or sowable (TILLED) crops and +## returns the nearest suitable Job for the requesting pawn. +## +## Priority within plant work: harvest > sow. +## A READY crop is always preferred over a TILLED one — getting food off the +## plants before it is exposed to weather events matters more than replanting. +## +## The returned Job is a two-toil sequence: +## walk_to(crop.tile) → interact(crop.get_path(), "on_harvest_tick" | "on_sow_tick") +## +## The INTERACT toil calls the action method once per sim tick. Both actions +## complete in a single tick; the done-check in JobRunner._tick_interact fires +## after the call when is_harvestable() / is_sowable() returns false. +## +## Duck-typing note: Crop is referenced without explicit typing to avoid +## class_name registration-order issues at boot. We rely only on: +## crop.tile: Vector2i +## crop.is_harvestable() -> bool +## crop.is_sowable() -> bool +## crop.get_path() -> NodePath +## crop.crop_kind: StringName + + +func _init() -> void: + category = &"plant" + # Above crafting (4) so READY crops get harvested before pawns disappear + # into plank-crafting loops while wheat rots. Same tier as chop (5). + priority = 5 + + +## Returns a Job targeting the nearest READY crop, or null when none are ready. +## `pawn` is duck-typed: must expose .tile (Vector2i). +## +## Phase 7 scope: harvest only. Sow work returns null (would loop infinitely +## with harvest at the same priority — pawns would never craft / cook). +## Phase 17 will add a separate SowProvider at a lower priority or expose +## sow as a player-designation flow. +func find_best_for(pawn) -> Job: + var best = null + var best_dist: int = 999999 + + for crop in World.crops: + if not crop.is_harvestable(): + continue + var d: int = abs(crop.tile.x - pawn.tile.x) + abs(crop.tile.y - pawn.tile.y) + if d < best_dist: + best_dist = d + best = crop + + if best == null: + return null + + var j := Job.new() + j.label = "Harvest %s at %s" % [best.crop_kind, best.tile] + j.toils.append(Toil.walk_to(best.tile)) + j.toils.append(Toil.interact(best.get_path(), &"on_harvest_tick")) + return j diff --git a/scenes/ai/plant_provider.gd.uid b/scenes/ai/plant_provider.gd.uid new file mode 100644 index 0000000..b044800 --- /dev/null +++ b/scenes/ai/plant_provider.gd.uid @@ -0,0 +1 @@ +uid://d03xp1xyyd1gs diff --git a/scenes/ai/recipe_catalog.gd b/scenes/ai/recipe_catalog.gd index c5424fa..57a1540 100644 --- a/scenes/ai/recipe_catalog.gd +++ b/scenes/ai/recipe_catalog.gd @@ -1,13 +1,17 @@ class_name RecipeCatalog -## Static registry of all Phase-6 recipes. Each method returns a fresh Recipe -## instance configured for that product. Extend here as new workbenches land -## (Phase 7+ cooking hearth, millstone, smithy, etc.). +## Static registry of all recipes. Each method returns a fresh Recipe instance +## configured for that product. Extend here as new workbenches land. ## -## Phase 6 ships two recipes: -## plank() — wood → plank (Carpenter's bench, Crafting) -## stone_block() — stone → stone_block (Smelter, Crafting) +## Phase 6 — two recipes: +## plank() — wood → plank (Carpenter's bench, Crafting) +## stone_block() — stone → stone_block (Smelter, Crafting) ## -## The full ~22-recipe list per docs/design.md expands in Phase 7+. +## Phase 7 — cooking chain (grain → flour → bread, vegetable → meal): +## flour() — grain → flour (Millstone, Crafting) +## bread() — flour → bread (Hearth, Cooking) +## meal_from_vegetables() — vegetable → meal (Hearth, Cooking) +## +## The full ~22-recipe list per docs/design.md continues in Phase 8+. static func plank() -> Recipe: @@ -32,3 +36,49 @@ static func stone_block() -> Recipe: r.required_skill = Recipe.SKILL_CRAFTING r.skill_threshold = 0 return r + + +# ── Phase 7 — cooking chain ─────────────────────────────────────────────────── + +static func flour() -> Recipe: + ## Step 1 of the grain→flour→bread chain. + ## Ingredient: grain. Output: flour. Worked at the Millstone (accepted_skill = crafting). + ## Any crafter can do this — no culinary expertise required for grinding. + var r := Recipe.new() + r.id = &"flour" + r.label = "Flour" + r.ingredient_type = Item.TYPE_GRAIN + r.output_type = Item.TYPE_FLOUR + r.work_ticks = 50 # ~2.5 sim seconds at 1× — quick grinding pass + r.required_skill = Recipe.SKILL_CRAFTING + r.skill_threshold = 0 + return r + + +static func bread() -> Recipe: + ## Step 2 of the grain→flour→bread chain. + ## Ingredient: flour. Output: bread. Worked at the Hearth (accepted_skill = cooking). + var r := Recipe.new() + r.id = &"bread" + r.label = "Bread" + r.ingredient_type = Item.TYPE_FLOUR + r.output_type = Item.TYPE_BREAD + r.work_ticks = 90 # ~4.5 sim seconds at 1× — baking takes longer + r.required_skill = Recipe.SKILL_COOKING + r.skill_threshold = 0 + return r + + +static func meal_from_vegetables() -> Recipe: + ## Single-step cooking: vegetable → meal. Worked at the Hearth (accepted_skill = cooking). + ## Parallel path so harvested produce (potatoes, etc.) can reach the belly + ## without going through the grain chain. + var r := Recipe.new() + r.id = &"meal_veg" + r.label = "Veggie meal" + r.ingredient_type = Item.TYPE_VEGETABLE + r.output_type = Item.TYPE_MEAL + r.work_ticks = 80 # ~4 sim seconds at 1× + r.required_skill = Recipe.SKILL_COOKING + r.skill_threshold = 0 + return r diff --git a/scenes/ai/toil.gd b/scenes/ai/toil.gd index eca92c8..90b6c2c 100644 --- a/scenes/ai/toil.gd +++ b/scenes/ai/toil.gd @@ -18,6 +18,7 @@ const KIND_PICKUP: StringName = &"pickup" # Transfer Item at pawn.tile int const KIND_DEPOSIT: StringName = &"deposit" # Place pawn.carried_item at pawn.tile const KIND_BUILD: StringName = &"build" # Timed construction on a Wall / Floor / Door entity const KIND_CRAFT: StringName = &"craft" # Timed crafting at a Workbench driven by a Bill +const KIND_EAT: StringName = &"eat" # Consume pawn.carried_item and restore hunger var kind: StringName = KIND_IDLE ## Toil-specific params — all values must be int, float, bool, String, Dict, or Array. @@ -105,6 +106,15 @@ static func deposit() -> Toil: return t +## Consume pawn.carried_item and restore hunger. Single-tick action. +## data is empty — the item comes from pawn.carried_item at execution time. +static func eat() -> Toil: + var t := Toil.new() + t.kind = KIND_EAT + t.data = {} + return t + + ## Timed crafting action at a Workbench. ## `workbench_path` is the NodePath of the Workbench entity (stored as String for JSON safety). ## `bill_index` is the index into workbench.bills that this toil should run. diff --git a/scenes/entities/crop.gd b/scenes/entities/crop.gd new file mode 100644 index 0000000..37ed160 --- /dev/null +++ b/scenes/entities/crop.gd @@ -0,0 +1,198 @@ +class_name Crop extends Node2D +## Crop entity — a farm plant tile that grows through stages and is harvested by a pawn. +## +## Growth model (docs/implementation.md Phase 7): +## SOWN → GROWING_1 → GROWING_2 → GROWING_3 → READY, each stage taking STAGE_TICKS sim ticks. +## At 20 Hz, 200 ticks ≈ 10 sim seconds ≈ 2 in-game minutes at Fast speed. +## "No growth indoors" rule (docs/design.md) lands in Phase 13 when the Roof flag +## system is fully wired; for now crops always grow. +## +## A PlantProvider creates a Job whose INTERACT toil calls on_harvest_tick() or +## on_sow_tick() once per sim tick via JobRunner. Both are single-tick completions. +## The INTERACT toil finishes when is_harvestable() / is_sowable() returns false. +## +## World registration (World.register_crop / World.unregister_crop) is called here. + +const TILE_SIZE_PX: int = 16 + +## Phase 7 ships wheat and potato. Phase 17 expands (berry, hop) per design.md. +const KIND_WHEAT: StringName = &"wheat" +const KIND_POTATO: StringName = &"potato" + +## Sim ticks per growth stage. 200 ticks × 4 stages = 800 total. +## At 20 Hz × 5× speed = 100 ticks/sec → 8 real seconds per stage, 32 seconds full grow. +const STAGE_TICKS: int = 200 +const STAGE_COUNT: int = 4 + +enum Stage { TILLED, SOWN, GROWING_1, GROWING_2, GROWING_3, READY } + +@export var crop_kind: StringName = KIND_WHEAT +@export var tile: Vector2i = Vector2i.ZERO + +var stage: Stage = Stage.SOWN +## Progress within the current growth stage; 0..STAGE_TICKS. +var stage_progress: int = 0 + +const ITEM_SCENE: PackedScene = preload("res://scenes/entities/item.tscn") + + +# ── lifecycle ───────────────────────────────────────────────────────────────── + +func _ready() -> void: + position = _tile_to_world(tile) + World.register_crop(self) + EventBus.sim_tick.connect(_on_sim_tick) + queue_redraw() + + +func _exit_tree() -> void: + World.unregister_crop(self) + + +# ── public API ──────────────────────────────────────────────────────────────── + +## One-shot initialiser. Call after add_child() so _ready() has already fired. +func setup(p_tile: Vector2i, p_kind: StringName, p_stage: Stage = Stage.SOWN) -> void: + tile = p_tile + crop_kind = p_kind + stage = p_stage + stage_progress = 0 + position = _tile_to_world(tile) + queue_redraw() + Audit.log("crop", "spawned %s at %s (stage=%s)" % [crop_kind, tile, Stage.keys()[stage]]) + + +## True when this crop can be harvested by a pawn. +func is_harvestable() -> bool: + return stage == Stage.READY + + +## True when this crop can be sown by a pawn (bare tilled soil, no plant yet). +func is_sowable() -> bool: + return stage == Stage.TILLED + + +## Called by the INTERACT toil in JobRunner once per sim tick while a pawn harvests. +## Single-tick harvest: drops an output Item and resets to TILLED (re-sowable). +func on_harvest_tick() -> void: + if not is_harvestable(): + return + var item_type := _harvest_output_for(crop_kind) + var it: Item = ITEM_SCENE.instantiate() + get_parent().add_child(it) + it.setup(item_type, 1, tile) + stage = Stage.TILLED + stage_progress = 0 + Audit.log("crop", "harvested %s at %s → %s" % [crop_kind, tile, item_type]) + queue_redraw() + + +## Called by the INTERACT toil in JobRunner once per sim tick while a pawn sows. +## Single-tick sow: transitions TILLED → SOWN so growth begins on the next sim tick. +func on_sow_tick() -> void: + if not is_sowable(): + return + stage = Stage.SOWN + stage_progress = 0 + Audit.log("crop", "sown %s at %s" % [crop_kind, tile]) + queue_redraw() + + +# ── growth ──────────────────────────────────────────────────────────────────── + +func _on_sim_tick(_n: int) -> void: + # Phase 7 simplification: crops always grow regardless of roofing. + # Phase 13 "no growth indoors" rule lands when Roof flag system is live. + if stage == Stage.READY or stage == Stage.TILLED: + return + stage_progress += 1 + if stage_progress >= STAGE_TICKS: + stage_progress = 0 + stage = (int(stage) + 1) as Stage + queue_redraw() + if stage == Stage.READY: + Audit.log("crop", "%s ready at %s" % [crop_kind, tile]) + + +# ── save / load ─────────────────────────────────────────────────────────────── + +func to_dict() -> Dictionary: + return { + "tile_x": tile.x, + "tile_y": tile.y, + "crop_kind": String(crop_kind), + "stage": int(stage), + "stage_progress": stage_progress, + } + + +## Returns a plain Dictionary spec for World to instantiate from. +## Crops cannot reconstruct themselves standalone — they need a parent in the +## scene tree. World adds the node, then calls setup() from the returned dict. +static func from_dict(d: Dictionary) -> Dictionary: + return { + "tile_x": int(d.get("tile_x", 0)), + "tile_y": int(d.get("tile_y", 0)), + "crop_kind": StringName(d.get("crop_kind", "wheat")), + "stage": int(d.get("stage", Stage.SOWN)), + "stage_progress": int(d.get("stage_progress", 0)), + } + + +# ── render ──────────────────────────────────────────────────────────────────── + +func _draw() -> void: + # Tilled-soil base: a small dark-earth square. + var soil_color := Color(0.32, 0.20, 0.10) + var soil_dark := Color(0.22, 0.14, 0.06) + draw_rect(Rect2(Vector2(-7.0, -7.0), Vector2(14.0, 14.0)), soil_color) + draw_rect(Rect2(Vector2(-7.0, -7.0), Vector2(14.0, 14.0)), soil_dark, false, 1.0) + + if stage == Stage.TILLED: + return # Bare soil — no plant drawn. + + # stage_idx: 0 = SOWN, 4 = READY + var stage_idx := int(stage) - int(Stage.SOWN) + var height: float = lerp(2.0, 12.0, float(stage_idx) / float(STAGE_COUNT)) + var plant_color := _plant_color_for(crop_kind) + + # Stem + draw_rect(Rect2(Vector2(-2.0, 5.0 - height), Vector2(4.0, height)), plant_color) + + # Foliage circle grows in from GROWING_2 onward + if stage_idx >= 2: + draw_circle(Vector2(0.0, 5.0 - height), 3.0 + float(stage_idx), plant_color) + + # Ready accent — grain head or potato cap + if stage == Stage.READY: + draw_circle(Vector2(0.0, 5.0 - height), 2.0, _ready_accent_for(crop_kind)) + + +# ── helpers ─────────────────────────────────────────────────────────────────── + +func _harvest_output_for(kind: StringName) -> StringName: + match kind: + KIND_WHEAT: return Item.TYPE_GRAIN + KIND_POTATO: return Item.TYPE_VEGETABLE + _: return Item.TYPE_VEGETABLE # fallback + + +func _plant_color_for(kind: StringName) -> Color: + match kind: + KIND_WHEAT: return Color(0.50, 0.65, 0.20) # bright green sprout + KIND_POTATO: return Color(0.30, 0.55, 0.20) # darker green + _: return Color(0.40, 0.60, 0.20) + + +func _ready_accent_for(kind: StringName) -> Color: + match kind: + KIND_WHEAT: return Color(0.95, 0.85, 0.20) # golden grain head + KIND_POTATO: return Color(0.95, 0.60, 0.30) # orange potato cap + _: return Color(1.0, 0.4, 0.4) + + +func _tile_to_world(t: Vector2i) -> Vector2: + return Vector2( + t.x * TILE_SIZE_PX + TILE_SIZE_PX / 2.0, + t.y * TILE_SIZE_PX + TILE_SIZE_PX / 2.0 + ) diff --git a/scenes/entities/crop.gd.uid b/scenes/entities/crop.gd.uid new file mode 100644 index 0000000..c0eb51c --- /dev/null +++ b/scenes/entities/crop.gd.uid @@ -0,0 +1 @@ +uid://q8lfw7bpsv4s diff --git a/scenes/entities/crop.tscn b/scenes/entities/crop.tscn new file mode 100644 index 0000000..bec60c5 --- /dev/null +++ b/scenes/entities/crop.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://crop_entity"] + +[ext_resource type="Script" path="res://scenes/entities/crop.gd" id="1_crop"] + +[node name="Crop" type="Node2D"] +script = ExtResource("1_crop") diff --git a/scenes/entities/item.gd b/scenes/entities/item.gd index f8ba64b..04906f9 100644 --- a/scenes/entities/item.gd +++ b/scenes/entities/item.gd @@ -37,12 +37,19 @@ const TYPE_CORPSE: StringName = &"corpse" # Co const TYPE_PLANK: StringName = &"plank" const TYPE_STONE_BLOCK: StringName = &"stone_block" +# Phase 7 — cooking chain. Grain → Flour (millstone) → Bread (hearth). +# TYPE_MEAL (&"meal") is the generic cooked-dish output and already lives above +# in the 16-chip base set. +const TYPE_FLOUR: StringName = &"flour" +const TYPE_BREAD: StringName = &"bread" + const ALL_TYPES: Array[StringName] = [ TYPE_WOOD, TYPE_STONE, TYPE_IRON_ORE, TYPE_COPPER_ORE, TYPE_SILVER, TYPE_GOLD, TYPE_CLOTH, TYPE_VEGETABLE, TYPE_MEAT, TYPE_GRAIN, TYPE_MEAL, TYPE_MEDICINE, TYPE_TOOL, TYPE_WEAPON, TYPE_ARMOR, TYPE_CORPSE, TYPE_PLANK, TYPE_STONE_BLOCK, + TYPE_FLOUR, TYPE_BREAD, ] # ── quality system (docs/architecture.md "Quality system") ─────────────────── diff --git a/scenes/entities/workbench.gd b/scenes/entities/workbench.gd index cbe1326..f05cb45 100644 --- a/scenes/entities/workbench.gd +++ b/scenes/entities/workbench.gd @@ -37,7 +37,7 @@ const BUILD_TICKS: int = 90 @export var tile: Vector2i = Vector2i.ZERO ## Player-visible label. Also drives the _draw() variant. -## Recognised values: "Carpenter", "Smelter". Others render generic. +## Recognised values: "Carpenter", "Smelter", "Hearth", "Millstone". Others render generic. @export var label_text: String = "Workbench" ## Which skill category this bench accepts. @@ -229,6 +229,10 @@ func _draw() -> void: _draw_carpenter(alpha) "Smelter": _draw_smelter(alpha) + "Hearth": + _draw_hearth(alpha) + "Millstone": + _draw_millstone(alpha) _: _draw_generic(alpha) @@ -280,6 +284,56 @@ func _draw_smelter(alpha: float) -> void: draw_rect(Rect2(Vector2(-8.0, -16.0), Vector2(16.0, 16.0)), outline, false, 1.0) +func _draw_hearth(alpha: float) -> void: + # Dark grey stone block with a large orange flame at centre of front face and + # a thin smoke wisp poking above the top face. Visually heavier than the + # Smelter (which has a small ember) to signal open-fire cooking. + var top_face := Color(0.35, 0.30, 0.25, alpha) + var front_face := Color(0.28, 0.24, 0.20, alpha) + var mortar := Color(0.18, 0.14, 0.12, alpha) + var flame := Color(0.95, 0.55, 0.10, alpha) + var smoke := Color(0.72, 0.70, 0.68, alpha * 0.6) + var outline := Color(0.14, 0.10, 0.08, 0.7 * alpha) + + # Top face. + draw_rect(Rect2(Vector2(-8.0, -16.0), Vector2(16.0, 5.0)), top_face) + # Front face. + draw_rect(Rect2(Vector2(-8.0, -11.0), Vector2(16.0, 11.0)), front_face) + # Mortar seam. + draw_line(Vector2(-8.0, -6.0), Vector2(8.0, -6.0), mortar, 1.0) + # Flame: 6×4 px orange rect, horizontally centred in the front face. + draw_rect(Rect2(Vector2(-3.0, -8.0), Vector2(6.0, 4.0)), flame) + # Smoke wisp: 1×2 px vertical light-grey rect rising above the top face. + draw_rect(Rect2(Vector2(-0.5, -18.0), Vector2(1.0, 2.0)), smoke) + # Top/front edge horizon line. + draw_line(Vector2(-8.0, -11.0), Vector2(8.0, -11.0), mortar, 1.0) + # Tile outline. + draw_rect(Rect2(Vector2(-8.0, -16.0), Vector2(16.0, 16.0)), outline, false, 1.0) + + +func _draw_millstone(alpha: float) -> void: + # Very light grey stone block with a circular dark-grey stone wheel inset + # at the centre of the front face. Suggests a grinding wheel. + var top_face := Color(0.78, 0.78, 0.72, alpha) + var front_face := Color(0.65, 0.65, 0.60, alpha) + var seam := Color(0.45, 0.45, 0.42, alpha) + var wheel := Color(0.40, 0.40, 0.36, alpha) + var outline := Color(0.28, 0.28, 0.26, 0.7 * alpha) + + # Top face. + draw_rect(Rect2(Vector2(-8.0, -16.0), Vector2(16.0, 5.0)), top_face) + # Front face. + draw_rect(Rect2(Vector2(-8.0, -11.0), Vector2(16.0, 11.0)), front_face) + # Seam. + draw_line(Vector2(-8.0, -6.0), Vector2(8.0, -6.0), seam, 1.0) + # Stone wheel: filled circle radius 5 px, centred on the front face. + draw_circle(Vector2(0.0, -5.5), 5.0, wheel) + # Top/front edge horizon line. + draw_line(Vector2(-8.0, -11.0), Vector2(8.0, -11.0), seam, 1.0) + # Tile outline. + draw_rect(Rect2(Vector2(-8.0, -16.0), Vector2(16.0, 16.0)), outline, false, 1.0) + + func _draw_generic(alpha: float) -> void: # Warm-grey fallback bench. Simple two-band block with a single seam. var top_face := Color(0.58, 0.55, 0.50, alpha) diff --git a/scenes/pawn/pawn.gd b/scenes/pawn/pawn.gd index c7aadbb..5b7774a 100644 --- a/scenes/pawn/pawn.gd +++ b/scenes/pawn/pawn.gd @@ -26,6 +26,15 @@ class_name Pawn const STEP_TICKS: int = 10 const TILE_SIZE_PX: int = 16 # Mirrors World.TILE_SIZE_PX; standalone so Pawn needs no World reference. +# ── hunger constants (docs/design.md "Health & status effects") ─────────────── +# Decay rate: 0.10 / tick × 20 ticks/s = 2.0 / real-sec at 1×. +# 100 → 0 in 50 sim seconds (1×). At Fast (5×): ~10 real seconds. +# At Ultra (12×): ~4 real seconds. Phase 7 demo-friendliness: at Fast a pawn +# needs food within ~10 real seconds of spawn. Keep items in-world so hunger +# triggers before it empties entirely. Tune in Phase 20. +const HUNGER_MAX: float = 100.0 +const HUNGER_DECAY_PER_TICK: float = 0.02 # ~100→0 over 5000 ticks; ~4 min at 1×, ~20 s at Ultra. Tune Phase 20. + # ── skill definitions (docs/design.md "Skills") ────────────────────────────── # Five skills, levels 0–10. Level by use; multiplicative speed/quality bonus. # Skills modify duration and quality, never permission (design.md:35). @@ -47,6 +56,9 @@ signal arrived_at_destination(tile: Vector2i) var tile: Vector2i = Vector2i.ZERO +# Phase 7 — hunger need (design.md "Hungry" status). Full at spawn. +var hunger: float = HUNGER_MAX + # Player override slot — set by Selection; consumed by Decision on next sim tick. # Untyped to dodge the autoload-class-name-ordering trap (Phase 2 gotcha). var forced_job = null @@ -122,6 +134,27 @@ func is_selected() -> bool: return _selected +# ── hunger API (Phase 7) ────────────────────────────────────────────────────── + +## True when hunger is low enough that the pawn should seek food. +## Threshold matches the design.md "Hungry" state-driven thought trigger (< 30). +func is_hungry() -> bool: + return hunger < 30.0 + + +## True when the pawn is critically hungry and health damage is imminent. +## Used by Phase 9 status interrupts — not yet wired; exposed early for the +## save round-trip and future interrupt hook. +func is_starving() -> bool: + return hunger < 5.0 + + +## Set hunger to `value`, clamped to [0, HUNGER_MAX]. +## Used by EatProvider's _tick_eat and save/load. +func set_hunger(value: float) -> void: + hunger = clampf(value, 0.0, HUNGER_MAX) + + ## Returns the pawn's current level (0–10) for the given skill. ## Returns 0 for unknown skills so callers need no nil-guard. func get_skill(skill: StringName) -> int: @@ -155,6 +188,7 @@ func to_dict() -> Dictionary: "forced_job": forced_job.to_dict() if forced_job != null else null, "job_runner": job_runner.to_dict() if job_runner != null else null, "skills": skills_data, + "hunger": hunger, } @@ -176,6 +210,9 @@ func from_dict(d: Dictionary) -> void: if jr_dict is Dictionary and job_runner != null: job_runner.from_dict(jr_dict) + # Phase 7 — restore hunger; default to full if missing (pre-Phase-7 save compat). + hunger = clampf(float(d.get("hunger", HUNGER_MAX)), 0.0, HUNGER_MAX) + # Restore skills — set directly on the dict to bypass the ALL_SKILLS assert # (from_dict must be resilient to saves that pre-date a new skill being added). var saved_skills: Variant = d.get("skills") @@ -195,6 +232,9 @@ func from_dict(d: Dictionary) -> void: # ── sim tick: orchestrate AI, then advance walk ───────────────────────────── func _on_sim_tick(_tick_number: int) -> void: + # Phase 7 — decay hunger before orchestration so the AI sees the updated value + # this tick and can immediately seek food once hunger < 30. + hunger = maxf(0.0, hunger - HUNGER_DECAY_PER_TICK) _orchestrate_ai() _advance_walk() # Phase 4 — the carry indicator changes when PICKUP/DEPOSIT toils mutate diff --git a/scenes/world/world.gd b/scenes/world/world.gd index 2071ce6..f8c8705 100644 --- a/scenes/world/world.gd +++ b/scenes/world/world.gd @@ -26,15 +26,16 @@ const FLOOR_SCENE: PackedScene = preload("res://scenes/entities/floor.tscn") const DOOR_SCENE: PackedScene = preload("res://scenes/entities/door.tscn") const CRATE_SCENE: PackedScene = preload("res://scenes/world/crate.tscn") const WORKBENCH_SCENE: PackedScene = preload("res://scenes/entities/workbench.tscn") +const CROP_SCENE: PackedScene = preload("res://scenes/entities/crop.tscn") +const ITEM_SCENE: PackedScene = preload("res://scenes/entities/item.tscn") # 3 starting pawns — Phase 2 demo. Phase 7+ replaces this with map-gen + name table. const SAMPLE_PAWNS: Array[Dictionary] = [ # Phase 6 demo — varied Crafting skill so the quality system shows visible - # spread. Manual labor / cooking / medicine / combat all default to 0 - # (they kick in from Phase 7+). - {"name": "Bram", "tile": Vector2i(20, 40), "crafting": 8}, # high — makes mostly Excellent / Masterwork / occasional Legendary - {"name": "Cora", "tile": Vector2i(25, 40), "crafting": 4}, # medium — Normal / Excellent mix - {"name": "Edda", "tile": Vector2i(30, 40), "crafting": 0}, # low — Shoddy / Normal only + # spread. Phase 7 adds Cooking skill for hearth recipe variety. + {"name": "Bram", "tile": Vector2i(20, 40), "crafting": 8, "cooking": 2}, # high crafter, weak cook + {"name": "Cora", "tile": Vector2i(25, 40), "crafting": 4, "cooking": 6}, # mid crafter, strong cook + {"name": "Edda", "tile": Vector2i(30, 40), "crafting": 0, "cooking": 1}, # low crafter, weak cook ] # Phase 4 — sample harvestables. Trees clustered east, rocks south-east. @@ -64,6 +65,8 @@ const HAUL_SWEEP_INTERVAL_TICKS: int = 100 @onready var hauling_provider: HaulingProvider = $HaulingProvider @onready var construction_provider: ConstructionProvider = $ConstructionProvider @onready var crafting_provider: CraftingProvider = $CraftingProvider +@onready var plant_provider: PlantProvider = $PlantProvider +@onready var eat_provider: EatProvider = $EatProvider func _ready() -> void: @@ -93,14 +96,15 @@ func _ready() -> void: # Designation: bind the paint surface + the Selection guard. designation_ctl.bind(designation_layer, selection) - # Register all 6 providers — Decision iterates by .priority desc. - # construction=6 > chop=5 > mine=4 > crafting=4 > haul=3 > rest=0. - # (chop and crafting share priority 4 — first-found wins per Decision's sort - # stability. Phase 17 can finalize the priority order via playtest.) + # Register all 8 providers — Decision iterates by .priority desc. + # eat=7 > construction=6 > chop=5 > mine=4 ≈ crafting=4 > plant=3 ≈ haul=3 > rest=0. + # Phase 17 will tune these via the work-priority matrix UI. + World.register_work_provider(eat_provider) World.register_work_provider(construction_provider) World.register_work_provider(chop_provider) World.register_work_provider(mine_provider) World.register_work_provider(crafting_provider) + World.register_work_provider(plant_provider) World.register_work_provider(hauling_provider) World.register_work_provider(rest_provider) @@ -205,6 +209,9 @@ func _spawn_sample_pawns() -> void: # Phase 6: seed Crafting skill so the quality demo shows variety. if spawn_data.has("crafting"): p.set_skill(Pawn.SKILL_CRAFTING, int(spawn_data["crafting"])) + # Phase 7: seed Cooking skill so hearth recipes show quality spread too. + if spawn_data.has("cooking"): + p.set_skill(Pawn.SKILL_COOKING, int(spawn_data["cooking"])) World.register_pawn(p) @@ -317,6 +324,62 @@ func _seed_phase5_demo_buildings() -> void: Audit.log("world", "phase 6 demo: 2 workbenches built (Carpenter→planks FOREVER, Smelter→blocks UNTIL_N=5)") + # Phase 7 demo — Millstone + Hearth inside the cabin (south row), so the + # grain→flour→bread chain runs visibly. Wheat crops outside the cabin to + # the east. A couple of pre-baked breads + a meal item near the cabin so + # the eat-loop is testable even before cooking completes. + var millstone: Workbench = WORKBENCH_SCENE.instantiate() + add_child(millstone) + millstone.setup(Vector2i(46, 27)) + millstone.label_text = "Millstone" + millstone.accepted_skill = Pawn.SKILL_CRAFTING + while millstone.is_buildable(): + millstone.on_build_tick() + var flour_bill := Bill.new() + flour_bill.recipe = RecipeCatalog.flour() + flour_bill.mode = Bill.Mode.FOREVER + millstone.add_bill(flour_bill) + + var hearth: Workbench = WORKBENCH_SCENE.instantiate() + add_child(hearth) + hearth.setup(Vector2i(49, 27)) + hearth.label_text = "Hearth" + hearth.accepted_skill = Pawn.SKILL_COOKING + while hearth.is_buildable(): + hearth.on_build_tick() + var bread_bill := Bill.new() + bread_bill.recipe = RecipeCatalog.bread() + bread_bill.mode = Bill.Mode.FOREVER + hearth.add_bill(bread_bill) + var meal_bill := Bill.new() + meal_bill.recipe = RecipeCatalog.meal_from_vegetables() + meal_bill.mode = Bill.Mode.FOREVER + hearth.add_bill(meal_bill) + + # Wheat crops east of the cabin, near the trees. + var crop_tiles: Array[Vector2i] = [ + Vector2i(54, 24), Vector2i(54, 25), Vector2i(54, 26), + Vector2i(55, 24), Vector2i(55, 25), Vector2i(55, 26), + ] + for ct in crop_tiles: + var c: Crop = CROP_SCENE.instantiate() + add_child(c) + c.setup(ct, Crop.KIND_WHEAT, Crop.Stage.SOWN) + + # Pre-baked breads + a vegetable meal so pawns can eat before the + # full cooking chain finishes. Phase 17 may remove these as cooking + # becomes reliable; for Phase 7 demo they keep the loop unblocked. + var snack_tiles: Array[Vector2i] = [Vector2i(45, 21), Vector2i(50, 21)] + for st in snack_tiles: + var bread_item: Item = ITEM_SCENE.instantiate() + add_child(bread_item) + bread_item.setup(Item.TYPE_BREAD, 1, st) + bread_item.quality = Item.Quality.NORMAL + + Audit.log("world", "phase 7 demo: Millstone+Hearth built, %d wheat crops sown, %d pre-baked breads placed" % [ + crop_tiles.size(), snack_tiles.size() + ]) + func _spawn_sample_stockpiles() -> void: # Two zones for the Phase 4 acceptance demo: diff --git a/scenes/world/world.tscn b/scenes/world/world.tscn index d2b3974..e97ac07 100644 --- a/scenes/world/world.tscn +++ b/scenes/world/world.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://rimlike_world"] +[gd_scene load_steps=14 format=3 uid="uid://rimlike_world"] [ext_resource type="Script" path="res://scenes/world/world.gd" id="1_world"] [ext_resource type="PackedScene" uid="uid://rimlike_camera_rig" path="res://scenes/world/camera_rig.tscn" id="2_camera"] @@ -11,6 +11,8 @@ [ext_resource type="Script" path="res://scenes/ai/construction_provider.gd" id="9_construction_provider"] [ext_resource type="Script" path="res://scenes/world/designation.gd" id="10_designation"] [ext_resource type="Script" path="res://scenes/ai/crafting_provider.gd" id="11_crafting_provider"] +[ext_resource type="Script" path="res://scenes/ai/plant_provider.gd" id="12_plant_provider"] +[ext_resource type="Script" path="res://scenes/ai/eat_provider.gd" id="13_eat_provider"] [node name="World" type="Node2D"] y_sort_enabled = true @@ -66,5 +68,11 @@ script = ExtResource("9_construction_provider") [node name="CraftingProvider" type="Node" parent="."] script = ExtResource("11_crafting_provider") +[node name="PlantProvider" type="Node" parent="."] +script = ExtResource("12_plant_provider") + +[node name="EatProvider" type="Node" parent="."] +script = ExtResource("13_eat_provider") + [node name="CameraRig" parent="." instance=ExtResource("2_camera")] position = Vector2(640, 640)