Phase 13: Rooms + Auto-roof + Beauty + Dirtiness + Cleaning
Three-agent fan-out — Opus pre-wrote Room class, World.rooms/room_at_tile/is_indoor, 4 EventBus signals before dispatch so the slices ran fully parallel. DECISION: Big-room UX = bump auto-roof cap to 16, banner above. Cabin (24 tiles) intentionally exceeds cap to exercise the warning path; a 5×5 test shed (9 interior tiles) was added to exercise the roof path. Room detection (Agent A): - scenes/world/room.gd — class_name Room, tiles/bounds/is_under_roof, contains_tile() bounds-then-list-checked, recompute_bounds() - scenes/world/room_detector.gd — class_name RoomDetector, BFS 4-dir from floor/door tiles, walls/terrain as boundary, doors counted as room interior. Detects up to 4× cap; auto-roofs only ≤16. - World.mark_wall_tile/mark_floor_tile/mark_door_tile hook BFS recompute - Door._complete() now erases wall-layer stamp + registers door tile - Designation.TOOL_NO_ROOF paint mode wired (UI button deferred Phase 17) - EventBus.room_changed / room_too_large signals Indoor/Shelter (Agent B): - Pawn._is_sheltered() rerouted: World.is_indoor() first, floor-proxy fallback - IndoorTintOverlay Node2D — _draw fills roofed-room tiles at α=0.10 warm - Crop._on_sim_tick skips stage advance when World.is_indoor(tile) Beauty + Dirtiness + Cleaning + Room thoughts (Agent C): - BeautySystem sparse map, linear falloff radius=3, Quality multiplier (SHODDY 0.5 → LEGENDARY 2.5). Base: Bed +2, Workbench +1, Torch +3, Hearth +4 - DirtinessSystem 0-100, tier crossings (clean<25/dirty<60/filthy≥60) emit tile_dirtiness_changed. bump/bump_clean/bump_pawn_traffic API - CleaningProvider priority=2, KIND_CLEAN toil, 2.5 dirt/tick for ~40 ticks - Bed/Torch/Workbench _complete() now register with BeautySystem - 7 room mood thoughts: clean_room (+2), dirty_room (-3), filthy_room (-6), beautiful_room (+4), ugly_room (-3), slept_in_room (+3 EVENT, wires Ph 17), ate_without_table (-3 EVENT, wires Ph 17) - Pawn._sync_room_thoughts called from _process_thoughts after cold block, defensive against null rooms/systems Integration recovery (Opus): - Agent C's BeautySystem/DirtinessSystem/CleaningProvider/IndoorTintOverlay instantiation in world.gd never landed (only field declarations + entity hooks survived). Added preloads + runtime add_child + autoload bindings + CleaningProvider registration + furniture pre-seed in _ready - Added _prestamp_test_shed_for_room_detector with _spawn_complete_wall/floor helpers so a 5×5 visible shed exercises the auto-roof path at boot MCP runtime verified: - Rooms: cabin Room#2 size=24 roofed=false (room_too_large fires), shed Room#3 size=9 roofed=true (auto-roof active) - beauty_map size=50 around prebuilt furniture; bed at (47,24) beauty=4.0 - Bram teleported to (36, 25) in shed → indoor=true, sheltered=true, thoughts=[clean_room +2], mood=52.0 - Screenshot: shed walls + brown floor visible; cabin warmly torch-lit; Spring 1/12 indicator; Day 1 07:52 Delegation: 3× gdscript-refactor (Sonnet) agents in parallel; integration recovery + MCP verify on Opus. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
92f4e5c945
commit
9cf9b7dbfd
28 changed files with 1286 additions and 28 deletions
65
scenes/ai/cleaning_provider.gd
Normal file
65
scenes/ai/cleaning_provider.gd
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
class_name CleaningProvider extends WorkProvider
|
||||
## Phase 13 — WorkProvider for the Cleaning work category.
|
||||
##
|
||||
## Priority 2: fires when there is nothing more productive to do
|
||||
## (below hauling=3, above rest=0).
|
||||
##
|
||||
## make_job / find_best_for logic:
|
||||
## Scan DirtinessSystem.dirt_map for tiles with dirt >= DIRTY_THRESHOLD.
|
||||
## Pick the nearest to the pawn by Manhattan distance.
|
||||
## Build a 2-toil job: walk_to(tile) → kind_clean(tile).
|
||||
##
|
||||
## There is no Cleaning skill yet (Phase 17+ skill matrix). The clean toil
|
||||
## takes a flat CLEAN_TICKS sim ticks to reduce dirt from any level to 0.
|
||||
##
|
||||
## JobRunner._tick_clean reduces DirtinessSystem.dirt_at(tile) by
|
||||
## DIRT_REDUCTION_PER_TICK each sim tick until dirt <= 0.
|
||||
##
|
||||
## Audit.log fires on job start and on toil completion (via JobRunner).
|
||||
|
||||
## Dirt level at or above which a tile is worth cleaning.
|
||||
const DIRTY_THRESHOLD: float = 25.0
|
||||
|
||||
## Base number of sim ticks to clean a tile from any level to 0.
|
||||
## No skill modifier for now; Phase 17 wires skill × speed.
|
||||
const CLEAN_TICKS: int = 40
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
category = &"clean"
|
||||
priority = 2
|
||||
|
||||
|
||||
# ── WorkProvider override ─────────────────────────────────────────────────────
|
||||
|
||||
## Returns a cleaning Job for `pawn`, or null if no dirty tiles exist.
|
||||
## Picks the tile closest to `pawn` (Manhattan distance) with dirt >= DIRTY_THRESHOLD.
|
||||
func find_best_for(pawn) -> Job:
|
||||
# Safety — dirtiness system may not be wired yet (Agent A rooms arrive slightly later).
|
||||
if World.get("dirtiness_system") == null:
|
||||
return null
|
||||
|
||||
var ds = World.dirtiness_system
|
||||
if ds == null:
|
||||
return null
|
||||
|
||||
var best_tile: Vector2i = Vector2i(-1, -1)
|
||||
var best_dist: int = 999999
|
||||
|
||||
for tile in ds.dirt_map.keys():
|
||||
var dirt_val: float = float(ds.dirt_map[tile])
|
||||
if dirt_val < DIRTY_THRESHOLD:
|
||||
continue
|
||||
var d: int = abs(tile.x - pawn.tile.x) + abs(tile.y - pawn.tile.y)
|
||||
if d < best_dist:
|
||||
best_dist = d
|
||||
best_tile = tile
|
||||
|
||||
if best_tile == Vector2i(-1, -1):
|
||||
return null
|
||||
|
||||
var j := Job.new()
|
||||
j.label = "Clean (%d,%d)" % [best_tile.x, best_tile.y]
|
||||
j.toils.append(Toil.walk_to(best_tile))
|
||||
j.toils.append(Toil.clean_at(best_tile))
|
||||
return j
|
||||
1
scenes/ai/cleaning_provider.gd.uid
Normal file
1
scenes/ai/cleaning_provider.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d3gw4tpsuvwiu
|
||||
|
|
@ -109,6 +109,8 @@ func tick() -> void:
|
|||
_tick_rescue(t)
|
||||
Toil.KIND_TREAT:
|
||||
_tick_treat(t)
|
||||
Toil.KIND_CLEAN:
|
||||
_tick_clean(t)
|
||||
|
||||
if t.done:
|
||||
job.advance()
|
||||
|
|
@ -746,6 +748,58 @@ func _tick_treat(t) -> void:
|
|||
t.done = true
|
||||
|
||||
|
||||
## Execute one tick of a CLEAN toil.
|
||||
##
|
||||
## First tick (started=false):
|
||||
## - Validate the dirtiness system is available. If not, skip immediately.
|
||||
## - Validate the target tile still has dirt >= DIRTY_THRESHOLD. If not, skip.
|
||||
## - Mark started=true and log the clean start.
|
||||
##
|
||||
## Every tick:
|
||||
## - Reduce dirt at the tile by DIRT_REDUCTION_PER_TICK via DirtinessSystem.bump_clean().
|
||||
## - Done when dirt <= 0.
|
||||
##
|
||||
## DIRTY_THRESHOLD and DIRT_REDUCTION_PER_TICK mirror CleaningProvider constants.
|
||||
## 100.0 / 40 ticks = 2.5/tick ensures any tile (max 100 dirt) is clean in 40 ticks.
|
||||
const _CLEAN_DIRTY_THRESHOLD: float = 25.0
|
||||
const _DIRT_REDUCTION_PER_TICK: float = 2.5 # 100 / 40 ticks
|
||||
|
||||
func _tick_clean(t) -> void:
|
||||
var tile := Vector2i(int(t.data.get("clean_x", 0)), int(t.data.get("clean_y", 0)))
|
||||
|
||||
# Safety — dirtiness system may not be wired yet during early boot.
|
||||
var ds = World.get("dirtiness_system")
|
||||
if ds == null:
|
||||
t.done = true
|
||||
return
|
||||
|
||||
if not t.data.get("started", false):
|
||||
# ── first-tick: validate tile is still worth cleaning ─────────────────
|
||||
var current_dirt: float = ds.dirt_at(tile)
|
||||
if current_dirt < _CLEAN_DIRTY_THRESHOLD:
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s clean: tile %s already clean (dirt=%.1f) — skipping" % [pawn.pawn_name, tile, current_dirt]
|
||||
)
|
||||
t.done = true
|
||||
return
|
||||
t.data["started"] = true
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s clean start at %s (dirt=%.1f)" % [pawn.pawn_name, tile, current_dirt]
|
||||
)
|
||||
|
||||
# ── per-tick cleaning ──────────────────────────────────────────────────────
|
||||
ds.bump_clean(tile, _DIRT_REDUCTION_PER_TICK)
|
||||
var remaining: float = ds.dirt_at(tile)
|
||||
if remaining <= 0.0:
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s clean done at %s" % [pawn.pawn_name, tile]
|
||||
)
|
||||
t.done = true
|
||||
|
||||
|
||||
## Resolve the patient Pawn node from the NodePath stored in `t.data["patient"]`.
|
||||
## Returns null and logs if the node is absent or no longer valid.
|
||||
## Shared by _tick_rescue and _tick_treat.
|
||||
|
|
|
|||
|
|
@ -129,6 +129,98 @@ static func cold_thought() -> Thought:
|
|||
return t
|
||||
|
||||
|
||||
## ── Phase 13 — Room beauty / dirtiness thoughts ─────────────────────────────
|
||||
# Synced in Pawn._process_thoughts() after the damp/soaked/cold block.
|
||||
# All are PERSISTENT; the sync removes old ones before adding the active tier.
|
||||
|
||||
## Positive mood boost when average room beauty >= 4.0.
|
||||
## modifier=+4, max_stacks=1, PERSISTENT.
|
||||
static func beautiful_room() -> Thought:
|
||||
var t := Thought.new()
|
||||
t.id = &"beautiful_room"
|
||||
t.label = "Beautiful room"
|
||||
t.modifier = 4
|
||||
t.lifetime = Thought.Lifetime.PERSISTENT
|
||||
t.max_stacks = 1
|
||||
return t
|
||||
|
||||
|
||||
## Negative mood penalty when average room beauty < 0 (e.g. corpses present, Phase 14).
|
||||
## modifier=-3, max_stacks=1, PERSISTENT.
|
||||
static func ugly_room() -> Thought:
|
||||
var t := Thought.new()
|
||||
t.id = &"ugly_room"
|
||||
t.label = "Ugly room"
|
||||
t.modifier = -3
|
||||
t.lifetime = Thought.Lifetime.PERSISTENT
|
||||
t.max_stacks = 1
|
||||
return t
|
||||
|
||||
|
||||
## Positive mood boost when average room dirtiness < 25 (clean tier).
|
||||
## modifier=+2, max_stacks=1, PERSISTENT.
|
||||
static func clean_room() -> Thought:
|
||||
var t := Thought.new()
|
||||
t.id = &"clean_room"
|
||||
t.label = "Clean room"
|
||||
t.modifier = 2
|
||||
t.lifetime = Thought.Lifetime.PERSISTENT
|
||||
t.max_stacks = 1
|
||||
return t
|
||||
|
||||
|
||||
## Negative mood penalty when average room dirtiness is in dirty tier (25..60).
|
||||
## modifier=-3, max_stacks=1, PERSISTENT.
|
||||
static func dirty_room() -> Thought:
|
||||
var t := Thought.new()
|
||||
t.id = &"dirty_room"
|
||||
t.label = "Dirty room"
|
||||
t.modifier = -3
|
||||
t.lifetime = Thought.Lifetime.PERSISTENT
|
||||
t.max_stacks = 1
|
||||
return t
|
||||
|
||||
|
||||
## Strong negative mood penalty when average room dirtiness >= 60 (filthy tier).
|
||||
## modifier=-6, max_stacks=1, PERSISTENT.
|
||||
static func filthy_room() -> Thought:
|
||||
var t := Thought.new()
|
||||
t.id = &"filthy_room"
|
||||
t.label = "Filthy room"
|
||||
t.modifier = -6
|
||||
t.lifetime = Thought.Lifetime.PERSISTENT
|
||||
t.max_stacks = 1
|
||||
return t
|
||||
|
||||
|
||||
## Positive mood boost after sleeping in an indoor room.
|
||||
## modifier=+3, max_stacks=1, EVENT, ~1200 ticks (~60 in-game sec at 1×).
|
||||
## Phase 17 wires this into the sleep toil; factory added here for catalog completeness.
|
||||
static func slept_in_room() -> Thought:
|
||||
var t := Thought.new()
|
||||
t.id = &"slept_in_room"
|
||||
t.label = "Slept in a room"
|
||||
t.modifier = 3
|
||||
t.lifetime = Thought.Lifetime.EVENT
|
||||
t.ticks_remaining = 1200
|
||||
t.max_stacks = 1
|
||||
return t
|
||||
|
||||
|
||||
## Negative mood penalty for eating without a table nearby.
|
||||
## modifier=-3, max_stacks=1, EVENT, ~800 ticks (~40 in-game sec at 1×).
|
||||
## Phase 17 wires this into the eat toil; factory added here for catalog completeness.
|
||||
static func ate_without_table() -> Thought:
|
||||
var t := Thought.new()
|
||||
t.id = &"ate_without_table"
|
||||
t.label = "Ate without a table"
|
||||
t.modifier = -3
|
||||
t.lifetime = Thought.Lifetime.EVENT
|
||||
t.ticks_remaining = 800
|
||||
t.max_stacks = 1
|
||||
return t
|
||||
|
||||
|
||||
## Small mood boost after eating a cooked meal or bread.
|
||||
## Fires in _tick_eat when item_type is TYPE_MEAL or TYPE_BREAD.
|
||||
## Stacks up to 3 (multiple good meals compound, but cap at 3).
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ const KIND_EAT: StringName = &"eat" # Consume pawn.carried_item and
|
|||
const KIND_SLEEP: StringName = &"sleep" # Sleep in a Bed (or on the floor) until pawn.sleep is full
|
||||
const KIND_RESCUE: StringName = &"rescue" # Marker: doctor has visited the downed pawn; single-tick no-op
|
||||
const KIND_TREAT: StringName = &"treat" # Multi-tick: apply medicine until patient HP ≥ revive threshold + no bleeding
|
||||
const KIND_CLEAN: StringName = &"clean" # Multi-tick: reduce dirt on a tile until clean (Phase 13 Cleaning category)
|
||||
|
||||
var kind: StringName = KIND_IDLE
|
||||
## Toil-specific params — all values must be int, float, bool, String, Dict, or Array.
|
||||
|
|
@ -183,6 +184,25 @@ static func treat(patient_path: NodePath) -> Toil:
|
|||
return t
|
||||
|
||||
|
||||
## Multi-tick cleaning action on a floor tile.
|
||||
## `tile` is the Vector2i world-tile coordinate to clean; stored as int pair for JSON safety.
|
||||
## JobRunner._tick_clean reduces DirtinessSystem.dirt_at(tile) by ~2.5/tick until dirt <= 0
|
||||
## (40 base ticks per tile; Phase 17 may add skill bonus).
|
||||
##
|
||||
## data keys:
|
||||
## "clean_x" / "clean_y" — tile coords (ints, JSON-safe)
|
||||
## "started" — bool; false until first tick
|
||||
static func clean_at(tile: Vector2i) -> Toil:
|
||||
var t := Toil.new()
|
||||
t.kind = KIND_CLEAN
|
||||
t.data = {
|
||||
"clean_x": tile.x,
|
||||
"clean_y": tile.y,
|
||||
"started": false,
|
||||
}
|
||||
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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue