def potential_interactions(cls, target, context, **kwargs):
     (position, _, result) = cls._get_target_position_surface_and_test_off_lot(target, context)
     if not result:
         return
     if position is not None and not terrain.is_position_in_street(position):
         return
     yield super().potential_interactions(context.sim, context, **kwargs)
예제 #2
0
 def _can_sims_start_social(self, actor_sim, target_sim):
     distance_squared = (actor_sim.position - target_sim.position).magnitude_squared()
     if distance_squared > self.SOCIAL_MAX_START_DISTANCE:
         return False
     cone_dot = math.cos(self.SOCIAL_VIEW_CONE_ANGLE*0.5)
     actor_to_target_dot = self._sim_forward_to_sim_dot(actor_sim, target_sim)
     if actor_to_target_dot <= cone_dot:
         target_to_actor_dot = self._sim_forward_to_sim_dot(target_sim, actor_sim)
         if target_to_actor_dot <= cone_dot:
             return False
     if terrain.is_position_in_street(actor_sim.position):
         return False
     if terrain.is_position_in_street(target_sim.position):
         return False
     middle_position = (actor_sim.position + target_sim.position)*0.5
     if terrain.is_position_in_street(middle_position):
         return False
     return True
 def potential_interactions(cls, target, context, **kwargs):
     (position, _,
      result) = cls._get_target_position_surface_and_test_off_lot(
          target, context)
     if not result:
         return
     if position is not None and not terrain.is_position_in_street(
             position):
         return
     yield super().potential_interactions(context.sim, context, **kwargs)
 def get_sim_available_for_walkby_flavor(self):
     if self._cur_state is None or not self._cur_state._is_available_for_interruption():
         return
     if services.time_service().sim_now < self._flavor_cooldown_until:
         return
     if self._walker is not None and self._walker.opacity < 1.0:
         return
     if self._walker is not None and terrain.is_position_in_street(self._walker.position):
         return
     return self._walker
예제 #5
0
 def _test(cls, target, context, **kwargs):
     (position, _, result) = cls._get_target_position_surface_and_test_off_lot(target, context)
     if not result:
         return result
     if position is not None and not terrain.is_position_in_street(position):
         return TestResult(False, 'Cannot Travel from terrain outside of the street!')
     result = cls.travel_test(context)
     if not result:
         return result
     return TestResult.TRUE
예제 #6
0
 def get_sim_available_for_walkby_flavor(self):
     if self._cur_state is None or not self._cur_state._is_available_for_interruption(
     ):
         return
     if services.time_service().sim_now < self._flavor_cooldown_until:
         return
     if self._walker is not None and self._walker.opacity < 1.0:
         return
     if self._walker is not None and terrain.is_position_in_street(
             self._walker.position):
         return
     return self._walker
 def _can_sims_start_social(self, actor_sim, target_sim):
     distance_squared = (actor_sim.position -
                         target_sim.position).magnitude_squared()
     if distance_squared > self.SOCIAL_MAX_START_DISTANCE:
         return False
     cone_dot = math.cos(self.SOCIAL_VIEW_CONE_ANGLE * 0.5)
     actor_to_target_dot = self._sim_forward_to_sim_dot(
         actor_sim, target_sim)
     if actor_to_target_dot <= cone_dot:
         target_to_actor_dot = self._sim_forward_to_sim_dot(
             target_sim, actor_sim)
         if target_to_actor_dot <= cone_dot:
             return False
     if terrain.is_position_in_street(actor_sim.position):
         return False
     if terrain.is_position_in_street(target_sim.position):
         return False
     middle_position = (actor_sim.position + target_sim.position) * 0.5
     if terrain.is_position_in_street(middle_position):
         return False
     return True
예제 #8
0
 def _test(cls, target, context, **kwargs):
     (position, _,
      result) = cls._get_target_position_surface_and_test_off_lot(
          target, context)
     if not result:
         return result
     if position is not None and not terrain.is_position_in_street(
             position):
         return TestResult(
             False, 'Cannot Travel from terrain outside of the street!')
     result = cls.travel_test(context)
     if not result:
         return result
     return TestResult.TRUE
예제 #9
0
 def __call__(self, context=None):
     if context is None:
         return TestResult(
             False,
             'Interaction Context is None. Make sure this test is Tuned on an Interaction.'
         )
     pick_info = context.pick
     if pick_info is None:
         return TestResult(
             False,
             'PickTerrainTest cannot run without a valid pick info from the Interaction Context.'
         )
     if pick_info.pick_type not in PICK_TRAVEL:
         return TestResult(
             False,
             'Attempting to run a PickTerrainTest with a pick that has an invalid type.'
         )
     if self.terrain_feature is not None:
         zone_id = services.current_zone_id()
         if not build_buy.find_floor_feature(
                 zone_id, self.terrain_feature, pick_info.location,
                 pick_info.routing_surface.secondary_id,
                 self.terrain_feature_radius):
             return TestResult(
                 False,
                 'Location does not have the required floor feature.')
     if self.terrain_location == PickTerrainType.ANYWHERE:
         return TestResult.TRUE
     on_lot = services.current_zone().lot.is_position_on_lot(
         pick_info.location)
     if self.terrain_location == PickTerrainType.ON_LOT:
         if on_lot:
             return TestResult.TRUE
         return TestResult(False, 'Pick Terrain is not ON_LOT as expected.')
     if self.terrain_location == PickTerrainType.OFF_LOT:
         if not on_lot:
             return TestResult.TRUE
         return TestResult(False,
                           'Pick Terrain is not OFF_LOT as expected.')
     current_zone_id = services.current_zone().id
     other_zone_id = pick_info.get_zone_id_from_pick_location()
     if self.terrain_location == PickTerrainType.ON_OTHER_LOT:
         if not on_lot and other_zone_id is not None and other_zone_id != current_zone_id:
             return TestResult.TRUE
         return TestResult(False,
                           'Pick Terrain is not ON_OTHER_LOT as expected.')
     if self.terrain_location == PickTerrainType.NO_LOT:
         if other_zone_id is None:
             return TestResult.TRUE
         return TestResult(
             False, 'Pick Terrain is is on a valid lot, but not expected.')
     in_street = is_position_in_street(pick_info.location)
     if self.terrain_location == PickTerrainType.IN_STREET:
         if in_street:
             return TestResult.TRUE
         return TestResult(False,
                           'Pick Terrain is not IN_STREET as expected.')
     if self.terrain_location == PickTerrainType.OFF_STREET:
         if not in_street:
             return TestResult.TRUE
         return TestResult(
             False, 'Pick Terrain is in the street, but not expected.')
     if self.terrain_location == PickTerrainType.IS_OUTSIDE:
         is_outside = is_location_outside(pick_info.location,
                                          pick_info.level)
         if is_outside:
             return TestResult.TRUE
         return TestResult(False, 'Pick Terrain is not outside')
     return TestResult.TRUE