AiParameters.java 3.0 KB

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