W6: Water and swimming
The simulation has a global sea level (Simulation.sea_level, changed with set_sea_level and read every tick, so the tide can move it mid-match). Walkers wade more slowly in water over WADE_DEPTH; in water SWIM_DEPTH deep they swim: floating head-out, sprint-swimming, diving with crouch, kicking out with jump, and standing again in the shallows. Falling into deep water does no fall damage. Water tracks breath, stamina and drowning in whole ticks: swimming spends stamina, an exhausted swimmer slips under, and with no breath left the tide phase's drown damage lands once a second. All of it, plus the sea level, is in the state hash. WaterView draws the sea surface at the simulation's level with a procedural shader: depth-tinted colour, foam at the waterline, ripples. Closes #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,9 @@ const CRACK_COLOUR: Color = Color(1.0, 0.0, 1.0)
|
||||
## the camera stands `poi_view` (x right, y up, z out of the front) from its origin.
|
||||
@export var poi_kind: String = ""
|
||||
@export var poi_view: Vector3 = Vector3(6.0, 7.0, 22.0)
|
||||
## Draw the sea at `sea_level`. Never in crack checks, where it would hide seams.
|
||||
@export var show_water: bool = true
|
||||
@export var sea_level: float = Tuning.SEA_LEVEL_START
|
||||
## Draw the island's props too.
|
||||
@export var show_props: bool = false
|
||||
## When set, frame the first prop of this kind whose surroundings hold at least
|
||||
@@ -113,6 +116,10 @@ func _ready() -> void:
|
||||
sim_props.damage(crowd[index], 100000)
|
||||
prop_view_node.sync()
|
||||
break
|
||||
if show_water and not crack_check:
|
||||
var water: WaterView = WaterView.new()
|
||||
water.set_level(sea_level)
|
||||
add_child(water)
|
||||
add_child(camera)
|
||||
camera.look_at(look_at_point)
|
||||
camera.make_current()
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureWater" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
island_seed = 2
|
||||
show_props = true
|
||||
sea_level = 18.0
|
||||
@@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureWater" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
island_seed = 2
|
||||
show_props = true
|
||||
poi_kind = "dock"
|
||||
poi_view = Vector3(-18, 9, 26)
|
||||
Reference in New Issue
Block a user