TileUpdater.java 958 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package me.hammerle.supersnuvi.rendering;
  2. import java.util.LinkedList;
  3. public class TileUpdater
  4. {
  5. private static class Update
  6. {
  7. private final int l;
  8. private final int x;
  9. private final int y;
  10. public Update(int l, int x, int y)
  11. {
  12. this.l = l;
  13. this.x = x;
  14. this.y = y;
  15. }
  16. }
  17. private final LinkedList<Update> updates = new LinkedList<>();
  18. private boolean updateAll = false;
  19. public void add(int layer, int x, int y)
  20. {
  21. updates.add(new Update(layer, x, y));
  22. }
  23. public void forEach(UpdateConsumer uc)
  24. {
  25. updates.forEach((up) -> uc.accept(up.l, up.x, up.y));
  26. }
  27. public void updateAll()
  28. {
  29. updateAll = true;
  30. }
  31. public boolean shouldUpdateAll()
  32. {
  33. return updateAll;
  34. }
  35. public void clear()
  36. {
  37. updates.clear();
  38. updateAll = false;
  39. }
  40. }