Files
tidewall/test/client/test_water_view.gd
T
claudeandClaude Opus 5.5 be987b6f82 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>
2026-11-11 12:24:50 -05:00

21 lines
806 B
GDScript

extends TestCase
## The client sea from issue W6 follows the simulation's sea level.
func test_surface_follows_the_simulation_sea_level() -> void:
var sim: Simulation = Simulation.new(1, SimGround.flat())
var view: WaterView = WaterView.new()
view.follow(sim)
assert_eq(view.surface().position.y, Tuning.SEA_LEVEL_START)
sim.set_sea_level(8.0)
view.follow(sim)
assert_eq(view.surface().position.y, 8.0)
assert_eq(view.level, 8.0)
# The surface covers the whole world and well past it, so no edge is ever in view.
var mesh: PlaneMesh = view.surface().mesh
assert_true(mesh.size.x >= Tuning.WORLD_SIZE_METRES * 4.0)
assert_near(view.surface().position.x, Tuning.WORLD_SIZE_METRES * 0.5, 0.001)
assert_eq(view.surface().cast_shadow, GeometryInstance3D.SHADOW_CASTING_SETTING_OFF)
view.free()