Key extractors by stable planet identity
This commit is contained in:
parent
14081ad230
commit
e2d4297ee5
11 changed files with 71 additions and 16 deletions
15
GameState.gd
15
GameState.gd
|
|
@ -18,6 +18,7 @@ var return_world_position: Vector2 = Vector2.ZERO
|
|||
var return_camera_zoom: float = 1.0
|
||||
|
||||
var planet_name: String = ""
|
||||
var planet_id: String = ""
|
||||
var planet_definition_id: String = "rocky"
|
||||
|
||||
# Explored-chunk history for the world map's fog-of-war reveal. Lives
|
||||
|
|
@ -881,15 +882,16 @@ func rotate_formation(radians: float) -> void:
|
|||
# Extractors mine into their OWN local stock. They do not own a magical
|
||||
# hauler: ore becomes spendable only when a hub-stationed transporter picks
|
||||
# up a full load and physically delivers it to the mothership. Entries are
|
||||
# {"position", "planet_name", "resource_type", "inventory", "mining_progress"}.
|
||||
# {"position", "planet_id", "planet_name", "resource_type", "inventory", "mining_progress"}.
|
||||
const EXTRACTOR_RATE: float = 2.0 # ore per second
|
||||
|
||||
var extractors: Array = []
|
||||
|
||||
|
||||
func has_extractor_at(planet_name: String) -> bool:
|
||||
func has_extractor_at(planet_key: String) -> bool:
|
||||
for e in extractors:
|
||||
if e.planet_name == planet_name:
|
||||
# Old saves have no planet_id; their name remains a migration fallback.
|
||||
if String(e.get("planet_id", e.get("planet_name", ""))) == planet_key:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
|
@ -897,9 +899,12 @@ func has_extractor_at(planet_name: String) -> bool:
|
|||
signal extractor_added(planet_name: String)
|
||||
|
||||
|
||||
func add_extractor(planet_name: String, at_position: Vector2, resource_type: String = "ore") -> void:
|
||||
func add_extractor(planet_name: String, at_position: Vector2, resource_type: String = "ore",
|
||||
planet_key: String = "") -> void:
|
||||
var stable_id: String = planet_key if planet_key != "" else planet_name
|
||||
extractors.append({
|
||||
"position": at_position,
|
||||
"planet_id": stable_id,
|
||||
"planet_name": planet_name,
|
||||
"resource_type": resource_type,
|
||||
"inventory": INVENTORY.new(),
|
||||
|
|
@ -909,7 +914,7 @@ func add_extractor(planet_name: String, at_position: Vector2, resource_type: Str
|
|||
# so the Planet node is already in the tree with its _ready() long since
|
||||
# run. Without this it kept showing no derrick until it happened to
|
||||
# despawn and respawn, which reads as the build having done nothing.
|
||||
extractor_added.emit(planet_name)
|
||||
extractor_added.emit(stable_id)
|
||||
|
||||
|
||||
func extractor_stock(index: int) -> int:
|
||||
|
|
|
|||
Loading…
Reference in a new issue