2
0

WalkingManager.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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.<br>
  103. * Zoey76: TODO: Move to own file, and use getters and setters.
  104. */
  105. private class WalkInfo
  106. {
  107. protected ScheduledFuture<?> _walkCheckTask;
  108. protected boolean _blocked = false;
  109. protected boolean _suspended = false;
  110. protected boolean _stoppedByAttack = false;
  111. protected int _currentNode = 0;
  112. protected boolean _forward = true; // Determines first --> last or first <-- last direction
  113. private final String _routeName;
  114. protected long _lastActionTime; // Debug field
  115. public WalkInfo(String routeName)
  116. {
  117. _routeName = routeName;
  118. }
  119. /**
  120. * @return name of route of this WalkInfo.
  121. */
  122. protected L2WalkRoute getRoute()
  123. {
  124. return _routes.get(_routeName);
  125. }
  126. /**
  127. * @return current node of this WalkInfo.
  128. */
  129. protected L2NpcWalkerNode getCurrentNode()
  130. {
  131. return getRoute().getNodeList().get(_currentNode);
  132. }
  133. /**
  134. * Calculate next node for this WalkInfo and send debug message from given npc
  135. * @param npc NPC to debug message to be sent from
  136. */
  137. protected void calculateNextNode(L2Npc npc)
  138. {
  139. // Check this first, within the bounds of random moving, we have no conception of "first" or "last" node
  140. if (getRoute().getRepeatType() == REPEAT_RANDOM)
  141. {
  142. int newNode = _currentNode;
  143. while (newNode == _currentNode)
  144. {
  145. newNode = Rnd.get(getRoute().getNodesCount());
  146. }
  147. _currentNode = newNode;
  148. npc.sendDebugMessage("Route: " + getRoute().getName() + ", next random node is " + _currentNode);
  149. }
  150. else
  151. {
  152. if (_forward)
  153. {
  154. _currentNode++;
  155. }
  156. else
  157. {
  158. _currentNode--;
  159. }
  160. if (_currentNode == getRoute().getNodesCount()) // Last node arrived
  161. {
  162. // Notify quest
  163. if (npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_ROUTE_FINISHED) != null)
  164. {
  165. for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_ROUTE_FINISHED))
  166. {
  167. quest.notifyRouteFinished(npc);
  168. }
  169. }
  170. npc.sendDebugMessage("Route: " + getRoute().getName() + ", last node arrived");
  171. if (!getRoute().repeatWalk())
  172. {
  173. cancelMoving(npc);
  174. return;
  175. }
  176. switch (getRoute().getRepeatType())
  177. {
  178. case REPEAT_GO_BACK:
  179. _forward = false;
  180. _currentNode -= 2;
  181. break;
  182. case REPEAT_GO_FIRST:
  183. _currentNode = 0;
  184. break;
  185. case REPEAT_TELE_FIRST:
  186. npc.teleToLocation(npc.getSpawn().getLocx(), npc.getSpawn().getLocy(), npc.getSpawn().getLocz());
  187. _currentNode = 0;
  188. break;
  189. }
  190. }
  191. else if (_currentNode == -1) // First node arrived, when direction is first <-- last
  192. {
  193. _currentNode = 1;
  194. _forward = true;
  195. }
  196. }
  197. }
  198. }
  199. protected WalkingManager()
  200. {
  201. load();
  202. }
  203. @Override
  204. public final void load()
  205. {
  206. parseDatapackFile("data/Routes.xml");
  207. _log.info(getClass().getSimpleName() + ": Loaded " + _routes.size() + " walking routes.");
  208. }
  209. @Override
  210. protected void parseDocument()
  211. {
  212. Node n = getCurrentDocument().getFirstChild();
  213. for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  214. {
  215. if (d.getNodeName().equals("route"))
  216. {
  217. final String routeName = parseString(d.getAttributes(), "name");
  218. boolean repeat = parseBoolean(d.getAttributes(), "repeat");
  219. String repeatStyle = d.getAttributes().getNamedItem("repeatStyle").getNodeValue();
  220. byte repeatType;
  221. if (repeatStyle.equalsIgnoreCase("back"))
  222. {
  223. repeatType = REPEAT_GO_BACK;
  224. }
  225. else if (repeatStyle.equalsIgnoreCase("cycle"))
  226. {
  227. repeatType = REPEAT_GO_FIRST;
  228. }
  229. else if (repeatStyle.equalsIgnoreCase("conveyor"))
  230. {
  231. repeatType = REPEAT_TELE_FIRST;
  232. }
  233. else if (repeatStyle.equalsIgnoreCase("random"))
  234. {
  235. repeatType = REPEAT_RANDOM;
  236. }
  237. else
  238. {
  239. repeatType = -1;
  240. }
  241. final List<L2NpcWalkerNode> list = new ArrayList<>();
  242. for (Node r = d.getFirstChild(); r != null; r = r.getNextSibling())
  243. {
  244. if (r.getNodeName().equals("point"))
  245. {
  246. NamedNodeMap attrs = r.getAttributes();
  247. int x = parseInt(attrs, "X");
  248. int y = parseInt(attrs, "Y");
  249. int z = parseInt(attrs, "Z");
  250. int delay = parseInt(attrs, "delay");
  251. String chatString = null;
  252. NpcStringId npcString = null;
  253. Node node = attrs.getNamedItem("string");
  254. if (node != null)
  255. {
  256. chatString = node.getNodeValue();
  257. }
  258. else
  259. {
  260. node = attrs.getNamedItem("npcString");
  261. if (node != null)
  262. {
  263. npcString = NpcStringId.getNpcStringId(node.getNodeValue());
  264. if (npcString == null)
  265. {
  266. _log.warning(getClass().getSimpleName() + ": Unknown npcstring '" + node.getNodeValue() + ".");
  267. continue;
  268. }
  269. }
  270. else
  271. {
  272. node = attrs.getNamedItem("npcStringId");
  273. if (node != null)
  274. {
  275. npcString = NpcStringId.getNpcStringId(Integer.parseInt(node.getNodeValue()));
  276. if (npcString == null)
  277. {
  278. _log.warning(getClass().getSimpleName() + ": Unknown npcstring '" + node.getNodeValue() + ".");
  279. continue;
  280. }
  281. }
  282. }
  283. }
  284. list.add(new L2NpcWalkerNode(0, npcString, chatString, x, y, z, delay, parseBoolean(attrs, "run")));
  285. }
  286. else if (r.getNodeName().equals("target"))
  287. {
  288. NamedNodeMap attrs = r.getAttributes();
  289. try
  290. {
  291. int npcId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
  292. int x = 0, y = 0, z = 0;
  293. x = Integer.parseInt(attrs.getNamedItem("spawnX").getNodeValue());
  294. y = Integer.parseInt(attrs.getNamedItem("spawnY").getNodeValue());
  295. z = Integer.parseInt(attrs.getNamedItem("spawnZ").getNodeValue());
  296. NpcRoutesHolder holder = _routesToAttach.containsKey(npcId) ? _routesToAttach.get(npcId) : new NpcRoutesHolder();
  297. holder.addRoute(routeName, new Location(x, y, z));
  298. _routesToAttach.put(npcId, holder);
  299. }
  300. catch (Exception e)
  301. {
  302. _log.warning("Walking Manager: Error in target definition for route : " + routeName);
  303. }
  304. }
  305. }
  306. _routes.put(routeName, new L2WalkRoute(routeName, list, repeat, false, repeatType));
  307. }
  308. }
  309. }
  310. /**
  311. * @param npc NPC to check
  312. * @return {@code true} if given NPC, or its leader is controlled by Walking Manager and moves currently.
  313. */
  314. public boolean isOnWalk(L2Npc npc)
  315. {
  316. L2MonsterInstance monster = null;
  317. if (npc.isMonster())
  318. {
  319. if (((L2MonsterInstance) npc).getLeader() == null)
  320. {
  321. monster = (L2MonsterInstance) npc;
  322. }
  323. else
  324. {
  325. monster = ((L2MonsterInstance) npc).getLeader();
  326. }
  327. }
  328. if (((monster != null) && !isRegistered(monster)) || !isRegistered(npc))
  329. {
  330. return false;
  331. }
  332. WalkInfo walk = monster != null ? _activeRoutes.get(monster.getObjectId()) : _activeRoutes.get(npc.getObjectId());
  333. if (walk._stoppedByAttack || walk._suspended)
  334. {
  335. return false;
  336. }
  337. return true;
  338. }
  339. /**
  340. * @param npc NPC to check
  341. * @return {@code true} if given NPC controlled by Walking Manager.
  342. */
  343. public boolean isRegistered(L2Npc npc)
  344. {
  345. return _activeRoutes.containsKey(npc.getObjectId());
  346. }
  347. /**
  348. * @param npc
  349. * @return name of route
  350. */
  351. public String getRouteName(L2Npc npc)
  352. {
  353. return _activeRoutes.containsKey(npc.getObjectId()) ? _activeRoutes.get(npc.getObjectId()).getRoute().getName() : "";
  354. }
  355. /**
  356. * Start to move given NPC by given route
  357. * @param npc NPC to move
  358. * @param routeName name of route to move by
  359. */
  360. public void startMoving(final L2Npc npc, final String routeName)
  361. {
  362. if (_routes.containsKey(routeName) && (npc != null) && !npc.isDead()) // check, if these route and NPC present
  363. {
  364. if (!_activeRoutes.containsKey(npc.getObjectId())) // new walk task
  365. {
  366. // only if not already moved / not engaged in battle... should not happens if called on spawn
  367. if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE) || (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE))
  368. {
  369. WalkInfo walk = new WalkInfo(routeName);
  370. if (npc.isDebug())
  371. {
  372. walk._lastActionTime = System.currentTimeMillis();
  373. }
  374. L2NpcWalkerNode node = walk.getCurrentNode();
  375. // adjust next waypoint, if NPC spawns at first waypoint
  376. if ((npc.getX() == node.getMoveX()) && (npc.getY() == node.getMoveY()))
  377. {
  378. walk.calculateNextNode(npc);
  379. node = walk.getCurrentNode();
  380. npc.sendDebugMessage("Route " + routeName + ", spawn point is same with first waypoint, adjusted to next");
  381. }
  382. if (!npc.isInsideRadius(node.getMoveX(), node.getMoveY(), node.getMoveZ(), 3000, true, false))
  383. {
  384. npc.sendDebugMessage("Route " + routeName + ", NPC is too far from starting point, walking will no start");
  385. return;
  386. }
  387. npc.sendDebugMessage("Starting to move at route " + routeName);
  388. npc.setIsRunning(node.getRunning());
  389. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(node.getMoveX(), node.getMoveY(), node.getMoveZ(), 0));
  390. walk._walkCheckTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Runnable()
  391. {
  392. @Override
  393. public void run()
  394. {
  395. startMoving(npc, routeName);
  396. }
  397. }, 60000, 60000); // start walk check task, for resuming walk after fight
  398. npc.getKnownList().startTrackingTask();
  399. _activeRoutes.put(npc.getObjectId(), walk); // register route
  400. }
  401. else
  402. {
  403. npc.sendDebugMessage("Trying to start move at route " + routeName + ", but cannot now, scheduled");
  404. ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  405. {
  406. @Override
  407. public void run()
  408. {
  409. startMoving(npc, routeName);
  410. }
  411. }, 60000);
  412. }
  413. }
  414. else
  415. // walk was stopped due to some reason (arrived to node, script action, fight or something else), resume it
  416. {
  417. if (_activeRoutes.containsKey(npc.getObjectId()) && ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE) || (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)))
  418. {
  419. WalkInfo walk = _activeRoutes.get(npc.getObjectId());
  420. // Prevent call simultaneously from scheduled task and onArrived() or temporarily stop walking for resuming in future
  421. if (walk._blocked || walk._suspended)
  422. {
  423. npc.sendDebugMessage("Trying continue to move at route " + routeName + ", but cannot now (operation is blocked)");
  424. return;
  425. }
  426. walk._blocked = true;
  427. L2NpcWalkerNode node = walk.getCurrentNode();
  428. npc.sendDebugMessage("Route id: " + routeName + ", continue to node " + walk._currentNode);
  429. npc.setIsRunning(node.getRunning());
  430. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(node.getMoveX(), node.getMoveY(), node.getMoveZ(), 0));
  431. walk._blocked = false;
  432. walk._stoppedByAttack = false;
  433. }
  434. else
  435. {
  436. npc.sendDebugMessage("Trying continue to move at route " + routeName + ", but cannot now (wrong AI state)");
  437. }
  438. }
  439. }
  440. }
  441. /**
  442. * Cancel NPC moving permanently
  443. * @param npc NPC to cancel
  444. */
  445. public synchronized void cancelMoving(L2Npc npc)
  446. {
  447. if (_activeRoutes.containsKey(npc.getObjectId()))
  448. {
  449. final WalkInfo walk = _activeRoutes.remove(npc.getObjectId());
  450. walk._walkCheckTask.cancel(true);
  451. npc.getKnownList().stopTrackingTask();
  452. }
  453. }
  454. /**
  455. * Resumes previously stopped moving
  456. * @param npc NPC to resume
  457. */
  458. public void resumeMoving(final L2Npc npc)
  459. {
  460. if (!_activeRoutes.containsKey(npc.getObjectId()))
  461. {
  462. return;
  463. }
  464. WalkInfo walk = _activeRoutes.get(npc.getObjectId());
  465. walk._suspended = false;
  466. walk._stoppedByAttack = false;
  467. startMoving(npc, walk.getRoute().getName());
  468. }
  469. /**
  470. * Pause NPC moving until it will be resumed
  471. * @param npc NPC to pause moving
  472. * @param suspend {@code true} if moving was temporarily suspended for some reasons of AI-controlling script
  473. * @param stoppedByAttack {@code true} if moving was suspended because of NPC was attacked or desired to attack
  474. */
  475. public void stopMoving(L2Npc npc, boolean suspend, boolean stoppedByAttack)
  476. {
  477. L2MonsterInstance monster = null;
  478. if (npc.isMonster())
  479. {
  480. if (((L2MonsterInstance) npc).getLeader() == null)
  481. {
  482. monster = (L2MonsterInstance) npc;
  483. }
  484. else
  485. {
  486. monster = ((L2MonsterInstance) npc).getLeader();
  487. }
  488. }
  489. if (((monster != null) && !isRegistered(monster)) || !isRegistered(npc))
  490. {
  491. return;
  492. }
  493. WalkInfo walk = monster != null ? _activeRoutes.get(monster.getObjectId()) : _activeRoutes.get(npc.getObjectId());
  494. walk._suspended = suspend;
  495. walk._stoppedByAttack = stoppedByAttack;
  496. if (monster != null)
  497. {
  498. monster.stopMove(null);
  499. monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
  500. }
  501. else
  502. {
  503. npc.stopMove(null);
  504. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
  505. }
  506. }
  507. /**
  508. * Manage "node arriving"-related tasks: schedule move to next node; send ON_NODE_ARRIVED event to Quest script
  509. * @param npc NPC to manage
  510. */
  511. public void onArrived(final L2Npc npc)
  512. {
  513. if (_activeRoutes.containsKey(npc.getObjectId()))
  514. {
  515. // Notify quest
  516. if (npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_NODE_ARRIVED) != null)
  517. {
  518. for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_NODE_ARRIVED))
  519. {
  520. quest.notifyNodeArrived(npc);
  521. }
  522. }
  523. WalkInfo walk = _activeRoutes.get(npc.getObjectId());
  524. // Opposite should not happen... but happens sometime
  525. if ((walk._currentNode >= 0) && (walk._currentNode < walk.getRoute().getNodesCount()))
  526. {
  527. L2NpcWalkerNode node = walk.getRoute().getNodeList().get(walk._currentNode);
  528. if (npc.isInsideRadius(node.getMoveX(), node.getMoveY(), node.getMoveZ(), 10, false, false))
  529. {
  530. npc.sendDebugMessage("Route: " + walk.getRoute().getName() + ", arrived to node " + walk._currentNode);
  531. npc.sendDebugMessage("Done in " + ((System.currentTimeMillis() - walk._lastActionTime) / 1000) + " s.");
  532. walk.calculateNextNode(npc);
  533. int delay = node.getDelay();
  534. walk._blocked = true; // prevents to be ran from walk check task, if there is delay in this node.
  535. if (node.getNpcString() != null)
  536. {
  537. Broadcast.toKnownPlayers(npc, new NpcSay(npc, Say2.NPC_ALL, node.getNpcString()));
  538. }
  539. else
  540. {
  541. final String text = node.getChatText();
  542. if ((text != null) && !text.isEmpty())
  543. {
  544. Broadcast.toKnownPlayers(npc, new NpcSay(npc, Say2.NPC_ALL, text));
  545. }
  546. }
  547. if (npc.isDebug())
  548. {
  549. walk._lastActionTime = System.currentTimeMillis();
  550. }
  551. ThreadPoolManager.getInstance().scheduleGeneral(new ArrivedTask(npc, walk), 100 + (delay * 1000L));
  552. }
  553. }
  554. }
  555. }
  556. /**
  557. * Manage "on death"-related tasks: permanently cancel moving of died NPC
  558. * @param npc NPC to manage
  559. */
  560. public void onDeath(L2Npc npc)
  561. {
  562. cancelMoving(npc);
  563. }
  564. /**
  565. * Manage "on spawn"-related tasks: start NPC moving, if there is route attached to its spawn point
  566. * @param npc NPC to manage
  567. */
  568. public void onSpawn(L2Npc npc)
  569. {
  570. if (_routesToAttach.containsKey(npc.getNpcId()))
  571. {
  572. final String routeName = _routesToAttach.get(npc.getNpcId()).getRouteName(npc);
  573. if (!routeName.isEmpty())
  574. {
  575. startMoving(npc, routeName);
  576. }
  577. }
  578. }
  579. private class ArrivedTask implements Runnable
  580. {
  581. WalkInfo _walk;
  582. L2Npc _npc;
  583. public ArrivedTask(L2Npc npc, WalkInfo walk)
  584. {
  585. _npc = npc;
  586. _walk = walk;
  587. }
  588. @Override
  589. public void run()
  590. {
  591. _walk._blocked = false;
  592. startMoving(_npc, _walk.getRoute().getName());
  593. }
  594. }
  595. public static final WalkingManager getInstance()
  596. {
  597. return SingletonHolder._instance;
  598. }
  599. private static class SingletonHolder
  600. {
  601. protected static final WalkingManager _instance = new WalkingManager();
  602. }
  603. }