extends Node2D class_name Shield @export var MaxShieldCapacity : int = 8 #максимальный заряд щита @export var ShieldChargeRate : float = 1 #скорость зарядки щита @export var RechargeTimer : Timer @export var LaserTimer : Timer @export var LaserChargeRate : float = 20 @onready var Capacity : float = MaxShieldCapacity #текущий заряд щита var CanRecharge : bool = false var LaserRecharge : bool = true func _ready(): RechargeTimer.timeout.connect(recharging_timer) LaserTimer.timeout.connect(laser_timer) func deal_damage(damage : float): Capacity -= damage if Capacity < 0: get_parent().Hull.HP += Capacity Capacity = 0 CanRecharge = false RechargeTimer.start() LaserTimer.start() func recharging_timer(): CanRecharge = true func _physics_process(delta): if CanRecharge: Capacity += ShieldChargeRate * delta if Capacity > MaxShieldCapacity: Capacity = MaxShieldCapacity CanRecharge = false if LaserRecharge: get_parent().Hull.Ammunition["Laser Energy"] += LaserChargeRate * delta if get_parent().Hull.Ammunition["Laser Energy"] > get_parent().Hull.MaxAmmunition["Laser Energy"]: get_parent().Hull.Ammunition["Laser Energy"] = get_parent().Hull.MaxAmmunition["Laser Energy"] LaserRecharge = false func laser_timer(): LaserRecharge = true