///// <summary> ///// Расчитать расход топлива для прыжка ///// </summary> ///// <returns></returns> //public long CalculateFuelForJump(IGameObject obj, IGameObject targetLoc) //{ // var d = DistanceFor(obj, targetLoc); //} public double DistanceFor(IGameObject a, IGameObject b) { LocalPosition alp = LocalPosition.Empty, blp= LocalPosition.Empty; var ls = a.Ask(LocalSystem.Query.ResolvePosition) .Cast<QueryResponse<LocalPosition>>() .FirstOrDefault(); if (ls != null) alp = ls.Value; ls = b.Ask(LocalSystem.Query.ResolvePosition) .Cast<QueryResponse<LocalPosition>>() .FirstOrDefault(); if (ls != null) blp = ls.Value; while (!alp.Unknown && !blp.Unknown) { if (alp.LocalSystem.Level > blp.LocalSystem.Level) alp = alp.LocalSystem.TranslateUp(alp.Coords); else if (alp.LocalSystem.Level < blp.LocalSystem.Level) blp = blp.LocalSystem.TranslateUp(blp.Coords); if (alp.LocalSystem.Level == blp.LocalSystem.Level) if (alp.LocalSystem != blp.LocalSystem) { alp = alp.LocalSystem.TranslateUp(alp.Coords); blp = blp.LocalSystem.TranslateUp(blp.Coords); } else { return alp.Coords.Distance(blp.Coords) * alp.LocalSystem.Resolution; } } return double.PositiveInfinity; }