private IEnumerator RefireCooldownCoroutine() { while (true) { yield return(new WaitUntil(() => primaryFireActive)); while (primaryFireActive && !ammoBehavior.GetReloadActive()) { primaryFireOnCooldown = true; if (ammoBehavior.ConsumeAmmo(1)) { GameObject newProjectile = Instantiate <GameObject>(projectile, GetSpawnLocation(), new Quaternion()); IProjectile projectileScript = newProjectile.GetComponent <IProjectile>(); projectileScript.Init(player, GetSpawnDirection(), projectileVelocity, projectileDamage); NetworkServer.Spawn(newProjectile); } yield return(new WaitForSecondsRealtime(refireTime)); primaryFireOnCooldown = false; } } }