Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This function moves to an existing unit or object with x, y properties.
- It can also accept a preset unit.
- If you want to go to a preset unit based on its area, type and id, use Pather.moveToPreset().
- */
- moveToUnit: function (unit, offX, offY, clearPath) { // Maybe use range instead of offsets
- switch (arguments.length) {
- case 1:
- offX = 0;
- case 2:
- offY = 0;
- case 3:
- clearPath = false;
- break;
- }
- if (!unit || !unit.hasOwnProperty("x") || !unit.hasOwnProperty("y")) {
- throw new Error("moveToUnit: Invalid unit.");
- }
- if (unit instanceof PresetUnit) {
- return this.moveTo(unit.roomx * 5 + unit.x + offX, unit.roomy * 5 + unit.y + offY, 2, clearPath);
- }
- return this.moveTo(unit.x + offX, unit.y + offY, 2, clearPath);
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement