diff options
Diffstat (limited to 'src/game/build_graph.cpp')
| -rw-r--r-- | src/game/build_graph.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/game/build_graph.cpp b/src/game/build_graph.cpp index 032bbf5..a1195af 100644 --- a/src/game/build_graph.cpp +++ b/src/game/build_graph.cpp @@ -291,6 +291,21 @@ int BuildGraph::kill_grounded() { // Destruction // ============================================================================= +void BuildGraph::apply_recoil(float x, float y, float radius, + float dx, float dy, float strength) { + if (radius <= 0.0f || strength <= 0.0f) return; + + for (auto& n : nodes) { + if (n.is_foundation) continue; // pinned: the ground eats the recoil + float ox = n.x - x, oy = n.y - y; + float d = std::sqrt(ox*ox + oy*oy); + if (d >= radius) continue; + float f = 1.0f - d / radius; // linear falloff, as in apply_splash + n.vx += dx * strength * f; + n.vy += dy * strength * f; + } +} + void BuildGraph::apply_splash(float x, float y, float radius, float damage, float knockback) { if (radius <= 0.0f) return; |
