11constexpr double kOver = 1.0;
13constexpr double kHitsOver = 5.0;
18 if (!places_.empty() && sent <= places_.back().sent) {
21 places_.push_back({.sent = sent, .x = x, .z = z});
22 while (places_.size() > 2 && places_.back().sent - places_[1].sent >= kOver) {
28 if (places_.size() < 2) {
32 for (std::size_t i = 1; i < places_.size(); ++i) {
33 metres += std::hypot(places_[i].x - places_[i - 1].x,
34 places_[i].z - places_[i - 1].z);
36 return static_cast<float>(metres /
37 (places_.back().sent - places_.front().sent));
41 hits_.push_back({.at = at, .amount = amount});
42 while (!hits_.empty() && at - hits_.front().at > kHitsOver) {
48 std::size_t count = 0;
49 for (
const Hit& hit : hits_) {
50 count += now - hit.at < kHitsOver ? 1 : 0;
52 return static_cast<float>(
static_cast<double>(count) / kHitsOver);
57 for (
const Hit& hit : hits_) {
58 damage += now - hit.at < kHitsOver ? hit.amount : 0;
60 return static_cast<float>(damage / kHitsOver);
float DamagePerSecond(double now) const
void Add(double at, uint32_t amount)
A hit that did the amount, at the time, in seconds on our clock.
float PerSecond(double now) const
Over the last five seconds to now, as a swing takes about one.
float MetresASecond() const
void Add(double sent, float x, float z)