Advertisement
Guest User

Untitled

a guest
Jun 10th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. package com.l2jfrozen.gameserver.datatables;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Collection;
  5.  
  6. import com.l2jrcore.gameserver.model.L2Object;
  7. import com.l2jrcore.gameserver.model.actor.instance.L2FenceInstance;
  8.  
  9. public class FenceTable
  10. {
  11. public static ArrayList<L2FenceInstance> fences = new ArrayList<>();
  12.  
  13. public static void addFence(L2FenceInstance fence)
  14. {
  15. fences.add(fence);
  16. }
  17.  
  18. public static ArrayList<L2FenceInstance> getAllFences()
  19. {
  20. return fences;
  21. }
  22.  
  23. public static void removeFence(L2FenceInstance fence)
  24. {
  25. if (fences.contains(fence))
  26. fences.remove(fence);
  27. }
  28.  
  29. public static boolean canSeeTarget(L2Object source, int x, int y)
  30. {
  31. Collection<L2Object> objects = source.getKnownList().getKnownObjects().values();
  32.  
  33. for (L2Object obj : objects)
  34. {
  35. if (obj instanceof L2FenceInstance)
  36. {
  37. L2FenceInstance fence = (L2FenceInstance) obj;
  38.  
  39. if (fence.isBetween(source.getX(), source.getY(), x, y))
  40. return false;
  41. }
  42. }
  43.  
  44. return true;
  45. }
  46.  
  47. public static boolean canSeeTarget(int x, int y, int tx, int ty)
  48. {
  49. for (L2FenceInstance fence : fences)
  50. {
  51. if (fence.isBetween(x, y, tx, ty))
  52. return false;
  53. }
  54.  
  55. return true;
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement