Compare commits

..

2 commits

Author SHA1 Message Date
c93f889ff1 Crop sprites — atlas art + four growable kinds
Replaces the procedural stem-and-circle draw with an ElvGames atlas-backed
Sprite2D. Crops now pick a per-kind 64×32 (or 80×32) sheet from
art/sprites/crops/ and slice cols 0..3 across the SOWN..READY stage range
(TILLED keeps the bare dirt rect). The plant sprite is anchored so its
bottom edge sits at the tile bottom, matching the tree convention.

Four kinds wired in: wheat, potato, corn, strawberry. The boot demo's
crop patch now plants one column per kind so all four show up in the
spring start state. Harvest outputs map: wheat/corn → grain,
potato/strawberry → vegetable.

Tooltip already capitalises crop_kind so 'Corn' / 'Strawberry' show
through with no UI change.
2026-05-15 19:39:57 +01:00
f67c12c51f Clear designation tile-highlight when jobs complete
Each entity completion handler (wall/floor/door/bed/torch/workbench/crate
/tree/rock/big_rock/grave_slot) now calls World.clear_designation_at(tile)
so the orange/blue/etc. highlight overlay disappears with the job.
BigRock iterates its footprint to clear all four tiles.

World.designation_ctl is set during the scene boot wire-up; the helper
no-ops when the controller is absent (e.g. headless tests).
2026-05-15 19:31:55 +01:00
22 changed files with 290 additions and 42 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dnojyvpvkbgp"
path="res://.godot/imported/FG_Crops_Corns.png-52c1e938a7347a7a7cc4f2d86fb0cf6a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/sprites/crops/FG_Crops_Corns.png"
dest_files=["res://.godot/imported/FG_Crops_Corns.png-52c1e938a7347a7a7cc4f2d86fb0cf6a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bog4kf8oxem3c"
path="res://.godot/imported/FG_Crops_Potato.png-88c3e45c5fd7242fdfc215cb59085e31.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/sprites/crops/FG_Crops_Potato.png"
dest_files=["res://.godot/imported/FG_Crops_Potato.png-88c3e45c5fd7242fdfc215cb59085e31.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c3wjj1t2ye2wr"
path="res://.godot/imported/FG_Crops_Strawberry.png-76d99d39b51e1c404f00c643db378da4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/sprites/crops/FG_Crops_Strawberry.png"
dest_files=["res://.godot/imported/FG_Crops_Strawberry.png-76d99d39b51e1c404f00c643db378da4.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://hbjgdtt0tkpe"
path="res://.godot/imported/FG_Crops_Wheat.png-e1d42717b3eaa01ef1c1aae3ae9445e7.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/sprites/crops/FG_Crops_Wheat.png"
dest_files=["res://.godot/imported/FG_Crops_Wheat.png-e1d42717b3eaa01ef1c1aae3ae9445e7.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -28,6 +28,11 @@ var stockpiles: Array = [] # Array of StorageDestination (StockpileZone for
# its _ready(). Don't access before the world scene is mounted.
var pathfinder = null
## Reference to the in-scene Designation controller. Wired by world.gd _ready
## so entities completing a job can call World.clear_designation_at(tile) to
## remove the lingering ghost paint without depending on the scene tree path.
var designation_ctl = null
# Phase 5 — build queue. Holds Wall/Floor/Door/Crate ghost entities (not yet
# completed). ConstructionProvider iterates this for the nearest buildable site.
# Entities call register_build_site() in _ready and unregister_build_site() when
@ -83,6 +88,14 @@ var grave_markers: Array = []
var items_needing_haul: Dictionary = {}
## Clear the designation ghost at `tile`, if any. Entities call this from
## their _complete / fell / mined handlers so the visual highlight disappears
## once the job is done. Safe no-op if designation_ctl isn't wired (headless).
func clear_designation_at(tile: Vector2i) -> void:
if designation_ctl != null:
designation_ctl.clear_cell(tile)
func register_work_provider(wp) -> void:
assert(wp != null, "World.register_work_provider: provider is null")
if not work_providers.has(wp):

View file

@ -279,6 +279,7 @@ func _complete() -> void:
if sprite != null:
sprite.modulate.a = 1.0
queue_redraw()
World.clear_designation_at(tile)
Audit.log("bed", "%s built at %s" % [label_text, tile])
# Phase 13 — notify BeautySystem so nearby tile beauty scores update.
var bs = World.get("beauty_system")

View file

@ -149,6 +149,9 @@ func mined() -> void:
Audit.log("big_rock", "mined 2×2 at %s; %d stone drops" % [origin_tile, STONE_DROPS_ON_MINE])
if Audio != null:
Audio.play_sfx(&"mine_tick")
# BigRocks span 2×2 — clear the designation stamp from every footprint tile.
for ft in footprint_tiles():
World.clear_designation_at(ft)
queue_free()

View file

@ -15,9 +15,12 @@ class_name Crop extends Node2D
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"
## Available crop kinds. Each maps to an ElvGames 64×32 sprite sheet
## (4 stages × 16w × 32h, plant anchored to bottom row).
const KIND_WHEAT: StringName = &"wheat"
const KIND_POTATO: StringName = &"potato"
const KIND_CORN: StringName = &"corn"
const KIND_STRAWBERRY: StringName = &"strawberry"
## 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.
@ -26,6 +29,20 @@ const STAGE_COUNT: int = 4
enum Stage { TILLED, SOWN, GROWING_1, GROWING_2, GROWING_3, READY }
## Per-kind sprite atlas. Strawberry / Corn are 80×32 (5 stages) — we still slice
## the first 4 cols, which gives the same progression (the 5th col is a
## post-harvest regrow frame we don't use).
const _CROP_TEXTURES: Dictionary = {
KIND_WHEAT: preload("res://art/sprites/crops/FG_Crops_Wheat.png"),
KIND_POTATO: preload("res://art/sprites/crops/FG_Crops_Potato.png"),
KIND_CORN: preload("res://art/sprites/crops/FG_Crops_Corns.png"),
KIND_STRAWBERRY: preload("res://art/sprites/crops/FG_Crops_Strawberry.png"),
}
## Width / height of one stage cell in pixels.
const _STAGE_W: int = 16
const _STAGE_H: int = 32
@export var crop_kind: StringName = KIND_WHEAT
@export var tile: Vector2i = Vector2i.ZERO
@ -37,6 +54,9 @@ var stage_progress: int = 0
# indoor detection for this crop instance so we don't flood the audit log.
var _logged_indoor: bool = false
# Child Sprite2D — created in _ready, region_rect updated whenever stage flips.
var _sprite: Sprite2D = null
const ITEM_SCENE: PackedScene = preload("res://scenes/entities/item.tscn")
@ -44,6 +64,7 @@ const ITEM_SCENE: PackedScene = preload("res://scenes/entities/item.tscn")
func _ready() -> void:
position = _tile_to_world(tile)
_build_sprite()
World.register_crop(self)
EventBus.sim_tick.connect(_on_sim_tick)
queue_redraw()
@ -62,6 +83,9 @@ func setup(p_tile: Vector2i, p_kind: StringName, p_stage: Stage = Stage.SOWN) ->
stage = p_stage
stage_progress = 0
position = _tile_to_world(tile)
if _sprite != null:
_sprite.texture = _texture_for(crop_kind)
_refresh_sprite_region()
queue_redraw()
Audit.log("crop", "spawned %s at %s (stage=%s)" % [crop_kind, tile, Stage.keys()[stage]])
@ -87,6 +111,7 @@ func on_harvest_tick() -> void:
it.setup(item_type, 1, tile)
stage = Stage.TILLED
stage_progress = 0
_refresh_sprite_region()
Audit.log("crop", "harvested %s at %s%s" % [crop_kind, tile, item_type])
queue_redraw()
@ -98,6 +123,7 @@ func on_sow_tick() -> void:
return
stage = Stage.SOWN
stage_progress = 0
_refresh_sprite_region()
Audit.log("crop", "sown %s at %s" % [crop_kind, tile])
queue_redraw()
@ -122,6 +148,7 @@ func _on_sim_tick(_n: int) -> void:
if stage_progress >= STAGE_TICKS:
stage_progress = 0
stage = (int(stage) + 1) as Stage
_refresh_sprite_region()
queue_redraw()
if stage == Stage.READY:
Audit.log("crop", "%s ready at %s" % [crop_kind, tile])
@ -156,53 +183,70 @@ static func from_dict(d: Dictionary) -> Dictionary:
# ── render ────────────────────────────────────────────────────────────────────
func _draw() -> void:
# Tilled-soil base: a small dark-earth square.
# Tilled-soil base draws under the plant sprite. Stays visible at every stage
# so the player sees the patch as cultivated.
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)
# ── sprite helpers ────────────────────────────────────────────────────────────
# Stem
draw_rect(Rect2(Vector2(-2.0, 5.0 - height), Vector2(4.0, height)), plant_color)
func _build_sprite() -> void:
_sprite = Sprite2D.new()
_sprite.name = "Sprite"
_sprite.texture = _texture_for(crop_kind)
_sprite.region_enabled = true
_sprite.centered = true
# 32-tall sprite anchored so its bottom edge sits at the tile's bottom row
# (local +8 from tile centre). Sprite half-height = 16 → offset.y = 8 - 16 = -8.
_sprite.offset = Vector2(0, -8)
# Draw the plant above the soil rect but below pawns/items.
_sprite.z_index = 0
add_child(_sprite)
_refresh_sprite_region()
# 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))
func _refresh_sprite_region() -> void:
if _sprite == null:
return
var idx := _sprite_stage_index(stage)
if idx < 0:
_sprite.visible = false
return
_sprite.visible = true
_sprite.region_rect = Rect2(idx * _STAGE_W, 0, _STAGE_W, _STAGE_H)
## Map game-stage to one of the 4 sprite columns. TILLED has no plant frame.
## SOWN..GROWING_2 step through cols 0..2; GROWING_3 and READY both land on
## col 3 (mature). The harvest designation overlay is what cues the player
## that READY is ready — sprite alone doesn't need a fifth frame.
func _sprite_stage_index(s: Stage) -> int:
match s:
Stage.TILLED: return -1
Stage.SOWN: return 0
Stage.GROWING_1: return 1
Stage.GROWING_2: return 2
Stage.GROWING_3: return 3
Stage.READY: return 3
_: return 0
# ── helpers ───────────────────────────────────────────────────────────────────
func _texture_for(kind: StringName) -> Texture2D:
return _CROP_TEXTURES.get(kind, _CROP_TEXTURES[KIND_WHEAT])
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)
KIND_WHEAT: return Item.TYPE_GRAIN
KIND_POTATO: return Item.TYPE_VEGETABLE
KIND_CORN: return Item.TYPE_GRAIN
KIND_STRAWBERRY: return Item.TYPE_VEGETABLE
_: return Item.TYPE_VEGETABLE
func _tile_to_world(t: Vector2i) -> Vector2:

View file

@ -181,4 +181,5 @@ func _complete() -> void:
if sprite != null:
sprite.modulate.a = 1.0
queue_redraw()
World.clear_designation_at(tile)
Audit.log("door", "door completed at %s" % tile)

View file

@ -172,4 +172,5 @@ func _complete() -> void:
# Floors do NOT block pathfinding — no pathfinder call here.
World.mark_floor_tile(tile, floor_material)
queue_redraw()
World.clear_designation_at(tile)
Audit.log("floor", "%s floor completed at %s" % [floor_material, tile])

View file

@ -224,4 +224,5 @@ func from_dict(d: Dictionary) -> void:
func _complete_dig() -> void:
_dug = true
queue_redraw()
World.clear_designation_at(tile)
Audit.log("grave_slot", "grave dug at %s (ready for burial)" % tile)

View file

@ -124,6 +124,7 @@ func mined() -> void:
Audit.log("rock", "mined at %s; %d stone drop" % [tile, STONE_DROPS_ON_MINE])
if Audio != null:
Audio.play_sfx(&"mine_tick")
World.clear_designation_at(tile)
queue_free()

View file

@ -245,6 +245,7 @@ func _complete() -> void:
if _light != null:
_light.enabled = _is_on
queue_redraw()
World.clear_designation_at(tile)
Audit.log("torch", "built at %s" % tile)
# Phase 13 — notify BeautySystem so nearby tile beauty scores update.
var bs = World.get("beauty_system")

View file

@ -119,6 +119,7 @@ func fell() -> void:
Audit.log("tree", "felled at %s; %d wood drops" % [tile, drops_count])
if Audio != null:
Audio.play_sfx(&"tree_fell")
World.clear_designation_at(tile)
queue_free()

View file

@ -241,4 +241,5 @@ func _complete() -> void:
queue_redraw()
queue_redraw()
World.clear_designation_at(tile)
Audit.log("wall", "%s wall completed at %s" % [wall_material, tile])

View file

@ -419,6 +419,7 @@ func _complete() -> void:
if _light != null:
_light.enabled = is_on()
queue_redraw()
World.clear_designation_at(tile)
Audit.log("workbench", "%s built at %s" % [label_text, tile])
# Phase 13 — notify BeautySystem so nearby tile beauty scores update.
# Hearth gets base beauty 4 (warm glow); other benches get 1.

View file

@ -143,6 +143,7 @@ func on_build_tick() -> void:
if build_progress >= BUILD_TICKS:
_completed = true
emit_signal("contents_changed")
World.clear_designation_at(tile)
Audit.log("crate", "built at %s (capacity %d)" % [tile, CAPACITY])
queue_redraw()

View file

@ -185,6 +185,9 @@ func _ready() -> void:
# Designation: bind the paint surface + the Selection guard.
designation_ctl.bind(designation_layer, selection)
# Expose on the autoload so entities can clear their ghost stamp on
# completion (Tree.fell, Wall._complete, etc.).
World.designation_ctl = designation_ctl
# Register all 10 providers — Decision iterates by .priority desc.
# doctor=9 > sleep=8 > eat=7 > construction=6 > chop=5 ≈ plant=5 > mine=4
@ -558,15 +561,30 @@ func _seed_phase5_demo_buildings() -> void:
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),
# Mixed crops east of the cabin, near the trees. One column per kind so the
# player sees the four atlas variants side-by-side from the boot demo.
var crop_plan: Array = [
[Vector2i(54, 24), Crop.KIND_WHEAT],
[Vector2i(54, 25), Crop.KIND_WHEAT],
[Vector2i(54, 26), Crop.KIND_WHEAT],
[Vector2i(55, 24), Crop.KIND_POTATO],
[Vector2i(55, 25), Crop.KIND_POTATO],
[Vector2i(55, 26), Crop.KIND_POTATO],
[Vector2i(56, 24), Crop.KIND_CORN],
[Vector2i(56, 25), Crop.KIND_CORN],
[Vector2i(56, 26), Crop.KIND_CORN],
[Vector2i(57, 24), Crop.KIND_STRAWBERRY],
[Vector2i(57, 25), Crop.KIND_STRAWBERRY],
[Vector2i(57, 26), Crop.KIND_STRAWBERRY],
]
for ct in crop_tiles:
var crop_tiles: Array[Vector2i] = []
for entry in crop_plan:
var ct: Vector2i = entry[0]
var kind: StringName = entry[1]
crop_tiles.append(ct)
var c: Crop = CROP_SCENE.instantiate()
add_child(c)
c.setup(ct, Crop.KIND_WHEAT, Crop.Stage.SOWN)
c.setup(ct, kind, 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
@ -578,7 +596,7 @@ func _seed_phase5_demo_buildings() -> void:
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" % [
Audit.log("world", "phase 7 demo: Millstone+Hearth built, %d crops sown (mixed kinds), %d pre-baked breads placed" % [
crop_tiles.size(), snack_tiles.size()
])