|
|
@ -2,9 +2,15 @@ class_name Block |
|
|
|
extends StaticBody3D |
|
|
|
|
|
|
|
|
|
|
|
@onready var block_faces: Node3D = $BlockFaces |
|
|
|
@onready var highlight_mesh: MeshInstance3D = $HighlightMesh |
|
|
|
|
|
|
|
@onready var east_face: MeshInstance3D = $BlockFaces/EastFace |
|
|
|
@onready var west_face: MeshInstance3D = $BlockFaces/WestFace |
|
|
|
@onready var north_face: MeshInstance3D = $BlockFaces/NorthFace |
|
|
|
@onready var south_face: MeshInstance3D = $BlockFaces/SouthFace |
|
|
|
@onready var top_face: MeshInstance3D = $BlockFaces/TopFace |
|
|
|
@onready var bottom_face: MeshInstance3D = $BlockFaces/BottomFace |
|
|
|
|
|
|
|
var id: String |
|
|
|
var resource: BlockResource |
|
|
|
|
|
|
@ -29,10 +35,21 @@ func set_id(block_id: String) -> void: |
|
|
|
|
|
|
|
|
|
|
|
func _apply_materials() -> void: |
|
|
|
if block_faces == null: return |
|
|
|
if east_face == null: return |
|
|
|
|
|
|
|
# This could probably be improved/simplified |
|
|
|
_apply_material(east_face, resource.material_east) |
|
|
|
_apply_material(west_face, resource.material_west) |
|
|
|
_apply_material(north_face, resource.material_north) |
|
|
|
_apply_material(south_face, resource.material_south) |
|
|
|
_apply_material(top_face, resource.material_top) |
|
|
|
_apply_material(bottom_face, resource.material_bottom) |
|
|
|
|
|
|
|
func _apply_material(face: MeshInstance3D, material: StandardMaterial3D) -> void: |
|
|
|
if material == null: |
|
|
|
material = resource.material_east # Default to East face (first) |
|
|
|
|
|
|
|
for face: MeshInstance3D in block_faces.get_children(): |
|
|
|
face.set_surface_override_material(0, resource.material) |
|
|
|
face.set_surface_override_material(0, material) |
|
|
|
|
|
|
|
func _get_resource_data() -> void: |
|
|
|
if not id: |
|
|
|