-- Agent-authored server policy. Geometry is calculated here, not baked into -- one building prefab. Only immutable frames and typed build commands cross. local PACKAGE = "studio.generated.meshy-hero" local FLOORS, BAYS_X, BAYS_Z = 3, 5, 4 local BAY, STOREY, FRONT = 4, 4.2, 8 local BATCH, CADENCE = 10, 5 local plan = {} local function put(part, x, y, z, yaw) table.insert(plan, {kind="build_prefab", prefab="package:"..PACKAGE..":"..part, x=x, y=y, z=z, yaw=yaw or 0, scale=1}) end local width, depth = BAYS_X*BAY, BAYS_Z*BAY local half = width/2 -- Courtyard slabs; the two middle bays remain an open atrium above ground. for floor=0,FLOORS do for ix=0,BAYS_X-1 do for iz=0,BAYS_Z-1 do local atrium = floor>0 and ix==2 and (iz==1 or iz==2) if not atrium then put(floor==FLOORS and "roof" or "floor", -half+2+ix*BAY, 0.18+floor*STOREY, FRONT+2+iz*BAY) end end end if floor=#plan or frame.tick%CADENCE~=0 then return {},state end local last=math.min(state.value+BATCH,#plan) local commands={} for index=state.value+1,last do table.insert(commands,plan[index]) end -- Cursor advances in the SAME authoritative transaction as the pieces. -- Checkpoint recovery continues exactly once; it never rebuilds a hole. return commands,{type="integer",value=last} end, }