The above cooldown is slightly defective: it does not cool the gun unless you are firing.
Simplify it a bunch… check these scribbles:
Cooldown timers, gun bullet intervals, shot spacing, rate of fire:
GunHeat (gunheat) spawning shooting rate of fire: