IPlotOperation CreateNonCachedFromMatchControl(TileMatchControl tm, IRenderCallbackFactory <Nothing, TTile> r) { var po = PlotOperations.FromContext(RenderingConfig) .Create(tm.Matcher) .ForViewport() .WithRenderer(r.CreateRenderer <Nothing>(this, Nothing.Instance)) .Build(); return(po); }
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()); }
IPlotOperation CreateFromMatchControl(TileMatchControl tm, IRenderCallbackFactory <Nothing, TTile> r) { if (tm.Cachable) { var cache = PlotOperations.FromContext(RenderingConfig) .Create(tm.Matcher) .WithCache() .ForViewport() .WithRenderer(r.CreateRenderer <Nothing>(this, Nothing.Instance)) .Build(); tm.CacheControl(cache); return(cache); } return(CreateNonCachedFromMatchControl(tm, r)); }
/// <summary> /// Produces the rendering pipeline for rendering the wall and item layer. /// /// This operation consists of three tile renderer operations per map /// coordinate. Each operation must be executed as a single batch for each /// map coordinate so that later tiles can correctly paint over these /// tiles if needed. /// </summary> /// <returns></returns> IPlotOperation CreateItemLayerPlotOperation <TRenderParameter>(IRenderCallbackFactory <TRenderParameter, TTile> rendererFactory, ITileRegistry <TTile> tiles, TRenderParameter sortingLayer) { IRenderPlotOperation <TTile, Nothing> CreateWallPlotter() { var matcher = new AggregateTileMatcher <TTile, Nothing> (CreateWallMatcher(tiles), CreateDecoMatcher(tiles)); return(PlotOperations.FromContext(RenderingConfig) .Create(matcher) .WithCache() .ForViewport() .Build()); } IRenderPlotOperation <TTile, Nothing> CreateItemPlotter() { // Selects all items stored at a give map location. // The item will be passed through to the renderer layer as context for post processing. var itemMatcher = new ItemListMatcher <TTile>(GameData, tiles); // Take the item context and update the rendered position of the item based on the item's location. // This converts the context from IItem to Nothing after adjusting the coordinates. var conv = new DungeonGameItemLocationResolver <TTile, Nothing>(GameData.ItemService, RenderingConfig.Viewport); return(PlotOperations.FromContext(RenderingConfig) .Create(itemMatcher) .ForViewport() .WithConversion(conv) .Build()); } var renderer = new BatchedPositionedSpriteRenderer <TTile, Nothing>(rendererFactory.CreateRenderer <Nothing>(this, sortingLayer)); var batch = new BatchedPlotOperation <TTile, Nothing>(renderer, CreateWallPlotter(), CreateItemPlotter()); return(batch); }