extends RefCounted var g var batches={} var count=0 func piece(p,size,kind=0,rotation=Vector3.ZERO): if not batches.has(kind):batches[kind]=[] batches[kind].append(Transform3D(Basis.from_euler(rotation).scaled(size),p));count+=1 func rod(a,b,r=.025,kind=1): if not batches.has(kind):batches[kind]=[] var basis=Basis(Quaternion(Vector3.UP,(b-a).normalized())).scaled(Vector3(r*2,a.distance_to(b),r*2)) batches[kind].append(Transform3D(basis,(a+b)*.5));count+=1 func barrel(p): for j in range(24): var a=j*TAU/24 piece(p+Vector3(cos(a)*.34,.44,sin(a)*.34),Vector3(.085,.85,.055),2,Vector3(0,-a+PI/2,0)) for y in [.12,.42,.76]: for j in range(24): var a=j*TAU/24;var b=(j+1)*TAU/24 rod(p+Vector3(cos(a)*.37,y,sin(a)*.37),p+Vector3(cos(b)*.37,y,sin(b)*.37),.018) for j in range(6):piece(p+Vector3((j-2.5)*.105,.865,0),Vector3(.10,.035,sqrt(maxf(.01,.11-pow((j-2.5)*.105,2)))*2),2) func crate(p,size): for side in [-1,1]: for j in range(6): piece(p+Vector3(side*size.x*.5,size.y*.5,(j-2.5)*size.z/6),Vector3(.06,size.y,size.z/6-.01),2) piece(p+Vector3((j-2.5)*size.x/6,size.y*.5,side*size.z*.5),Vector3(size.x/6-.01,size.y,.06),2) for y in [.1,size.y-.1]: piece(p+Vector3(0,y,side*(size.z*.5+.04)),Vector3(size.x,.09,.05),0) for x in [-size.x*.4,size.x*.4]:piece(p+Vector3(x,y,side*(size.z*.5+.08)),Vector3.ONE*.035,3) func build(game): g=game # Dense wall-mounted hardware, leaving circulation around the workstation clear. for x in [-7.65,7.65]: for z in [-5,-3,-1,1,3,5]: piece(Vector3(x,1.0,z),Vector3(.055,1.9,.12),0) for y in [.2,.55,.9,1.25,1.6,1.9]:piece(Vector3(x-sign(x)*.05,y,z),Vector3(.035,.045,.045),3) for y in [.55,1.45]:piece(Vector3(x,y,0),Vector3(.06,.08,12.0),0) # Service pipes, flanges and a pressure vessel behind the playable space. for y in [2.3,2.65]: rod(Vector3(-2,y,-6.15),Vector3(7,y,-6.15),.085) for x in [-1,1,3,5,7]: rod(Vector3(x-.04,y,-6.15),Vector3(x+.04,y,-6.15),.14) for j in range(6): var a=j*TAU/6;piece(Vector3(x+.05,y+sin(a)*.115,-6.15+cos(a)*.115),Vector3.ONE*.035,3) rod(Vector3(6.7,.1,-5.1),Vector3(6.7,1.9,-5.1),.42) for y in [.25,1.7]:rod(Vector3(6.7,y-.04,-5.1),Vector3(6.7,y+.04,-5.1),.47) rod(Vector3(6.7,1.9,-5.1),Vector3(6.7,2.65,-5.1),.09) rod(Vector3(6.7,2.65,-5.1),Vector3(6.7,2.65,-6.15),.09) for j in range(16): var a=j*TAU/16;var b=(j+1)*TAU/16 rod(Vector3(6.7+cos(a)*.25,1.2+sin(a)*.25,-4.6),Vector3(6.7+cos(b)*.25,1.2+sin(b)*.25,-4.6),.025) for a in [0,PI/2]:rod(Vector3(6.7-cos(a)*.25,1.2-sin(a)*.25,-4.6),Vector3(6.7+cos(a)*.25,1.2+sin(a)*.25,-4.6),.025) for p in [Vector3(-6.8,0,-5.3),Vector3(-7.0,0,-4.4),Vector3(5.4,0,-5.6)]:barrel(p) crate(Vector3(4.5,0,-5.4),Vector3(.75,.60,.70));crate(Vector3(4.6,.62,-5.4),Vector3(.6,.45,.6)) # Tools, hooks, a work table and suspended cables on the rear wall. for x in [-2.3,-1.8,-1.3,-.8,-.3]: rod(Vector3(x,1.1,-6.05),Vector3(x,1.9,-6.05),.023) piece(Vector3(x,1.1,-6.02),Vector3(.17,.07,.07),0) rod(Vector3(x,1.92,-6.15),Vector3(x,1.92,-5.95),.025) for x in [-2.4,.5]: for z in [-5.2,-5.8]:piece(Vector3(x,.45,z),Vector3(.08,.9,.08),2) for j in range(5):piece(Vector3(-.95,.95,-5.8+j*.15),Vector3(3.1,.08,.14),2) for j in range(10): var x=-2.0+j*.24 rod(Vector3(x,1.02,-5.65),Vector3(x+.12,1.02,-5.25),.016) piece(Vector3(x+.12,1.02,-5.25),Vector3(.07,.06,.10),0) # Loose masonry, chips, inset drains and fastening plates at the edges. for j in range(100): var x=-7.1+fmod(j*1.371,14.2);var z=-6.0+fmod(j*2.13,1.0) if x < -3.8 and x > -6.7:continue piece(Vector3(x,.09,z),Vector3(.06+fmod(j*.03,.12),.08,.12),4,Vector3(.1,j*1.7,.1)) for z in [-2.3,2.6]: piece(Vector3(-6.5,.045,z),Vector3(.8,.035,.5),0) for j in range(8):piece(Vector3(-6.85+j*.1,.066,z),Vector3(.04,.025,.48),3) for x in [-7.4,7.4]: for z in range(-6,7): piece(Vector3(x,.055,z),Vector3(.25,.03,.32),0) for dz in [-.1,.1]:piece(Vector3(x,.08,z+dz),Vector3.ONE*.035,3) # Wall reliefs and iron brackets add a second scale of detail above the tools. for x in [-2.5,1.0,4.0,7.5]: for y in [.35,1.35,2.35]: piece(Vector3(x,y,-6.0),Vector3(.68,.12,.10),0) for dx in [-.25,.25]:piece(Vector3(x+dx,y,-5.92),Vector3.ONE*.06,3) for side in [-1,1]:rod(Vector3(x,2.75,-6.1),Vector3(x+side*.40,2.15,-6.1),.04) # Equipment gantries and a hanging cage remain outside the navigable floor. for x in [-8.8,8.8]: for z in [-4,3.6]: piece(Vector3(x,1.6,z),Vector3(.18,3.2,.18),0) piece(Vector3(x-sign(x)*.45,3.2,z),Vector3(1.1,.16,.18),0) rod(Vector3(x,2.5,z),Vector3(x-sign(x)*.8,3.2,z),.04) for side in [-1,1]: var p=Vector3(side*8.9,-.8,.5) for j in range(12): var a=j*TAU/12;rod(p+Vector3(cos(a)*.5,0,sin(a)*.5),p+Vector3(cos(a)*.5,1.6,sin(a)*.5),.022) for y in [0,.7,1.6]: for j in range(12): var a=j*TAU/12;var a2=(j+1)*TAU/12 rod(p+Vector3(cos(a)*.5,y,sin(a)*.5),p+Vector3(cos(a2)*.5,y,sin(a2)*.5),.035) flush() g.set_meta("dressing_parts",count) func flush(): var offsets=[Vector3.ZERO] # Repeat the service infrastructure in neighbouring cells with instancing. for p in g.architecture.detailed_positions:offsets.append(p) for kind in batches: var mesh: Mesh if kind==1: var cylinder=CylinderMesh.new();cylinder.top_radius=.5;cylinder.bottom_radius=.5;cylinder.height=1;cylinder.radial_segments=16;mesh=cylinder else: var box=BoxMesh.new();box.size=Vector3.ONE;mesh=box var mm=MultiMesh.new();mm.transform_format=MultiMesh.TRANSFORM_3D;mm.mesh=mesh;mm.instance_count=batches[kind].size()*offsets.size() var index=0 var moving_wall_parts=[] for offset in offsets: for tr in batches[kind]: var t=tr if offset==Vector3.ZERO and t.origin.x>=7.35: t.origin.x+=4.05 moving_wall_parts.append({"index":index,"transform":t}) t.origin+=offset;mm.set_instance_transform(index,t);index+=1 var node=MultiMeshInstance3D.new();g.add_child(node);node.multimesh=mm node.set_meta("right_wall_dressing",moving_wall_parts) var mat=ShaderMaterial.new();mat.shader=preload("res://timber.gdshader") if kind==2 else preload("res://forged.gdshader") mat.set_shader_parameter("tint",[Color("242621"),Color("373931"),Color("403326"),Color("615b48"),Color("494a42")][kind]);node.material_override=mat node.cast_shadow=GeometryInstance3D.SHADOW_CASTING_SETTING_OFF