class_name Block extends StaticBody3D @onready var collision_shape: CollisionShape3D = $CollisionShape3D @onready var highlight_mesh: MeshInstance3D = $HighlightMesh @onready var block_mesh: MeshInstance3D = $BlockMesh var id: String var resource: BlockResource func _exit_tree() -> void: if Waila.ref.get_target() == self: Waila.ref.release_target() func _ready() -> void: _apply_material() func get_id() -> String: return id func hook() -> void: if not GameSettingsManager.settings.game_options.enable_block_highlight: return highlight_mesh.visible = true # TODO: Rename to something else (maybe remove()) # Move to signal? func destroy_block() -> void: queue_free() func release() -> void: highlight_mesh.visible = false func set_id(block_id: String) -> void: id = block_id _load_resource_data() _apply_material() func _apply_material() -> void: if block_mesh == null: return if resource == null: return block_mesh.set_surface_override_material(0, resource.material_texture) func _load_resource_data() -> void: if not id: printerr("Could not load resource data. Block ID was empty.") return if not id in DBItems.data: printerr("Could not load resource data. Unknown Block ID: ", id) return resource = DBItems.data[id]