Beyond_Beyaan.Galaxy.IsDestinationValid C# (CSharp) Метод

IsDestinationValid() приватный Метод

private IsDestinationValid ( StarSystem destination, bool hasExtended, Empire whichEmpire ) : bool
destination StarSystem
hasExtended bool
whichEmpire Empire
Результат bool
        private bool IsDestinationValid(StarSystem destination, bool hasExtended, Empire whichEmpire)
        {
            if (destination.Planets[0].Owner == whichEmpire)
            {
                //By default, always true if destination is owned
                return true;
            }
            int fuelRange = (whichEmpire.TechnologyManager.FuelRange + (hasExtended ? 3 : 0)) * PARSEC_SIZE_IN_PIXELS;
            fuelRange *= fuelRange; //To avoid square rooting
            foreach (StarSystem system in starSystems)
            {
                if (system.Planets[0].Owner == whichEmpire)
                {
                    float x = destination.X - system.X;
                    float y = destination.Y - system.Y;
                    if ((x * x) + (y * y) <= fuelRange)
                    {
                        return true;
                    }
                }
            }
            return false;
        }