AiParameters.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.ai2;
  16. import java.util.EnumSet;
  17. import java.util.List;
  18. import java.util.Queue;
  19. import java.util.concurrent.PriorityBlockingQueue;
  20. import com.l2jserver.gameserver.model.actor.L2Character;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import javolution.util.FastList;
  23. /**
  24. *
  25. * @author -Wooden-
  26. *
  27. */
  28. public class AiParameters
  29. {
  30. private Queue<AiEvent> _eventQueue;
  31. private EnumSet<AiEventType> _inhibitions;
  32. private L2Npc _actor;
  33. private List<Hated> _hated;
  34. private List<Liked> _liked;
  35. public class Hated
  36. {
  37. public L2Character character;
  38. public HateReason reason;
  39. public int degree;
  40. }
  41. public class Liked
  42. {
  43. public L2Character character;
  44. public LikeReason reason;
  45. public int degree;
  46. }
  47. public enum HateReason
  48. {
  49. GAVE_DAMMAGE,
  50. HEALS_ENNEMY,
  51. GAVE_DAMMAGE_TO_FRIEND,
  52. IS_ENNEMY
  53. }
  54. public enum LikeReason
  55. {
  56. FRIEND,
  57. HEALED,
  58. HEALED_FRIEND,
  59. GAVE_DAMMAGE_TO_ENNEMY
  60. }
  61. public AiParameters(L2Npc actor)
  62. {
  63. _eventQueue = new PriorityBlockingQueue<AiEvent>();
  64. _hated = new FastList<Hated>();
  65. _liked = new FastList<Liked>();
  66. _actor = actor;
  67. _inhibitions = EnumSet.noneOf(AiEventType.class);
  68. }
  69. /**
  70. * @return
  71. */
  72. public boolean hasEvents()
  73. {
  74. return _eventQueue.isEmpty();
  75. }
  76. /**
  77. * @return
  78. */
  79. public AiEvent nextEvent()
  80. {
  81. return _eventQueue.poll();
  82. }
  83. public void queueEvents(AiEvent set)
  84. {
  85. _eventQueue.offer(set);
  86. }
  87. public L2Npc getActor()
  88. {
  89. return _actor;
  90. }
  91. public List<Hated> getHated()
  92. {
  93. return _hated;
  94. }
  95. public List<Liked> getLiked()
  96. {
  97. return _liked;
  98. }
  99. public void addLiked(Liked cha)
  100. {
  101. _liked.add(cha);
  102. }
  103. public void addHated(Hated cha)
  104. {
  105. _hated.add(cha);
  106. }
  107. public void clear()
  108. {
  109. _hated.clear();
  110. _liked.clear();
  111. _eventQueue.clear();
  112. _inhibitions.clear();
  113. }
  114. public void inhibit(AiEventType type)
  115. {
  116. _inhibitions.add(type);
  117. }
  118. public void deInhibit(AiEventType type)
  119. {
  120. _inhibitions.remove(type);
  121. }
  122. /**
  123. * @param type
  124. * @return
  125. */
  126. public boolean isEventInhibited(AiEventType type)
  127. {
  128. return _inhibitions.contains(type);
  129. }
  130. }