|
Britbot
|
Split the enemy into its groups Should be invoked every turn to re-analyze.
Definition at line 54 of file Enemy.cs. {
EnemyGroup[] analysis = Enemy.AnalyzeFull(cancellationToken).ToArray();
if (Groups.Count == 0)
return analysis.ToList();
List<EnemyGroup> veteranGroups = new List<EnemyGroup>(analysis.Length);
bool[] removeAtAnalysis = new bool[analysis.Length];
for (int i = 0; i < analysis.Length; i++)
{
//Throwing an exception if cancellation was requested.
cancellationToken.ThrowIfCancellationRequested();
EnemyGroup enemyGroup = analysis[i];
foreach (EnemyGroup veteran in Enemy.Groups)
{
//Throwing an exception if cancellation was requested.
cancellationToken.ThrowIfCancellationRequested();
/*
* check if the groups are the same.
* Note that Equals() does a contextual comparison and not reference comparison
* (I overrided it to check if the pirates in each enemy group are the same)
*/
if (veteran.Equals(enemyGroup))
{
/*
* note that we are adding the group already in the old Groups list
* it's the same object
*/
veteranGroups.Add(veteran);
removeAtAnalysis[i] = true;
break;
}
}
}
//add the groups to the veteran list..
veteranGroups.AddRange(analysis.Where((t, i) => !removeAtAnalysis[i]));
//..and return
return veteranGroups;
}
|
1.7.6.1