예제 #1
0
 def _run_preroll_autonomy(self):
     used_target_list = []
     sim_list = list(self._startup_sims_set)
     for sim_id in sim_list:
         sim_info = self.get(sim_id)
         if sim_info is None:
             self._startup_sims_set.discard(sim_id)
         if sim_info in self._sim_infos_excluded_from_preroll:
             self._startup_sims_set.discard(sim_id)
         sim = sim_info.get_sim_instance()
         if sim is None:
             self._startup_sims_set.discard(sim_id)
         caches.clear_all_caches()
         sim.set_allow_route_instantly_when_hitting_marks(True)
         (interaction_started,
          interaction_target) = sim.run_preroll_autonomy(used_target_list)
         if interaction_started:
             logger.debug(
                 'sim: {} started interaction:{} as part of preroll autonomy.',
                 sim, interaction_started)
             used_target_list.append(interaction_target)
         else:
             logger.debug(
                 'sim: {} failed to choose interaction as part of preroll autonomy.',
                 sim)
             self._startup_sims_set.discard(sim_id)
예제 #2
0
 def instanced_sim_info_including_baby_gen(self, allow_hidden_flags=0):
     object_manager = services.object_manager()
     for sim_info in self.get_all():
         if sim_info.is_baby:
             sim_or_baby = object_manager.get(sim_info.id)
         else:
             sim_or_baby = sim_info.get_sim_instance(allow_hidden_flags=allow_hidden_flags)
         while sim_or_baby is not None:
             yield sim_info
예제 #3
0
 def instanced_sim_info_including_baby_gen(self, allow_hidden_flags=0):
     object_manager = services.object_manager()
     for sim_info in self.get_all():
         if sim_info.is_baby:
             sim_or_baby = object_manager.get(sim_info.id)
         else:
             sim_or_baby = sim_info.get_sim_instance(
                 allow_hidden_flags=allow_hidden_flags)
         while sim_or_baby is not None:
             yield sim_info
예제 #4
0
 def push_sims_to_go_home(self):
     go_home_affordance = sims.sim_info.SimInfo.GO_HOME_FROM_OPEN_STREET
     if go_home_affordance is None:
         return
     for sim_id in self._sim_ids_to_push_go_home:
         sim_info = self.get(sim_id)
         if sim_info is None:
             pass
         sim = sim_info.get_sim_instance()
         while sim is not None:
             context = interactions.context.InteractionContext(sim, interactions.context.InteractionContext.SOURCE_SCRIPT, interactions.priority.Priority.High)
             if not sim.push_super_affordance(go_home_affordance, None, context):
                 logger.warn('Failed to push sim to go home from open street: {}', sim_info, owner='msantander')
예제 #5
0
 def save(self, zone_data=None, open_street_data=None, **kwargs):
     owning_household = services.current_zone().get_active_lot_owner_household()
     situation_manager = services.get_zone_situation_manager()
     for sim_info in self.get_all():
         while sim_info.account_id is not None:
             sim = sim_info.get_sim_instance(allow_hidden_flags=ALL_HIDDEN_REASONS)
             if sim is not None:
                 if sim.is_selectable or owning_household is not None and sim_info in owning_household:
                     if sim.is_on_active_lot() or sim.has_hidden_flags(HiddenReasonFlag.RABBIT_HOLE):
                         sim_info._serialization_option = sims.sim_info_types.SimSerializationOption.LOT
                     else:
                         sim_info._serialization_option = sims.sim_info_types.SimSerializationOption.OPEN_STREETS
                         sim_info._serialization_option = situation_manager.get_sim_serialization_option(sim)
                 else:
                     sim_info._serialization_option = situation_manager.get_sim_serialization_option(sim)
             sim_info.save_sim()
예제 #6
0
 def push_sims_to_go_home(self):
     go_home_affordance = sims.sim_info.SimInfo.GO_HOME_FROM_OPEN_STREET
     if go_home_affordance is None:
         return
     for sim_id in self._sim_ids_to_push_go_home:
         sim_info = self.get(sim_id)
         if sim_info is None:
             pass
         sim = sim_info.get_sim_instance()
         while sim is not None:
             context = interactions.context.InteractionContext(
                 sim, interactions.context.InteractionContext.SOURCE_SCRIPT,
                 interactions.priority.Priority.High)
             if not sim.push_super_affordance(go_home_affordance, None,
                                              context):
                 logger.warn(
                     'Failed to push sim to go home from open street: {}',
                     sim_info,
                     owner='msantander')
예제 #7
0
 def save(self, zone_data=None, open_street_data=None, **kwargs):
     owning_household = services.current_zone(
     ).get_active_lot_owner_household()
     situation_manager = services.get_zone_situation_manager()
     for sim_info in self.get_all():
         while sim_info.account_id is not None:
             sim = sim_info.get_sim_instance(
                 allow_hidden_flags=ALL_HIDDEN_REASONS)
             if sim is not None:
                 if sim.is_selectable or owning_household is not None and sim_info in owning_household:
                     if sim.is_on_active_lot() or sim.has_hidden_flags(
                             HiddenReasonFlag.RABBIT_HOLE):
                         sim_info._serialization_option = sims.sim_info_types.SimSerializationOption.LOT
                     else:
                         sim_info._serialization_option = sims.sim_info_types.SimSerializationOption.OPEN_STREETS
                         sim_info._serialization_option = situation_manager.get_sim_serialization_option(
                             sim)
                 else:
                     sim_info._serialization_option = situation_manager.get_sim_serialization_option(
                         sim)
             sim_info.save_sim()
예제 #8
0
 def _run_preroll_autonomy(self):
     used_target_list = []
     sim_list = list(self._startup_sims_set)
     for sim_id in sim_list:
         sim_info = self.get(sim_id)
         if sim_info is None:
             self._startup_sims_set.discard(sim_id)
         if sim_info in self._sim_infos_excluded_from_preroll:
             self._startup_sims_set.discard(sim_id)
         sim = sim_info.get_sim_instance()
         if sim is None:
             self._startup_sims_set.discard(sim_id)
         caches.clear_all_caches()
         sim.set_allow_route_instantly_when_hitting_marks(True)
         (interaction_started, interaction_target) = sim.run_preroll_autonomy(used_target_list)
         if interaction_started:
             logger.debug('sim: {} started interaction:{} as part of preroll autonomy.', sim, interaction_started)
             used_target_list.append(interaction_target)
         else:
             logger.debug('sim: {} failed to choose interaction as part of preroll autonomy.', sim)
             self._startup_sims_set.discard(sim_id)
예제 #9
0
 def get_by_id(self, sim_id):
     for sim_info in self._sim_infos:
         while sim_info.sim_id == sim_id:
             return sim_info.get_sim_instance()
예제 #10
0
 def instanced_sims_gen(self, allow_hidden_flags=0):
     for sim_info in self._sim_infos:
         while sim_info.is_instanced(allow_hidden_flags=allow_hidden_flags):
             yield sim_info.get_sim_instance(
                 allow_hidden_flags=allow_hidden_flags)