diff --git a/src/world/generation/feature/metro/metro_construct_simple/metro_construct_simple.gd b/src/world/generation/feature/metro/metro_construct_simple/metro_construct_simple.gd index 6a3f5f4..c63a304 100644 --- a/src/world/generation/feature/metro/metro_construct_simple/metro_construct_simple.gd +++ b/src/world/generation/feature/metro/metro_construct_simple/metro_construct_simple.gd @@ -3,7 +3,22 @@ class_name MetroConstructSimple extends GenerationFeature @export var min_height := 48.0 @export var height_factor := 200.0 +@export var p_roof_carve := 0.2 + @onready var construct_box: CSGBox3D = %ConstructBox +@onready var carve_pivot: CSGCombiner3D = %CarvePivot + + +func generate_carve() -> void: + var carve_value := absf(sample_noise_at(global_position + Vector3(0, 65535, 0))) + if wrapf(carve_value * 65535.0, 0, 1) < p_roof_carve: + carve_pivot.position.y = construct_box.position.y + + var rotate_value := absf(sample_noise_at(global_position + Vector3(0, 42069, 0))) + var rotations := floorf(wrapf(rotate_value * 65535, 0, 8)) + carve_pivot.rotation.y = rotations * PI / 4 + else: + carve_pivot.queue_free() func generate_feature(lod: WorldGen.LOD) -> void: @@ -13,3 +28,4 @@ func generate_feature(lod: WorldGen.LOD) -> void: var height := value * height_factor + min_height construct_box.position.y = height / 2 construct_box.size.y = height + generate_carve() diff --git a/src/world/generation/feature/metro/metro_construct_simple/metro_construct_simple.tscn b/src/world/generation/feature/metro/metro_construct_simple/metro_construct_simple.tscn index 2e88814..6a703f5 100644 --- a/src/world/generation/feature/metro/metro_construct_simple/metro_construct_simple.tscn +++ b/src/world/generation/feature/metro/metro_construct_simple/metro_construct_simple.tscn @@ -42,3 +42,12 @@ size = Vector3(48, 48, 48) script = ExtResource("2_74b57") lod = 2 metadata/_custom_type_script = "uid://cv0o1lirqeq44" + +[node name="CarvePivot" type="CSGCombiner3D" parent="ConstructBox"] +unique_name_in_owner = true +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 24, 0) +operation = 2 + +[node name="CarveBox" type="CSGBox3D" parent="ConstructBox/CarvePivot"] +transform = Transform3D(1, 0, 0, 0, 0.70710677, -0.70710677, 0, 0.70710677, 0.70710677, 0, 0, 24) +size = Vector3(100, 48, 100)