示例#1
0
 public TileMatchControl(ITileMatcher <TTexureTile, TContext> matcher,
                         Action <IPlotOperation> cacheControl = null)
 {
     Matcher      = matcher ?? throw new ArgumentNullException(nameof(matcher));
     Cachable     = true;
     CacheControl = cacheControl ?? CacheControlNoOp;
 }
示例#2
0
 public PlotOperation(ITileMatcher <TRenderTile, TContext> matcher,
                      RenderType renderType,
                      IRenderCallback <TRenderTile, TContext> renderer = null)
 {
     this.matcher = matcher;
     adapter      = new RendererAdapter <TRenderTile, TContext>(renderType, renderer);
     onMatchFound = adapter.MatchFound;
 }
示例#3
0
        protected IPlotOperation CreatePlot <TContext, TRenderParameter>(IRenderCallbackFactory <TRenderParameter, TTile> renderer,
                                                                         ITileMatcher <TTile, TContext> matcher,
                                                                         TRenderParameter sortingLayer)
        {
            var p = PlotOperations.FromContext(RenderingConfig)
                    .Create(matcher)
                    .WithCache()
                    .ForViewport()
                    .WithRenderer(renderer.CreateRenderer <TContext>(this, sortingLayer));

            return(p.Build());
        }
示例#4
0
        public bool TryBuildBlendLayer(out ITileMatcher <TTile, Nothing> result)
        {
            var blendSelf     = new bool[GameData.Rules.TerrainTypes.Count];
            var blendGraphics = new string[GameData.Rules.TerrainTypes.Count];

            // Precompute the blending information ..
            //
            // This locates the declared blend texture for all terrain types and
            foreach (var t in GameData.Rules.TerrainTypes)
            {
                var graphic  = mappingHelper.Find(t);
                var tilename = graphic.GetBlendGraphicFor(tileSet.BlendLayer);

                if (tilename == null || !tileRegistry.TryFind(tilename, out var _))
                {
                    continue;
                }

                var indexOf = GameData.Rules.TerrainTypes.IndexOf(t);
                blendGraphics[indexOf] = tilename;
                blendSelf[indexOf]     = graphic.DrawInBlendLayer;
            }

            var terrain = GameData.Terrain;

            string MapQuery(int x, int y) => blendGraphics[terrain[x, y].TerrainIdx];
            bool IsBlending(int x, int y) => blendSelf[terrain[x, y].TerrainIdx];

            if (BlendingTileGeneratorRegistry.TryCreate(out var reg,
                                                        tileRegistry,
                                                        tileSet.RenderType,
                                                        textureOperations,
                                                        tileProducer,
                                                        tileSet.TileSize))
            {
                var p = reg.Populate(blendGraphics);
                result = new BlendNeighboursSelector2 <TTile, Nothing>(p,
                                                                       renderingConfig.MatcherNavigator,
                                                                       MapQuery,
                                                                       IsBlending);
                return(true);
            }

            result = default;
            return(false);
        }
示例#5
0
 public TileMatchControl(ITileMatcher <TTile, Nothing> matcher,
                         Action <IPlotOperation> cacheControl = null) : base(matcher, cacheControl)
 {
 }
示例#6
0
 public void Add(TKey key, ITileMatcher <TTile, TContext> matcher)
 {
     matchers.Add(key, matcher);
 }
示例#7
0
 public FilteringTileMatcher(Func <int, int, bool> filterCondition, ITileMatcher <TRenderTile, TContext> matcher)
 {
     this.filterCondition = filterCondition ?? throw new ArgumentNullException(nameof(filterCondition));
     this.matcher         = matcher ?? throw new ArgumentNullException(nameof(matcher));
 }
示例#8
0
 public TransformingTileMatcher(ITileMatcher <TRenderTile, TContextSource> parent,
                                Func <int, int, TRenderTile, TContextSource, TContextTarget> converter) : base(parent)
 {
     this.converter = converter;
 }
示例#9
0
 protected TransformingTileMatcherBase(ITileMatcher <TRenderTile, TContextSource> parent)
 {
     this.parent = parent ?? throw new ArgumentNullException(nameof(parent));
 }
示例#10
0
 public void Add(ITileMatcher <TRenderTile, TContext> m)
 {
     matchers.Add(m);
 }