Repository navigation
PWA4: Show farmhouse and forester ranges while the planting tool is open - #9
Merged
Merged
Conversation
The game's planting tools draw no working areas, so a player marking crops or trees has to pin or re-select each farmhouse or forester to see where it reaches. While a crop or tree planting tool is open, the service now outlines every building that plants it, alongside the player's pins: - ToolEnteredEvent/ToolExitedEvent with `Tool is PlantingTool` (what the game's PlantingModeService uses) record the plant's resource group. PlantingToolGroupSpec is internal, so the tool group is not used. - The next UpdateSingleton scans EntityComponentRegistry.GetAll<Workplace> for buildings whose PlanterBuildingSpec.PlantableResourceGroup matches PlantableSpec.ResourceGroup, the pairing PlanterBuilding and PlantingToolButtonFactory use: farmhouses for crops, aquatic farmhouses for aquatic crops, foresters for trees and bushes. Construction sites are included, as pins already allow. The scan waits for the update because ToolService.SwitchTool posts the old tool's exit and the new tool's entry in one call, so switching between two crops of the same planters keeps their cached ranges and does no work. - A planter created or deleted while the tool is open triggers a rescan. - PinRefreshPlanner entries are now pinned, shown, or both, with one cache. Show(set) replaces the shown set: a building leaving it keeps its range only while pinned, and one joining it reuses a pin's cache. Navigation, selection and construction-mode handling apply to shown buildings exactly as to pins. - Clear pinned areas clears only pins; the tool's buildings stay until it closes. The renderer is released once nothing is drawn. Display only: all work stays in UpdateSingleton and event handlers that set fields; no tick, save or persistence interface, no patches. Tests (tests/Program.cs, 67 -> 95 checks): - PlantingRanges.Shows, a Unity-free rule linked into Checks.csproj. - Planner counts: opening a crop's tool queries each farmhouse once and rebuilds once; another crop for the same farmhouses is 0/0; switching to a tree queries only the forester; closing is 0 queries and 1 rebuild back to the pins; pinned-and-shown buildings keep one cache. - The rule on the game's Blueprints.zip: every plantable shows at least one planter, crops only farmhouses, trees and bushes only foresters; every planter is a workplace with an access point. - The service's tool handlers, driven with the game's own PlantingTool, CancelPlantingTool and tool events through reflection. Before the fix the checks do not compile (CS0103 PlantingRanges, CS1061 no Show on PinRefreshPlanner). Nine mutations (Show dropping pinned buildings, Add refusing a shown one, Remove dropping a shown one, Show forgetting caches, a case-insensitive rule, a rule accepting buildings without a group, exit not hiding, any tool showing planters, entry not scheduling a scan) each fail a check. The registry scan itself runs only in game. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Review found that no check exercised the service's own wiring of the planting tool: deleting `_planner.Show(_planters)` from ShowPlanters, or reverting ClearAll to wipe everything, still passed all 95 checks. Two offline checks on the service instance the checks already build: - ClearAll with one pinned entity and one the tool shows leaves only the shown one drawn and no pins. - ShowPlanters (the scan UpdateSingleton starts with) after leaving the tool, with no pins, empties the planner and clears the scan flag. UpdateSingleton itself reads Time.unscaledTime and cannot run outside the game; the registry scan, the create/delete rescans and the release on the last unpin remain in-game checks. Both checks fail on those two mutations and pass on the fix (97 checks). VALIDATION.md: - Playtest step 2 now leaves the planting tool before checking the pinned forester, since a tree tool outlines every forester by itself. - The Automated checks bullet goes back to its 1.0.0 wording. That section records the 1.0.0 release (it still says 38 checks) and is refreshed at release time together with the check count. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
9 tasks
- WorkAreaService constructor: keep PWA4's EntityComponentRegistry and PWA2's ILoc. - tests/Program.cs: move the planting-rule and planner Show checks above the game-free split so CI runs them, and raise GameChecks to 56. Full run: 104/104; no-argument run: 48 passed, 56 skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kramsey458
marked this pull request as ready for review
September 22, 2026 16:41
kramsey458
added a commit
that referenced
this pull request
Sep 22, 2026
- WorkAreaService constructor: keep PWA2's ILoc alongside PWA3's EntityRegistry and SettlementReferenceService, and keep the localized clear button next to the pin-file restore in PostLoad. - tests/Program.cs: keep the PinStore checks above the game-free split, raise GameChecks to 65, and allow the pin file's format, file names and argument-check text in the hard-coded UI text check. Full run: 142/142; no-argument run: 77 passed, 65 skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While a crop or tree planting tool is open, the mod now outlines the working area of every building that can plant the selected plant. The outlines are drawn alongside the player's pins:
Buildings still under construction are included. The outlines disappear when you leave the planting tool, and pins are unaffected.
This is display only. All work stays in
UpdateSingleton, the event handlers only set fields, and nothing adds a tick, save or persistence interface or a Harmony patch.Items
PWA4: show farmhouse and forester ranges while the planting tool is open
What changed
ToolEnteredEventandToolExitedEventwithTool is PlantingToolrecord only the selected plant'sResourceGroup. The game's ownPlantingModeServiceuses the same hook.UpdateSingletonscansEntityComponentRegistry.GetAll<Workplace>(). It keeps each building whosePlanterBuildingSpec.PlantableResourceGroupmatches the plant, usingPlantingRanges.Shows, a Unity-free rule. This is the same pairingPlanterBuilding.GetAllowedPlantablesandPlantingToolButtonFactoryuse (ordinal==).ToolService.SwitchToolInternalposts the old tool's exit and the new tool's entry in one call. Waiting means that switching between two crops planted by the same farmhouses keeps their cached ranges and costs 0 queries.PinRefreshPlannerentries are now pinned, shown by the tool, or both, with one cache per building.Show(set)replaces the shown set. A building that leaves the set keeps its range only while it is pinned. Navigation, selection and construction-mode handling apply to shown buildings exactly as they do to pins.EntityComponent.Initializeregisters the entity before it postsEntityInitializedEvent, andInternalDeleteunregisters it before it postsEntityDeletedEvent, so the scan sees the current set.Tests (
tests/Program.cs, +30 checks)PlantingRanges.Showsrule.OnToolEntered/OnToolExitedthrough reflection with the game's ownPlantingTool,CancelPlantingToolandToolEntered/ExitedEvent.Workplaceis still anIRegisteredComponent, as a guard against game updates.Blueprints.zip. Every plantable shows at least one planter. Crops show only farmhouses, and trees and bushes only foresters. Carrot, Cattail, Pine and BlueberryBush map exactly. Every planter hasWorkplaceSpecandBuildingAccessibleSpec.[OnEvent]subscription checks.ClearAllkeeps the tool's building and drops only the pin. The scan after leaving the tool, with no pins, empties the planner.Fail before, pass after
Program.cs(109,7): error CS0103: The name 'PlantingRanges' does not exist in the current contextProgram.cs(118,9): error CS1061: 'PinRefreshPlanner<FakePin, ...>' does not contain a definition for 'Show'PlantingRanges.cslink left inChecks.csproj, the build instead fails with CS2001, file not found._planner.Show(_planters)fromShowPlanters.ClearAllto wipe everything.Tests
bb694dd, #6 head)7ec9ee2)build.ps1 -GameDir <Timberborn>(builds, runs Checks, packages)dotnet run --project tests/Checks.csproj -c Release -- <Timberborn> <dll> <package>Co-op impact
None. The change is display only and does not affect simulation or the wire format, so co-op players do not need to update together.
NavMeshUpdater.ProcessInstantChanges, which clears the cache in the same call.GetAll<T>only reads the registry and never inserts into it.OnInitialized,OnDeletedand the tool handlers only read_plantingand callGetComponenton a live entity, so they cannot throw inside a simulation event post.Proposed CHANGELOG lines
Needs in-game / two-player testing
Decisions for the maintainer
PlantingToolGroupSpecis internal, and the chosen plant decides farmhouses versus foresters.Merge coordination
claude/checks-ci). CI: run the pin-logic checks without the game on GitHub Actions #7 hard-codesconst int GameChecks = 27and returns early after the 11 PinSet checks when it gets no arguments. Once PWA1: re-query only the pins a navigation change can reach #6, CI: run the pin-logic checks without the game on GitHub Actions #7 and this PR are combined:var game = Path.GetFullPath(args[0]);, below the planner and planting-rule checks.GameChecks = 49, plus any game-dependent checks PWA2: Localize the work-area panel and clear-button text #8 adds.claude/localize-ui). PWA2: Localize the work-area panel and clear-button text #8 changes theWorkAreaServiceconstructor (addsILoc) andClearAll/Notify, so it will conflict textually with this PR's constructor parameter (EntityComponentRegistry) and itsClearAll/Resetchanges. PWA1: re-query only the pins a navigation change can reach #6 already conflicts with PWA2: Localize the work-area panel and clear-button text #8 in the same places. This PR adds no UI strings.Release-time doc updates (not done here: they are release text or the live site)
docs/, built frommain):docs/index.html("does no work while nothing is pinned, and releases its meshes when you clear").docs/troubleshooting.html("does no work while nothing is pinned").docs/faq.html("nothing runs while there are no pins, and the mesh is released when you clear").Review
Three adversarial reviewers checked
79e1790. All three approved.docs/is the live site frommain.7ec9ee2: the Automated checks bullet is back to its 1.0.0 wording and is listed for release time.7ec9ee2with two offline checks on the service instance. They fail when_planner.Show(_planters)is removed fromShowPlantersand whenClearAllwipes the tool's buildings.UpdateSingletoncannot run offline (Time.unscaledTimeis an ECall), so the registry scan, the create and delete rescans (the two-player item) and the release on the last unpin stay in game only.Workplace/IRegisteredComponentcheck cannot fail against the DLLs the mod was built with. Kept, not counted as scan coverage. It loads the type from the game folder passed at run time, so it catches a game update that drops the interface when the checks are re-run against a new install, which VALIDATION.md asks for after each update.🤖 Generated with Claude Code