-- Close-range geometric corroboration, NOT an engine-reported parent link. -- MountComponent + zero-offset AttachableComponent, fixed FileDiver data snapshot. -- Names independently matched to unique hashes in the installed base model. -- No serialized node index is used. Runtime must query has_node/node each sample. local M={radius=.35,margin=.5,max_mechs=8,max_arms=16} local profiles={ ['79e4b3d2da5e45e3']={L={resource='824b7e0c4c879eb5',name='attach_turret_l_socket'},R={resource='08f6089289c83d22',name='attach_turret_r_socket'}}, ['c2d449ecf7facab1']={L={resource='e5f64dcc3bfe9dd1',name='attach_turret_l'},R={resource='ff9878576a4c543b',name='attach_turret_r'}}, ['7b2326f6fd9c8069']={L={resource='0736bee2d6328726',name='attach_turret_l'},R={resource='17c5d12d8d5dee2c',name='attach_turret_r'}}, ['35dbf54f016f3624']={L={resource='65489809a8181b96',name='attach_turret_l_socket'},R={resource='df51fe8d62f294be',name='attach_turret_r_socket'}}, } function M.specs(d)return d and profiles[d.resource]end local function valid(p) if type(p)~='table'then return false end for i=1,3 do local n=p[i];if type(n)~='number'or n~=n or math.abs(n)>1000000 then return false end end return true end function M.select(current,bodies,arms,key,distance) local meta={heuristic=true,method='MOUNT_POINT_TEST',radius=M.radius,margin=M.margin,slots={},native_parent_proven=false} local function no(why)return nil,why,meta end if #bodies<1 or #bodies>M.max_mechs or #arms<1 or #arms>M.max_arms then return no('MOUNT_COUNT_BOUND')end local all,here,seen={},{},{} for _,body in ipairs(bodies)do local d=body.descriptor;local specs=M.specs(d) if not specs or seen[d.entity]then return no('MOUNT_BODY_INVALID')end;seen[d.entity]=true for _,side in ipairs({'L','R'})do local slot=body.mounts and body.mounts[side];local spec=specs[side] if not slot or slot.name~=spec.name or slot.resource~=spec.resource or not valid(slot.position)then return no('MOUNT_SLOT_INVALID')end local entry={descriptor=d,side=side,resource=spec.resource,position=slot.position};all[#all+1]=entry if key(d)==key(current)then here[side]=entry end end end if not here.L or not here.R then return no('MOUNT_CURRENT_NOT_FOUND')end for _,arm in ipairs(arms)do if not valid(arm.position)or seen[arm.descriptor.entity]then return no('MOUNT_ARM_INVALID')end;seen[arm.descriptor.entity]=true end local selected,used={},{} for _,side in ipairs({'L','R'})do local slot=here[side];local best,second,pick=math.huge,math.huge,nil for _,arm in ipairs(arms)do if arm.descriptor.resource==slot.resource then local residual=distance(slot.position,arm.position) if residual