21 lines
452 B
GDScript
21 lines
452 B
GDScript
extends StaticBody2D
|
|
class_name Chest
|
|
|
|
@export var buff: Buff
|
|
|
|
const CHEST_OPENED = preload("res://assets/chest_opened.png")
|
|
var recipients = []
|
|
var opened := false
|
|
|
|
func open(entity) -> Buff:
|
|
if not recipients.has(entity):
|
|
if not opened:
|
|
opened = true
|
|
$Sprite2D.texture = CHEST_OPENED
|
|
var buff_texture := Sprite2D.new()
|
|
buff_texture.texture = buff.image
|
|
add_child(buff_texture)
|
|
recipients.append(entity)
|
|
return buff
|
|
return null
|