public DamageInfo(FarmUnit unit, FarmUnit target) { this.Unit = unit; this.Delay = unit.GetAttackDelay(target); this.PredictedHealth = target.GetPredictedHealth(unit, this.Delay); if (this.PredictedHealth <= 0) { this.IsValid = false; return; } this.MinDamage = unit.GetDamage(target); this.IsInAttackRange = unit.Unit.Distance(target.Unit) < unit.Unit.GetAttackRange(target.Unit); }
public void AttackCanceled(FarmUnit target) { foreach (var unit in this.units) { if (unit.Target?.Equals(target) != true) { continue; } if (!unit.AttackSleeper.IsSleeping) { continue; } var delay = (unit.AttackStartTime + unit.GetAttackDelay(target)) - GameManager.RawGameTime; if (target.GetPredictedHealth(unit, delay) > unit.GetDamage(target)) { unit.Stop(); } } }