Skip to content

Commit

Permalink
Merge pull request #157 from luken/feature-improve_move
Browse files Browse the repository at this point in the history
Feature improve move
  • Loading branch information
gamingrobot committed Oct 1, 2015
2 parents 0c30d42 + 7e42276 commit 4428cba
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions spock/plugins/helpers/movement.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

import logging
import math

from spock.plugins.base import PluginBase
from spock.utils import pl_announce
Expand All @@ -22,6 +21,12 @@ def __init__(self):
def move_to(self, x, y, z):
self.move_location = Vector3(x, y, z)

def stop(self):
self.move_location = None

def is_moving(self):
return self.move_location is not None


@pl_announce('Movement')
class MovementPlugin(PluginBase):
Expand Down Expand Up @@ -68,9 +73,10 @@ def do_pathfinding(self):
move = self.movement
clinfo = self.clientinfo
if move.move_location is not None:
if move.move_location.x == math.floor(clinfo.position.x) \
and move.move_location.z == math.floor(clinfo.position.z):
move.move_location = None
if round(move.move_location.x, 2) == round(clinfo.position.x, 2) \
and round(move.move_location.z, 2) == \
round(clinfo.position.z, 2):
move.stop()
else:
self.physics.move_target(move.move_location)
self.physics.walk()

0 comments on commit 4428cba

Please sign in to comment.