sow no longer needs grain + add crop zone paint tools
Bug: pawns weren't replanting. _find_sow required a TYPE_GRAIN item as seed, but Millstone's flour bill (FOREVER) consumed all grain before sow could claim it. With CookingProvider now priority 6, grain contention is fatal — TILLED crops sit forever. Fix: removed the grain requirement. Sow is now Rimworld-style — the designation triggers work; no input is consumed. _find_sow returns a 2-toil job (walk → interact). Crop.on_sow_tick just flips stage to SOWN. Feature: 4 new paint tools in BuildDrawer's new "Farm" section column — TOOL_PAINT_CROP_WHEAT/POTATO/CORN/STRAWBERRY. Painting a grass tile spawns a TILLED Crop entity that pawns then sow. World rejects non-grass tiles, occupied tiles, and non-walkable terrain. 9 new string keys, kind-specific thumbnail draws (gold/tan/yellow/red). MCP verified: 12 forced-TILLED crops fully cycled TILLED → SOWN → growth → READY within ~3000 ticks. Paint tool spawned wheat crop at (35, 30); wall tile at (44, 23) correctly rejected. Followup smell: cancelling a designation on a player-painted crop will queue_free even if grown — Crop has no can_complete. Future guard could skip crops past TILLED. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
87a7beb22b
commit
c6c88acc47
6 changed files with 107 additions and 54 deletions
|
|
@ -12,17 +12,10 @@ class_name PlantProvider extends WorkProvider
|
|||
## Harvest Job (two toils):
|
||||
## walk_to(crop.tile) → interact(crop.get_path(), "on_harvest_tick")
|
||||
##
|
||||
## Sow Job (four toils):
|
||||
## walk_to(grain_item.tile) → pickup → walk_to(crop.tile)
|
||||
## → interact(crop.get_path(), "on_sow_tick")
|
||||
## The grain item is consumed by the INTERACT completion (on_sow_tick does
|
||||
## the stage transition; the pawn's carried item is cleared by the provider
|
||||
## by queuing a DROP toil after interact, or — simpler — on_sow_tick itself
|
||||
## does not free the item, so we add a consume step here).
|
||||
##
|
||||
## Seed item: Item.TYPE_GRAIN (&"grain") — universal MVP seed for all crop kinds.
|
||||
## Wheat/corn already produce grain on harvest. Potato/strawberry accept grain
|
||||
## as seed in the same way (MVP simplification noted in design.md).
|
||||
## Sow Job (two toils — no seed cost, Rimworld-style):
|
||||
## walk_to(crop.tile) → interact(crop.get_path(), "on_sow_tick")
|
||||
## The designation alone triggers work; no grain is consumed. on_sow_tick()
|
||||
## flips the crop from TILLED → SOWN so growth begins on the next sim 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
|
||||
|
|
@ -54,9 +47,6 @@ func find_best_for(pawn) -> Job:
|
|||
return j
|
||||
|
||||
# ── 2. Sow pass — only if no harvest work exists ─────────────────────────
|
||||
# Pawn must not already be carrying something (no double-carry).
|
||||
if pawn.carried_item != null:
|
||||
return null
|
||||
return _find_sow(pawn)
|
||||
|
||||
|
||||
|
|
@ -89,11 +79,10 @@ func _find_harvest(pawn) -> Job:
|
|||
return j
|
||||
|
||||
|
||||
## Scan World.crops for the nearest sowable (TILLED) crop, find a reachable
|
||||
## grain item to use as seed, and build a 4-toil sow job.
|
||||
## Returns null when no sowable tile or no grain exists.
|
||||
## Scan World.crops for the nearest sowable (TILLED) crop and build a 2-toil
|
||||
## sow job. No seed item is consumed — sow is a free designation (Rimworld-style).
|
||||
## Returns null when no sowable crop is reachable.
|
||||
func _find_sow(pawn) -> Job:
|
||||
# Find the nearest sowable crop the pawn can reach.
|
||||
var best_crop = null
|
||||
var best_crop_dist: int = 999999
|
||||
|
||||
|
|
@ -114,45 +103,9 @@ func _find_sow(pawn) -> Job:
|
|||
if best_crop == null:
|
||||
return null
|
||||
|
||||
# Find the nearest free grain item in the world.
|
||||
var best_grain = null
|
||||
var best_grain_dist: int = 999999
|
||||
|
||||
for it in World.items:
|
||||
if it.item_type != Item.TYPE_GRAIN:
|
||||
continue
|
||||
if it.being_carried:
|
||||
continue
|
||||
# Reachability pre-check for the grain item too.
|
||||
if pawn.tile != it.tile and World.pathfinder != null:
|
||||
if World.pathfinder.find_path(pawn.tile, it.tile).is_empty():
|
||||
continue
|
||||
var d: int = abs(it.tile.x - pawn.tile.x) + abs(it.tile.y - pawn.tile.y)
|
||||
if d < best_grain_dist:
|
||||
best_grain_dist = d
|
||||
best_grain = it
|
||||
|
||||
if best_grain == null:
|
||||
return null
|
||||
|
||||
var j := Job.new()
|
||||
j.label = "Sow %s at %s" % [best_crop.crop_kind, best_crop.tile]
|
||||
j.target_node = best_crop
|
||||
# Walk to the grain, pick it up, walk to the crop tile, sow.
|
||||
# on_sow_tick() transitions the crop TILLED → SOWN; after the interact toil
|
||||
# the pawn still carries the consumed grain. A trailing DROP toil deposits
|
||||
# it at the pawn's current tile (which is the crop tile); the item simply
|
||||
# falls on the ground and HaulingProvider re-hauls it. This is intentional
|
||||
# MVP behaviour — the player sees the seed "planted" and any excess grain is
|
||||
# returned to the floor for hauling. A future refinement can consume it
|
||||
# outright by adding a CONSUME toil kind to JobRunner.
|
||||
j.toils.append(Toil.walk_to(best_grain.tile))
|
||||
j.toils.append(Toil.pickup())
|
||||
j.toils.append(Toil.walk_to(best_crop.tile))
|
||||
j.toils.append(Toil.interact(best_crop.get_path(), &"on_sow_tick"))
|
||||
# Deposit the consumed grain at the crop tile so HaulingProvider can route
|
||||
# it back to a stockpile. MVP simplification: the seed is not destroyed on
|
||||
# sow — it becomes a floor item. A future CONSUME toil kind in JobRunner
|
||||
# would burn the item in-place without spawning a floor stack.
|
||||
j.toils.append(Toil.deposit())
|
||||
return j
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue