extends "res://objects/enemy/enemy.gd" const Explosion = preload("res://objects/enemy/explosion.tscn") onready var chain = $Chain onready var hitbox = $Hitbox onready var respawn_time: float = 1.0 func _ready(): var ground_cast = $GroundCast ground_cast.force_raycast_update() if ground_cast.is_colliding(): chain.points[1].y = chain.to_local(ground_cast.get_collision_point()).y func _process(delta): chain.points[0].x = hitbox.position.x func _on_Hitbox_area_entered(area): if area.is_in_group("explosion"): var timer = get_tree().create_timer(0.2, false) timer.connect("timeout", self, "die") if area.is_in_group("player_hitbox"): var explosion = Explosion.instance() explosion.global_position = hitbox.global_position get_parent().get_parent().call_deferred("add_child", explosion) die() func die(): if blood: var death_particles = DeathParticles.instance() death_particles.global_position = hitbox.global_position death_particles.emitting = true get_parent().get_parent().add_child(death_particles) $Hitbox/Sprite.visible = false hitbox.monitoring = false hitbox.monitorable = false yield(get_tree().create_timer(respawn_time), "timeout") hitbox.monitorable = true hitbox.monitoring = true $Hitbox/Sprite.visible = true