extends Node2D



# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass

func on_enemy_died(enemy):
	call_deferred("drop_item", enemy)
	
func drop_item(enemy):
	if not is_instance_valid(enemy):
		return
	for entry in enemy.drop_table:
		if randf() < entry.chance:
			var drop = entry.drop.instantiate()
			drop.global_position = enemy.global_position
			add_child(drop)
