def update_can_reproduce(sim_info: SimInfo, can_reproduce: bool) -> bool: """update_can_reproduce(sim_info, can_reproduce) Update a Sims ability to reproduce. .. note:: Will only update Pet Sims. :param sim_info: An instance of a Sim. :type sim_info: SimInfo :param can_reproduce: If True, the Sim will have the ability to reproduce.\ If False, the Sim will not have the ability to reproduce. :type can_reproduce: bool :return: True, if successful. False, if not. :rtype: bool """ if sim_info is None: return False if not CommonSpeciesUtils.is_pet(sim_info): return False if can_reproduce: CommonTraitUtils.remove_trait( sim_info, CommonTraitId.PREGNANCY_OPTIONS_PET_CAN_NOT_REPRODUCE) CommonTraitUtils.add_trait( sim_info, CommonTraitId.PREGNANCY_OPTIONS_PET_CAN_REPRODUCE) else: CommonTraitUtils.remove_trait( sim_info, CommonTraitId.PREGNANCY_OPTIONS_PET_CAN_REPRODUCE) CommonTraitUtils.add_trait( sim_info, CommonTraitId.PREGNANCY_OPTIONS_PET_CAN_NOT_REPRODUCE) from sims4communitylib.events.sim.common_sim_event_dispatcher import CommonSimEventDispatcherService CommonSimEventDispatcherService( )._on_sim_change_gender_options_can_reproduce(sim_info) return True
def can_impregnate(sim_info: SimInfo) -> bool: """can_impregnate(sim_info) Determine if a Sim can impregnate other sims. :param sim_info: The Sim being checked. :type sim_info: SimInfo :return: True, if they can. False, if they cannot. :rtype: bool """ from sims4communitylib.utils.sims.common_trait_utils import CommonTraitUtils from sims4communitylib.enums.traits_enum import CommonTraitId if CommonSpeciesUtils.is_human(sim_info): if CommonTraitUtils.has_trait( sim_info, CommonTraitId.GENDER_OPTIONS_PREGNANCY_CAN_NOT_IMPREGNATE): return False return CommonTraitUtils.has_trait( sim_info, CommonTraitId.GENDER_OPTIONS_PREGNANCY_CAN_IMPREGNATE) elif CommonSpeciesUtils.is_pet(sim_info): if CommonTraitUtils.has_trait( sim_info, CommonTraitId.PREGNANCY_OPTIONS_PET_CAN_NOT_REPRODUCE): return False return CommonTraitUtils.has_trait( sim_info, CommonTraitId.PREGNANCY_OPTIONS_PET_CAN_REPRODUCE) return False
def get_valid_motives(self, sim_info: SimInfo) -> Tuple[str]: """ Retrieve a collection of all valid motives. """ motives: Tuple[str] = tuple() if CommonOccultUtils.is_vampire(sim_info): motives += (CMMotive.SOCIAL, CMMotive.FUN, CMMotive.HYGIENE, CMMotive.VAMPIRE_THIRST, CMMotive.VAMPIRE_POWER) elif CommonOccultUtils.is_robot(sim_info): motives += (CMMotive.SOCIAL, CMMotive.FUN, CMMotive.SERVO_DURABILITY, CMMotive.SERVO_CHARGE) elif CommonOccultUtils.is_plant_sim(sim_info): motives += ( CMMotive.SOCIAL, CMMotive.FUN, CMMotive.HYGIENE, CMMotive.HUNGER, CMMotive.ENERGY, CMMotive.PLANT_SIM_WATER, ) else: motives += (CMMotive.SOCIAL, CMMotive.FUN, CMMotive.HYGIENE, CMMotive.HUNGER, CMMotive.ENERGY, CMMotive.BLADDER) if CommonSpeciesUtils.is_pet(sim_info): motives += (CMMotive.BOWEL, ) trimmed_result: List[str] = list() for motive in motives: trimmed_result.append(motive.replace('CMMotive.', '').lower()) return tuple(trimmed_result)
def can_translate_motive(self, sim_info: SimInfo, motive_name: str) -> bool: """ Determine if a motive is valid. """ if motive_name is None: return False if motive_name == CMMotive.BOWEL: if not CommonSpeciesUtils.is_pet(sim_info): return False return True return motive_name in CMMotiveUtils._MOTIVE_MAPPINGS
def is_old_pet(sim_info: SimInfo) -> bool: """is_old_pet(sim_info) Determine if a sim is an Adult or Elder Pet (Cat, Small Dog, Large Dog). :param sim_info: The Sim to check. :type sim_info: SimInfo :return: True, if the Sim is an Adult or Elder Pet (Cat, Small Dog, Large Dog). False, if the Sim is not. :rtype: bool """ return CommonAgeUtils.is_adult_or_elder( sim_info) and CommonSpeciesUtils.is_pet(sim_info)
def open(self): """ Open the dialog. """ try: def _on_close() -> None: if self._on_close is not None: self._on_close() if CommonSpeciesUtils.is_pet(self._sim_info): self._settings_pet(on_close=_on_close) else: self._settings_human(on_close=_on_close) except Exception as ex: self.log.error( 'Error occurred while opening custom gender settings dialog.', exception=ex)
def can_impregnate(sim_info: SimInfo) -> bool: """ Determine if a Sim can impregnate other sims. """ from sims4communitylib.utils.sims.common_trait_utils import CommonTraitUtils from sims4communitylib.enums.traits_enum import CommonTraitId if CommonSpeciesUtils.is_human(sim_info): if CommonTraitUtils.has_trait( sim_info, CommonTraitId.GENDER_OPTIONS_PREGNANCY_CAN_NOT_IMPREGNATE): return False return CommonTraitUtils.has_trait( sim_info, CommonTraitId.GENDER_OPTIONS_PREGNANCY_CAN_IMPREGNATE) elif CommonSpeciesUtils.is_pet(sim_info): if CommonTraitUtils.has_trait( sim_info, CommonTraitId.PREGNANCY_OPTIONS_PET_CAN_NOT_REPRODUCE): return False return CommonTraitUtils.has_trait( sim_info, CommonTraitId.PREGNANCY_OPTIONS_PET_CAN_REPRODUCE) return False
def get_body_frame(sim_info: SimInfo) -> 'CommonBodyFrame': """get_body_frame(sim_info) Retrieve the CommonBodyFrame of a sim. :param sim_info: An instance of a Sim. :type sim_info: SimInfo :return: The body frame of the Sim or CommonBodyFrame.INVALID if their current body frame cannot be determined. :rtype: CommonBodyFrame """ from sims4communitylib.utils.sims.common_sim_gender_option_utils import CommonSimGenderOptionUtils if CommonSpeciesUtils.is_pet(sim_info): if CommonGenderUtils.is_male(sim_info): return CommonBodyFrame.MASCULINE if CommonGenderUtils.is_female(sim_info): return CommonBodyFrame.FEMININE return CommonBodyFrame.INVALID if CommonSimGenderOptionUtils.has_masculine_frame(sim_info): return CommonBodyFrame.MASCULINE if CommonSimGenderOptionUtils.has_feminine_frame(sim_info): return CommonBodyFrame.FEMININE return CommonBodyFrame.INVALID
def _update_gender_options(self, sim_info: SimInfo): update_outfits = False if self._setting_utils.force_all_sims_to_male( ) and not CommonGenderUtils.is_male(sim_info): CommonGenderUtils.swap_gender(sim_info, update_gender_options=False) update_outfits = True elif self._setting_utils.force_all_sims_to_female( ) and not CommonGenderUtils.is_female(sim_info): CommonGenderUtils.swap_gender(sim_info, update_gender_options=False) update_outfits = True if CommonGenderUtils.is_male(sim_info): if CommonSpeciesUtils.is_pet(sim_info): if self._setting_utils.all_male_options.can_reproduce( ) and not CommonSimGenderOptionUtils.can_reproduce(sim_info): CommonSimGenderOptionUtils.update_can_reproduce( sim_info, True) if self._setting_utils.all_male_options.cannot_reproduce( ) and not CommonSimGenderOptionUtils.can_not_reproduce( sim_info): CommonSimGenderOptionUtils.update_can_reproduce( sim_info, False) elif CommonSpeciesUtils.is_human(sim_info): if self._setting_utils.all_male_options.use_toilet_standing( ) and not CommonSimGenderOptionUtils.uses_toilet_standing( sim_info): CommonSimGenderOptionUtils.update_toilet_usage( sim_info, True) update_outfits = True if self._setting_utils.all_male_options.use_toilet_sitting( ) and not CommonSimGenderOptionUtils.uses_toilet_sitting( sim_info): CommonSimGenderOptionUtils.update_toilet_usage( sim_info, False) update_outfits = True if self._setting_utils.all_male_options.prefer_menswear( ) and not CommonSimGenderOptionUtils.prefers_menswear( sim_info): CommonSimGenderOptionUtils.update_clothing_preference( sim_info, True) if self._setting_utils.all_male_options.prefer_womenswear( ) and not CommonSimGenderOptionUtils.prefers_womenswear( sim_info): CommonSimGenderOptionUtils.update_clothing_preference( sim_info, False) if self._setting_utils.all_male_options.force_masculine_body_frame( ) and not CommonSimGenderOptionUtils.has_masculine_frame( sim_info): CommonSimGenderOptionUtils.update_body_frame( sim_info, True) if self._setting_utils.all_male_options.force_feminine_body_frame( ) and not CommonSimGenderOptionUtils.has_feminine_frame( sim_info): CommonSimGenderOptionUtils.update_body_frame( sim_info, False) if self._setting_utils.all_male_options.can_impregnate( ) and not CommonSimGenderOptionUtils.can_impregnate(sim_info): CommonSimGenderOptionUtils.update_can_impregnate( sim_info, True) if self._setting_utils.all_male_options.cannot_impregnate( ) and not CommonSimGenderOptionUtils.can_not_impregnate( sim_info): CommonSimGenderOptionUtils.update_can_impregnate( sim_info, False) if self._setting_utils.all_male_options.can_be_impregnated( ) and not CommonSimGenderOptionUtils.can_be_impregnated( sim_info): CommonSimGenderOptionUtils.update_can_be_impregnated( sim_info, True) if self._setting_utils.all_male_options.cannot_be_impregnated( ) and not CommonSimGenderOptionUtils.can_not_be_impregnated( sim_info): CommonSimGenderOptionUtils.update_can_be_impregnated( sim_info, False) if self._setting_utils.all_male_options.force_breasts_on( ) and not CommonSimGenderOptionUtils.has_breasts(sim_info): CommonSimGenderOptionUtils.update_has_breasts( sim_info, True) update_outfits = True if self._setting_utils.all_male_options.force_breasts_off( ) and CommonSimGenderOptionUtils.has_breasts(sim_info): CommonSimGenderOptionUtils.update_has_breasts( sim_info, False) update_outfits = True elif CommonGenderUtils.is_female(sim_info): if CommonSpeciesUtils.is_pet(sim_info): if self._setting_utils.all_female_options.can_reproduce( ) and not CommonSimGenderOptionUtils.can_reproduce(sim_info): CommonSimGenderOptionUtils.update_can_reproduce( sim_info, True) if self._setting_utils.all_female_options.cannot_reproduce( ) and not CommonSimGenderOptionUtils.can_not_reproduce( sim_info): CommonSimGenderOptionUtils.update_can_reproduce( sim_info, False) elif CommonSpeciesUtils.is_human(sim_info): if self._setting_utils.all_female_options.use_toilet_standing( ) and not CommonSimGenderOptionUtils.uses_toilet_standing( sim_info): CommonSimGenderOptionUtils.update_toilet_usage( sim_info, True) update_outfits = True if self._setting_utils.all_female_options.use_toilet_sitting( ) and not CommonSimGenderOptionUtils.uses_toilet_sitting( sim_info): CommonSimGenderOptionUtils.update_toilet_usage( sim_info, False) update_outfits = True if self._setting_utils.all_female_options.prefer_menswear( ) and not CommonSimGenderOptionUtils.prefers_menswear( sim_info): CommonSimGenderOptionUtils.update_clothing_preference( sim_info, True) if self._setting_utils.all_female_options.prefer_womenswear( ) and not CommonSimGenderOptionUtils.prefers_womenswear( sim_info): CommonSimGenderOptionUtils.update_clothing_preference( sim_info, False) if self._setting_utils.all_female_options.force_masculine_body_frame( ) and not CommonSimGenderOptionUtils.has_masculine_frame( sim_info): CommonSimGenderOptionUtils.update_body_frame( sim_info, True) if self._setting_utils.all_female_options.force_feminine_body_frame( ) and not CommonSimGenderOptionUtils.has_feminine_frame( sim_info): CommonSimGenderOptionUtils.update_body_frame( sim_info, False) if self._setting_utils.all_female_options.can_impregnate( ) and not CommonSimGenderOptionUtils.can_impregnate(sim_info): CommonSimGenderOptionUtils.update_can_impregnate( sim_info, True) if self._setting_utils.all_female_options.cannot_impregnate( ) and not CommonSimGenderOptionUtils.can_not_impregnate( sim_info): CommonSimGenderOptionUtils.update_can_impregnate( sim_info, False) if self._setting_utils.all_female_options.can_be_impregnated( ) and not CommonSimGenderOptionUtils.can_be_impregnated( sim_info): CommonSimGenderOptionUtils.update_can_be_impregnated( sim_info, True) if self._setting_utils.all_female_options.cannot_be_impregnated( ) and not CommonSimGenderOptionUtils.can_not_be_impregnated( sim_info): CommonSimGenderOptionUtils.update_can_be_impregnated( sim_info, False) if self._setting_utils.all_female_options.force_breasts_on( ) and not CommonSimGenderOptionUtils.has_breasts(sim_info): CommonSimGenderOptionUtils.update_has_breasts( sim_info, True) update_outfits = True if self._setting_utils.all_female_options.force_breasts_off( ) and CommonSimGenderOptionUtils.has_breasts(sim_info): CommonSimGenderOptionUtils.update_has_breasts( sim_info, False) update_outfits = True if update_outfits: CommonOutfitUtils.update_outfits(sim_info)
def is_old_pet(sim_info: SimInfo) -> bool: """ Determine if a sim is an Adult or Elder Pet. """ return CommonAgeUtils.is_adult_or_elder(sim_info) and CommonSpeciesUtils.is_pet(sim_info)
def is_elder_pet(sim_info: SimInfo) -> bool: """ Determine if a sim is an Elder Pet. """ return CommonAgeUtils.is_elder(sim_info) and CommonSpeciesUtils.is_pet(sim_info)
def is_adult_pet(sim_info: SimInfo) -> bool: """ Determine if a sim is an Adult Pet. """ return CommonAgeUtils.is_adult(sim_info) and CommonSpeciesUtils.is_pet(sim_info)
def is_child_pet(sim_info: SimInfo) -> bool: """ Determine if a sim is a Child Pet. """ return CommonAgeUtils.is_child(sim_info) and CommonSpeciesUtils.is_pet(sim_info)
def is_enabled_for_interactions(self, sim_info: SimInfo) -> bool: """ Determine if a Sim is enabled for Custom Gender Setting interactions. """ return CommonSpeciesUtils.is_human(sim_info) or CommonSpeciesUtils.is_pet(sim_info)