shrujupatches.lua 695 B

12345678910111213141516171819202122232425262728
  1. ShrujuPatches = class()
  2. function ShrujuPatches:init()
  3. self.index = 1
  4. self.objects = {}
  5. self.harvestLevel = 0
  6. self.flowLevel = 0
  7. end
  8. function ShrujuPatches:update()
  9. table.with(self.objects, 'update')
  10. local conf = config.biomes[ctx.biome]
  11. if conf.shrujuPatches[self.index] and ctx.timer * ls.tickrate > conf.shrujuPatches[self.index] then
  12. self:add()
  13. end
  14. end
  15. function ShrujuPatches:add()
  16. local x = ctx.map.width * (.2 + (self.index == 2 and .6 or 0))
  17. local patch = ShrujuPatch()
  18. patch.id = self.index
  19. table.merge({x = x}, patch)
  20. patch:activate()
  21. table.insert(self.objects, patch)
  22. ctx.hud.shrujuPatches[patch.id].patch = patch
  23. self.index = self.index + 1
  24. end