void UpdateForDamageType(DamageType damageType, int oldValue) { int change = _currentDamage[damageType] - oldValue; if (change == 0) { return; } int changeSign = Math.Sign(change); foreach (var threshold in Thresholds[damageType]) { var value = threshold.Value; if (((value * changeSign) > (oldValue * changeSign)) && ((value * changeSign) <= (_currentDamage[damageType] * changeSign))) { var excessDamage = change - value; var typeOfDamage = damageType; if (change - value < 0) { excessDamage = 0; } var args = new DamageThresholdPassedEventArgs(threshold, (changeSign > 0), excessDamage); DamageThresholdPassed?.Invoke(this, args); } } }
/// <inheritdoc /> public void OnDamageThresholdPassed(object obj, DamageThresholdPassedEventArgs e) { if (e.Passed && e.DamageThreshold == Threshold) { Owner.EntityManager.DeleteEntity(Owner); } }
void IOnDamageBehavior.OnDamageThresholdPassed(object damageable, DamageThresholdPassedEventArgs e) { DamageableComponent damage = (DamageableComponent)damageable; if (e.DamageThreshold.ThresholdType != ThresholdType.HUDUpdate) { ChangeDamageState(DamageTemplate.CalculateDamageState(damage)); } //specifies if we have a client to update the hud for if (CanReceiveStatusEffect(Owner)) { DamageTemplate.ChangeHudState(damage); } }
void IOnDamageBehavior.OnDamageThresholdPassed(object damageable, DamageThresholdPassedEventArgs e) { DamageableComponent damage = (DamageableComponent)damageable; if (e.DamageThreshold.ThresholdType != ThresholdType.HUDUpdate) { ChangeDamageState(DamageTemplate.CalculateDamageState(damage)); } if (Owner.TryGetComponent(out BasicActorComponent actor)) //specifies if we have a client to update the hud for { var hudstatechange = DamageTemplate.ChangeHudState(damage); SendNetworkMessage(hudstatechange); } }
void UpdateForDamageType(DamageType damageType, int oldValue) { int change = CurrentDamage[damageType] - oldValue; if (change == 0) { return; } int changeSign = Math.Sign(change); foreach (int value in Thresholds[damageType]) { if (((value * changeSign) > (oldValue * changeSign)) && ((value * changeSign) <= (CurrentDamage[damageType] * changeSign))) { var args = new DamageThresholdPassedEventArgs(new DamageThreshold(damageType, value), (changeSign > 0)); DamageThresholdPassed?.Invoke(this, args); } } }