For me it seems the error is in
Code:
private void damageAiControlledPlane(AiActor actorMain)
{
foreach (AiActor actor in actorMain.Group().GetItems())
{
if (actor == null || !(actor is AiAircraft))
return;
AiAircraft aircraft = (actor as AiAircraft);
if (!isAiControlledPlane(aircraft))
return;
if (aircraft == null)
return;
(actor as AiAircraft).Destroy();
}
}
Why you use the Group to destroy a single Airplane? Do you test the Group for null value? It make no sense to me to use the Group in this case.