class_name Block
|
|
extends StaticBody3D
|
|
|
|
|
|
enum Types {
|
|
DIRT,
|
|
STONE,
|
|
}
|
|
|
|
const Materials: Dictionary[Types, StandardMaterial3D] = {
|
|
Types.DIRT: preload("res://assets/materials/dirt.tres"),
|
|
Types.STONE: preload("res://assets/materials/stone.tres"),
|
|
}
|
|
|
|
@export var material: StandardMaterial3D
|
|
@export var type: Types
|
|
|
|
@onready var block_faces: Node3D = $BlockFaces
|
|
|
|
|
|
func _ready() -> void:
|
|
_apply_materials()
|
|
|
|
|
|
func apply_material() -> void:
|
|
material = Materials[type]
|
|
|
|
func _apply_materials() -> void:
|
|
for face: MeshInstance3D in block_faces.get_children():
|
|
face.set_surface_override_material(0, material)
|