Add gas giant resource system
This commit is contained in:
parent
8f7b58f2a8
commit
fc68c4e8cf
9 changed files with 180 additions and 10 deletions
21
GameState.gd
21
GameState.gd
|
|
@ -28,6 +28,11 @@ var explored_chunks: Dictionary = {}
|
|||
# first - drop this back to 0 for a real playthrough.
|
||||
var rocks: int = 500
|
||||
|
||||
# Gas is a second, banked resource. It is deliberately separate from ore:
|
||||
# construction still spends ore, while future gas technologies can consume
|
||||
# gas without making the two materials silently interchangeable.
|
||||
var gas: int = 0
|
||||
|
||||
# Ore the fleet is physically carrying and has not delivered yet (#14). Mining
|
||||
# fills this, not `rocks`: ore is cargo until the fleet brings it home, so a
|
||||
# long mining run is a real trip with something to lose rather than instant
|
||||
|
|
@ -772,7 +777,7 @@ 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", "stock", "mining_progress"}.
|
||||
# {"position", "planet_name", "resource_type", "stock", "mining_progress"}.
|
||||
const EXTRACTOR_RATE: float = 2.0 # ore per second
|
||||
|
||||
var extractors: Array = []
|
||||
|
|
@ -788,10 +793,11 @@ func has_extractor_at(planet_name: String) -> bool:
|
|||
signal extractor_added(planet_name: String)
|
||||
|
||||
|
||||
func add_extractor(planet_name: String, at_position: Vector2) -> void:
|
||||
func add_extractor(planet_name: String, at_position: Vector2, resource_type: String = "ore") -> void:
|
||||
extractors.append({
|
||||
"position": at_position,
|
||||
"planet_name": planet_name,
|
||||
"resource_type": resource_type,
|
||||
"stock": 0,
|
||||
"mining_progress": 0.0,
|
||||
})
|
||||
|
|
@ -917,7 +923,7 @@ func _station_transporter(built_at: Vector2) -> void:
|
|||
return
|
||||
transporters.append({
|
||||
"hub_id": int(hub.id), "state": TRANSPORTER_RETURNING, "target_id": 0,
|
||||
"carrying": 0, "progress": 0.0, "from": built_at, "to": hub.position,
|
||||
"carrying": 0, "resource_type": "ore", "progress": 0.0, "from": built_at, "to": hub.position,
|
||||
})
|
||||
|
||||
|
||||
|
|
@ -977,6 +983,7 @@ func _dispatch_transporters() -> void:
|
|||
if chosen_extractor.is_empty():
|
||||
return
|
||||
chosen_extractor.extractor_index = i
|
||||
chosen_extractor.resource_type = String(extractor.get("resource_type", "ore"))
|
||||
chosen_extractor.target_id = 0
|
||||
_begin_leg(chosen_extractor, transporter_position(chosen_extractor), extractor.position,
|
||||
TRANSPORTER_TO_EXTRACTOR)
|
||||
|
|
@ -1058,10 +1065,14 @@ func _arrive(t: Dictionary) -> void:
|
|||
return
|
||||
extractor.stock = int(extractor.stock) - load
|
||||
t.carrying = load
|
||||
t.resource_type = String(extractor.get("resource_type", "ore"))
|
||||
_begin_leg(t, here, get_mothership_position(), TRANSPORTER_TO_MOTHERSHIP_FROM_EXTRACTOR)
|
||||
TRANSPORTER_TO_MOTHERSHIP_FROM_EXTRACTOR:
|
||||
# Bank only on arrival; while in flight the ore remains in carrying.
|
||||
rocks += int(t.carrying)
|
||||
# Bank only on arrival; cargo retains the extractor's resource type.
|
||||
if String(t.get("resource_type", "ore")) == "gas":
|
||||
gas += int(t.carrying)
|
||||
else:
|
||||
rocks += int(t.carrying)
|
||||
t.carrying = 0
|
||||
t.extractor_index = -1
|
||||
_begin_leg(t, here, hub_pos if hub_pos != null else here, TRANSPORTER_RETURNING)
|
||||
|
|
|
|||
Loading…
Reference in a new issue