예제 #1
0
 def get_body_type(body_type_id):
     '''
     Returns native BodyType instance.
     :param body_type_id: int -> outfit body type id
     :return: BodyType -> native BodyType instance of given outfit body type id
     '''
     return BodyType(int(body_type_id))
    def get_body_type_cas_part_is_attached_to(
        sim_info: SimInfo,
        cas_part_id: int,
        outfit_category_and_index: Tuple[OutfitCategory,
                                         int] = None) -> BodyType:
        """get_body_type_cas_part_is_attached_to(sim_info, cas_part_id, outfit_category_and_index=None)

        Retrieve the BodyType that a cas part is attached to within a Sims outfit.

        :param sim_info: The SimInfo of the Sim to check.
        :type sim_info: SimInfo
        :param cas_part_id: A decimal identifier of the CAS part to locate.
        :type cas_part_id: int
        :param outfit_category_and_index: The outfit category and index of the Sims outfit to check. Default is the Sims current outfit.
        :type outfit_category_and_index: Tuple[OutfitCategory, int], optional
        :return: The BodyType the specified cas part id is attached to or -1 if the cas part is not found.
        :rtype: BodyType
        """
        log.format_with_message(
            'Retrieving BodyType for cas part.',
            sim=sim_info,
            cas_part_id=cas_part_id,
            outfit_category_and_index=outfit_category_and_index)
        if outfit_category_and_index is None:
            outfit_category_and_index = CommonOutfitUtils.get_current_outfit(
                sim_info)
        log.format(cas_part_id=cas_part_id,
                   outfit_category_and_index=outfit_category_and_index)
        outfit_parts = CommonOutfitUtils.get_outfit_parts(
            sim_info, outfit_category_and_index=outfit_category_and_index)
        if not outfit_parts:
            log.debug('No body parts found.')
            return BodyType.NONE
        log.format_with_message('Found body parts from outfit.',
                                body_parts=outfit_parts)
        for body_type in outfit_parts.keys():
            if cas_part_id != outfit_parts[body_type]:
                continue
            log.format_with_message('Found BodyType.',
                                    body_type=BodyType(body_type))
            return BodyType(body_type)
        log.debug('No BodyType found matching the cas part.')
        return BodyType.NONE
    def get_body_type_of_cas_part(cas_part_id: int) -> Union[BodyType, None]:
        """get_body_type_of_cas_part(cas_part_id)

        Retrieve the BodyType of a CAS part.

        :param cas_part_id: The decimal identifier of a CAS part.
        :type cas_part_id: int
        :return: The default BodyType of the CAS part or None if the Body Type of a cas part is not an actual BodyType.
        :rtype: Union[BodyType, None]
        """
        body_type = get_caspart_bodytype(cas_part_id)
        if body_type not in BodyType:
            return None
        return BodyType(body_type)
    def get_body_type_cas_part_is_attached_to(
        sim_info: SimInfo,
        cas_part_id: int,
        outfit_category_and_index: Tuple[OutfitCategory, int] = None
    ) -> Union[BodyType, int]:
        """get_body_type_cas_part_is_attached_to(sim_info, cas_part_id, outfit_category_and_index=None)

        Retrieve the BodyType that a CAS part is attached to within a Sims outfit.

        :param sim_info: The SimInfo of the Sim to check.
        :type sim_info: SimInfo
        :param cas_part_id: A decimal identifier of the CAS part to locate.
        :type cas_part_id: int
        :param outfit_category_and_index: The outfit category and index of the Sims outfit to check. If None, the current outfit of the Sim will be used.
        :type outfit_category_and_index: Tuple[OutfitCategory, int], optional
        :return: The BodyType the specified CAS part id is attached to or BodyType.NONE if the CAS part is not found or the Sim does not have body parts for their outfit.
        :rtype: Union[BodyType, int]
        """
        log.format_with_message(
            'Retrieving BodyType for CAS part.',
            sim=sim_info,
            cas_part_id=cas_part_id,
            outfit_category_and_index=outfit_category_and_index)
        if outfit_category_and_index is None:
            outfit_category_and_index = CommonOutfitUtils.get_current_outfit(
                sim_info)
        log.format(cas_part_id=cas_part_id,
                   outfit_category_and_index=outfit_category_and_index)
        outfit_parts = CommonOutfitUtils.get_outfit_parts(
            sim_info, outfit_category_and_index=outfit_category_and_index)
        if not outfit_parts:
            log.debug('No body parts found on Sim!')
            return BodyType.NONE
        log.format_with_message('Found body parts from outfit.',
                                body_parts=outfit_parts)
        for body_type in outfit_parts.keys():
            if cas_part_id != outfit_parts[body_type]:
                continue
            # noinspection PyBroadException
            try:
                body_type = BodyType(body_type)
            except:
                body_type = body_type
            log.format_with_message(
                'Found the BodyType the specified CAS part is attached to.',
                body_type=body_type)
            return body_type
        log.debug('No BodyType was found matching the specified CAS part.')
        return BodyType.NONE
    def get_body_type_of_cas_part(cas_part_id: int) -> Union[BodyType, int]:
        """get_body_type_of_cas_part(cas_part_id)

        Retrieve the BodyType of a CAS part.

        .. note:: Some Body Types don't appear in the BodyType enum.

        :param cas_part_id: The decimal identifier of a CAS part.
        :type cas_part_id: int
        :return: The default BodyType of the CAS part or an int if the Body Type is not within the BodyType enum.
        :rtype: Union[BodyType, int]
        """
        body_type = get_caspart_bodytype(cas_part_id)
        if body_type not in BodyType:
            return body_type
        # noinspection PyBroadException
        try:
            return BodyType(body_type)
        except:
            return body_type
예제 #6
0
 def _get_body_type(*args):
     try:
         return BodyType(args[0])
     except:
         return BodyType.NONE