player_score_accumulator = {
    ACC_TIMER = 2.0,

    acc = 0.0,
    cached_score = nil,
    timer = 0.0,
}

function player_score_accumulator:init()

end

function player_score_accumulator:tick(dt)
    self.current_score = GetInt("level.players."..GetInt("level.player.id")..".damage")

    if self.cached_score ~= nil then
        if self.cached_score ~= self.current_score then
            self.timer = self.ACC_TIMER
            self.acc = self.acc + (self.current_score - self.cached_score)
        end
    end
    self.cached_score = self.current_score

    if self.timer < 0.0 then
        self.acc = 0.0
    else
        self.timer = self.timer - dt
    end

    SetInt("level.player_acc_score", self.acc)
end
