Pawn knows which task it is walking to #116
No reviewers
Labels
No labels
assets
bug
duplicate
enhancement
help wanted
invalid
question
testing
ui
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
liamjd/UntitledColonyBuilder!116
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "112-pawn-knows-its-task"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pawn.PawnState.WORKINGwas declared and unreachable: every arriving pawn was idled, so nothing could tell "arrived because it was wandering" from "arrived at the cell it was sent to in order to work". The rule now is:Pawn.current_task_id, defaulting to -1Pawns.tasks: TaskManager, injected bygame.gdbeside the existingbuildings.tasksPawns.assign_task()/clear_task(), and the three signal handlers that clearTaskManager.task_releasedandTaskManager.get_task()Two traps this hit, both worth knowing
The signals are connected from the
taskssetter, not_ready().game.gdinjects the manager from its own_ready(), and child_ready()runs first — so a connection made inPawns._ready()sees a null manager and never fires. Same shape as the re-path signal race intest_pawn_repath.gd's header.Clearing is looked up by
current_task_id, nottask.assignee.cancel()andrelease()both setassignee = -1before they emit, so a handler readingtask.assigneesearches for pawn -1 and silently finds nothing. The lookup bycurrent_task_idis also independent of whatever the manager later does toassignee.stop()deliberately does not clear the task.repath_pawns()is stop-then-move_to, so clearing there would drop the task of every pawn a building re-routed — the #56 scenario this issue exists to handle. Two tests pin it.Verification
test/unit/test_pawn_task_arrival.gd, 14 tests, written before the implementation and red for the right reason at that point. Full suite headless: 536 passing, 0 failing, 1 risky/pending (pre-existing), no orphans.Not verified visually, and does not need to be: nothing here draws. The pawn reaching
WORKINGhas no on-screen consequence yet — that arrives with #75.Left undone
remove()on a pawn holding a claimed task still leaves that task assigned to a dead id. The fix is arelease()from the removal path, but it wants #111's decision on whetherassigneestays single-valued first.assign_task()over a pawn that already holds a task silently drops the old one, which leaves that task CLAIMED with an assignee that is no longer working on it. Orchestration belongs to #75, so it is that ticket's to guard.Closes #112
🤖 Generated with Claude Code