Compose buildings from definitions and interaction components #34

Closed
opened 2026-08-14 11:53:09 +00:00 by metaheavens · 1 comment
Owner

Problem

Building.gd, BuildController.gd, WorldMapContent.gd, and GameState.gd contain repeated building_type switches for visuals, animation, prices, available actions, menus, placement exceptions, production, and map markers. BuildController in particular must know the behavior and UI of every building.

Direction

Create a BuildingDefinition resource for static metadata such as name, icon, cost, map style, and scene. Give building scenes composable capability nodes for behavior and interactions, such as ProductionComponent, InventoryComponent, ResearchProvider, CraftingProvider, and ActionProvider. Context actions should be queried from the selected building rather than assembled by a central building-type switch.

Migrate incrementally, starting with mothership, extractor, transport hub, lab, and ship crafter behavior that already exercises different capabilities.

Acceptance criteria

  • A building exposes its available context actions through components or an interface; BuildController does not switch on building_type to decide which action buttons or menu to show.
  • Building visuals and animation live in the building scene/components rather than Building.gd drawing branches.
  • Cost, icon, display name, and map marker style come from BuildingDefinition.
  • Production and storage behavior is attached only to buildings that need it.
  • Adding a simple building with an existing set of capabilities requires a definition/scene and no edits to BuildController, Building.gd, WorldMapContent.gd, or GameState type switches.
  • Existing build placement, action-menu folding, production, and map-marker tests continue to pass.
## Problem Building.gd, BuildController.gd, WorldMapContent.gd, and GameState.gd contain repeated building_type switches for visuals, animation, prices, available actions, menus, placement exceptions, production, and map markers. BuildController in particular must know the behavior and UI of every building. ## Direction Create a BuildingDefinition resource for static metadata such as name, icon, cost, map style, and scene. Give building scenes composable capability nodes for behavior and interactions, such as ProductionComponent, InventoryComponent, ResearchProvider, CraftingProvider, and ActionProvider. Context actions should be queried from the selected building rather than assembled by a central building-type switch. Migrate incrementally, starting with mothership, extractor, transport hub, lab, and ship crafter behavior that already exercises different capabilities. ## Acceptance criteria - A building exposes its available context actions through components or an interface; BuildController does not switch on building_type to decide which action buttons or menu to show. - Building visuals and animation live in the building scene/components rather than Building.gd drawing branches. - Cost, icon, display name, and map marker style come from BuildingDefinition. - Production and storage behavior is attached only to buildings that need it. - Adding a simple building with an existing set of capabilities requires a definition/scene and no edits to BuildController, Building.gd, WorldMapContent.gd, or GameState type switches. - Existing build placement, action-menu folding, production, and map-marker tests continue to pass.
Author
Owner

Implemented in commit 0504b24. Buildings now use BuildingDefinition resources for metadata, costs, menu/map presentation and placement rules; visual scenes compose action providers, while BuildController and GameState query definitions/capabilities. Added test_building_composition plus updated animation, placement, popup, map and replacement regressions. Targeted building tests pass.

Implemented in commit 0504b24. Buildings now use BuildingDefinition resources for metadata, costs, menu/map presentation and placement rules; visual scenes compose action providers, while BuildController and GameState query definitions/capabilities. Added test_building_composition plus updated animation, placement, popup, map and replacement regressions. Targeted building tests pass.
Sign in to join this conversation.
No labels
No milestone
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
metaheavens/spaceship#34
No description provided.