WalkingManager.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /*
  2. * Copyright (C) 2004-2013 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.instancemanager;
  20. import java.util.ArrayList;
  21. import java.util.HashMap;
  22. import java.util.List;
  23. import java.util.Map;
  24. import java.util.concurrent.ScheduledFuture;
  25. import org.w3c.dom.NamedNodeMap;
  26. import org.w3c.dom.Node;
  27. import com.l2jserver.gameserver.ThreadPoolManager;
  28. import com.l2jserver.gameserver.ai.CtrlIntention;
  29. import com.l2jserver.gameserver.engines.DocumentParser;
  30. import com.l2jserver.gameserver.model.L2CharPosition;
  31. import com.l2jserver.gameserver.model.L2NpcWalkerNode;
  32. import com.l2jserver.gameserver.model.L2WalkRoute;
  33. import com.l2jserver.gameserver.model.Location;
  34. import com.l2jserver.gameserver.model.actor.L2Npc;
  35. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  36. import com.l2jserver.gameserver.model.quest.Quest;
  37. import com.l2jserver.gameserver.network.NpcStringId;
  38. import com.l2jserver.gameserver.network.clientpackets.Say2;
  39. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  40. import com.l2jserver.gameserver.util.Broadcast;
  41. import com.l2jserver.util.Rnd;
  42. /**
  43. * This class manages walking monsters.
  44. * @author GKR
  45. */
  46. public class WalkingManager extends DocumentParser
  47. {
  48. // Repeat style:
  49. // 0 - go back
  50. // 1 - go to first point (circle style)
  51. // 2 - teleport to first point (conveyor style)
  52. // 3 - random walking between points.
  53. private static final byte REPEAT_GO_BACK = 0;
  54. private static final byte REPEAT_GO_FIRST = 1;
  55. private static final byte REPEAT_TELE_FIRST = 2;
  56. private static final byte REPEAT_RANDOM = 3;
  57. protected final Map<String, L2WalkRoute> _routes = new HashMap<>(); // all available routes
  58. private final Map<Integer, WalkInfo> _activeRoutes = new HashMap<>(); // each record represents NPC, moving by predefined route from _routes, and moving progress
  59. private final Map<Integer, NpcRoutesHolder> _routesToAttach = new HashMap<>(); // each record represents NPC and all available routes for it
  60. /**
  61. * Holds depending between NPC's spawn point and route
  62. */
  63. private class NpcRoutesHolder
  64. {
  65. private final Map<String, String> _correspondences;
  66. public NpcRoutesHolder()
  67. {
  68. _correspondences = new HashMap<>();
  69. }
  70. /**
  71. * Add correspondence between specific route and specific spawn point
  72. * @param routeName name of route
  73. * @param loc Location of spawn point
  74. */
  75. public void addRoute(String routeName, Location loc)
  76. {
  77. _correspondences.put(getUniqueKey(loc), routeName);
  78. }
  79. /**
  80. * @param npc
  81. * @return route name for given NPC.
  82. */
  83. public String getRouteName(L2Npc npc)
  84. {
  85. if (npc.getSpawn() != null)
  86. {
  87. String key = getUniqueKey(npc.getSpawn().getSpawnLocation());
  88. return _correspondences.containsKey(key) ? _correspondences.get(key) : "";
  89. }
  90. return "";
  91. }
  92. /**
  93. * @param loc
  94. * @return unique text string for given Location.
  95. */
  96. private String getUniqueKey(Location loc)
  97. {
  98. return (loc.getX() + "-" + loc.getY() + "-" + loc.getZ());
  99. }
  100. }
  101. /**
  102. * Holds info about current walk progress
  103. */
  104. private class WalkInfo
  105. {
  106. protected ScheduledFuture<?> _walkCheckTask;
  107. protected boolean _blocked = false;
  108. protected boolean _suspended = false;
  109. protected boolean _stoppedByAttack = false;
  110. protected int _currentNode = 0;
  111. protected boolean _forward = true; // Determines first --> last or first <-- last direction
  112. private final String _routeName;
  113. protected long _lastActionTime; // Debug field
  114. public WalkInfo(String routeName)
  115. {
  116. _routeName = routeName;
  117. }
  118. /**
  119. * @return name of route of this WalkInfo.
  120. */
  121. protected L2WalkRoute getRoute()
  122. {
  123. return _routes.get(_routeName);
  124. }
  125. /**
  126. * @return current node of this WalkInfo.
  127. */
  128. protected L2NpcWalkerNode getCurrentNode()
  129. {
  130. return getRoute().getNodeList().get(_currentNode);
  131. }
  132. /**
  133. * Calculate next node for this WalkInfo and send debug message from given npc
  134. * @param npc NPC to debug message to be sent from
  135. */
  136. protected void calculateNextNode(L2Npc npc)
  137. {
  138. // Check this first, within the bounds of random moving, we have no conception of "first" or "last" node
  139. if (getRoute().getRepeatType() == REPEAT_RANDOM)
  140. {
  141. int newNode = _currentNode;
  142. while (newNode == _currentNode)
  143. {
  144. newNode = Rnd.get(getRoute().getNodesCount());
  145. }
  146. _currentNode = newNode;
  147. npc.sendDebugMessage("Route: " + getRoute().getName() + ", next random node is " + _currentNode);
  148. }
  149. else
  150. {
  151. if (_forward)
  152. {
  153. _currentNode++;
  154. }
  155. else
  156. {
  157. _currentNode--;
  158. }
  159. if (_currentNode == getRoute().getNodesCount()) // Last node arrived
  160. {
  161. // Notify quest
  162. if (npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_ROUTE_FINISHED) != null)
  163. {
  164. for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_ROUTE_FINISHED))
  165. {
  166. quest.notifyRouteFinished(npc);
  167. }
  168. }
  169. npc.sendDebugMessage("Route: " + getRoute().getName() + ", last node arrived");
  170. if (!getRoute().repeatWalk())
  171. {
  172. cancelMoving(npc);
  173. return;
  174. }
  175. switch (getRoute().getRepeatType())
  176. {
  177. case REPEAT_GO_BACK:
  178. _forward = false;
  179. _currentNode -= 2;
  180. break;
  181. case REPEAT_GO_FIRST:
  182. _currentNode = 0;
  183. break;
  184. case REPEAT_TELE_FIRST:
  185. npc.teleToLocation(npc.getSpawn().getLocx(), npc.getSpawn().getLocy(), npc.getSpawn().getLocz());
  186. _currentNode = 0;
  187. break;
  188. }
  189. }
  190. else if (_currentNode == -1) // First node arrived, when direction is first <-- last
  191. {
  192. _currentNode = 1;
  193. _forward = true;
  194. }
  195. }
  196. }
  197. }
  198. protected WalkingManager()
  199. {
  200. load();
  201. }
  202. @Override
  203. public final void load()
  204. {
  205. parseDatapackFile("data/Routes.xml");
  206. _log.info(getClass().getSimpleName() + ": Loaded " + _routes.size() + " walking routes.");
  207. }
  208. @Override
  209. protected void parseDocument()
  210. {
  211. Node n = getCurrentDocument().getFirstChild();
  212. for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  213. {
  214. if (d.getNodeName().equals("route"))
  215. {
  216. final String routeName = parseString(d.getAttributes(), "name");
  217. boolean repeat = parseBoolean(d.getAttributes(), "repeat");
  218. String repeatStyle = d.getAttributes().getNamedItem("repeatStyle").getNodeValue();
  219. byte repeatType;
  220. if (repeatStyle.equalsIgnoreCase("back"))
  221. {
  222. repeatType = REPEAT_GO_BACK;
  223. }
  224. else if (repeatStyle.equalsIgnoreCase("cycle"))
  225. {
  226. repeatType = REPEAT_GO_FIRST;
  227. }
  228. else if (repeatStyle.equalsIgnoreCase("conveyor"))
  229. {
  230. repeatType = REPEAT_TELE_FIRST;
  231. }
  232. else if (repeatStyle.equalsIgnoreCase("random"))
  233. {
  234. repeatType = REPEAT_RANDOM;
  235. }
  236. else
  237. {
  238. repeatType = -1;
  239. }
  240. final List<L2NpcWalkerNode> list = new ArrayList<>();
  241. for (Node r = d.getFirstChild(); r != null; r = r.getNextSibling())
  242. {
  243. if (r.getNodeName().equals("point"))
  244. {
  245. NamedNodeMap attrs = r.getAttributes();
  246. int x = parseInt(attrs, "X");
  247. int y = parseInt(attrs, "Y");
  248. int z = parseInt(attrs, "Z");
  249. int delay = parseInt(attrs, "delay");
  250. String chatString = null;
  251. NpcStringId npcString = null;
  252. Node node = attrs.getNamedItem("string");
  253. if (node != null)
  254. {
  255. chatString = node.getNodeValue();
  256. }
  257. else
  258. {
  259. node = attrs.getNamedItem("npcString");
  260. if (node != null)
  261. {
  262. npcString = NpcStringId.getNpcStringId(node.getNodeValue());
  263. if (npcString == null)
  264. {
  265. _log.warning(getClass().getSimpleName() + ": Unknown npcstring '" + node.getNodeValue() + ".");
  266. continue;
  267. }
  268. }
  269. else
  270. {
  271. node = attrs.getNamedItem("npcStringId");
  272. if (node != null)
  273. {
  274. npcString = NpcStringId.getNpcStringId(Integer.parseInt(node.getNodeValue()));
  275. if (npcString == null)
  276. {
  277. _log.warning(getClass().getSimpleName() + ": Unknown npcstring '" + node.getNodeValue() + ".");
  278. continue;
  279. }
  280. }
  281. }
  282. }
  283. list.add(new L2NpcWalkerNode(0, npcString, chatString, x, y, z, delay, parseBoolean(attrs, "run")));
  284. }
  285. else if (r.getNodeName().equals("target"))
  286. {
  287. NamedNodeMap attrs = r.getAttributes();
  288. try
  289. {
  290. int npcId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
  291. int x = 0, y = 0, z = 0;
  292. x = Integer.parseInt(attrs.getNamedItem("spawnX").getNodeValue());
  293. y = Integer.parseInt(attrs.getNamedItem("spawnY").getNodeValue());
  294. z = Integer.parseInt(attrs.getNamedItem("spawnZ").getNodeValue());
  295. NpcRoutesHolder holder = _routesToAttach.containsKey(npcId) ? _routesToAttach.get(npcId) : new NpcRoutesHolder();
  296. holder.addRoute(routeName, new Location(x, y, z));
  297. _routesToAttach.put(npcId, holder);
  298. }
  299. catch (Exception e)
  300. {
  301. _log.warning("Walking Manager: Error in target definition for route : " + routeName);
  302. }
  303. }
  304. }
  305. _routes.put(routeName, new L2WalkRoute(routeName, list, repeat, false, repeatType));
  306. }
  307. }
  308. }
  309. /**
  310. * @param npc NPC to check
  311. * @return {@code true} if given NPC, or its leader is controlled by Walking Manager and moves currently.
  312. */
  313. public boolean isOnWalk(L2Npc npc)
  314. {
  315. L2MonsterInstance monster = null;
  316. if (npc.isMonster())
  317. {
  318. if (((L2MonsterInstance) npc).getLeader() == null)
  319. {
  320. monster = (L2MonsterInstance) npc;
  321. }
  322. else
  323. {
  324. monster = ((L2MonsterInstance) npc).getLeader();
  325. }
  326. }
  327. if (((monster != null) && !isRegistered(monster)) || !isRegistered(npc))
  328. {
  329. return false;
  330. }
  331. WalkInfo walk = monster != null ? _activeRoutes.get(monster.getObjectId()) : _activeRoutes.get(npc.getObjectId());
  332. if (walk._stoppedByAttack || walk._suspended)
  333. {
  334. return false;
  335. }
  336. return true;
  337. }
  338. /**
  339. * @param npc NPC to check
  340. * @return {@code true} if given NPC controlled by Walking Manager.
  341. */
  342. public boolean isRegistered(L2Npc npc)
  343. {
  344. return _activeRoutes.containsKey(npc.getObjectId());
  345. }
  346. /**
  347. * @param npc
  348. * @return name of route
  349. */
  350. public String getRouteName(L2Npc npc)
  351. {
  352. return _activeRoutes.containsKey(npc.getObjectId()) ? _activeRoutes.get(npc.getObjectId()).getRoute().getName() : "";
  353. }
  354. /**
  355. * Start to move given NPC by given route
  356. * @param npc NPC to move
  357. * @param routeName name of route to move by
  358. */
  359. public void startMoving(final L2Npc npc, final String routeName)
  360. {
  361. if (_routes.containsKey(routeName) && (npc != null) && !npc.isDead()) // check, if these route and NPC present
  362. {
  363. if (!_activeRoutes.containsKey(npc.getObjectId())) // new walk task
  364. {
  365. // only if not already moved / not engaged in battle... should not happens if called on spawn
  366. if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE) || (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE))
  367. {
  368. WalkInfo walk = new WalkInfo(routeName);
  369. if (npc.isDebug())
  370. {
  371. walk._lastActionTime = System.currentTimeMillis();
  372. }
  373. L2NpcWalkerNode node = walk.getCurrentNode();
  374. // adjust next waypoint, if NPC spawns at first waypoint
  375. if ((npc.getX() == node.getMoveX()) && (npc.getY() == node.getMoveY()))
  376. {
  377. walk.calculateNextNode(npc);
  378. node = walk.getCurrentNode();
  379. npc.sendDebugMessage("Route " + routeName + ", spawn point is same with first waypoint, adjusted to next");
  380. }
  381. if (!npc.isInsideRadius(node.getMoveX(), node.getMoveY(), node.getMoveZ(), 3000, true, false))
  382. {
  383. npc.sendDebugMessage("Route " + routeName + ", NPC is too far from starting point, walking will no start");
  384. return;
  385. }
  386. npc.sendDebugMessage("Starting to move at route " + routeName);
  387. npc.setIsRunning(node.getRunning());
  388. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(node.getMoveX(), node.getMoveY(), node.getMoveZ(), 0));
  389. walk._walkCheckTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Runnable()
  390. {
  391. @Override
  392. public void run()
  393. {
  394. startMoving(npc, routeName);
  395. }
  396. }, 60000, 60000); // start walk check task, for resuming walk after fight
  397. npc.getKnownList().startTrackingTask();
  398. _activeRoutes.put(npc.getObjectId(), walk); // register route
  399. }
  400. else
  401. {
  402. npc.sendDebugMessage("Trying to start move at route " + routeName + ", but cannot now, scheduled");
  403. ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  404. {
  405. @Override
  406. public void run()
  407. {
  408. startMoving(npc, routeName);
  409. }
  410. }, 60000);
  411. }
  412. }
  413. else
  414. // walk was stopped due to some reason (arrived to node, script action, fight or something else), resume it
  415. {
  416. if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE) || (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE))
  417. {
  418. WalkInfo walk = _activeRoutes.get(npc.getObjectId());
  419. // Prevent call simultaneously from scheduled task and onArrived() or temporarily stop walking for resuming in future
  420. if (walk._blocked || walk._suspended)
  421. {
  422. npc.sendDebugMessage("Trying continue to move at route " + routeName + ", but cannot now (operation is blocked)");
  423. return;
  424. }
  425. walk._blocked = true;
  426. L2NpcWalkerNode node = walk.getCurrentNode();
  427. npc.sendDebugMessage("Route id: " + routeName + ", continue to node " + walk._currentNode);
  428. npc.setIsRunning(node.getRunning());
  429. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(node.getMoveX(), node.getMoveY(), node.getMoveZ(), 0));
  430. walk._blocked = false;
  431. walk._stoppedByAttack = false;
  432. }
  433. else
  434. {
  435. npc.sendDebugMessage("Trying continue to move at route " + routeName + ", but cannot now (wrong AI state)");
  436. }
  437. }
  438. }
  439. }
  440. /**
  441. * Cancel NPC moving permanently
  442. * @param npc NPC to cancel
  443. */
  444. public synchronized void cancelMoving(L2Npc npc)
  445. {
  446. if (_activeRoutes.containsKey(npc.getObjectId()))
  447. {
  448. final WalkInfo walk = _activeRoutes.remove(npc.getObjectId());
  449. walk._walkCheckTask.cancel(true);
  450. npc.getKnownList().stopTrackingTask();
  451. }
  452. }
  453. /**
  454. * Resumes previously stopped moving
  455. * @param npc NPC to resume
  456. */
  457. public void resumeMoving(final L2Npc npc)
  458. {
  459. if (!_activeRoutes.containsKey(npc.getObjectId()))
  460. {
  461. return;
  462. }
  463. WalkInfo walk = _activeRoutes.get(npc.getObjectId());
  464. walk._suspended = false;
  465. walk._stoppedByAttack = false;
  466. startMoving(npc, walk.getRoute().getName());
  467. }
  468. /**
  469. * Pause NPC moving until it will be resumed
  470. * @param npc NPC to pause moving
  471. * @param suspend {@code true} if moving was temporarily suspended for some reasons of AI-controlling script
  472. * @param stoppedByAttack {@code true} if moving was suspended because of NPC was attacked or desired to attack
  473. */
  474. public void stopMoving(L2Npc npc, boolean suspend, boolean stoppedByAttack)
  475. {
  476. L2MonsterInstance monster = null;
  477. if (npc.isMonster())
  478. {
  479. if (((L2MonsterInstance) npc).getLeader() == null)
  480. {
  481. monster = (L2MonsterInstance) npc;
  482. }
  483. else
  484. {
  485. monster = ((L2MonsterInstance) npc).getLeader();
  486. }
  487. }
  488. if (((monster != null) && !isRegistered(monster)) || !isRegistered(npc))
  489. {
  490. return;
  491. }
  492. WalkInfo walk = monster != null ? _activeRoutes.get(monster.getObjectId()) : _activeRoutes.get(npc.getObjectId());
  493. walk._suspended = suspend;
  494. walk._stoppedByAttack = stoppedByAttack;
  495. if (monster != null)
  496. {
  497. monster.stopMove(null);
  498. monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
  499. }
  500. else
  501. {
  502. npc.stopMove(null);
  503. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
  504. }
  505. }
  506. /**
  507. * Manage "node arriving"-related tasks: schedule move to next node; send ON_NODE_ARRIVED event to Quest script
  508. * @param npc NPC to manage
  509. */
  510. public void onArrived(final L2Npc npc)
  511. {
  512. if (_activeRoutes.containsKey(npc.getObjectId()))
  513. {
  514. // Notify quest
  515. if (npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_NODE_ARRIVED) != null)
  516. {
  517. for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_NODE_ARRIVED))
  518. {
  519. quest.notifyNodeArrived(npc);
  520. }
  521. }
  522. WalkInfo walk = _activeRoutes.get(npc.getObjectId());
  523. // Opposite should not happen... but happens sometime
  524. if ((walk._currentNode >= 0) && (walk._currentNode < walk.getRoute().getNodesCount()))
  525. {
  526. L2NpcWalkerNode node = walk.getRoute().getNodeList().get(walk._currentNode);
  527. if (npc.isInsideRadius(node.getMoveX(), node.getMoveY(), node.getMoveZ(), 10, false, false))
  528. {
  529. npc.sendDebugMessage("Route: " + walk.getRoute().getName() + ", arrived to node " + walk._currentNode);
  530. npc.sendDebugMessage("Done in " + ((System.currentTimeMillis() - walk._lastActionTime) / 1000) + " s.");
  531. walk.calculateNextNode(npc);
  532. int delay = node.getDelay();
  533. walk._blocked = true; // prevents to be ran from walk check task, if there is delay in this node.
  534. if (node.getNpcString() != null)
  535. {
  536. Broadcast.toKnownPlayers(npc, new NpcSay(npc, Say2.NPC_ALL, node.getNpcString()));
  537. }
  538. else
  539. {
  540. final String text = node.getChatText();
  541. if ((text != null) && !text.isEmpty())
  542. {
  543. Broadcast.toKnownPlayers(npc, new NpcSay(npc, Say2.NPC_ALL, text));
  544. }
  545. }
  546. if (npc.isDebug())
  547. {
  548. walk._lastActionTime = System.currentTimeMillis();
  549. }
  550. ThreadPoolManager.getInstance().scheduleGeneral(new ArrivedTask(npc, walk), 100 + (delay * 1000L));
  551. }
  552. }
  553. }
  554. }
  555. /**
  556. * Manage "on death"-related tasks: permanently cancel moving of died NPC
  557. * @param npc NPC to manage
  558. */
  559. public void onDeath(L2Npc npc)
  560. {
  561. cancelMoving(npc);
  562. }
  563. /**
  564. * Manage "on spawn"-related tasks: start NPC moving, if there is route attached to its spawn point
  565. * @param npc NPC to manage
  566. */
  567. public void onSpawn(L2Npc npc)
  568. {
  569. if (_routesToAttach.containsKey(npc.getNpcId()))
  570. {
  571. final String routeName = _routesToAttach.get(npc.getNpcId()).getRouteName(npc);
  572. if (!routeName.isEmpty())
  573. {
  574. startMoving(npc, routeName);
  575. }
  576. }
  577. }
  578. private class ArrivedTask implements Runnable
  579. {
  580. WalkInfo _walk;
  581. L2Npc _npc;
  582. public ArrivedTask(L2Npc npc, WalkInfo walk)
  583. {
  584. _npc = npc;
  585. _walk = walk;
  586. }
  587. @Override
  588. public void run()
  589. {
  590. _walk._blocked = false;
  591. startMoving(_npc, _walk.getRoute().getName());
  592. }
  593. }
  594. public static final WalkingManager getInstance()
  595. {
  596. return SingletonHolder._instance;
  597. }
  598. private static class SingletonHolder
  599. {
  600. protected static final WalkingManager _instance = new WalkingManager();
  601. }
  602. }