private void OnRefreshMovespeed(EntityUid uid, SlowOnDamageComponent component, RefreshMovementSpeedModifiersEvent args) { if (!EntityManager.TryGetComponent <DamageableComponent>(uid, out var damage)) { return; } if (damage.TotalDamage == FixedPoint2.Zero) { return; } // Get closest threshold FixedPoint2 closest = FixedPoint2.Zero; var total = damage.TotalDamage; foreach (var thres in component.SpeedModifierThresholds) { if (FixedPoint2.Dist(thres.Key, total) < FixedPoint2.Dist(closest, total)) { closest = thres.Key; } } if (closest != FixedPoint2.Zero) { var speed = component.SpeedModifierThresholds[closest]; args.ModifySpeed(speed, speed); } }