extends KinematicBody


var hidden = true
var target = null
var canunhide = false

func _ready():
	if !randi()%8: hidden = false
	
	if hidden:
		hide()


func _process(delta):
	move_and_collide(Vector3(0,-5,0))
					

func _on_BeenHere_body_entered(body):
	if body.is_in_group("player"):
		target = body
		canunhide = true
		print("we got one")


func _on_VisibilityNotifier_camera_entered(camera):
	choose_hide()
	
	
func unhide():
	if canunhide:
		hidden = false
		$Sprite3D.visible = true
		$InnerDamage.enabled = true
		$MiddleDamage.enabled = true
		$OuterDamage.enabled = true
		$Poision/CollisionShape.disabled = false
		
		
func hide():
	hidden = true
	$Sprite3D.visible = false
	$InnerDamage.enabled = false
	$MiddleDamage.enabled = false
	$OuterDamage.enabled = false
	$Poision/CollisionShape.disabled = true



func choose_hide():
	randomize()
	
	if !$Sprite3D.visible:
		if !randi()%4: unhide()
		
	if $Sprite3D.visible:
		if !randi()%2: hide()


func _on_Poision_body_entered(body):
	if body.is_in_group("player"):
		body.poison(12,3,1.5)
