extends StaticBody2D

export var alignment: String = 'V'


func _ready() -> void:
    if not alignment in ['V', 'H']:
        print('Silver Barrier rotation needs to be "V" or "H"')
    elif alignment == 'H':
        rotation_degrees = 90
    return


func _on_unlock_body_entered(body: Node) -> void:
    if not 'player' in body.get_groups():
        return

    if body.has_item('Silver Key'):
        body.remove_item('Silver Key')
        $Sprite.animation = 'open'
        $Collision.set_deferred('disabled', true)
        $Unlock.set_deferred('monitoring', false)
    return
