class_name Viruling extends Entity; @onready var animated_sprite = $AnimatedSprite2D @onready var collider = $CollisionShape2D @onready var contact_hitbox = $ContactHitbox @onready var collision_shape = collider.shape @onready var attack_timer = $AttackTimer @onready var death_timer = $DeathTimer @onready var explosion_sfx = $ExplosionSFX var is_dying = false var attack_speed = 0 var speed_multiplier = 100 const INITIAL_HEALTH = 10 const ATTACK_DAMAGE = 10 const ATTACK_KNOCKBACK = 5000 func _init() -> void: super._init(INITIAL_HEALTH, speed_multiplier, ATTACK_DAMAGE) # Called when the node enters the scene tree for the first time. func _ready() -> void: velocity.x = attack_speed contact_hitbox.body_entered.connect(body_connect) contact_hitbox.visible = false animated_sprite.play("spin") # Called every frame. 'delta' is the elapsed time since the previous frame. func _physics_process(delta: float) -> void: if !is_dying: contact_hitbox.visible = false if contact_hitbox.visible else true super._physics_process(delta) velocity.x = attack_speed velocity.y = 0 # jank move_and_slide() func _process(delta: float) -> void: if health <= 0: is_dying = true death_timer.start() health = 99999 if is_dying: animated_sprite.play("death") explosion_sfx.play() contact_hitbox.visible = false speed_multiplier = 0 if death_timer.is_stopped(): queue_free() func body_connect(node: Node): if node is Entity and node != self and attack_timer.is_stopped(): attack_timer.start() node.health -= damage node.take_knockback(ATTACK_KNOCKBACK) if node.has_method("hurt_anim"): node.call("hurt_anim") func charge() -> void: attack_speed = -speed_multiplier