HostFeeler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
dl 0
loc 19
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A direction_is_free() 0 3 1
A position_is_free() 0 8 2
A __init__() 0 4 1
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
5
6
class HostFeeler:
7
8
    def __init__(self, context, object_id):
9
        self._context = context
10
        self._object_id = object_id
11
        self._current_position = context.metas.value.get(POSITION, self._object_id)
12
13
    def direction_is_free(self, direction_of_home):
14
        position_will_be = get_position_with_direction_decal(direction_of_home, self._current_position)
15
        return self._context.position_is_penetrable(position_will_be)
16
17
    def position_is_free(self, position):
18
        threed_position = (0, position[0], position[1])
19
        points_distance = distance_from_points(threed_position, self._current_position)
20
        if points_distance > 1:
21
            raise Exception("Can't feel so far (%s to %s: %s)" % (str(self._current_position),
22
                                                                  str(position),
23
                                                                  str(points_distance)))
24
        return self._context.position_is_penetrable(threed_position)
25