Refine movement, water recovery, and UI baseline

This commit is contained in:
Alexander Sellite 2026-07-25 17:04:39 -04:00
parent d2fe367891
commit e2067e3bf4
23 changed files with 905 additions and 146 deletions

View file

@ -71,6 +71,7 @@ var _cast_position: Vector3
var _pickup_position: Vector3
var _active_tween: Tween
var _rod_tween: Tween
var _bite_tween: Tween
func _ready() -> void:
@ -179,29 +180,30 @@ func show_bite() -> void:
if _mode != VisualMode.FISHING:
return
_kill_active_tween()
var bite_position: Vector3 = _with_water_height(_bobber.global_position)
_bobber.global_position = bite_position
_active_tween = create_tween()
_active_tween.set_trans(Tween.TRANS_QUAD)
_active_tween.tween_property(
_kill_bite_tween()
_bobber.scale = Vector3.ONE
_bite_tween = create_tween()
_bite_tween.set_trans(Tween.TRANS_QUAD)
_bite_tween.set_ease(Tween.EASE_IN_OUT)
_bite_tween.tween_property(
_bobber,
"global_position:y",
get_water_surface_height() - 0.25,
0.11
"scale",
Vector3.ONE * 0.68,
0.08
)
_active_tween.tween_property(
_bite_tween.tween_property(
_bobber,
"global_position:y",
get_water_surface_height() + 0.05,
0.14
"scale",
Vector3.ONE * 1.2,
0.1
)
_active_tween.tween_property(
_bite_tween.tween_property(
_bobber,
"global_position:y",
bite_position.y,
0.12
"scale",
Vector3.ONE,
0.1
)
_bite_tween.finished.connect(_on_bite_tween_finished)
func show_withdrawal_position(position: Vector3) -> void:
@ -225,7 +227,6 @@ func show_reel_position(position: Vector3, _input_held: bool) -> void:
return
_kill_active_tween()
_bobber.scale = Vector3.ONE
_bobber.global_position = _with_water_height(position)
@ -235,6 +236,7 @@ func play_outcome(outcome: StringName) -> void:
return
_kill_active_tween()
_kill_bite_tween()
_kill_rod_tween()
_restore_rod_neutral()
_mode = VisualMode.OUTCOME
@ -274,15 +276,6 @@ func play_outcome(outcome: StringName) -> void:
get_water_surface_height() - 0.4,
0.2
)
&"miss":
_active_tween.set_parallel(true)
_active_tween.tween_property(
_bobber,
"global_position:y",
get_water_surface_height() - 0.4,
0.3
)
_active_tween.tween_property(_bobber, "scale", Vector3.ONE * 0.65, 0.3)
&"invalid":
var return_target: Vector3 = _bobber.global_position
if _rod_tip != null:
@ -310,6 +303,7 @@ func play_outcome(outcome: StringName) -> void:
func cleanup() -> void:
_kill_active_tween()
_kill_bite_tween()
_kill_rod_tween()
_restore_rod_neutral()
_mode = VisualMode.NONE
@ -752,6 +746,18 @@ func _kill_active_tween() -> void:
_active_tween = null
func _kill_bite_tween() -> void:
if _bite_tween != null and _bite_tween.is_valid():
_bite_tween.kill()
_bite_tween = null
if is_instance_valid(_bobber):
_bobber.scale = Vector3.ONE
func _on_bite_tween_finished() -> void:
_bite_tween = null
func _kill_rod_tween() -> void:
if _rod_tween != null and _rod_tween.is_valid():
_rod_tween.kill()

View file

@ -37,7 +37,6 @@ enum FishingState {
AIMING_CAST,
CASTING,
WAITING_FOR_BITE,
BITE_ACTIVE,
FIGHTING,
SHOWING_CATCH,
COOLDOWN,
@ -62,7 +61,6 @@ enum FishingState {
@export_category("Timing")
@export_range(0.1, 30.0, 0.1) var wait_time: float = 2.0
@export_range(0.1, 10.0, 0.1) var bite_window_duration: float = 1.5
@export_range(0.1, 10.0, 0.1) var cooldown_duration: float = 1.0
@export_category("Selection")
@ -80,6 +78,7 @@ enum FishingState {
@onready var _presentation: FishingPresentationType = %FishingPresentation
var state: FishingState = FishingState.READY
var _external_input_blocked: bool = false
var _local_player: PlayerType
var _local_inventory: FishInventoryType
var _local_collection_log: CollectionLogType
@ -127,12 +126,46 @@ func setup(
func can_open_player_menu() -> bool:
return state in [
return not _external_input_blocked and state in [
FishingState.READY,
FishingState.WAITING_FOR_BITE,
]
func begin_water_recovery() -> void:
_external_input_blocked = true
if state in [
FishingState.AIMING_CAST,
FishingState.CASTING,
FishingState.WAITING_FOR_BITE,
FishingState.FIGHTING,
]:
_cancel_attempt()
elif state == FishingState.SHOWING_CATCH:
_secure_showcase_catch_for_recovery()
func end_water_recovery() -> void:
_external_input_blocked = false
func _secure_showcase_catch_for_recovery() -> void:
if (
_pending_catch != null
and _local_inventory != null
and _local_collection_log != null
):
_local_inventory.add_catch(_pending_catch)
_local_collection_log.mark_discovered(_pending_catch.fish_id)
_pending_catch = null
_showcase_ready = false
_put_away_press_armed = false
showcase_changed.emit("", "", 0.0, false)
if _active_player != null:
_active_player.end_catch_showcase(Callable(), true)
_cleanup_attempt()
func _exit_tree() -> void:
_showcase_restore_generation += 1
if (
@ -174,10 +207,6 @@ func _process(delta: float) -> void:
_confirm_cast()
FishingState.WAITING_FOR_BITE:
_update_waiting_for_bite(delta)
FishingState.BITE_ACTIVE:
_state_time_remaining -= delta
if _state_time_remaining <= 0.0:
_miss_bite()
FishingState.FIGHTING:
if not Input.is_action_pressed("fish_primary"):
_catch_controller.set_reel_input(false)
@ -188,6 +217,8 @@ func _process(delta: float) -> void:
func _unhandled_input(event: InputEvent) -> void:
if _external_input_blocked:
return
if (
event.is_action_pressed("ui_cancel")
and state == FishingState.SHOWING_CATCH
@ -202,7 +233,6 @@ func _unhandled_input(event: InputEvent) -> void:
FishingState.AIMING_CAST,
FishingState.CASTING,
FishingState.WAITING_FOR_BITE,
FishingState.BITE_ACTIVE,
FishingState.FIGHTING,
]
):
@ -226,8 +256,6 @@ func _unhandled_input(event: InputEvent) -> void:
_presentation.set_line_mode(
FishingPresentationType.LineMode.TAUT
)
FishingState.BITE_ACTIVE:
_confirm_hook()
FishingState.FIGHTING:
_catch_controller.handle_primary_pressed()
_presentation.set_line_mode(
@ -442,19 +470,8 @@ func _activate_bite() -> void:
if state != FishingState.WAITING_FOR_BITE:
return
state = FishingState.BITE_ACTIVE
_state_time_remaining = bite_window_duration
_withdrawal_input_held = false
bite_activated.emit()
status_changed.emit("Bite! Left click to hook")
_presentation.set_line_mode(FishingPresentationType.LineMode.TAUT)
_presentation.show_bite()
func _confirm_hook() -> void:
if (
state != FishingState.BITE_ACTIVE
or _active_player == null
_active_player == null
or _selected_fish == null
or _selected_fish.catch_profile == null
):
@ -463,8 +480,10 @@ func _confirm_hook() -> void:
state = FishingState.FIGHTING
_state_time_remaining = 0.0
_withdrawal_input_held = false
_fight_start_position = _bobber_water_position
status_changed.emit("Hold left click to reel")
bite_activated.emit()
status_changed.emit("Fish on!")
_presentation.set_line_mode(FishingPresentationType.LineMode.TAUT)
_presentation.begin_reeling()
_catch_controller.start_encounter(
@ -472,7 +491,10 @@ func _confirm_hook() -> void:
_active_player.reel_speed,
_active_player.click_power
)
_catch_controller.set_reel_input(true)
_catch_controller.set_reel_input(
Input.is_action_pressed("fish_primary")
)
_presentation.show_bite()
func _on_catch_encounter_updated(
@ -613,12 +635,6 @@ func _finish_showcase_put_away(
_cleanup_attempt(cooldown_message)
func _miss_bite() -> void:
if state != FishingState.BITE_ACTIVE:
return
_cleanup_attempt("The fish got away.", &"miss")
func _cleanup_attempt(
cooldown_message: String = "",
visual_outcome: StringName = &"",