|
Britbot
|
Normal analysis of enemy groups, without considering the previous configurations Note that using this method alone will break the heading mechanism because this method technically return new groups each time (although they might be the same config)
Definition at line 116 of file Enemy.cs. {
List<EnemyGroup> updatedGroups = new List<EnemyGroup>();
IEnumerable<Pirate> enemyAlivePirates = Bot.Game.AllEnemyPirates().Where(p => !p.IsLost);
//iterate over all the alive pirate of the enemy
foreach (Pirate pete in enemyAlivePirates)
{
//Throwing an exception if cancellation was requested.
cancellationToken.ThrowIfCancellationRequested();
//create a new group and add the current pirate to it
EnemyGroup newGroup = new EnemyGroup();
newGroup.EnemyPirates.Add(pete.Id);
//check if there are any older group already containing the current pirate
List<EnemyGroup> containsPete = updatedGroups.Where(g => g.IsInGroup(pete.Id)).ToList();
if (containsPete.Count > 0)
{
//if there are, remove these groups
updatedGroups.RemoveAll(g => g.IsInGroup(pete.Id));
//Add the pirates from the groups we removed to the current new group
foreach (EnemyGroup gr in containsPete)
{
//Throwing an exception if cancellation was requested.
cancellationToken.ThrowIfCancellationRequested();
newGroup.EnemyPirates.AddRange(gr.EnemyPirates);
}
}
//important, it must be here or direction cant be calculated
//Set location
newGroup.PrevLoc = newGroup.GetLocation();
//add the new group to the list of groups
updatedGroups.Add(newGroup);
}
return updatedGroups;
}
|
1.7.6.1