ConstructionTask: placing a building enqueues construction #70

Closed
opened 2026-09-07 20:37:20 +01:00 by liamjd · 1 comment
Owner

Part of milestone #5. Depends on #66 and #67.

The first concrete task type. Buildings.place() already carries the comment that status will become PLANNED once task management exists.

AC:

  • Buildings.place() creates the building with status PLANNED and enqueues a ConstructionTask targeting the building's entrance cell
  • Starting work moves the building to UNDER_CONSTRUCTION; work_remaining starts at type.build_time ticks
  • Completion moves the building to BUILT and emits a signal (building_built or a status-changed signal; decide and note in the PR)
  • Buildings receives its TaskManager by injection from game.gd, the same way it receives map, so the registry still works standalone in tests
  • Cancelling the task while PLANNED removes the building record (the deconstruction issue defines the UI that triggers this)
  • Unit tests through the registry: place enqueues one task; completing it flips status; count_of and at_limit still count PLANNED buildings toward the limit
Part of milestone #5. Depends on #66 and #67. The first concrete task type. `Buildings.place()` already carries the comment that status will become PLANNED once task management exists. AC: - `Buildings.place()` creates the building with status PLANNED and enqueues a `ConstructionTask` targeting the building's entrance cell - Starting work moves the building to UNDER_CONSTRUCTION; `work_remaining` starts at `type.build_time` ticks - Completion moves the building to BUILT and emits a signal (`building_built` or a status-changed signal; decide and note in the PR) - `Buildings` receives its `TaskManager` by injection from game.gd, the same way it receives `map`, so the registry still works standalone in tests - Cancelling the task while PLANNED removes the building record (the deconstruction issue defines the UI that triggers this) - Unit tests through the registry: place enqueues one task; completing it flips status; count_of and at_limit still count PLANNED buildings toward the limit
Author
Owner

AC correction, from #88 (PR #107).

This issue's second AC reads:

work_remaining starts at type.build_time ticks

All three parts of that are now stale:

  • The field is build_days, not build_time.
  • It is days, not ticks — convert with type.build_work_ticks(), which is the single conversion site. Do not call GameCalendar.days_to_ticks() here directly, or the conversion exists twice.
  • The unit is pawn-days, i.e. labour, not elapsed time. A 10 pawn-day mine is 10 days for one pawn and 3.3 for three. work_remaining counts work actually performed, so walking to the site and hauling do not decrement it.

So the line should read: work_remaining starts at type.build_work_ticks().

One AC was also deferred from #88 to here, because it needs a task type to assert against: a BuildingType authored at N days yields the matching work_remaining on the ConstructionTask it produces. Worth adding to this issue's test list. The deferral is recorded in test/unit/test_building_type.gd's docstring.

Note also that colony_rocket.tres has build_days = 0.0 deliberately — the Colony Centre lands already built. Whatever creates construction tasks should decide what a zero means: no task at all, or a task that completes on its first work tick.

**AC correction, from #88 (PR #107).** This issue's second AC reads: > `work_remaining` starts at `type.build_time` ticks All three parts of that are now stale: - The field is **`build_days`**, not `build_time`. - It is **days**, not ticks — convert with `type.build_work_ticks()`, which is the single conversion site. Do not call `GameCalendar.days_to_ticks()` here directly, or the conversion exists twice. - The unit is **pawn-days**, i.e. labour, not elapsed time. A 10 pawn-day mine is 10 days for one pawn and 3.3 for three. `work_remaining` counts work actually performed, so walking to the site and hauling do not decrement it. So the line should read: *`work_remaining` starts at `type.build_work_ticks()`*. One AC was also deferred from #88 to here, because it needs a task type to assert against: **a `BuildingType` authored at N days yields the matching `work_remaining` on the `ConstructionTask` it produces.** Worth adding to this issue's test list. The deferral is recorded in `test/unit/test_building_type.gd`'s docstring. Note also that `colony_rocket.tres` has `build_days = 0.0` deliberately — the Colony Centre lands already built. Whatever creates construction tasks should decide what a zero means: no task at all, or a task that completes on its first work tick.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liamjd/UntitledColonyBuilder#70
No description provided.