feat: adapt fishing visuals to character scale

This commit is contained in:
Alexander Sellite 2026-08-08 10:25:17 -04:00
parent 038b628061
commit 0bbd449c55
4 changed files with 63 additions and 13 deletions

View file

@ -59,6 +59,7 @@ var _cast_arrival_position: Vector3
var _cast_tracks_water_surface: bool = false
var _bobber_surface_position: Vector3
var _bobber_idle_elapsed: float = 0.0
var _bobber_base_scale: Vector3 = Vector3.ONE
var _active_tween: Tween
var _rod_tween: Tween
var _bite_tween: Tween
@ -94,11 +95,13 @@ func begin_aim(
minimum_target: Vector3,
target_normal: Vector3,
target_is_fishable: bool,
character_scale: float = 1.0,
) -> void:
cleanup()
if rod_tip == null or rod == null:
return
_bobber_base_scale = Vector3.ONE * maxf(character_scale, 0.01)
_mode = VisualMode.AIMING
_rod = rod
_rod_tip = rod_tip
@ -158,7 +161,7 @@ func begin_cast(
_mode = VisualMode.CASTING
_target_marker.visible = false
_bobber.visible = true
_bobber.scale = Vector3.ONE
_bobber.scale = _bobber_base_scale
_cast_arrival_position = (
blocked_landing_position if cast_is_blocked else target
)
@ -188,26 +191,26 @@ func show_bite() -> void:
return
_kill_bite_tween()
_bobber.scale = Vector3.ONE
_bobber.scale = _bobber_base_scale
_bite_tween = create_tween()
_bite_tween.set_trans(Tween.TRANS_QUAD)
_bite_tween.set_ease(Tween.EASE_IN_OUT)
_bite_tween.tween_property(
_bobber,
"scale",
Vector3.ONE * 0.68,
_bobber_base_scale * 0.68,
0.08
)
_bite_tween.tween_property(
_bobber,
"scale",
Vector3.ONE * 1.2,
_bobber_base_scale * 1.2,
0.1
)
_bite_tween.tween_property(
_bobber,
"scale",
Vector3.ONE,
_bobber_base_scale,
0.1
)
_bite_tween.finished.connect(_on_bite_tween_finished)
@ -247,7 +250,7 @@ func play_outcome(outcome: StringName) -> void:
# Withdrawal is a visible return, not an instant cancellation. Keep the
# bobber present even if the preceding reel update hid or reset it.
_bobber.visible = true
_bobber.scale = Vector3.ONE
_bobber.scale = _bobber_base_scale
_active_tween = create_tween()
_active_tween.set_trans(Tween.TRANS_QUAD)
_active_tween.set_ease(Tween.EASE_IN)
@ -296,6 +299,7 @@ func cleanup() -> void:
_invalid_target_marker.visible = false
_bobber.visible = false
_bobber.scale = Vector3.ONE
_bobber_base_scale = Vector3.ONE
_bobber.rotation = Vector3.ZERO
_cast_arrival_position = Vector3.ZERO
_cast_tracks_water_surface = false
@ -475,7 +479,7 @@ func _kill_bite_tween() -> void:
_bite_tween.kill()
_bite_tween = null
if is_instance_valid(_bobber):
_bobber.scale = Vector3.ONE
_bobber.scale = _bobber_base_scale
func _on_bite_tween_finished() -> void:

View file

@ -609,7 +609,8 @@ func _begin_aiming(player: PlayerType) -> void:
_active_player.get_fishing_rod(),
preview_position,
_aim_surface_sample.normal,
target_is_fishable
target_is_fishable,
_active_player.get_character_visual_scale(),
)
@ -952,6 +953,7 @@ func _activate_bite() -> void:
return
state = FishingState.FIGHTING
_active_player.set_fighting_visual(true)
_state_time_remaining = 0.0
_withdrawal_input_held = false
_pending_catch = _fish_selector.create_catch(_selected_fish)
@ -1040,6 +1042,7 @@ func _on_catch_completed() -> void:
_cancel_attempt()
return
_stop_fight_audio()
_active_player.set_fighting_visual(false)
state = FishingState.SHOWING_CATCH
_showcase_ready = false
_showcase_outcome_completed = false
@ -1162,6 +1165,8 @@ func _cleanup_attempt(
) -> void:
_stop_fight_audio()
_stop_reeling_audio()
if _active_player != null:
_active_player.set_fighting_visual(false)
if not visual_outcome.is_empty():
if state == FishingState.RETURNING:
return
@ -1190,6 +1195,7 @@ func _cleanup_attempt(
func _finalize_attempt_cleanup(cooldown_message: String) -> void:
_showcase_restore_generation += 1
if _active_player != null:
_active_player.set_fighting_visual(false)
_active_player.end_catch_showcase()
_active_player.set_movement_enabled(true)
_active_player = null
@ -1477,6 +1483,8 @@ func _on_network_bite_started(_attempt_id: String) -> void:
return
_stop_reeling_audio()
state = FishingState.FIGHTING
if _active_player != null:
_active_player.set_fighting_visual(true)
_withdrawal_input_held = false
_network_primary_input_held = Input.is_action_pressed("fish_primary")
_network_input_resend_elapsed = 0.0
@ -1567,6 +1575,8 @@ func _on_network_catch_received(fish_catch: FishCatchType) -> void:
return
_stop_fight_audio()
_pending_catch = fish_catch
if _active_player != null:
_active_player.set_fighting_visual(false)
state = FishingState.SHOWING_CATCH
_showcase_ready = false
_showcase_outcome_completed = false

View file

@ -19,6 +19,7 @@ var _return_tween: Tween
var _showcase_tween: Tween
var _return_showcase_catch: FishCatch
var _bobber_idle_elapsed: float = 0.0
var _bobber_base_scale: Vector3 = Vector3.ONE
func setup(owning_player: Player) -> void:
@ -52,11 +53,12 @@ func show_cast(origin: Vector3, target: Vector3) -> void:
return
_kill_cast_tween()
_active = true
_bobber_base_scale = Vector3.ONE * _owner.get_character_visual_scale()
_target = origin
_pending_target = target
_bobber_idle_elapsed = 0.0
_bobber.global_position = origin
_bobber.scale = Vector3.ONE
_bobber.scale = _bobber_base_scale
_bobber.visible = true
_line.visible = true
_owner.set_active_item_is_rod(true)
@ -87,12 +89,16 @@ func update_bobber(world_position: Vector3) -> void:
func show_bite() -> void:
if not _active:
return
if _owner != null and is_instance_valid(_owner):
_owner.set_fighting_visual(true)
var tween: Tween = create_tween()
tween.tween_property(_bobber, "scale", Vector3.ONE * 0.7, 0.08)
tween.tween_property(_bobber, "scale", Vector3.ONE, 0.12)
tween.tween_property(_bobber, "scale", _bobber_base_scale * 0.7, 0.08)
tween.tween_property(_bobber, "scale", _bobber_base_scale, 0.12)
func play_return(showcase_catch: FishCatch = null) -> void:
if _owner != null and is_instance_valid(_owner):
_owner.set_fighting_visual(false)
if not _active or _bobber == null:
cleanup()
return_completed.emit()
@ -128,10 +134,12 @@ func cleanup() -> void:
_return_showcase_catch = null
_bobber_idle_elapsed = 0.0
if _owner != null and is_instance_valid(_owner):
_owner.set_fighting_visual(false)
_owner.end_catch_showcase(Callable(), true)
if _bobber != null:
_bobber.visible = false
_bobber.scale = Vector3.ONE
_bobber_base_scale = Vector3.ONE
if _line != null:
_line.visible = false
_line_mesh.clear_surfaces()