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.
 

30 lines
1019 B

class_name DroppedBlock
extends Node3D
# TODO: It may not make sense to use Block here due to the use of StaticBody
# StaticBody shouldn't generally be moved, making throwing and even the animation not recommended
@export var block_scale: float = .25
@onready var animation_player: AnimationPlayer = $AnimationPlayer
@onready var block: Block = $Block
func initialize(id: String, _position: Vector3) -> void:
_position.y -= .2 # Bring the block closer to the floor (Probably a better way to handle this)
position = _position
block.set_id(id)
block.collision_shape.disabled = true
block.scale = Vector3(block_scale, block_scale, block_scale)
animation_player.play("start_animation")
func _on_pickup_area_body_entered(body: Node3D) -> void:
if not body is Player: return
# TODO: Update stack count dynamically
var stack_count: int = 1
var item: DBItemResource = (DBItems.data[block.get_id()] as Resource).duplicate()
item.amount = stack_count
InventoryManager.item_picked_up.emit(item)
queue_free()