def is_sim_info_wearing_all_outfit_parts(sim_info, outfit, outfit_key): outfit_data = outfit.get_outfit(*outfit_key) current_outfit_data = sim_info.get_outfit(*sim_info.get_current_outfit()) return set( part_id for part_id in outfit_data.part_ids if get_caspart_bodytype(part_id) in CLOTHING_BODY_TYPES).issubset( set(current_outfit_data.part_ids))
def get_cas_part_body_type_id(cas_part_id): ''' Returns outfit cas part outfit body type id. :param cas_part_id: int -> outfit cas part id :return: int -> returns passed outfit cas part body type id ''' return get_caspart_bodytype(cas_part_id)
def modify_sim_info(self, source_sim_info, modified_sim_info, random_seed): if set_caspart(source_sim_info._base, modified_sim_info._base, self.cas_part, self.should_toggle, self.replace_with_random, self.update_genetics, random_seed, remove_conflicting=self.remove_conflicting): return BodyTypeFlag.make_body_type_flag( get_caspart_bodytype(self.cas_part)) if not self.expect_invalid_parts: sis = [] instanced_sim = source_sim_info.get_sim_instance() if instanced_sim is not None: sis = instanced_sim.get_all_running_and_queued_interactions( ) active_mods = source_sim_info.appearance_tracker.active_displayed_appearance_modifiers( ) logger.error( 'Unable to set cas part {}\nSim: {}, Gender: {}, Age: {} \nActive Modifiers: \n{} \nInteractions: \n{}', self, source_sim_info, source_sim_info.gender, source_sim_info.age, active_mods, sis) return BodyTypeFlag.NONE
def set_tan_level(self, tan_level=None, force_update=False): if not self._sim_info.is_simulating: return tan_level_changed = False if tan_level is not None: tan_level_changed = self._tan_level is not tan_level self._tan_level = tan_level if self._tan_level == TanLevel.NO_TAN: self._outfit_part_data_list = None if self.UPDATE_TAN_LINES_BUFF is not None: if self._sim_info.has_buff(self.UPDATE_TAN_LINES_BUFF): if self.TAN_PRANK_BUFF is not None and self._sim_info.has_buff( self.TAN_PRANK_BUFF) and self.TAN_PRANK_CAS_PARTS: part_id = random.choice(self.TAN_PRANK_CAS_PARTS) body_type = get_caspart_bodytype(part_id) self._outfit_part_data_list = ((part_id, body_type), ) else: current_outfit = self._sim_info.get_current_outfit() current_outfit_data = self._sim_info.get_outfit( *current_outfit) self._outfit_part_data_list = tuple( zip(current_outfit_data.part_ids, current_outfit_data.body_types)) self._force_update = False if tan_level_changed: self._suntan_force_updated = False elif force_update: if self._suntan_force_updated: return self._suntan_force_updated = True self._force_update = True self._sim_info.resend_suntan_data()
def is_cas_part_loaded(cas_part_id): ''' Returns if outfit cas part exists. If native get_caspart_bodytype method can't return proper body type for the passed cas part, that cas part doesn't exist. :param cas_part_id: int -> outfit cas part id :return: bool -> if passed outfit cas part exist ''' return get_caspart_bodytype(int(cas_part_id)) > 0
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 modify_sim_info(self, source_sim_info, modified_sim_info, random_seed): self._last_modified_type = None part_to_set = None for (key_part, value_part) in self.replace_part_map.items(): if source_sim_info.get_outfits().has_cas_part(key_part): part_to_set = value_part break if part_to_set is None: if self.default_set_part is not None: part_to_set = self.default_set_part if part_to_set is None: return BodyTypeFlag.NONE self._last_modified_type = get_caspart_bodytype(part_to_set) if set_caspart(source_sim_info._base, modified_sim_info._base, part_to_set, False, False, self.update_genetics, random_seed, remove_conflicting=True): return BodyTypeFlag.make_body_type_flag( get_caspart_bodytype(part_to_set)) if not self.expect_invalid_parts: sis = [] instanced_sim = source_sim_info.get_sim_instance() if instanced_sim is not None: sis = instanced_sim.get_all_running_and_queued_interactions( ) active_mods = source_sim_info.appearance_tracker.active_displayed_appearance_modifiers( ) logger.error( 'Unable to set cas part {}\nSim: {}, Gender: {}, Age: {} \nActive Modifiers: \n{} \nInteractions: \n{}', self, source_sim_info, source_sim_info.gender, source_sim_info.age, active_mods, sis) return BodyTypeFlag.NONE
def get_cas_parts_from_mannequin_data(self, sim_info, outfit_category_and_index): to_add = [] to_remove = [] mannequin_data = self.get_club_uniform_data( sim_info.age, sim_info.clothing_preference_gender) random_outfit = mannequin_data.get_random_outfit( outfit_categories=(outfit_category_and_index[0], )) if random_outfit[0] == outfit_category_and_index[ 0] and mannequin_data.has_outfit(random_outfit): outfit_data = mannequin_data.get_outfit(*random_outfit) to_add.extend( part_id for part_id in outfit_data.part_ids if get_caspart_bodytype(part_id) in CLOTHING_BODY_TYPES) if to_add: for outfit in sim_info.get_outfits_in_category( outfit_category_and_index[0]): for part in outfit.part_ids: body_type = get_caspart_bodytype(part) if body_type in CLOTHING_BODY_TYPES: if body_type not in outfit_data.body_types: to_remove.append(part) break return (to_add, to_remove)
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
def combinable_sorting_key(self): return get_caspart_bodytype(self.cas_part)