public bool RenderAsHouse(ZoneClusterMemberConsumption zoneClusterMember)
        {
            if (!_zoneClusterMembers.Contains(zoneClusterMember))
            {
                throw new InvalidOperationException();
            }
            int localDensity = PopulationDensity;

            if (localDensity > _zoneClusterMembers.Count(x => !x.IsCentralClusterMember))
            {
                return(false);
            }

            while (_houseMembers.Count > localDensity)
            {
                _houseMembers.Pop();
            }
            ;

            while (_houseMembers.Count < localDensity)
            {
                _houseMembers
                .Push(_zoneClusterMembers
                      .Where(x => !x.IsCentralClusterMember)
                      .OrderBy(x => Guid.NewGuid()
                               )
                      .Except(_houseMembers)
                      .First()
                      );
            }
            ;

            return(_houseMembers.Contains(zoneClusterMember));
        }
Esempio n. 2
0
 protected BaseImplementedZoneClusterConsumption(
     Func <ZoneInfoFinder> createZoneInfoFinderFunc,
     IElectricityBehaviour electricityBehaviour,
     Color color,
     int widthInZones,
     int heightInZones)
     : base(electricityBehaviour)
 {
     _zoneClusterMembers = ZoneClusterMemberConsumption
                           .Generate(this, createZoneInfoFinderFunc, widthInZones, heightInZones, color)
                           .ToList();
 }