private void RemoveWorkerFromHarvestAssignments(ProxyStarcraft.Unit unit)
 {
     foreach (var pair in workersByMineralDeposit)
     {
         if (pair.Value.Contains(unit.Tag))
         {
             pair.Value.Remove(unit.Tag);
         }
     }
 }
        private static ProxyStarcraft.Unit GetTarget(ProxyStarcraft.Unit unit, GameState gameState)
        {
            // Only valid for units with exactly one weapon
            var range = gameState.UnitTypes[unit.Raw.UnitType].Weapons[0].Range;

            ProxyStarcraft.Unit target = null;

            foreach (var enemyUnit in gameState.EnemyUnits)
            {
                var distance = unit.GetDistance(enemyUnit);
                if (distance < range)
                {
                    if (target == null ||
                        enemyUnit.Raw.Health < target.Raw.Health ||
                        (enemyUnit.Raw.Health == target.Raw.Health && distance < unit.GetDistance(target)))
                    {
                        target = enemyUnit;
                    }
                }
            }

            return(target);
        }