extends RefCounted # One layout for the playable room and the instanced cells in the distance. # All courses meet exactly; only the arrow slits and gate openings are empty. static func layout(left,right,depth,gate_x): var parts=[] for z in [-depth,depth]: wall(parts,Vector3(left,0,z),Vector3.RIGHT,right-left,gate_x-left) for x in [left,right]: wall(parts,Vector3(x,0,-depth),Vector3.BACK,depth*2,-100.0) for x in [left,right]: for z in [-depth,depth]: var first=parts.size();tower(parts,Vector3(x,0,z)) for i in range(first,parts.size()):parts[i]["normal"]=Vector3(-1 if x==left else 1,0,signf(z)) return parts static func add(parts,pos,size,feature): parts.append({"position":pos,"size":size,"feature":feature}) static func course(parts,start,axis,a,b,bottom,top,feature): if b-a<.001:return var size=Vector3(.46,top-bottom,.46) if axis.x!=0:size.x=b-a else:size.z=b-a add(parts,start+axis*((a+b)*.5)+Vector3.UP*((bottom+top)*.5),size,feature) static func wall(parts,start,axis,length,gate): var first=parts.size() var sections=[[0.0,length]] if gate>0 and gate