extends StaticBody3D @export var heal_amount: float = 30.0 # Сколько здоровья восстанавливает аптечка var detect_area: Area3D = null func _ready() -> void: detect_area = $DetectArea if detect_area == null: print("[АПТЕЧКА] ОШИБКА: Узел 'DetectArea' не найден!") func _physics_process(_delta: float) -> void: if detect_area == null: return # Этот код плавно вращает модель аптечки вокруг своей оси Y rotate_y(deg_to_rad(90.0) * _delta) # 90 градусов в секунду # Используем наш проверенный и неубиваемый метод опроса зоны var overlapping_bodies = detect_area.get_overlapping_bodies() for body in overlapping_bodies: if body == self: continue # Опознаем игрока по наличию WeaponManager var weapon_manager = body.find_child("WeaponManager", true, false) if weapon_manager == null and body.get_parent(): weapon_manager = body.get_parent().find_child("WeaponManager", true, false) if weapon_manager != null: # Ищем HealthComponent игрока var player_node = body if body.find_child("WeaponManager", true, false) else body.get_parent() var player_health = player_node.find_child("HealthComponent", true, false) if player_health: # Проверяем, нужно ли игрока вообще лечить (если хп меньше максимального) if player_health.current_health < player_health.max_health: # Лечим игрока player_health.current_health += heal_amount # Защита от избыточного лечения (чтобы здоровье не стало 120 из 100) if player_health.current_health > player_health.max_health: player_health.current_health = player_health.max_health print("[АПТЕЧКА] Игрок исцелен на ", heal_amount, ". Текущее здоровье: ", player_health.current_health) # Удаляем аптечку с земли, так как игрок её использовал queue_free() return