public QueryResult <AnimatedCellBitmapSetLayers> GetFor(ZoneInfoSnapshot snapshot) { return(snapshot .Pipe(x => x.AreaZoneConsumption as IntersectingZoneConsumption) .ToQueryResult() .WithResultIfHasMatch(x => { if (x.NorthSouthZoneConsumption is RoadZoneConsumption || x.EastWestZoneConsumption is RoadZoneConsumption) { return GetRoadIntersectionTypes() .Single(y => y.TrafficDensity == x.GetTrafficDensity()) .GetFor(snapshot); } if (x.NorthSouthZoneConsumption is PowerLineConsumption) { if (x.EastWestZoneConsumption is WaterZoneConsumption) { return _powerNsWaterEwLazy.Value.Up.ToQueryResult(); } else if (x.EastWestZoneConsumption is RailRoadZoneConsumption) { return _railNsPowerEwLazy.Value.Right.ToQueryResult(); } throw new InvalidOperationException(); } else if (x.NorthSouthZoneConsumption is WaterZoneConsumption) { if (x.EastWestZoneConsumption is PowerLineConsumption) { return _powerNsWaterEwLazy.Value.Right.ToQueryResult(); } else if (x.EastWestZoneConsumption is RailRoadZoneConsumption) { return _railNsWaterEwLazy.Value.Right.ToQueryResult(); } throw new InvalidOperationException(); } else if (x.NorthSouthZoneConsumption is RailRoadZoneConsumption) { if (x.EastWestZoneConsumption is PowerLineConsumption) { return _railNsPowerEwLazy.Value.Up.ToQueryResult(); } else if (x.EastWestZoneConsumption is WaterZoneConsumption) { return _railNsWaterEwLazy.Value.Up.ToQueryResult(); } throw new InvalidOperationException(); } return QueryResult <AnimatedCellBitmapSetLayers> .Empty; }, QueryResult <AnimatedCellBitmapSetLayers> .Empty)); }
public QueryResult <AnimatedCellBitmapSetLayers> GetFor(ZoneInfoSnapshot snapShot) { var maxPop = BaseGrowthZoneClusterConsumption.MaximumPopulation / _layerDictionaryLazy.Value.Max(x => x.Key.GrowthZoneClusterTileInfo.Density); return(snapShot .Pipe(x => { return (snapShot.AreaZoneConsumption as ZoneClusterMemberConsumption) .ToQueryResult() .WithResultIfHasMatch(y => y.ParentBaseZoneClusterConsumption is T) ? (x.AreaZoneConsumption as ZoneClusterMemberConsumption).ToQueryResult() : default(ZoneClusterMemberConsumption).ToQueryResult(); }) .Pipe(clusterMember => { return clusterMember.WithResultIfHasMatch(c => { var parent = (T)c.ParentBaseZoneClusterConsumption; if (parent.PopulationDensity < 9) { if (parent.RenderAsHouse(c)) { return _houseLayerDictionaryLazy .Value .ToArray() .Pipe(set => set[c.Id % set.Length]) .Value .ToQueryResult(); } return _layerDictionaryLazy .Value .Where(x => x.Key.Point == c.PositionInCluster) .First(x => x.Key.GrowthZoneClusterTileInfo.Density == 0) .Value .ToQueryResult(); } return _layerDictionaryLazy .Value .Where(x => x.Key.Point == c.PositionInCluster) .Where(x => x.Key.GrowthZoneClusterTileInfo.Density == Math.Ceiling(c.PopulationDensity / (decimal)maxPop)) .ToArray() .Pipe(set => { var id = (clusterMember .MatchingObject .ParentBaseZoneClusterConsumption as BaseGrowthZoneClusterConsumption) .Id; return set[id % set.Length]; }) .Value .ToQueryResult(); }, QueryResult <AnimatedCellBitmapSetLayers> .Empty); })); }
public QueryResult <AnimatedCellBitmapSetLayers> GetFor(ZoneInfoSnapshot snapshot) { return(snapshot .Pipe(x => x.AreaZoneConsumption as IntersectingZoneConsumption) .ToQueryResult() .WithResultIfHasMatch(x => { if (x.NorthSouthZoneConsumption is RoadZoneConsumption) { if (x.EastWestZoneConsumption is RailRoadZoneConsumption) { return _railNsRoadEw.Right.ToQueryResult(); } else if (x.EastWestZoneConsumption is WaterZoneConsumption) { return _waterNsRoadEw.Right.ToQueryResult(); } else if (x.EastWestZoneConsumption is PowerLineConsumption) { return _powerNsRoadEw.Right.ToQueryResult(); } throw new InvalidOperationException(); } else if (x.EastWestZoneConsumption is RoadZoneConsumption) { if (x.NorthSouthZoneConsumption is RailRoadZoneConsumption) { return _railNsRoadEw.Up.ToQueryResult(); } else if (x.NorthSouthZoneConsumption is WaterZoneConsumption) { return _waterNsRoadEw.Up.ToQueryResult(); } else if (x.NorthSouthZoneConsumption is PowerLineConsumption) { return _powerNsRoadEw.Up.ToQueryResult(); } throw new InvalidOperationException(); } return QueryResult <AnimatedCellBitmapSetLayers> .Empty; }, QueryResult <AnimatedCellBitmapSetLayers> .Empty )); }
public QueryResult <AnimatedCellBitmapSetLayers> GetFor(ZoneInfoSnapshot snapShot) { return(snapShot .Pipe(x => { return (snapShot.AreaZoneConsumption as ZoneClusterMemberConsumption) .ToQueryResult() .WithResultIfHasMatch(y => y.ParentBaseZoneClusterConsumption is StaticZoneClusterConsumption) ? (x.AreaZoneConsumption as ZoneClusterMemberConsumption).ToQueryResult() : default(ZoneClusterMemberConsumption).ToQueryResult(); }) .Pipe(clusterMember => clusterMember.WithResultIfHasMatch(x => _layerDictionaryLazy .Value .Single(y => y.Key.Item1 == x.ParentBaseZoneClusterConsumption.GetType() && y.Key.Item2 == x.PositionInCluster) .Value .ToQueryResult() , QueryResult <AnimatedCellBitmapSetLayers> .Empty) )); }