From 6919c1af96daf5270085f7c88325246d7936a384 Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Wed, 5 Mar 2025 18:00:32 -0500 Subject: [PATCH] Minor formatting update --- data_structure/block.gd | 2 -- scenes/blocks/block.gd | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/data_structure/block.gd b/data_structure/block.gd index 26ed7bf..e4183e5 100644 --- a/data_structure/block.gd +++ b/data_structure/block.gd @@ -2,8 +2,6 @@ class_name BlockResource extends ItemResource -# TODO: Replace with "missing texture" resource - ## East material is also the default material if not provided @export var material_east: StandardMaterial3D = null @export var material_west: StandardMaterial3D = null diff --git a/scenes/blocks/block.gd b/scenes/blocks/block.gd index cf64ff2..2a4c7f7 100644 --- a/scenes/blocks/block.gd +++ b/scenes/blocks/block.gd @@ -30,10 +30,18 @@ func release() -> void: func set_id(block_id: String) -> void: id = block_id - _get_resource_data() + _load_resource_data() _apply_materials() +## Apply a specific material to a MeshInstance3D +## If material is null, the EastFace material will be used +func _apply_material(face: MeshInstance3D, material: StandardMaterial3D) -> void: + if material == null: + material = resource.material_east # Default to East face (first) + + face.set_surface_override_material(0, material) + func _apply_materials() -> void: if east_face == null: return @@ -45,13 +53,7 @@ func _apply_materials() -> void: _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) - - face.set_surface_override_material(0, material) - -func _get_resource_data() -> void: +func _load_resource_data() -> void: if not id: printerr("Block ID was expected but was not received") return