def pick_texture(cls, crafter, canvas_types: CanvasType) -> PaintingTexture: resolver = SingleSimResolver(crafter.sim_info) weights = [] for weighted_texture in cls._textures: weight = weighted_texture.weight texture = weighted_texture.texture if canvas_types & texture.canvas_types: if texture.tests.run_tests(resolver): weights.append((weight, texture)) texture = sims4.random.pop_weighted(weights) if texture is None and cls._textures: for weighted_texture in cls._textures: weight = weighted_texture.weight texture = weighted_texture.texture if canvas_types & texture.canvas_types: logger.error( 'Tuning Error: No texture of {0} passed tests for {1}, defaulting to {2}', cls._textures, crafter.sim_info, texture, owner='nbaker') return texture texture = cls._textures[0].texture logger.error( 'Tuning Error: No texture of {0} was correct type for {1}, defaulting to {2}', cls._textures, crafter.sim_info, texture, owner='nbaker') return texture return texture
def setup_crafted_object(cls, crafted_object, crafter, is_final_product): super().setup_crafted_object(crafted_object, crafter, is_final_product) if is_final_product: texture = cls.pick_texture(crafter) if texture is None: logger.error('Tuning Error: No texture found for {0}', crafted_object, owner='nbaker') return texture.apply_to_object(crafted_object)
def _verify_tuning_callback(cls): super()._verify_tuning_callback() if cls.painting_style is None: logger.error( 'PaintingRecipe {} does not have a painting_style tuned.', cls.__name__) if cls.first_phases and cls.final_product_canvas_tuning is None: logger.error( "PaintingRecipe {}'s final product does not have a CanvasComponent: {}", cls.__name__, cls.final_product_type)
def setup_crafted_object(cls, crafted_object, crafter, is_final_product): super().setup_crafted_object(crafted_object, crafter, is_final_product) if crafted_object.canvas_component is not None: texture = cls.pick_texture(crafted_object, crafter) if texture is None: logger.error('Tuning Error: No texture found for {0}', crafted_object, owner='nbaker') return reveal_level = crafted_object.canvas_component.painting_reveal_level texture.apply_to_object(crafted_object) if reveal_level is not None: crafted_object.canvas_component.painting_reveal_level = reveal_level
def pick_texture(cls, crafter, canvas_types) -> PaintingTexture: resolver = SingleSimResolver(crafter.sim_info) weights = [] for weighted_texture in cls._textures: weight = weighted_texture.weight texture = weighted_texture.texture while canvas_types & texture.canvas_types: if texture.tests.run_tests(resolver): weights.append((weight, texture)) texture = sims4.random.pop_weighted(weights) if texture is None and cls._textures: for weighted_texture in cls._textures: weight = weighted_texture.weight texture = weighted_texture.texture while canvas_types & texture.canvas_types: logger.error('Tuning Error: No texture of {0} passed tests for {1}, defaulting to {2}', cls._textures, crafter.sim_info, texture, owner='nbaker') return texture texture = cls._textures[0].texture logger.error('Tuning Error: No texture of {0} was correct type for {1}, defaulting to {2}', cls._textures, crafter.sim_info, texture, owner='nbaker') return texture return texture
def _verify_tuning_callback(cls): super()._verify_tuning_callback() if cls.painting_style is None: logger.error('PaintingRecipe {} does not have a painting_style tuned.', cls.__name__) if cls.first_phases and cls.final_product_canvas_tuning is None: logger.error("PaintingRecipe {}'s final product does not have a CanvasComponent: {}", cls.__name__, cls.final_product_type)