buff.lua 367 B

12345678910111213141516171819202122232425
  1. local buff = {}
  2. buff.remove = f.noop
  3. function buff:bind()
  4. self.timer = self.duration
  5. return {
  6. love.update
  7. :subscribe(self:wrap(self.rot))
  8. }
  9. end
  10. function buff:rot()
  11. if self.timer then
  12. local rate = lib.tick.rate
  13. self.timer = self.timer - rate
  14. if self.timer <= 0 then
  15. self.owner.buffs:remove(self)
  16. end
  17. end
  18. end
  19. return buff