#pragma once #include #include // Accumulates positions to produce their centroid (the center between them). // Shared by the behavior executors that steer toward the middle of a group of // entities (AdvanceExecutor: defence stations; StandbyExecutor: friendly ships). struct Centroid { QVector2D sum; int count = 0; void add(const QVector2D& point) { sum += point; count += 1; } std::optional value() const { if (count == 0) { return std::nullopt; } return sum / static_cast(count); } };