Ejemplo n.º 1
0
    def on_started(self, interaction_sim: Sim,
                   interaction_target: Any) -> bool:
        target_location = CommonObjectLocationUtils.get_location(
            interaction_sim)

        # noinspection PyUnresolvedReferences
        picked_sim_info = CommonSimUtils.get_sim_info(
            self.get_participant(ParticipantType.PickedSim))

        if picked_sim_info is None:
            return False
        if CommonSimUtils.get_sim_instance(picked_sim_info) is not None:
            if CommonAgeUtils.is_baby(picked_sim_info):
                # Sim is spawned, so let's move them to the Active Sim.
                CommonSimLocationUtils.set_location(picked_sim_info,
                                                    target_location)
        else:
            # Sim is not spawned, so let's spawn them.
            if CommonAgeUtils.is_baby(picked_sim_info):
                from sims.baby.baby_utils import create_and_place_baby
                create_and_place_baby(
                    picked_sim_info,
                    position=target_location.transform.translation,
                    routing_surface=target_location.routing_surface)
            else:
                CommonSimSpawnUtils.spawn_sim(picked_sim_info,
                                              location=target_location)
        return True
Ejemplo n.º 2
0
 def get_tags(self) -> Tuple[OCCASPartQueryTag]:
     result: Tuple[OCCASPartQueryTag] = (
         OCCASPartQueryTag(OCCASPartTagType.AGE, CommonAgeUtils.get_age(self._sim_info)),
         OCCASPartQueryTag(OCCASPartTagType.GENDER, CommonGenderUtils.get_gender(self._sim_info)),
         OCCASPartQueryTag(OCCASPartTagType.SPECIES, CommonSpecies.get_species(self._sim_info)),
     )
     return result
Ejemplo n.º 3
0
 def __str__(self) -> str:
     return '{}: {}, Age: {}, Gender: {}, Species: {}'.format(
         self.__class__.__name__,
         CommonSimNameUtils.get_full_name(self._sim_info),
         CommonAgeUtils.get_age(self._sim_info),
         CommonGenderUtils.get_gender(self._sim_info),
         CommonSpecies.get_species(self._sim_info)
     )
Ejemplo n.º 4
0
    def get_age(sim_info: SimInfo) -> 'CommonAge':
        """get_age(sim_info)

        Retrieve the CommonAge of a Sim.

        :param sim_info: An instance of a Sim.
        :type sim_info: SimInfo
        :return: The CommonAge that represents what age a Sim is or CommonAge.INVALID if their age cannot be determined.
        :rtype: CommonAge
        """
        from sims4communitylib.utils.sims.common_age_utils import CommonAgeUtils
        if CommonAgeUtils.is_baby(sim_info):
            return CommonAge.BABY
        elif CommonAgeUtils.is_toddler(sim_info):
            return CommonAge.TODDLER
        elif CommonAgeUtils.is_child(sim_info):
            return CommonAge.CHILD
        elif CommonAgeUtils.is_teen(sim_info):
            return CommonAge.TEEN
        elif CommonAgeUtils.is_young_adult(sim_info):
            return CommonAge.YOUNGADULT
        elif CommonAgeUtils.is_adult(sim_info):
            return CommonAge.ADULT
        elif CommonAgeUtils.is_elder(sim_info):
            return CommonAge.ELDER
        return CommonAge.INVALID
 def get_tags(self) -> Tuple[CSFSliderQueryTag]:
     result: Tuple[CSFSliderQueryTag] = (
         CSFSliderQueryTag(CSFSliderTagType.GENDER,
                           CommonGenderUtils.get_gender(self._sim_info)),
         CSFSliderQueryTag(CSFSliderTagType.AGE,
                           CommonAgeUtils.get_age(self._sim_info)),
         CSFSliderQueryTag(CSFSliderTagType.SPECIES,
                           CommonSpecies.get_species(self._sim_info)),
     )
     return result
Ejemplo n.º 6
0
 def run(
     self,
     sim_info: SimInfo,
     on_completed: Callable[[bool],
                            None] = CommonFunctionUtils.noop) -> bool:
     result = CommonAgeUtils.set_age(sim_info, self.age)
     if result:
         CommonSimSpawnUtils.soft_reset(sim_info,
                                        cause='S4CM Sim Age Change')
     on_completed(result)
     return result
Ejemplo n.º 7
0
    def is_mature_adult_human(sim_info: SimInfo) -> bool:
        """is_mature_adult_human(sim_info)

        Determine if a sim is an Adult Human.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is an Adult Human. False, if the Sim is not.
        :rtype: bool
        """
        return CommonAgeUtils.is_mature_adult(
            sim_info) and CommonSpeciesUtils.is_human(sim_info)
Ejemplo n.º 8
0
    def is_teen_adult_or_elder_human(sim_info: SimInfo) -> bool:
        """is_teen_adult_or_elder_human(sim_info)

        Determine if a sim is a Teen, Young Adult, Adult, or Elder Human.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is a Teen, Young Adult, Adult, or Elder Human. False, if the Sim is not.
        :rtype: bool
        """
        return CommonAgeUtils.is_teen_adult_or_elder(
            sim_info) and CommonSpeciesUtils.is_human(sim_info)
Ejemplo n.º 9
0
    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)
Ejemplo n.º 10
0
    def is_baby_toddler_or_child_human(sim_info: SimInfo) -> bool:
        """is_baby_toddler_or_child_human(sim_info)

        Determine if a sim is a Baby, Toddler, or Child Human.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is a Baby, Toddler, or Child Human. False, if the Sim is not.
        :rtype: bool
        """
        return CommonAgeUtils.is_baby_toddler_or_child(
            sim_info) and CommonSpeciesUtils.is_human(sim_info)
Ejemplo n.º 11
0
    def is_child_or_teen_human(sim_info: SimInfo) -> bool:
        """is_child_or_teen_human(sim_info)

        Determine if a sim is a Child or Teen Human.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is a Child or Teen Human. False, if the Sim is not.
        :rtype: bool
        """
        return CommonAgeUtils.is_child_or_teen(
            sim_info) and CommonSpeciesUtils.is_human(sim_info)
Ejemplo n.º 12
0
 def _on_submit(chosen_sim_info_list: Tuple[SimInfo]) -> None:
     if chosen_sim_info_list is None or not chosen_sim_info_list:
         return
     for chosen_sim_info in chosen_sim_info_list:
         # noinspection PyBroadException
         try:
             if CommonAgeUtils.is_baby(chosen_sim_info):
                 from sims.baby.baby_utils import create_and_place_baby
                 create_and_place_baby(chosen_sim_info, position=target_location.transform.translation, routing_surface=target_location.routing_surface)
             else:
                 CommonSimSpawnUtils.spawn_sim(chosen_sim_info, location=target_location)
         except:
             pass
Ejemplo n.º 13
0
    def are_same_age_and_species(sim_info: SimInfo,
                                 other_sim_info: SimInfo) -> bool:
        """are_same_age_and_species(sim_info, other_sim_info)

        Determine if two Sims are the same Age and the same Species.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :param other_sim_info: The other Sim to compare to.
        :type other_sim_info: SimInfo
        :return: True, if both Sims are the same Age and Species. False, if they are not.
        :rtype: bool
        """
        return CommonAgeUtils.are_same_age(
            sim_info, other_sim_info) and CommonSpeciesUtils.are_same_species(
                sim_info, other_sim_info)
    def can_create_pregnancy(sim_info: SimInfo,
                             ignore_gender_options: bool = False) -> bool:
        """can_create_pregnancy(sim_info, ignore_gender_options=False)

        Determine if a Sim is able to create a pregnancy.

        :param sim_info: An instance of a Sim.
        :type sim_info: SimInfo
        :param ignore_gender_options: If set to True, pregnancy gender options will be ignored.\
        If set to False, the Sim will be checked for having either Can Impregnate or Can Be Impregnated. Default is False.
        :type ignore_gender_options: bool, optional
        :return: True, if the Sim can produce a pregnancy. False, if not.
        :rtype: bool
        """
        if not ignore_gender_options:
            if not CommonSimPregnancyUtils.can_impregnate(
                    sim_info
            ) and not CommonSimPregnancyUtils.can_be_impregnated(sim_info):
                return False
        return CommonAgeUtils.is_adult_or_elder(sim_info)
Ejemplo n.º 15
0
    def generate_for_sim(sim_info: SimInfo) -> 'CommonAvailableForSim':
        """generate_for_sim(sim_info)

        Generate an available for, for a Sim.

        :param sim_info: An instance of a Sim.
        :type sim_info: SimInfo
        :return: An available for matching the specified Sim.
        :rtype: CommonAvailableForSim
        """
        from sims4communitylib.utils.sims.common_age_utils import CommonAgeUtils
        gender = CommonGender.get_gender(sim_info)
        if gender == CommonGender.INVALID:
            genders = tuple()
        else:
            genders = (gender,)
        age = CommonAge.get_age(sim_info)
        if age == CommonAge.INVALID:
            ages = tuple()
        elif CommonAgeUtils.is_teen_adult_or_elder_age(age):
            ages = (CommonAge.TEEN, CommonAge.YOUNGADULT, CommonAge.ADULT, CommonAge.ELDER)
        else:
            ages = (age,)
        sim_species = CommonSpecies.get_species(sim_info)
        if sim_species == CommonSpecies.INVALID:
            species = tuple()
        else:
            species = (sim_species,)
        occult_type = CommonOccultType.determine_occult_type(sim_info)
        if occult_type == CommonOccultType.NON_OCCULT:
            occult_types = (occult_type,)
        else:
            occult_types = (CommonOccultType.NON_OCCULT, occult_type)
        return CommonAvailableForSim(
            genders=genders,
            ages=ages,
            species=species,
            occult_types=occult_types
        )
Ejemplo n.º 16
0
 def are_allowed_romantic_relationship(sim_info_a: SimInfo,
                                       sim_info_b: SimInfo) -> bool:
     """Whether or not two Sims are allowed to have a Romantic relationship together."""
     if not S4CMSettingUtils.is_allowed_romantic_relationship(
             sim_info_a
     ) or not S4CMSettingUtils.is_allowed_romantic_relationship(sim_info_b):
         return False
     if CommonRelationshipUtils.are_blood_relatives(sim_info_a, sim_info_b):
         return False
     if not CommonSpeciesUtils.are_same_species(sim_info_a, sim_info_b):
         return False
     if CommonAgeUtils.is_teen(sim_info_a) and CommonAgeUtils.is_teen(
             sim_info_b):
         return True
     # Teen to Teen is ok, this check prevents Teen to Adult/Elder/etc. like vanilla has it.
     if CommonAgeUtils.is_teen(sim_info_a) or CommonAgeUtils.is_teen(
             sim_info_b):
         return False
     # If the Sims are not Adults, they can be assumed to be either a Young Adult, Adult, or Elder
     return CommonAgeUtils.is_adult_or_elder(sim_info_a)\
            and CommonAgeUtils.is_adult_or_elder(sim_info_b)
Ejemplo n.º 17
0
 def is_sim_allowed_to_perform_adult_sim_operations(
         sim_info: SimInfo) -> bool:
     """Whether or not the Sim is allowed to perform Operations intended for Adult Sims."""
     return CommonAgeUtils.is_adult_or_elder(sim_info)
Ejemplo n.º 18
0
 def are_same_age_and_species(sim_info: SimInfo, other_sim_info: SimInfo) -> bool:
     """
         Determine if two Sims are the same Age and the same Species.
     """
     return CommonAgeUtils.are_same_age(sim_info, other_sim_info) and CommonSpeciesUtils.are_same_species(sim_info, other_sim_info)
Ejemplo n.º 19
0
 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)
Ejemplo n.º 20
0
 def is_elder_human(sim_info: SimInfo) -> bool:
     """
         Determine if a sim is an Elder Human.
     """
     return CommonAgeUtils.is_elder(sim_info) and CommonSpeciesUtils.is_human(sim_info)
Ejemplo n.º 21
0
 def is_baby_human(sim_info: SimInfo) -> bool:
     """
         Determine if a sim is a Baby Human.
     """
     return CommonAgeUtils.is_baby(sim_info) and CommonSpeciesUtils.is_human(sim_info)
Ejemplo n.º 22
0
 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)
Ejemplo n.º 23
0
 def is_baby_toddler_or_child_human(sim_info: SimInfo) -> bool:
     """
         Determine if a sim is a Baby, Toddler, or Child Human.
     """
     return CommonAgeUtils.is_baby_toddler_or_child(sim_info) and CommonSpeciesUtils.is_human(sim_info)
Ejemplo n.º 24
0
    def _setup_dialog(self, option_dialog: CommonChooseButtonOptionDialog,
                      on_close: Callable[[],
                                         None], on_previous: Callable[[],
                                                                      None],
                      reopen: Callable[[], None], **__) -> bool:
        def _operation_run(operation: S4CMSingleSimOperation):
            def _on_operation_complete(_: bool) -> None:
                reopen()

            operation.run(self._sim_info, on_completed=_on_operation_complete)

        if CommonAgeUtils.is_age_available_for_sim(self._sim_info,
                                                   CommonAge.TODDLER):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'Toddler',
                    CommonAge.TODDLER,
                    CommonDialogResponseOptionContext(CommonStringId.TODDLER),
                    on_chosen=lambda *_, **__: _operation_run(
                        S4CMSetAgeToddlerOp())))

        if CommonAgeUtils.is_age_available_for_sim(self._sim_info,
                                                   CommonAge.CHILD):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'Child',
                    CommonAge.CHILD,
                    CommonDialogResponseOptionContext(CommonStringId.CHILD),
                    on_chosen=lambda *_, **__: _operation_run(
                        S4CMSetAgeChildOp())))

        if CommonAgeUtils.is_age_available_for_sim(self._sim_info,
                                                   CommonAge.TEEN):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'Teen',
                    CommonAge.TEEN,
                    CommonDialogResponseOptionContext(CommonStringId.TEEN),
                    on_chosen=lambda *_, **__: _operation_run(S4CMSetAgeTeenOp(
                    ))))

        if CommonAgeUtils.is_age_available_for_sim(self._sim_info,
                                                   CommonAge.YOUNGADULT):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'YoungAdult',
                    CommonAge.YOUNGADULT,
                    CommonDialogResponseOptionContext(
                        CommonStringId.YOUNG_ADULT),
                    on_chosen=lambda *_, **__: _operation_run(
                        S4CMSetAgeYoungAdultOp())))

        if CommonAgeUtils.is_age_available_for_sim(self._sim_info,
                                                   CommonAge.ADULT):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'Adult',
                    CommonAge.ADULT,
                    CommonDialogResponseOptionContext(CommonStringId.ADULT),
                    on_chosen=lambda *_, **__: _operation_run(
                        S4CMSetAgeAdultOp())))

        if CommonAgeUtils.is_age_available_for_sim(self._sim_info,
                                                   CommonAge.ELDER):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'Elder',
                    CommonAge.ELDER,
                    CommonDialogResponseOptionContext(CommonStringId.ELDER),
                    on_chosen=lambda *_, **__: _operation_run(
                        S4CMSetAgeElderOp())))
        return True
Ejemplo n.º 25
0
 def is_adult_human(sim_info: SimInfo) -> bool:
     """
         Determine if a sim is a Young Adult or Adult Human.
     """
     return CommonAgeUtils.is_adult(sim_info) and CommonSpeciesUtils.is_human(sim_info)
Ejemplo n.º 26
0
 def is_child_or_teen_human(sim_info: SimInfo) -> bool:
     """
         Determine if a sim is a Child or Teen Human.
     """
     return CommonAgeUtils.is_child_or_teen(sim_info) and CommonSpeciesUtils.is_human(sim_info)
Ejemplo n.º 27
0
 def is_allowed_romantic_relationship(sim_info: SimInfo) -> bool:
     """Determine if a Sim is allowed to have a romantic relationship with another Sim."""
     return CommonAgeUtils.is_teen_adult_or_elder(sim_info)
Ejemplo n.º 28
0
 def _is_valid_sim(_sim_info: SimInfo) -> bool:
     return CommonSpeciesUtils.is_human(
         _sim_info) and not CommonAgeUtils.is_baby(_sim_info)
Ejemplo n.º 29
0
 def is_enabled_for_interactions(sim_info: SimInfo) -> bool:
     """ Determine if a Sim can perform the Outfit Customization interactions. """
     return not CommonAgeUtils.is_baby(sim_info)
Ejemplo n.º 30
0
 def is_baby_or_toddler_human(sim_info: SimInfo) -> bool:
     """
         Determine if a sim is a Baby or Toddler Human.
     """
     return CommonAgeUtils.is_baby_or_toddler(sim_info) and CommonSpeciesUtils.is_human(sim_info)