Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

29 рядки
527 B

  1. module.exports = {
  2. id: null,
  3. mob: null,
  4. pos: {
  5. x: 0,
  6. y: 0
  7. },
  8. init: function () {
  9. const { instance, id, pos: { x, y } } = this;
  10. this.mob = instance.objects.find(o => o.id === id);
  11. this.mob.mob.originX = x;
  12. this.mob.mob.originY = y;
  13. this.mob.mob.goHome = true;
  14. },
  15. update: function () {
  16. const { pos: { x: targetX, y: targetY } } = this;
  17. const { mob: { x, y } } = this;
  18. const distance = Math.max(Math.abs(x - targetX), Math.abs(y - targetY));
  19. if (distance > 0)
  20. return;
  21. this.end = true;
  22. }
  23. };