Edit: Even better code to destroy all aircraft
Code:
if (GamePlay.gpArmies() != null && GamePlay.gpArmies().Length > 0)
{
foreach (int armyIndex in GamePlay.gpArmies())
{
if (GamePlay.gpAirGroups(armyIndex) != null && GamePlay.gpAirGroups(armyIndex).Length > 0)
{
foreach (AiAirGroup airGroup in GamePlay.gpAirGroups(armyIndex))
{
if (airGroup.GetItems() != null && airGroup.GetItems().Length > 0)
{
foreach (AiActor actor in airGroup.GetItems())
{
if (actor is AiAircraft)
{
AiAircraft aircraft = actor as AiAircraft;
aircraft.Destroy();
}
}
}
}
}
}
}