public void ReloadBR(float lingerTimer = 0f, bool forceFail = false) { hideLoadIndicator = true; if (!this.hasAuthority) { return; } if (!forceFail) { float reloadPercent = reloadProgress / reloadLength; ReloadQuality r = ReloadQuality.Bad; if (reloadPercent >= 1 - reloadBarGoodEndPercent && reloadPercent < 1 - reloadBarGoodBeginPercent) { r = ReloadQuality.Good; } else if (reloadPercent >= 1 - reloadBarGoodBeginPercent && reloadPercent <= 1 - reloadBarPerfectBeginPercent) { r = ReloadQuality.Perfect; } else { r = ReloadQuality.Bad; } if (r != ReloadQuality.Bad) { pauseReload = true; if (r == ReloadQuality.Perfect) { BattleRiflePerfectReload(); } SetReloadQuality(r, true); reloadLingerTimer = lingerTimer; if (reloadLingerTimer <= 0f) { finishedReload = true; } triggeredBRReload = true; } else { failedReload = true; Util.PlaySound(ReloadController.failSoundString, base.gameObject); CmdPlayReloadFail(); } } else if (forceFail) { pauseReload = true; triggeredBRReload = true; SetReloadQuality(ReloadQuality.Bad, false); reloadLingerTimer = lingerTimer; if (reloadLingerTimer <= 0f) { finishedReload = true; } } }
public override void OnEnter() { base.OnEnter(); base.characterBody.isSprinting = false; if (this.quality == ReloadQuality.None) { this.quality = ReloadQuality.Normal; } var charge = base.gameObject.GetComponent <SniperUIController>().GetCharge(); if (charge > 1.0f) { this.isCharged = true; } this.duration = baseDuration / base.attackSpeedStat; this.damage = base.damageStat * baseMult * charge; switch (this.quality) { case ReloadQuality.Normal: this.damage *= normalMult; break; case ReloadQuality.Good: this.damage *= goodMult; break; case ReloadQuality.Perfect: this.damage *= perfectMult; break; } base.characterBody.SetAimTimer(2f); this.Fire(); }
public void Reload(float lingerTimer = 0f) { hideLoadIndicator = false; if (!this.hasAuthority) { return; } reloadLingerTimer = lingerTimer; pauseReload = true; float reloadPercent = reloadProgress / reloadLength; ReloadQuality r = ReloadQuality.Bad; if (reloadPercent >= reloadBarPerfectBeginPercent && reloadPercent < reloadBarGoodBeginPercent) { r = ReloadQuality.Perfect; } else if (reloadPercent >= reloadBarGoodBeginPercent && reloadPercent <= reloadBarGoodEndPercent) { r = ReloadQuality.Good; } else { r = ReloadQuality.Bad; failedReload = true; } reloadLingerTimer = lingerTimer; SetReloadQuality(r); hideLoadIndicator = false; if (reloadLingerTimer <= 0f) { finishedReload = true; } }
//The sound code is duplicated in RpcPlayReloadSound because the reload sound should be instantaneous for the client triggering it, while it's ok if it's delayed for other players. public void SetReloadQuality(ReloadQuality r, bool playLoadSound = true) { this.currentReloadQuality = r; if (playLoadSound) { switch (this.currentReloadQuality) { case ReloadQuality.Good: Util.PlaySound(ReloadController.goodReloadSoundString, base.gameObject); break; case ReloadQuality.Perfect: Util.PlaySound(ReloadController.perfectReloadSoundString, base.gameObject); break; default: break; } } Util.PlaySound(ReloadController.boltReloadSoundString, base.gameObject); Util.PlaySound(ReloadController.casingSoundString, base.gameObject); CmdPlayReloadSound((int)this.currentReloadQuality, playLoadSound); }