A Minecraft style clone in Godot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

39 lines
878 B

class_name Block
extends StaticBody3D
const PREFAB: PackedScene = preload("res://scenes/blocks/block.tscn")
@export var block_mesh: BlockMesh
@export var collision_shape: CollisionShape3D
@export var highlight_mesh: MeshInstance3D
var id: String
func _exit_tree() -> void:
if Waila.ref.get_target() == self:
Waila.ref.release_target()
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
if id in DBItems.data:
block_mesh.apply_material(DBItems.data[id].material_texture)
else:
printerr("Unknown Block ID: ", id)