/** * Shared configuration for Unreal Engine class names and aliases. * Centralizes class mappings to avoid duplication across handlers. */ /** * User-friendly class name aliases to full Unreal class paths. * These allow users to specify simpler names like 'PointLight' instead of '/Script/Engine.PointLight'. */ export const ACTOR_CLASS_ALIASES: Record = { // Special cases that need component addition 'SplineActor': '/Script/Engine.Actor', 'Spline': '/Script/Engine.Actor', // Light actors 'PointLight': '/Script/Engine.PointLight', 'SpotLight': '/Script/Engine.SpotLight', 'DirectionalLight': '/Script/Engine.DirectionalLight', 'RectLight': '/Script/Engine.RectLight', // Camera actors 'Camera': '/Script/Engine.CameraActor', 'CameraActor': '/Script/Engine.CameraActor', // Mesh actors 'StaticMeshActor': '/Script/Engine.StaticMeshActor', 'SkeletalMeshActor': '/Script/Engine.SkeletalMeshActor', // Gameplay actors 'PlayerStart': '/Script/Engine.PlayerStart', 'Pawn': '/Script/Engine.Pawn', 'Character': '/Script/Engine.Character', 'Actor': '/Script/Engine.Actor', // Trigger volumes 'TriggerBox': '/Script/Engine.TriggerBox', 'TriggerSphere': '/Script/Engine.TriggerSphere', 'BlockingVolume': '/Script/Engine.BlockingVolume', }; /** * Class aliases that require a component to be auto-added after spawning. */ export const CLASSES_REQUIRING_COMPONENT: Record = { 'SplineActor': 'SplineComponent', 'Spline': 'SplineComponent', }; const NORMALIZED_ACTOR_CLASS_ALIASES = new Map( Object.entries(ACTOR_CLASS_ALIASES).map(([alias, classPath]) => [alias.toLowerCase(), classPath]) ); const NORMALIZED_CLASSES_REQUIRING_COMPONENT = new Map( Object.entries(CLASSES_REQUIRING_COMPONENT).map(([className, component]) => [className.toLowerCase(), component]) ); function normalizeAliasKey(value: string): string { return value.trim().toLowerCase(); } /** * Resolve a class name alias to its full Unreal class path. * @param classNameOrPath - The class name or alias to resolve * @returns The full class path, or the original if not an alias */ export function resolveClassAlias(classNameOrPath: string): string { return ACTOR_CLASS_ALIASES[classNameOrPath] ?? NORMALIZED_ACTOR_CLASS_ALIASES.get(normalizeAliasKey(classNameOrPath)) ?? classNameOrPath; } /** * Check if a class alias requires an auto-added component. * @param className - The original class name or alias * @returns The component name to add, or undefined */ export function getRequiredComponent(className: string): string | undefined { return CLASSES_REQUIRING_COMPONENT[className] ?? NORMALIZED_CLASSES_REQUIRING_COMPONENT.get(normalizeAliasKey(className)); }