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)
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
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
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')
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()
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')
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()
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)
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()
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)