Files
Blockline/scripts/stair_flight.gd
T

29 lines
1.1 KiB
GDScript
Raw Normal View History

2026-09-12 11:01:37 +02:00
class_name StairFlight
extends RefCounted
# A single static assembly: continuous walking ramp and attached smooth guards.
static func build(parent: Node3D, origin: Vector3, direction: float, rise: float, exterior: bool, batch: UrbanMeshBatch) -> void:
var body := StaticBody3D.new()
body.name = "UnifiedStairFlight"
body.collision_layer = 1
body.collision_mask = 0
parent.add_child(body)
var points := PackedVector3Array()
for end in [0.0, 1.0]:
var z: float = origin.z + direction * (-0.6 + end * 8.0)
var y: float = origin.y + end * rise
for x in [-1.06, 1.06]:
for h in [-0.24, 0.0]: points.append(Vector3(origin.x+x, y+h, z))
add_shape(body, points)
if exterior:
for side in [-1, 1]:
# The guard shares the ramp boundary; no gap or individual tread faces.
StairGuard.build(body, origin.x + side, origin.z, direction, origin.y, rise, batch)
static func add_shape(body: StaticBody3D, points: PackedVector3Array) -> void:
var shape := ConvexPolygonShape3D.new()
shape.points = points
var collider := CollisionShape3D.new()
collider.shape = shape
body.add_child(collider)