import os import re def process_file(filepath): with open(filepath, 'r', encoding='utf-8') as f: content = f.read() original_content = content # Common object names: gameObject, object, rootObject, childObject, parentObject patterns = [r'\b(gameObject|object|rootObject|childObject|parentObject|currentObject|mainCamera|directionalLight|cube|valve|tank|alarmBeacon)\.(Id|ParentId|Name)\b', r'\b(gameObject|object|rootObject|childObject|parentObject|currentObject|mainCamera|directionalLight|cube|valve|tank|alarmBeacon)->(Id|ParentId|Name)\b'] for pat in patterns: def replacer(match): obj_name = match.group(1) prop_name = match.group(2) op = '.' if '.' in match.group(0) else '->' return f"{obj_name}{op}Get{prop_name}()" content = re.sub(pat, replacer, content) if content != original_content: with open(filepath, 'w', encoding='utf-8') as f: f.write(content) print(f"Updated {filepath}") for root, _, files in os.walk('Source'): for file in files: if file.endswith('.cpp') or file.endswith('.h'): process_file(os.path.join(root, file))