Refactor recent gameplay systems after code review
This commit is contained in:
parent
3f3a22227d
commit
d68f4d4f88
57 changed files with 530 additions and 572 deletions
17
Fleet.gd
17
Fleet.gd
|
|
@ -80,7 +80,7 @@ func spawn_ships(count: int, center: Vector2 = Vector2.ZERO,
|
|||
ship.destroyed.connect(_on_ship_destroyed.bind(ship))
|
||||
|
||||
fleet_target = center
|
||||
GameState.sync_fleet_cargo_capacity(vessel_types())
|
||||
_sync_composition_state()
|
||||
|
||||
|
||||
func vessel_types() -> PackedStringArray:
|
||||
|
|
@ -91,6 +91,15 @@ func vessel_types() -> PackedStringArray:
|
|||
return result
|
||||
|
||||
|
||||
func _sync_composition_state() -> void:
|
||||
GameState.sync_fleet_cargo_capacity(vessel_types())
|
||||
# Composition changes are authoritative; scene teardown is not. Keeping
|
||||
# this out of SpeedFader prevents an outgoing scene's empty fleet from
|
||||
# resetting a boost while the same vessels are being restored on a surface.
|
||||
if not has_capability("distorder"):
|
||||
GameState.set_fleet_speed_multiplier(1.0)
|
||||
|
||||
|
||||
func has_vessel_type(vessel_type: String) -> bool:
|
||||
for ship in ships:
|
||||
if is_instance_valid(ship) and String(ship.vessel_type) == vessel_type:
|
||||
|
|
@ -139,7 +148,7 @@ func add_ship(vessel_type: String = GameState.VESSEL_INTERCEPTOR) -> bool:
|
|||
if ship.has_signal("destroyed"):
|
||||
ship.destroyed.connect(_on_ship_destroyed.bind(ship))
|
||||
ship.set_move_target(fleet_target + offset)
|
||||
GameState.sync_fleet_cargo_capacity(vessel_types())
|
||||
_sync_composition_state()
|
||||
return true
|
||||
|
||||
|
||||
|
|
@ -157,7 +166,7 @@ func store_ship(index: int) -> String:
|
|||
formation_offsets.remove_at(index)
|
||||
ship.queue_free()
|
||||
apply_formation()
|
||||
GameState.sync_fleet_cargo_capacity(vessel_types())
|
||||
_sync_composition_state()
|
||||
return vessel_type
|
||||
|
||||
|
||||
|
|
@ -283,7 +292,7 @@ func _on_ship_destroyed(ship: Node) -> void:
|
|||
if idx != -1:
|
||||
ships.remove_at(idx)
|
||||
formation_offsets.remove_at(idx)
|
||||
GameState.sync_fleet_cargo_capacity(vessel_types())
|
||||
_sync_composition_state()
|
||||
|
||||
|
||||
func get_centroid() -> Vector2:
|
||||
|
|
|
|||
Loading…
Reference in a new issue