Refactor fishing surfaces around authored water
This commit is contained in:
parent
9f52620a73
commit
9afa60f6a5
11 changed files with 198 additions and 172 deletions
|
|
@ -1,10 +1,6 @@
|
|||
class_name FishingPresentation
|
||||
extends Node3D
|
||||
|
||||
const WaterSurfaceMotionType = preload(
|
||||
"res://world/water_surface_motion.gd"
|
||||
)
|
||||
|
||||
signal cast_completed
|
||||
signal outcome_completed(outcome: StringName)
|
||||
signal presentation_interrupted
|
||||
|
|
@ -58,7 +54,6 @@ var _rod_tip: Marker3D
|
|||
var _rod_neutral_rotation: Vector3
|
||||
var _cast_arrival_position: Vector3
|
||||
var _active_cast_arc_height: float = 0.0
|
||||
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
|
||||
|
|
@ -76,9 +71,6 @@ func _process(delta: float) -> void:
|
|||
if _mode == VisualMode.FISHING and _bobber.visible:
|
||||
_bobber_idle_elapsed += delta
|
||||
_apply_bobber_idle_motion()
|
||||
var bobber_position := _bobber.global_position
|
||||
bobber_position.y += WaterSurfaceMotionType.get_default_height_offset()
|
||||
_bobber.global_position = bobber_position
|
||||
if _line_mode != LineMode.HIDDEN:
|
||||
_update_line(delta)
|
||||
|
||||
|
|
@ -173,8 +165,6 @@ func begin_cast(
|
|||
if resolved_arc_height >= 0.0
|
||||
else cast_arc_height
|
||||
)
|
||||
_cast_tracks_water_surface = not cast_is_blocked
|
||||
|
||||
var cast_start: Vector3 = _rod_tip.global_position
|
||||
_bobber.global_position = cast_start
|
||||
_begin_rod_release()
|
||||
|
|
@ -311,7 +301,6 @@ func cleanup() -> void:
|
|||
_bobber.rotation = Vector3.ZERO
|
||||
_cast_arrival_position = Vector3.ZERO
|
||||
_active_cast_arc_height = 0.0
|
||||
_cast_tracks_water_surface = false
|
||||
_bobber_surface_position = Vector3.ZERO
|
||||
_bobber_idle_elapsed = 0.0
|
||||
set_line_mode(LineMode.HIDDEN)
|
||||
|
|
@ -329,11 +318,6 @@ func _set_cast_sample(
|
|||
) -> void:
|
||||
var sample: Vector3 = start.lerp(target, progress)
|
||||
sample.y += sin(progress * PI) * _active_cast_arc_height
|
||||
if _cast_tracks_water_surface:
|
||||
sample.y += (
|
||||
WaterSurfaceMotionType.get_default_height_offset()
|
||||
* smoothstep(0.72, 1.0, progress)
|
||||
)
|
||||
_bobber.global_position = sample
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ enum FishingState {
|
|||
@export_range(1.0, 200.0, 1.0) var preview_ray_start_height: float = 100.0
|
||||
@export_range(1.0, 400.0, 1.0) var preview_surface_ray_length: float = 240.0
|
||||
@export_range(0.01, 1.0, 0.01) var preview_marker_vertical_offset: float = 0.06
|
||||
@export_range(0.0, 0.5, 0.01) var water_occlusion_tolerance: float = 0.04
|
||||
@export_range(0.0, 0.5, 0.01) var solid_probe_clearance: float = 0.04
|
||||
@export_range(0.01, 0.5, 0.01) var solid_bobber_clearance: float = 0.13
|
||||
|
||||
@export_category("Withdrawal")
|
||||
|
|
@ -1457,7 +1457,6 @@ func _configure_surface_resolver() -> void:
|
|||
_surface_resolver.query_radius = fishable_query_radius
|
||||
_surface_resolver.ray_start_height = preview_ray_start_height
|
||||
_surface_resolver.ray_length = preview_surface_ray_length
|
||||
_surface_resolver.water_occlusion_tolerance = water_occlusion_tolerance
|
||||
|
||||
|
||||
func resolve_fishing_surface(
|
||||
|
|
@ -1479,7 +1478,7 @@ func resolve_fishing_surface(
|
|||
get_world_3d().direct_space_state,
|
||||
target,
|
||||
resolved_reference_y,
|
||||
water_occlusion_tolerance,
|
||||
solid_probe_clearance,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ var solid_surface_mask: int = 1
|
|||
var query_radius: float = 0.08
|
||||
var ray_start_height: float = 100.0
|
||||
var ray_length: float = 240.0
|
||||
var water_occlusion_tolerance: float = 0.04
|
||||
var arc_sample_spacing: float = 0.3
|
||||
|
||||
var _water_query_shape: CylinderShape3D = CylinderShape3D.new()
|
||||
|
|
@ -52,9 +51,9 @@ func resolve_surface(
|
|||
var solid_is_above_water: bool = false
|
||||
if not solid_hit.is_empty():
|
||||
var solid_position: Vector3 = solid_hit["position"]
|
||||
solid_is_above_water = (
|
||||
solid_position.y >= water_height - water_occlusion_tolerance
|
||||
)
|
||||
# The water body's authored height is the exact shoreline authority:
|
||||
# submerged terrain is fishable and terrain at or above it is dry.
|
||||
solid_is_above_water = solid_position.y >= water_height
|
||||
if not solid_is_above_water:
|
||||
sample.has_surface = true
|
||||
sample.position = Vector3(
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@ extends RefCounted
|
|||
const FishableWaterRegionType = preload(
|
||||
"res://world/fishable_water_region.gd"
|
||||
)
|
||||
const WaterSurfaceMotionType = preload(
|
||||
"res://world/water_surface_motion.gd"
|
||||
)
|
||||
|
||||
var has_surface: bool = false
|
||||
var position: Vector3 = Vector3.ZERO
|
||||
|
|
@ -22,12 +19,7 @@ func is_fishable() -> bool:
|
|||
func get_marker_position(vertical_offset: float) -> Vector3:
|
||||
if not has_surface:
|
||||
return position
|
||||
var presentation_offset := vertical_offset
|
||||
if is_water_surface:
|
||||
presentation_offset += (
|
||||
WaterSurfaceMotionType.get_default_height_offset()
|
||||
)
|
||||
return position + normal.normalized() * presentation_offset
|
||||
return position + normal.normalized() * vertical_offset
|
||||
|
||||
|
||||
func get_bobber_position(solid_clearance: float) -> Vector3:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
class_name RemoteFishingPresentation
|
||||
extends Node3D
|
||||
|
||||
const WaterSurfaceMotionType = preload(
|
||||
"res://world/water_surface_motion.gd"
|
||||
)
|
||||
const LINE_THICKNESS: float = 0.016
|
||||
|
||||
signal return_completed
|
||||
|
|
@ -157,10 +154,6 @@ func _set_cast_sample(
|
|||
) -> void:
|
||||
_target = start.lerp(target, progress)
|
||||
_target.y += sin(progress * PI) * 2.0
|
||||
_target.y += (
|
||||
WaterSurfaceMotionType.get_default_height_offset()
|
||||
* smoothstep(0.72, 1.0, progress)
|
||||
)
|
||||
_bobber.global_position = _target
|
||||
|
||||
|
||||
|
|
@ -175,10 +168,7 @@ func _on_cast_finished() -> void:
|
|||
|
||||
func _apply_bobber_idle_motion() -> void:
|
||||
var phase: float = _bobber_idle_elapsed * 0.7 * TAU
|
||||
_target = _pending_target + Vector3.UP * (
|
||||
WaterSurfaceMotionType.get_default_height_offset()
|
||||
+ sin(phase) * 0.035
|
||||
)
|
||||
_target = _pending_target + Vector3.UP * sin(phase) * 0.035
|
||||
_bobber.global_position = _target
|
||||
_bobber.rotation.z = deg_to_rad(4.0) * sin(phase * 0.73)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue