spells.lua 518 B

123456789101112131415161718192021222324252627282930
  1. local Spells = class()
  2. function Spells:init()
  3. self.spells = {}
  4. self.depth = -100
  5. if ctx.view then ctx.view:register(self) end
  6. end
  7. function Spells:activate(owner, kind, ...)
  8. local s = new(kind)
  9. s.owner = ctx.players:get(owner)
  10. self.spells[s] = s
  11. s:activate(...)
  12. return s
  13. end
  14. function Spells:deactivate(s)
  15. f.exe(s.deactivate, s)
  16. self.spells[s] = nil
  17. end
  18. function Spells:update()
  19. table.with(self.spells, 'update')
  20. end
  21. function Spells:draw()
  22. table.with(self.spells, 'draw')
  23. end
  24. return Spells