#pragma once #include #include namespace mtgodot { // MapOutdoorWater: one shared vertical translation, alternating a random // 0..-15cm endpoint and zero, linearly interpolated over 1000..3000ms. struct WaterMotion { uint64_t start_ms = 0, duration_ms = 300; double begin = 0, end = 0, current = 0; bool initialized = false; double sample(uint64_t now, uint64_t next_duration, double next_depth_cm) { if (!initialized) { start_ms = now; initialized = true; } if (now - start_ms > duration_ms) { begin = current; end = end == 0 ? -std::clamp(next_depth_cm, 0.0, 15.0) * 0.01 : 0; start_ms = now; duration_ms = std::clamp(next_duration, 1000, 3000); } current = begin + (end - begin) * double(now - start_ms) / double(duration_ms); return current; } }; }