HostFeeler.py 1.2KB

12345678910111213141516171819202122232425
  1. from intelligine.synergy.event.move.direction import get_position_with_direction_decal
  2. from synergine_xyz.cst import POSITION
  3. from synergine_xyz.geometry import distance_from_points
  4. class HostFeeler:
  5. def __init__(self, context, object_id):
  6. self._context = context
  7. self._object_id = object_id
  8. self._current_position = context.metas.value.get(POSITION, self._object_id)
  9. def direction_is_free(self, direction_of_home):
  10. position_will_be = get_position_with_direction_decal(direction_of_home, self._current_position)
  11. return self._context.position_is_penetrable(position_will_be)
  12. def position_is_free(self, position):
  13. threed_position = (0, position[0], position[1])
  14. points_distance = distance_from_points(threed_position, self._current_position)
  15. if points_distance > 1:
  16. raise Exception("Can't feel so far (%s to %s: %s)" % (str(self._current_position),
  17. str(position),
  18. str(points_distance)))
  19. return self._context.position_is_penetrable(threed_position)