public bool UpdateFleetMovement(float frameDeltaTime)
{
bool stillHaveMovement = false;
foreach (Empire empire in _empires)
{
if (empire.FleetManager.MoveFleets(frameDeltaTime))
{
stillHaveMovement = true;
}
foreach (var fleet in empire.FleetManager.GetFleets())
{
fleet.VisibleToWhichEmpires.Clear();
//Update whether or not it's visible to other empires
foreach (Empire otherEmpire in _empires)
{
if (otherEmpire == empire)
{
continue; //no need to check owner
}
foreach (var planet in otherEmpire.PlanetManager.Planets)
{
float xDis = fleet.GalaxyX - planet.System.X;
float yDis = fleet.GalaxyY - planet.System.Y;
if ((xDis * xDis) + (yDis * yDis) < otherEmpire.TechnologyManager.PlanetRadarRange)
{
fleet.VisibleToWhichEmpires.Add(otherEmpire);
break;
}
}
if (otherEmpire.TechnologyManager.FleetRadarRange > 0 && !fleet.VisibleToWhichEmpires.Contains(otherEmpire))
{
//It first checks if other empire even have fleet radar, and if it's not already detected by planets, to improve performance
foreach (var otherFleet in otherEmpire.FleetManager.GetFleets())
{
float xDis = fleet.GalaxyX - otherFleet.GalaxyX;
float yDis = fleet.GalaxyY - otherFleet.GalaxyY;
if ((xDis * xDis) + (yDis * yDis) < otherEmpire.TechnologyManager.FleetRadarRange)
{
fleet.VisibleToWhichEmpires.Add(otherEmpire);
break;
}
}
}
}
}
}
return stillHaveMovement;
}