Files
2D_Game_test/PickupableObjects/Bomb/bomb.gd
2023-02-05 22:38:50 -05:00

36 lines
954 B
GDScript

extends PU_Item
@onready var is_reachable := false
@onready var current_player:CharacterBody2D = null
@onready var item_info = {
"item_name": item_name,
"item_description": item_description,
"item_type": item_type,
"item_clip_size": item_clip_size,
"item_ammo": item_ammo,
"item_cooldown": item_cooldown,
"item_texture": item_texture,
}
func _input(event):
if Input.is_action_pressed("interact") and is_reachable and current_player:
# if item_type == 0: # 0 is weapon
# print("Weapon!")
var result = current_player.add_inventory_item(item_info)
if result:
queue_free()
func _on_bomb_pu_area_body_entered(body):
if body.is_in_group("player"):
current_player = body
is_reachable = true
current_player.set_context_label("Pickup " + item_info.item_name + "?")
func _on_bomb_pu_area_body_exited(body):
if body.is_in_group("player"):
current_player.set_context_label("")
current_player = null
is_reachable = false