2024-02-22 06:22:22 +11:00
|
|
|
class_name GatlingWeapon extends HitscanWeapon
|
2023-11-15 15:19:40 +11:00
|
|
|
|
2024-02-22 06:22:22 +11:00
|
|
|
var time_since_firing_started: float = 0.0
|
|
|
|
var time_to_reach_max_speed: float = 0.0
|
|
|
|
var max_speed_multiplier: float = 0.0
|
|
|
|
var current_time_between_shots: float = 0.0
|
|
|
|
var final_time_between_shots: float = 0.0
|
2023-11-15 15:19:40 +11:00
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
super._ready()
|
|
|
|
time_to_reach_max_speed = stats.get_attribute("Speed Time")
|
|
|
|
max_speed_multiplier = stats.get_attribute("Speed Multiplier")
|
|
|
|
final_time_between_shots = time_between_shots / max_speed_multiplier
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> void:
|
|
|
|
super._process(delta)
|
|
|
|
if trigger_held:
|
|
|
|
time_since_firing_started += delta
|
2024-02-22 06:22:22 +11:00
|
|
|
var progress: float = clamp(time_since_firing_started / time_to_reach_max_speed, 0.0, 1.0)
|
2023-11-15 15:19:40 +11:00
|
|
|
current_time_between_shots = lerpf(time_between_shots, final_time_between_shots, progress)
|
2023-11-27 13:52:46 +11:00
|
|
|
if current_energy < energy_cost:
|
|
|
|
time_since_firing_started = 0.0
|
|
|
|
current_time_between_shots = time_between_shots
|
2023-11-15 15:19:40 +11:00
|
|
|
|
|
|
|
|
|
|
|
func _physics_process(_delta: float) -> void:
|
2023-11-28 16:52:15 +11:00
|
|
|
if trigger_held and current_energy >= energy_cost and time_since_firing >= current_time_between_shots:
|
2023-11-15 15:19:40 +11:00
|
|
|
time_since_firing -= current_time_between_shots
|
2023-11-28 16:52:15 +11:00
|
|
|
current_energy -= energy_cost
|
|
|
|
energy_changed.emit(current_energy)
|
2023-11-15 15:19:40 +11:00
|
|
|
shoot()
|
|
|
|
networked_shoot.rpc()
|
|
|
|
|
|
|
|
|
2024-02-22 06:22:22 +11:00
|
|
|
func release_trigger() -> void:
|
2023-11-15 15:19:40 +11:00
|
|
|
super.release_trigger()
|
|
|
|
time_since_firing_started = 0.0
|
|
|
|
current_time_between_shots = time_between_shots
|