extends CharacterBody2D @export var target: CollisionObject2D @export var default_move_speed: float = 100 @export var default_max_health: float = 10.0 @export var default_contact_damage: float = 5.0 @onready var contact_damage_cd: Timer = $ContactDamageCD @onready var animation_player: AnimationPlayer = $AnimationPlayer var move_speed: float var health: float var max_health: float var god_mode: bool = false func _ready() -> void: move_speed = default_move_speed max_health = default_max_health health = max_health GlobalConst.sig_debug_enemy_god_mode.connect(enemy_god_mode_toggle) func _physics_process(delta: float) -> void: if target: var direction = global_position.direction_to(target.global_position) var distance = global_position.distance_to(target.global_position) if distance > 4: velocity = direction * move_speed move_and_slide() else: deal_damage() func take_damage(value: float): if god_mode: return health -= value if health <= 0: die() func deal_damage(): if target.is_in_group("damagable"): if contact_damage_cd.is_stopped(): target.take_damage(default_contact_damage) contact_damage_cd.start() func die(): queue_free() func cheer_anim(): animation_player.play("jump") func enemy_god_mode_toggle(toggle_on: bool) -> void: god_mode = toggle_on