Debug clouds "world bounds"
This commit is contained in:
+29
-11
@@ -204,23 +204,39 @@ func _apply_progression_to_gardens(transition_context: Dictionary) -> void:
|
||||
|
||||
#region Scene setup and ready sequence
|
||||
|
||||
func _configure_clouds_for_gardens() -> void:
|
||||
if not clouds or not garden_parent:
|
||||
return
|
||||
# Spread clouds across the full scrollable garden width so they remain
|
||||
# visible regardless of which garden the player scrolls to.
|
||||
func _compute_cloud_world_bounds() -> Vector2:
|
||||
if not garden_parent:
|
||||
return Vector2.ZERO
|
||||
var garden_count: int = garden_parent.get_child_count()
|
||||
if garden_count <= 0:
|
||||
return
|
||||
var content_world_width: float = float(garden_count * GARDEN_SIZE)
|
||||
# max_scroll is what the parent will actually pass through scroll_offset.
|
||||
# The CloudsManager needs this (not just world_width) to position clouds
|
||||
# inside their reachable drift_x range when parallax_factor < 1.0.
|
||||
return Vector2.ZERO
|
||||
var trailing_spacer_width: float = 0.0
|
||||
if scroll_end_spacer:
|
||||
trailing_spacer_width = scroll_end_spacer.custom_minimum_size.x
|
||||
var content_world_width: float = float(garden_count * GARDEN_SIZE) + trailing_spacer_width
|
||||
var viewport_w: float = scroll_container.size.x
|
||||
if viewport_w <= 0.0:
|
||||
viewport_w = float(get_viewport_rect().size.x)
|
||||
var max_scroll: float = maxf(0.0, content_world_width - viewport_w)
|
||||
clouds.configure_world(content_world_width, max_scroll)
|
||||
return Vector2(content_world_width, max_scroll)
|
||||
|
||||
|
||||
func _configure_clouds_for_gardens() -> void:
|
||||
if not clouds:
|
||||
return
|
||||
var bounds: Vector2 = _compute_cloud_world_bounds()
|
||||
if bounds == Vector2.ZERO:
|
||||
return
|
||||
clouds.configure_world(bounds.x, bounds.y)
|
||||
|
||||
|
||||
func _refresh_cloud_world_bounds() -> void:
|
||||
if not clouds:
|
||||
return
|
||||
var bounds: Vector2 = _compute_cloud_world_bounds()
|
||||
if bounds == Vector2.ZERO:
|
||||
return
|
||||
clouds.set_world_bounds(bounds.x, bounds.y)
|
||||
|
||||
|
||||
func _scroll_to_starting_garden(_transition_context: Dictionary) -> void:
|
||||
@@ -1029,6 +1045,7 @@ func _set_up_final_boss_button() -> void:
|
||||
func _reset_final_boss_scroll_space() -> void:
|
||||
if scroll_end_spacer:
|
||||
scroll_end_spacer.custom_minimum_size.x = scroll_end_base_width
|
||||
_refresh_cloud_world_bounds()
|
||||
|
||||
|
||||
func _update_final_boss_scroll_space(final_boss_center: Vector2, final_boss_size: Vector2) -> void:
|
||||
@@ -1042,6 +1059,7 @@ func _update_final_boss_scroll_space(final_boss_center: Vector2, final_boss_size
|
||||
var final_boss_right_edge: float = final_boss_center.x + final_boss_size.x * 0.5
|
||||
var extra_width: float = max(0.0, final_boss_right_edge - last_garden_right_edge)
|
||||
scroll_end_spacer.custom_minimum_size.x = scroll_end_base_width + extra_width
|
||||
_refresh_cloud_world_bounds()
|
||||
|
||||
|
||||
func _extend_unlocked_path_to_final_boss() -> void:
|
||||
|
||||
@@ -60,12 +60,16 @@ func _process(delta: float) -> void:
|
||||
func configure_world(world_width: float, p_max_scroll: float = -1.0, override_clouds_per_screen: int = -1) -> void:
|
||||
if override_clouds_per_screen >= 0:
|
||||
clouds_per_screen = override_clouds_per_screen
|
||||
spawn_width = world_width
|
||||
max_scroll = p_max_scroll if p_max_scroll >= 0.0 else world_width
|
||||
set_world_bounds(world_width, p_max_scroll)
|
||||
screen_width = get_viewport_rect().size.x
|
||||
_initialize_clouds()
|
||||
|
||||
|
||||
func set_world_bounds(world_width: float, p_max_scroll: float = -1.0) -> void:
|
||||
spawn_width = world_width
|
||||
max_scroll = p_max_scroll if p_max_scroll >= 0.0 else world_width
|
||||
|
||||
|
||||
func _initialize_clouds() -> void:
|
||||
_populate_extra_clouds()
|
||||
cloud_speeds.clear()
|
||||
|
||||
Reference in New Issue
Block a user