Пример #1
0
        IEnumerable <Order> ClearBlockersOrders(World world, CPos topLeft)
        {
            var allTiles       = FootprintUtils.Tiles(world.Map.Rules, building, buildingInfo, topLeft).ToArray();
            var neightborTiles = Util.ExpandFootprint(allTiles, true).Except(allTiles)
                                 .Where(world.Map.Contains).ToList();

            var blockers = allTiles.SelectMany(world.ActorMap.GetActorsAt)
                           .Where(a => a.Owner == producer.Owner && a.IsIdle)
                           .Select(a => new TraitPair <Mobile> {
                Actor = a, Trait = a.TraitOrDefault <Mobile>()
            });

            foreach (var blocker in blockers.Where(x => x.Trait != null))
            {
                var availableCells = neightborTiles.Where(t => blocker.Trait.CanEnterCell(t)).ToList();
                if (availableCells.Count == 0)
                {
                    continue;
                }

                yield return(new Order("Move", blocker.Actor, false)
                {
                    TargetLocation = blocker.Actor.ClosestCell(availableCells)
                });
            }
        }