Esempio n. 1
0
def capped_line_of_sight(agent, player_struct, cap=20):
    """Return the block directly in the entity's line of sight, or a point in the distance"""
    xsect = agent.get_player_line_of_sight(player_struct)
    if xsect is not None and euclid_dist(pos_to_np(xsect),
                                         pos_to_np(player_struct.pos)) <= cap:
        return pos_to_np(xsect)

    # default to cap blocks in front of entity
    vec = rotation.look_vec(player_struct.look.yaw, player_struct.look.pitch)
    return cap * np.array(vec) + to_block_pos(pos_to_np(player_struct.pos))
Esempio n. 2
0
 def get_line_of_sight(self, pos, yaw, pitch):
     # it is assumed lv is unit normalized
     pos = tuple(self.to_world_coords(pos))
     lv = look_vec(yaw, pitch)
     dt = 1.0
     for n in range(2 * self.sl):
         p = tuple(np.round(np.add(pos, n * dt * lv)).astype("int32"))
         for i in range(-1, 2):
             for j in range(-1, 2):
                 for k in range(-1, 2):
                     sp = tuple(np.add(p, (i, j, k)))
                     if all([x >= 0 for x in sp]) and all(
                         [x < self.sl for x in sp]):
                         if tuple(self.blocks[sp]) != (0, 0):
                             # TODO: deal with close blocks artifacts,
                             # etc
                             return tuple(self.from_world_coords(sp))
     return
Esempio n. 3
0
 def action(self, yaw, pitch):
     self.agent.world_interaction_occurred = True
     a = look_vec(yaw, pitch)
     self._look_vec = [a[0], a[1], a[2]]
Esempio n. 4
0
 def action(self, yaw, pitch):
     a = look_vec(yaw, pitch)
     self._look_vec = [a[0], a[1], a[2]]