public UnitSpawnInfo TryGetValidSpawn(
            IEncampment encampment, Func <IHexCell, IEnumerable <IUnitTemplate> > unitSelector
            )
        {
            var encampmentLocation = EncampmentLocationCanon.GetOwnerOfPossession(encampment);

            foreach (var cell in Grid.GetCellsInRadius(encampmentLocation, 1, true))
            {
                var availableUnits = unitSelector(cell);

                if (availableUnits.Any())
                {
                    return(new UnitSpawnInfo()
                    {
                        IsValidSpawn = true, LocationOfUnit = cell,
                        TemplateToBuild = Randomizer.TakeRandom(availableUnits)
                    });
                }
            }

            return(new UnitSpawnInfo()
            {
                IsValidSpawn = false, LocationOfUnit = null, TemplateToBuild = null
            });
        }
        public void ComposeBarbarians(SerializableMapData mapData)
        {
            mapData.Encampments = new List <SerializableEncampmentData>();

            foreach (var encampment in EncampmentFactory.AllEncampments)
            {
                var location = EncampmentLocationCanon.GetOwnerOfPossession(encampment);

                var encampmentData = new SerializableEncampmentData()
                {
                    Location      = location.Coordinates,
                    SpawnProgress = encampment.SpawnProgress
                };

                mapData.Encampments.Add(encampmentData);
            }
        }