spaceship/buildings/BuildingDefinition.gd
Loïc Wisniewski c221584848 #99 (#97a): buildings have health, and can be destroyed
Nothing can attack a structure that cannot be hurt, so this is the floor the
rest of #97 stands on.

max_hp is per definition - an extractor bolted to a rock is not the
mothership - and the current value lives on the RECORD in GameState, not on
the Building node. Main.tscn is torn down and rebuilt on every trip to a
planet surface, so damage kept on a node would heal itself the moment the
player landed.

A record written before this carries no hp field at all. That reads as
undamaged rather than as zero, or an existing save would open on a field of
wrecks.

The mothership cannot be destroyed - it floors at 1hp. The bank, the hangar
and research all live there and a wiped fleet rebuilds there, so losing it
would be a soft-lock with no route back. Keyed on the "bank" capability
rather than on the type: whatever building holds the bank is the one that
cannot be lost.

Destroying a hub retires its transporters. Everything else keyed on a
building id already copes with the building being gone - a transporter
mid-delivery puts its cargo back rather than destroying it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-23 13:37:40 +02:00

25 lines
934 B
GDScript

class_name BuildingDefinition
extends Resource
@export var definition_id: String
@export var display_name: String
@export_multiline var description: String
@export var cost: int
@export var action_icon: int
@export var menu_icon: int
@export var visual_scene: PackedScene
@export var capabilities: PackedStringArray = []
@export var logistics: Resource
@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
# #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