def _on_yes_selected(_: Any): CommonBuffUtils.remove_buff(sim_info, _buff_id) # noinspection PyUnresolvedReferences CommonBasicNotification( S4CMSimControlMenuStringId.REMOVED_BUFF_TITLE, S4CMSimControlMenuStringId.REMOVED_BUFF_DESCRIPTION, title_tokens=(chosen_buff.buff_name(sim_info), str(_buff_id)), description_tokens=( CommonSimUtils.get_sim_instance(sim_info), chosen_buff.buff_name(sim_info), str(_buff_id), CommonBuffUtils.get_buff_name(chosen_buff))).show( icon=IconInfoData(obj_instance=CommonSimUtils. get_sim_instance(sim_info))) _reopen()
def create_interaction_context( sim_info: SimInfo, interaction_source: InteractionSource=InteractionContext.SOURCE_SCRIPT_WITH_USER_INTENT, priority: Priority=Priority.High, run_priority: Union[Priority, None]=Priority.High, insert_strategy: QueueInsertStrategy=QueueInsertStrategy.NEXT, must_run_next: bool=False, **kwargs ) -> Union[InteractionContext, None]: """create_interaction_context(\ sim_info,\ interaction_source=InteractionContext.SOURCE_SCRIPT_WITH_USER_INTENT,\ priority=Priority.High,\ run_priority=Priority.High,\ insert_strategy=QueueInsertStrategy.NEXT,\ must_run_next=False,\ **kwargs\ ) Create an InteractionContext. :param sim_info: An instance of a Sim. :type sim_info: SimInfo :param interaction_source: The source of the interaction. Default is InteractionContext.SOURCE_SCRIPT_WITH_USER_INTENT. :type interaction_source: InteractionSource, optional :param priority: The priority of the interaction. Default is Priority.High. :type priority: Priority, optional :param run_priority: The priority of running the interaction. Default is Priority.High. :type run_priority: Union[Priority, None], optional :param insert_strategy: The insert strategy for the interaction. Default is QueueInsertStrategy.NEXT. :type insert_strategy: QueueInsertStrategy, optional :param must_run_next: If True, the interaction will run next. Default is False. :type must_run_next: bool, optional :return: An interaction context for use with interactions or None if a problem occurs. :rtype: Union[InteractionContext, None] """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return None return InteractionContext( sim, interaction_source, priority, run_priority=run_priority, insert_strategy=insert_strategy, must_run_next=must_run_next, **kwargs )
def get_autonomy_state(sim_info: SimInfo) -> AutonomyState: """get_autonomy_state_setting(sim_info) Retrieve the current autonomy state of a Sim. :param sim_info: An instance of a Sim. :type sim_info: SimInfo """ from autonomy.autonomy_component import AutonomyComponent sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return AutonomyState.UNDEFINED autonomy_component: AutonomyComponent = CommonComponentUtils.get_component(sim, CommonComponentType.AUTONOMY) if autonomy_component is None or not hasattr(autonomy_component, 'get_autonomy_state_setting'): return AutonomyState.UNDEFINED return autonomy_component.get_autonomy_state_setting()
def get_orientation(sim_info: SimInfo) -> CommonQuaternion: """get_orientation(sim_info) Retrieve the orientation of a Sim. :param sim_info: An instance of a Sim. :type sim_info: SimInfo :return: The orientation of the Sim. :rtype: CommonQuaternion """ if sim_info is None: return CommonQuaternion.empty() sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return CommonQuaternion.empty() return CommonQuaternion.from_quaternion(sim.orientation)
def can_swim_at_location(sim_info: SimInfo, location: Location) -> bool: """can_swim_at_location(sim_info, location) Determine if a Sim can swim at the specified location. :param sim_info: The Sim to check. :type sim_info: SimInfo :param location: The Location to check. :type location: Location :return: True, if the Sim can swim at the specified location. False, if not. :rtype: bool """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return False return sim.should_be_swimming_at_position( location.transform.translation, location.level)
def is_engaged_in_club_gathering(sim_info: SimInfo) -> bool: """is_engaged_in_club_gathering(sim_info) Determine if a Sim is engaged in a Club Gathering. :param sim_info: An instance of a Sim. :type sim_info: SimInfo :return: True, if the Sim is engaged in a Club Gathering. False, if not. :rtype: bool """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return False club_service = services.get_club_service() if club_service is None: return False return sim in club_service.sims_to_gatherings_map
def run(self, sim_info: SimInfo, on_completed: Callable[[bool], None]=CommonFunctionUtils.noop) -> bool: def _on_close() -> None: on_completed(False) def _on_yes_selected(_: Any): from sims4controlmenu.dialogs.modify_sim_data.modify_skills.operations.set_skill_level import \ S4CMSetSkillLevelsSimOp skill_manager = CommonResourceUtils.get_instance_manager(Types.STATISTIC) sim = CommonSimUtils.get_sim_instance(sim_info) for skill in skill_manager.get_ordered_types(only_subclasses_of=Skill): skill: Skill = skill if not S4CMSetSkillLevelsSimOp()._is_skill_allowed_for_modification(sim_info, skill): continue if not skill.can_add(sim): self.verbose_log.format_with_message('Failed, Skill is not allowed for Sim.', skill=skill, sim=sim_info) continue skill_levels = tuple(range(0, skill.max_level + 1)) chosen_skill_level = random.choice(skill_levels) if chosen_skill_level == 0: if CommonSimSkillUtils.has_skill(sim_info, skill): CommonSimSkillUtils.remove_skill(sim_info, skill) else: CommonSimSkillUtils.set_current_skill_level(sim_info, skill, int(chosen_skill_level)) CommonBasicNotification( S4CMSimModifySkillsStringId.RANDOMIZED_SKILL_LEVELS_OF_SIM_TITLE, S4CMSimModifySkillsStringId.RANDOMIZED_SKILL_LEVELS_OF_SIM_DESCRIPTION, title_tokens=(sim,), description_tokens=(sim,) ).show(icon=IconInfoData(obj_instance=sim)) _on_close() def _on_no_selected(_: Any): _on_close() confirmation = CommonOkCancelDialog( S4CMStringId.CONFIRMATION, S4CMSimModifySkillsStringId.ARE_YOU_SURE_YOU_WANT_TO_RANDOMIZE_ALL_SKILLS_FOR_SIM, description_tokens=(CommonSimUtils.get_sim_instance(sim_info),), ok_text_identifier=S4CMStringId.YES, cancel_text_identifier=S4CMStringId.NO, mod_identity=self.mod_identity ) confirmation.show(on_ok_selected=_on_yes_selected, on_cancel_selected=_on_no_selected) return True
def fade_out(sim_info: SimInfo, fade_duration: float=1.0, immediate: bool=False, additional_channels: Iterator[Tuple[int, int, int]]=None): """fade_out(sim_info, fade_duration=1.0, immediate=False, additional_channels=None) Fade a Sim to become invisible. :param sim_info: An instance of a Sim. :type sim_info: SimInfo :param fade_duration: The number of milliseconds the fade effect should take to complete. Default is 1.0. :type fade_duration: float, optional :param immediate: If set to True, fade out will occur immediately. Default is False. :type immediate: bool, optional :param additional_channels: A collection of additional channels. The order of the inner tuple is Manager Id, Sim Id, and Mask. Default is None. :type additional_channels: Iterator[Tuple[int, int, int]], optional """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return sim.fade_out(fade_duration=fade_duration, immediate=immediate, additional_channels=additional_channels)
def send_to_position(sim_info: SimInfo, location_position: Vector3, level: int): """ Send a sim to the specified location. """ from server_commands.sim_commands import _build_terrain_interaction_target_and_context, CommandTuning if location_position is None: return False sim = CommonSimUtils.get_sim_instance(sim_info) # noinspection PyUnresolvedReferences pos = sims4.math.Vector3(location_position.x, location_position.y, location_position.z) routing_surface = routing.SurfaceIdentifier( CommonLocationUtils.get_current_zone_id(), level, routing.SurfaceType.SURFACETYPE_WORLD) (target, context) = _build_terrain_interaction_target_and_context( sim, pos, routing_surface, PickType.PICK_TERRAIN, objects.terrain.TerrainPoint) return sim.push_super_affordance( CommandTuning.TERRAIN_GOHERE_AFFORDANCE, target, context)
def has_use_preference_for_object(sim_info: SimInfo, preference_tag: CommonObjectPreferenceTag, game_object: GameObject) -> bool: """has_use_preference_for_object(sim_info, preference_tag, game_object) Determine if a Sim will have a preference for an Object when searching for Objects to use with a Tag. :param sim_info: An instance of a Sim. :type sim_info: SimInfo :param preference_tag: The tag to look for preference with. :type preference_tag: CommonObjectPreferenceTag :param game_object: An instance of an Object. :type game_object: GameObject :return: True, if the Sim will prefer to use the specified Object when searching for Objects to use with the specified Tag. False, if not. :rtype: bool """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None or game_object is None: return False return sim.is_object_use_preferred(preference_tag, game_object)
def _on_yes_selected(_: Any): skill_manager = CommonResourceUtils.get_instance_manager( Types.STATISTIC) sim = CommonSimUtils.get_sim_instance(sim_info) for skill in skill_manager.get_ordered_types( only_subclasses_of=Skill): skill: Skill = skill if not CommonSimSkillUtils.has_skill(sim_info, skill): continue CommonSimSkillUtils.remove_skill(sim_info, skill) CommonBasicNotification( S4CMSimModifySkillsStringId.REMOVED_ALL_SKILLS_TITLE, S4CMSimModifySkillsStringId.REMOVED_ALL_SKILLS_DESCRIPTION, title_tokens=(sim, ), description_tokens=(sim, )).show(icon=IconInfoData( obj_instance=sim)) _on_close()
def get_location(sim_info: SimInfo) -> Union[CommonLocation, None]: """get_location(sim_info) Retrieve the current location of a Sim. :param sim_info: The Sim to get the location of. :type sim_info: SimInfo :return: The current location of the Sim or None if the Sim does not have a location. :rtype: Union[CommonLocation, None] """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return None # noinspection PyBroadException try: return CommonLocation.from_location(sim.location) except: return None
def is_in_use_by(game_object: GameObject, sim_info: SimInfo) -> bool: """is_in_use_by(game_object, sim_info) Determine if an Object is in use by the specified Sim. :param game_object: An instance of an object. :type game_object: GameObject :param sim_info: An instance of a Sim. :type sim_info: SimInfo :return: True, if the object is in use by the specified Sim. False, if not. :rtype: bool """ if game_object is None: return False from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return False return game_object.in_use_by(sim)
def get_situations(sim_info: SimInfo, include_situation_callback: Callable[[Situation], bool]=None) -> Iterator[Situation]: """get_situations(sim_info, include_situation_callback=None) Retrieve all Situations that a Sim is currently involved in. :param sim_info: An instance of a Sim :type sim_info: SimInfo :param include_situation_callback: If the result of this callback is True, the Situation will be included in the results. If set to None, All situations will be included. Default is None. :type include_situation_callback: Callable[[Situation], bool], optional :return: An iterable of Situations that pass the include callback filter. :rtype: Iterator[Situation] """ sim = CommonSimUtils.get_sim_instance(sim_info) situations = tuple(services.get_zone_situation_manager().get_situations_sim_is_in(sim)) if sim is None or not situations: return tuple() for situation in situations: if include_situation_callback is not None and not include_situation_callback(situation): continue yield situation
def get_sim_info_of_all_sims_with_relationship_bits_generator(sim_info: SimInfo, relationship_bit_ids: Iterator[int], instanced_only: bool=True) -> Iterator[SimInfo]: """get_sim_info_of_all_sims_with_relationship_bits_generator(sim_info, relationship_bit_ids, instanced_only=True) Retrieve an Iterator of SimInfo for all Sims that have the specified relationship bits with the specified Sim. .. note:: For UNIDIRECTIONAL relationship bits, the direction is sim_info has relationship bit with target_sim_info Caregiver example: - The Caregiver has a relationship bit pointed at Toddler (The Caregiver would show "caregiving ward" when hovering over the toddler in the relationships panel) - The toddler would NOT have the relationship bit. - Sim is Caregiver of Toddler. :param sim_info: The Sim to locate relationship bits on. :type sim_info: SimInfo :param relationship_bit_ids: A collection of identifiers for relationship bits to locate connections with. :type relationship_bit_ids: Iterator[int] :param instanced_only: If True, only Sims that are currently loaded will be returned. :type instanced_only: bool, optional :return: An iterable of Sims that have any of the specified relationship bits with the specified Sim. :rtype: Iterator[SimInfo] """ sim_id = CommonSimUtils.get_sim_id(sim_info) for relationship in sim_info.relationship_tracker: if relationship.sim_id_a != sim_id: target_sim_id = relationship.sim_id_a else: target_sim_id = relationship.sim_id_b target_sim_info = CommonSimUtils.get_sim_info(target_sim_id) if target_sim_info is None: continue if instanced_only and CommonSimUtils.get_sim_instance(target_sim_info) is None: continue for relationship_bit_id in relationship_bit_ids: relationship_bit_instance = CommonResourceUtils.load_instance(Types.RELATIONSHIP_BIT, relationship_bit_id) if relationship_bit_instance is None: continue if relationship.has_bit(sim_id, relationship_bit_instance): yield target_sim_info break
def run( self, sim_info: SimInfo, on_completed: Callable[[bool], None] = CommonFunctionUtils.noop) -> bool: def _on_close() -> None: on_completed(False) def _on_yes_selected(_: Any): skill_manager = CommonResourceUtils.get_instance_manager( Types.STATISTIC) sim = CommonSimUtils.get_sim_instance(sim_info) for skill in skill_manager.get_ordered_types( only_subclasses_of=Skill): skill: Skill = skill if not CommonSimSkillUtils.has_skill(sim_info, skill): continue CommonSimSkillUtils.remove_skill(sim_info, skill) CommonBasicNotification( S4CMSimModifySkillsStringId.REMOVED_ALL_SKILLS_TITLE, S4CMSimModifySkillsStringId.REMOVED_ALL_SKILLS_DESCRIPTION, title_tokens=(sim, ), description_tokens=(sim, )).show(icon=IconInfoData( obj_instance=sim)) _on_close() def _on_no_selected(_: Any): _on_close() confirmation = CommonOkCancelDialog( S4CMStringId.CONFIRMATION, S4CMSimModifySkillsStringId. ARE_YOU_SURE_YOU_WANT_TO_REMOVE_ALL_SKILLS_FROM_SIM, description_tokens=(CommonSimUtils.get_sim_instance(sim_info), ), ok_text_identifier=S4CMStringId.YES, cancel_text_identifier=S4CMStringId.NO, mod_identity=self.mod_identity) confirmation.show(on_ok_selected=_on_yes_selected, on_cancel_selected=_on_no_selected) return True
def has_interactions_queued(sim_info: SimInfo, interaction_ids: Iterator[int]) -> bool: """has_interactions_queued(sim_info, interaction_ids) Determine if a Sim has any of the specified interactions in their interaction queue. :param sim_info: The Sim to check. :type sim_info: SimInfo :param interaction_ids: An iterable of identifiers of the interactions to check for. :type interaction_ids: int :return: True, if the Sim has any of the specified interactions queued. False, if not. :rtype: bool """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None or sim.queue is None: return False for interaction in sim.queue: interaction_id = getattr(interaction, 'guid64', None) if interaction_id in interaction_ids: return True return False
def despawn_sim(sim_info: SimInfo, cause: str = None) -> bool: """despawn_sim(sim_info, cause=None) Despawn a Sim. :param sim_info: The Sim to despawn. :type sim_info: SimInfo :param cause: The reason for the despawn. :type cause: str, optional :return: True, if the Sim was despawn successfully. False, if not. :rtype: bool """ if sim_info is None: return False from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return True cause = cause or 'Sim destroyed.' sim.destroy(cause=cause) return True
def get_queued_interactions_gen(sim_info: SimInfo, include_interaction_callback: Callable[[Interaction], bool]=None) -> Iterator[Interaction]: """get_queued_interactions_gen(sim_info, include_interaction_callback=None) Retrieve all interactions that a Sim currently has queued. :param sim_info: An instance of a Sim :type sim_info: SimInfo :param include_interaction_callback: If the result of this callback is True, the Interaction will be included in the results. If set to None, All interactions will be included. Default is None. :type include_interaction_callback: Callable[[Interaction], bool], optional :return: An iterable of Interactions that pass the include callback filter. :rtype: Iterator[Interaction] """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return tuple() if sim.queue is None or not tuple(sim.queue): return tuple() for interaction in sim.queue: if include_interaction_callback is not None and not include_interaction_callback(interaction): continue yield interaction
def set_location(sim_info: SimInfo, location: CommonLocation) -> bool: """set_location(sim_info, location) Set the location of a Sim. :param sim_info: An instance of a Sim. :type sim_info: SimInfo :param location: The location to put the Sim. :type location: CommonLocation :return: True, if the location of the Sim is successfully set. False, if not. :rtype: bool """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None or location is None: return False # noinspection PyBroadException try: sim.location = location except: return False return True
def get_wading_size(sim_info: SimInfo) -> Tuple[int, int]: """get_wading_size(sim_info) Retrieve the size of a Sim if they were to wade in a pool of water. :param sim_info: An instance of a Sim. :type sim_info: SimInfo :return: A tuple indicating the x and y wading size of a Sim from their origin point. :rtype: Tuple[int, int] """ # noinspection PyBroadException try: from world.ocean_tuning import OceanTuning except: return 0, 0 sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return 0, 0 wading_interval = OceanTuning.get_actor_wading_interval(sim) if wading_interval is None: return 0, 0 return wading_interval.lower_bound, wading_interval.upper_bound
def _on_chosen(_buff_id: int, chosen_buff: Buff): if chosen_buff is None: on_completed(False) return def _on_yes_selected(_: Any): CommonBuffUtils.remove_buff(sim_info, _buff_id) # noinspection PyUnresolvedReferences CommonBasicNotification( S4CMSimControlMenuStringId.REMOVED_BUFF_TITLE, S4CMSimControlMenuStringId.REMOVED_BUFF_DESCRIPTION, title_tokens=(chosen_buff.buff_name(sim_info), str(_buff_id)), description_tokens=( CommonSimUtils.get_sim_instance(sim_info), chosen_buff.buff_name(sim_info), str(_buff_id), CommonBuffUtils.get_buff_name(chosen_buff))).show( icon=IconInfoData(obj_instance=CommonSimUtils. get_sim_instance(sim_info))) _reopen() def _on_no_selected(_: Any): _reopen() # noinspection PyUnresolvedReferences confirmation = CommonOkCancelDialog( S4CMStringId.CONFIRMATION, S4CMSimControlMenuStringId. ARE_YOU_SURE_YOU_WANT_TO_REMOVE_BUFF, description_tokens=(chosen_buff.buff_name(sim_info), str(_buff_id), CommonBuffUtils.get_buff_name(chosen_buff), CommonSimUtils.get_sim_instance(sim_info)), ok_text_identifier=S4CMStringId.YES, cancel_text_identifier=S4CMStringId.NO, mod_identity=self.mod_identity) confirmation.show(on_ok_selected=_on_yes_selected, on_cancel_selected=_on_no_selected)
def despawn_sim(sim_info: SimInfo, source: str=None, cause: str=None, **kwargs) -> bool: """despawn_sim(sim_info, source=None, cause=None, **kwargs) Despawn a Sim. :param sim_info: The Sim to despawn. :type sim_info: SimInfo :param source: The source of the destruction. Default is None. :type source: str, optional :param cause: The cause of the destruction. Default is None. :type cause: str, optional :return: True, if the Sim was despawn successfully. False, if not. :rtype: bool """ if sim_info is None: return False from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return True cause = cause or 'Sim despawned.' sim.destroy(source=source, cause=cause, **kwargs) return True
def send_to_position(sim_info: SimInfo, position: CommonVector3, level: int) -> Union[EnqueueResult, None]: """send_to_position(sim_info, position, level) Send a Sim to the specified location. :param sim_info: The Sim to send. :type sim_info: SimInfo :param position: The position to send the sim to. :type position: CommonVector3 :param level: The level at which the position is located. :type level: int :return: The result of sending the Sim to the specified location or None if they could not go there. :rtype: EnqueueResult """ from server_commands.sim_commands import _build_terrain_interaction_target_and_context, CommandTuning if position is None: return None sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return None routing_surface = CommonSurfaceIdentifier.empty(secondary_id=level) (target, context) = _build_terrain_interaction_target_and_context(sim, position, routing_surface, PickType.PICK_TERRAIN, objects.terrain.TerrainPoint) return sim.push_super_affordance(CommandTuning.TERRAIN_GOHERE_AFFORDANCE, target, context)
def create_reservation_handler( object_instance: Union[GameObject, Part, BasicPropObject], sim_info: SimInfo, **kwargs) -> Union[_ReservationHandler, None]: """create_reservation_handler(object_instance, sim_info, **kwargs) Create a reservation handler for a Sim to reserve an object. :param object_instance: An instance of an object. :type object_instance: Union[GameObject, Part, BasicPropObject] :param sim_info: An instance of a Sim. This Sim will be reserving the object. :type sim_info: SimInfo :param kwargs: Keyword arguments used when creating the reservation handler. :type kwargs: Any :return: An instance of a Reservation Handler or None if a problem occurs. :rtype: Union[_ReservationHandler, None] """ if object_instance is None or sim_info is None: return None sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return None if not hasattr(object_instance, 'get_reservation_handler'): return None return object_instance.get_reservation_handler(sim, **kwargs)
def run( self, sim_info: SimInfo, on_completed: Callable[[bool], None] = CommonFunctionUtils.noop) -> bool: def _reopen() -> None: self.run(sim_info, on_completed=on_completed) def _on_close() -> None: on_completed(False) option_dialog = CommonChooseObjectOptionDialog( S4CMSimModifySkillsStringId.SET_SKILL_LEVELS, 0, on_close=_on_close, mod_identity=self.mod_identity, per_page=20000) def _on_input_setting_changed(_skill: Skill, new_skill_level: int, outcome: CommonChoiceOutcome): if new_skill_level is None or CommonChoiceOutcome.is_error_or_cancel( outcome): _reopen() return self.log.format_with_message('Setting skill level for Sim.', _skill=_skill, new_skill_level=new_skill_level) CommonSimSkillUtils.set_current_skill_level( sim_info, _skill, new_skill_level) if new_skill_level == 0: CommonSimSkillUtils.remove_skill(sim_info, _skill) _reopen() skill_manager = CommonResourceUtils.get_instance_manager( Types.STATISTIC) sim = CommonSimUtils.get_sim_instance(sim_info) for skill in skill_manager.get_ordered_types(only_subclasses_of=Skill): skill: Skill = skill skill_id = CommonSkillUtils.get_skill_id(skill) if skill_id is None: self.log.format_with_message('Missing skill id for Skill.', skill=skill) continue try: self.verbose_log.format_with_message( 'Attempting to display skill', skill=skill, skill_id=skill_id, sim=sim_info) if not skill.can_add(sim): self.verbose_log.format_with_message( 'Failed, Skill is not allowed for Sim.', skill=skill, skill_id=skill_id, sim=sim_info) continue if not CommonSimSkillUtils.has_skill(sim_info, skill_id): current_skill_level = 0 else: current_skill_level = int( CommonSimSkillUtils.get_current_skill_level( sim_info, skill_id, use_effective_skill_level=False)) stat_name = getattr(skill, 'stat_name', None) # noinspection PyUnresolvedReferences if stat_name and skill.stat_name.hash is not 0: # noinspection PyUnresolvedReferences display_name = skill.stat_name else: skill_name = skill.__name__ or 'Unknown Skill Name' skill_name = skill_name[0].upper() + skill_name[1:] display_name = LocalizationHelperTuning.get_raw_text( skill_name) # noinspection PyUnresolvedReferences if skill.hidden: display_name = CommonLocalizationUtils.create_localized_string( S4CMSimControlMenuStringId.STRING_SPACE_PAREN_STRING, tokens=(display_name, S4CMSimControlMenuStringId.HIDDEN)) display_name = CommonLocalizationUtils.create_localized_string( S4CMSimControlMenuStringId.STRING_COLON_SPACE_STRING, tokens=(display_name, str(current_skill_level))) # noinspection PyUnresolvedReferences description = CommonLocalizationUtils.create_localized_string( skill.skill_description, tokens=(sim_info, )) # noinspection PyUnresolvedReferences icon = skill.icon or CommonIconUtils.load_question_mark_icon() # MISSING ICON Identifier _MISSING_IMAGE_ICON_ID = 3526464109639239417 if icon.instance == 0 or icon.instance == _MISSING_IMAGE_ICON_ID: icon = CommonIconUtils.load_question_mark_icon() option_dialog.add_option( CommonDialogInputIntegerOption( self.mod_identity, skill, current_skill_level, CommonDialogOptionContext( display_name, description, icon=icon, is_enabled=self._is_skill_allowed_for_modification( sim_info, skill)), dialog_description_identifier=S4CMSimModifySkillsStringId .ENTER_A_VALE_BETWEEN_MIN_AND_MAX_FOR_SKILL, dialog_description_tokens=(str(0), str(int(skill.max_level)), str(current_skill_level)), min_value=0, max_value=int(skill.max_level), on_chosen=_on_input_setting_changed)) except Exception as ex: self.log.format_error_with_message('Failed to display skill.', skill=skill, skill_name=skill.__name__, skill_id=skill_id, exception=ex) if not option_dialog.has_options(): self.log.format_with_message('No skills available for the Sim!') on_completed(False) return False option_dialog.show(sim_info=sim_info, sort_options=True) return True
def get_location(sim_info: SimInfo) -> Union[Location, None]: """ Retrieve the current location of a Sim. """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return None return sim.location
def is_leaving_zone(sim_info: SimInfo) -> bool: """ Determine if a sim is currently leaving the zone. """ sim = CommonSimUtils.get_sim_instance(sim_info) return sim is not None and services.sim_spawner_service().sim_is_leaving(sim)
def get_position(sim_info: SimInfo) -> Union[Vector3, None]: """ Retrieve the current position of a Sim. """ sim = CommonSimUtils.get_sim_instance(sim_info) if sim is None: return None return sim.position
def _is_not_spawned(_sim_info: SimInfo): return CommonSimUtils.get_sim_instance(_sim_info) is None