gae_wild_jam/scripts/drop_manager.gd

23 lines
518 B
GDScript

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):
for entry in enemy.drop_table:
if randf() < entry.chance:
var drop = entry.drop.instantiate()
drop.global_position = enemy.global_position
add_child(drop)