2026-08-14 21:44:28 +02:00
|
|
|
class_name BuildingDefinition
|
|
|
|
|
extends Resource
|
|
|
|
|
|
|
|
|
|
@export var definition_id: String
|
|
|
|
|
@export var display_name: String
|
|
|
|
|
@export_multiline var description: String
|
#138: structures and doctrines cost more than rocks, and more the deeper they are
Both halves of the ticket, in the shape vessels have used since gas bombers
and laser ships: a definition carries an ore figure and, when it wants more
than ore, a dictionary that IS the price. `building_costs()` and
`skill_costs()` answer it the way `product_costs()` already did, so there is
one question with one answer whatever is being bought, and every payment
path now goes through `spend_resources` rather than `spend`.
Seven of ten structures and thirteen of seventeen doctrines now want gas,
energy or dark matter alongside their rocks, and the totals climb with tree
depth - structures 16/31/58/62/96 by depth, doctrines 15/30/73/96/143/258/530.
The constraint that shaped the table is REACHABILITY, and it is the reason
some prices stayed ore-only. Energy exists only where a gas burner stands,
and a gas burner needs Power Systems - so nothing at or before that depth
may be priced in energy, or it is a wall with no way through. Dark matter is
rarer still and appears once, on the deepest node in the game. The extractor
stays rocks-only despite its depth allowing gas, because the quest chain
reaches it before it has sent the player for any.
test_progressive_costs checks those as properties rather than transcribing
the numbers, so rebalancing a price costs nothing while breaking the shape
fails: nothing unreachable at its own depth, prices rising with depth, the
ore field agreeing with the dictionary (repairs quote the field alone, since
a repair drone carries ore and nothing else), and the quest chain never
asking for a structure it has not funded.
Two things cleaned up on the way:
- The per-building cost constants in GameState are gone. Nothing but tests
used them, and they were a second copy of a number the definitions already
hold - exactly what would drift once a price gained a resource.
- research_for_building() returns a display NAME, and the id-keyed half of
the tree wants an id. That mix-up is silent - skill_depth() of a name finds
no node and answers 0, so a deep structure reads as an ungated one, which
is how the first draft of the test let an unreachable price through.
research_node_for_building() is the id, and the name is expressed from it.
PriceTag no longer rebuilds its labels when re-told the same price; it
refreshes the held figures instead. The craft menu re-states prices every
frame and the build menu now does too, so that was a dozen Labels being torn
down and rebuilt sixty times a second.
2026-08-28 15:30:30 +02:00
|
|
|
# What it costs in ORE, and the whole price when it wants more than ore.
|
|
|
|
|
#
|
|
|
|
|
# #138: structures all charged rocks and nothing else, whatever they were.
|
|
|
|
|
# The dictionary is the same shape VesselDefinition has used since gas
|
|
|
|
|
# bombers and laser ships (build_cost / build_resource_costs): when it is
|
|
|
|
|
# empty the price is `cost` in ore, and when it is set it IS the price, ore
|
|
|
|
|
# included - and its ore entry must agree with `cost`, which the test pins,
|
|
|
|
|
# because repair costs are quoted from `cost` alone (a repair drone carries
|
|
|
|
|
# ore and nothing else).
|
2026-08-14 21:44:28 +02:00
|
|
|
@export var cost: int
|
#138: structures and doctrines cost more than rocks, and more the deeper they are
Both halves of the ticket, in the shape vessels have used since gas bombers
and laser ships: a definition carries an ore figure and, when it wants more
than ore, a dictionary that IS the price. `building_costs()` and
`skill_costs()` answer it the way `product_costs()` already did, so there is
one question with one answer whatever is being bought, and every payment
path now goes through `spend_resources` rather than `spend`.
Seven of ten structures and thirteen of seventeen doctrines now want gas,
energy or dark matter alongside their rocks, and the totals climb with tree
depth - structures 16/31/58/62/96 by depth, doctrines 15/30/73/96/143/258/530.
The constraint that shaped the table is REACHABILITY, and it is the reason
some prices stayed ore-only. Energy exists only where a gas burner stands,
and a gas burner needs Power Systems - so nothing at or before that depth
may be priced in energy, or it is a wall with no way through. Dark matter is
rarer still and appears once, on the deepest node in the game. The extractor
stays rocks-only despite its depth allowing gas, because the quest chain
reaches it before it has sent the player for any.
test_progressive_costs checks those as properties rather than transcribing
the numbers, so rebalancing a price costs nothing while breaking the shape
fails: nothing unreachable at its own depth, prices rising with depth, the
ore field agreeing with the dictionary (repairs quote the field alone, since
a repair drone carries ore and nothing else), and the quest chain never
asking for a structure it has not funded.
Two things cleaned up on the way:
- The per-building cost constants in GameState are gone. Nothing but tests
used them, and they were a second copy of a number the definitions already
hold - exactly what would drift once a price gained a resource.
- research_for_building() returns a display NAME, and the id-keyed half of
the tree wants an id. That mix-up is silent - skill_depth() of a name finds
no node and answers 0, so a deep structure reads as an ungated one, which
is how the first draft of the test let an unreachable price through.
research_node_for_building() is the id, and the name is expressed from it.
PriceTag no longer rebuilds its labels when re-told the same price; it
refreshes the held figures instead. The craft menu re-states prices every
frame and the build menu now does too, so that was a dozen Labels being torn
down and rebuilt sixty times a second.
2026-08-28 15:30:30 +02:00
|
|
|
@export var build_resource_costs: Dictionary = {}
|
2026-08-14 21:44:28 +02:00
|
|
|
@export var action_icon: int
|
|
|
|
|
@export var menu_icon: int
|
|
|
|
|
@export var visual_scene: PackedScene
|
2026-08-31 15:23:25 +02:00
|
|
|
# No explicit empty default: Godot 4.7.1 can lose the value when exporting a
|
|
|
|
|
# custom resource to binary .res.
|
|
|
|
|
@export var capabilities: PackedStringArray
|
2026-08-16 21:38:07 +02:00
|
|
|
@export var logistics: Resource
|
2026-08-14 21:44:28 +02:00
|
|
|
@export var map_color: Color = Color.WHITE
|
|
|
|
|
@export var map_sides: int = 4
|
|
|
|
|
@export var map_radius: float = 7.0
|
|
|
|
|
@export var map_phase: float = 0.0
|
|
|
|
|
@export var menu_button_name: String
|
|
|
|
|
@export var menu_label_name: String
|
|
|
|
|
@export var menu_cost_name: String
|
|
|
|
|
@export_enum("space", "planet") var placement_mode: String = "space"
|
|
|
|
|
@export var unique: bool = false
|
2026-08-23 13:37:40 +02:00
|
|
|
# #99: what a wave has to chew through to level this. Data rather than one
|
|
|
|
|
# constant for every structure - an extractor bolted to a rock is not the
|
|
|
|
|
# mothership. See GameState.damage_building().
|
|
|
|
|
@export var max_hp: int = 40
|