示例#1
0
 public IEnumerator <float> Bleed()
 {
     while (bleeding != null && bleeding.Count > 0)
     {
         double HealthPerSec    = BleedEffect.Instance.Config.HealthDrainPerSecond;
         double HealthPerSecInc = BleedEffect.Instance.Config.HealthDrainPerSecondIncrease;
         foreach (var ent in bleeding)
         {
             double  amount = HealthPerSec;
             EPlayer p      = EPlayer.Get(ent.Key);
             if (p.IsGodModeEnabled)
             {
                 bleeding.Remove(ent.Key);
             }
             if (ent.Value > 1)
             {
                 if (BleedEffect.Instance.Config.HealthDrainExponential)
                 {
                     double power = ent.Value;
                     if (amount < 1)
                     {
                         power /= BleedEffect.Instance.Config.HealthDrainDivisor;
                     }
                     amount = Math.Pow(HealthPerSec, power);
                 }
                 else
                 {
                     amount += HealthPerSecInc * (ent.Value - 1);
                 }
             }
             Log.Debug($"Player with id {ent.Key} has drained {amount} health.", BleedEffect.Instance.Config.Debug);
             if (p.Health - amount <= 0)
             {
                 bleeding.Remove(ent.Key);
                 beenShot.Remove(ent.Key);
                 p.Kill(DamageTypes.Bleeding);
                 continue;
             }
             p.Health -= (float)amount;
         }
         yield return(Timing.WaitForSeconds(1f));
     }
     BleedEffect.Instance.mainCoroEnabled = false;
     Log.Debug($"Stopping Coro {co}", BleedEffect.Instance.Config.Debug);
     BleedEffect.Instance.Coroutines.Remove(co);
     Timing.KillCoroutines(co);
     yield break;
 }