public IEnumerable <string> GetUndesirabilityReasons(BaseGrowthZoneClusterConsumption baseGrowthZoneClusterConsumption) { if (baseGrowthZoneClusterConsumption is ResidentialZoneClusterConsumption) { return(GetUndesirabilityReasons(baseGrowthZoneClusterConsumption, x => x.ResidentialTaxRate)); } if (baseGrowthZoneClusterConsumption is CommercialZoneClusterConsumption) { return(GetUndesirabilityReasons(baseGrowthZoneClusterConsumption, x => x.CommercialTaxRate)); } if (baseGrowthZoneClusterConsumption is IndustrialZoneClusterConsumption) { return(GetUndesirabilityReasons(baseGrowthZoneClusterConsumption, x => x.IndustrialTaxRate)); } throw new InvalidOperationException($"The type '{baseGrowthZoneClusterConsumption.GetType().Name}' is currently not supported."); }
public bool RepresentsUndesirabilityFor(BaseGrowthZoneClusterConsumption baseGrowthZoneClusterConsumption) { return(_undesireableForTypes.Contains(baseGrowthZoneClusterConsumption.GetType())); }
private QueryResult <Action> ObtainMatchAction <TBaseGrowthZoneClusterConsumption>( BaseGrowthZoneClusterConsumption origin, IEnumerable <IGrouping <int, IZoneInfoPathNode> > destinations ) where TBaseGrowthZoneClusterConsumption : BaseGrowthZoneClusterConsumption { _cancellationToken.ThrowIfCancellationRequested(); Action result = null; foreach (var zoneInfoPathNode in destinations .SelectMany(x => x) .OrderBy(x => x.Distance) .Where(zoneInfoPathNode => { var foundMatch = false; zoneInfoPathNode.WithDestination(z => z.WithZoneClusterIf <TBaseGrowthZoneClusterConsumption>( cluster => { if (cluster.CanGrowAndHasPower) { foundMatch = true; } }) ); if (!foundMatch || !AllowsForTraffic(zoneInfoPathNode)) { return(false); } return(true); }) .Take(origin.PopulationDensity + 1) ) { var localZoneInfoPathNode = zoneInfoPathNode; result = () => localZoneInfoPathNode.WithDestination(z => { if (!_growthZonesAndTravelDistances.ContainsKey(origin)) { _growthZonesAndTravelDistances.Add(origin, new List <int>()); } z.WithZoneClusterIf <TBaseGrowthZoneClusterConsumption>( cluster => { cluster.IncreaseOrDecreaseByPoweredState(); _grownClusters.Add(cluster); } ); var pathLength = 0; zoneInfoPathNode.WithPathMembers(zz => { zz.ZoneInfo.WithNetworkConsumptionIf <RoadZoneConsumption>(x => AddTrafficTo(x, origin)); zz.ZoneInfo.GrowthAlgorithmHighlightState.SetState(HighlightState.UsedAsPath); pathLength += zz.ZoneInfo.GetDistanceScoreBasedOnConsumption(); }); _growthZonesAndTravelDistances[origin].Add(pathLength); }); } return(QueryResult <Action> .Create(result)); }
public IEnumerable <string> GetUndesirabilityReasons(BaseGrowthZoneClusterConsumption baseGrowthZoneClusterConsumption) { return(Enumerable.Empty <string>()); }