extends "res://objects/characters/monsters/monster.gd"

func _process(delta):
	if velocity != null:
		if not $RayBottomLeft.is_colliding() or $RayLeft.is_colliding():
			velocity.x = speed
		if not $RayBottomRight.is_colliding() or $RayRight.is_colliding():
			velocity.x = -speed

"""
func stomped_on_head():
	if not $RayPlayerLeft.is_colliding() and not $RayPlayerRight.is_colliding():
		health = 0
		$Sprite.animation = "stomped"
		$StampedSound.play()
"""

func _on_PlayerCollision(body):
	if $Collision.disabled == false:
		if body.velocity.x > 0:
			body.monster_hit(-speed, damage)
		elif body.velocity.x < 0:
			body.monster_hit(speed, damage)
		elif velocity and velocity.x > 0:
			body.monster_hit(speed, damage)
		elif velocity and velocity.x < 0:
			body.monster_hit(-speed, damage)
