def _run_interaction_gen(self, timeline): Logger.log("running make selectable interaction...") try: super()._run_interaction_gen(timeline) sim_info = self.target.sim_info if self.context.target_sim_id is not None: sim_info = (services.sim_info_manager() .get(self.context.target_sim_id)) Logger.log("got sim info {} {}" .format(sim_info.first_name, sim_info.last_name)) SelectionGroupService \ .get(services.active_household_id()) \ .make_sim_selectable(sim_info) Logger.log("sim is now selectable!") services.get_first_client().set_active_sim_by_id(sim_info.id) Logger.log("sim is now active!") return True except BaseException: Logger.log(traceback.format_exc())
def _clear_missing_pet_data(self, pet_id): self._missing_pet_id = 0 self._alert_posted = False if self._return_alarm is not None: alarms.cancel_alarm(self._return_alarm) self._return_alarm = None sim_filter_service = services.sim_filter_service() global_blacklist = sim_filter_service.get_global_blacklist() if pet_id in global_blacklist: sim_filter_service.remove_sim_id_from_global_blacklist(pet_id, SimFilterGlobalBlacklistReason.MISSING_PET) services.hidden_sim_service().unhide_sim(pet_id) services.get_first_client().send_selectable_sims_update()
def run_away_succeeded(self, pet_info): self._running_away = False if self._missing_pet_id != 0: return self._missing_pet_id = pet_info.id pet_info.add_trait(self.MISSING_PET_TRAIT) away_action = self.DEFAULT_AWAY_ACTIONS.get(pet_info.species) services.hidden_sim_service().hide_sim(pet_info.id, default_away_action=away_action) if self._test_alarm: alarms.cancel_alarm(self._test_alarm) self._test_alarm = None return_interval = clock.interval_in_sim_minutes(self.RETURN_INTERVAL) self._add_return_alarm(return_interval) for sim_info in self._household.sim_info_gen(): if sim_info.id != pet_info.id: resolver = DoubleSimResolver(sim_info, pet_info) self.RUN_AWAY_LOOT_FOR_HOUSEHOLD.apply_to_resolver(resolver) sim_filter_service = services.sim_filter_service() sim_filter_service.add_sim_id_to_global_blacklist(pet_info.id, SimFilterGlobalBlacklistReason.MISSING_PET) services.get_first_client().send_selectable_sims_update()
def on_enter(self): super().on_enter() event_manager = services.get_event_manager() event_manager.register_events_for_update() client = services.get_first_client() client.refresh_achievement_data() for sim_info in client.selectable_sims: if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS): sim_info.start_aspiration_tracker_on_instantiation() event_manager.unregister_unused_handlers() event_manager.register_events_for_objectives() return _ZoneSpinUpStateResult.DONE
def client(self): return services.get_first_client()
def on_active_sim_changed(cls, handler): services.get_first_client().register_active_sim_changed(handler)
def replace_client_id_for_ui_commands(stripped_function_name): if stripped_function_name == "ui_dialog_pick_result" or stripped_function_name == "ui_dialog_respond": client_id = services.get_first_client().id else: client_id = 1000 return client_id
def factory(_): household = services.household_manager().create_household( services.get_first_client().account) household.set_to_hidden(family_funds=0) return household