Get appropriate texture path for an object, or None if it should use color. Args: obj_name: Name of the object Returns: str: Path to texture directory, or None if object should use solid color
(obj_name)
| 281 | |
| 282 | |
| 283 | def get_texture_for_object(obj_name): |
| 284 | """ |
| 285 | Get appropriate texture path for an object, or None if it should use color. |
| 286 | |
| 287 | Args: |
| 288 | obj_name: Name of the object |
| 289 | |
| 290 | Returns: |
| 291 | str: Path to texture directory, or None if object should use solid color |
| 292 | """ |
| 293 | # Check if object should use texture |
| 294 | if obj_name not in TEXTURED_OBJECTS: |
| 295 | return None |
| 296 | |
| 297 | # Get possible texture categories for this object |
| 298 | possible_categories = TEXTURED_OBJECTS[obj_name] |
| 299 | |
| 300 | # Randomly select one category from the possibilities |
| 301 | category = random.choice(possible_categories) |
| 302 | |
| 303 | # Get available textures in this category |
| 304 | if category not in TEXTURE_CATEGORIES: |
| 305 | print(f" Warning: Unknown texture category '{category}' for {obj_name}") |
| 306 | return None |
| 307 | |
| 308 | available_textures = TEXTURE_CATEGORIES[category] |
| 309 | |
| 310 | # Select random texture from category |
| 311 | texture_name = random.choice(available_textures) |
| 312 | texture_path = os.path.join(TEXTURES_BASE, texture_name) |
| 313 | |
| 314 | # Verify texture exists |
| 315 | if not os.path.exists(texture_path): |
| 316 | print(f" Warning: Texture path not found: {texture_path}") |
| 317 | return None |
| 318 | |
| 319 | return texture_path |
| 320 | |
| 321 | |
| 322 | def get_color_for_object(obj_name, character_name=None): |
no outgoing calls
no test coverage detected